pax_global_header00006660000000000000000000000064126571702730014524gustar00rootroot0000000000000052 comment=072f52df8385816ad840730c9761810fe4a5e3dc weboob-1.1/000077500000000000000000000000001265717027300126425ustar00rootroot00000000000000weboob-1.1/.gitignore000066400000000000000000000002031265717027300146250ustar00rootroot00000000000000*_ui.py *.pyc *.swp Session.vim build dist *.egg-info *~ tags docs/source/api modules/modules.list /localconfig *.idea/ *.DS_Store weboob-1.1/.mailmap000066400000000000000000000023301265717027300142610ustar00rootroot00000000000000Romain Bignon Romain Bignon Juke Juke Julien Hebert Clément Schreiner Noé Rubinstein Johann Broudin Florent Fourcot Florent Florent Fourcot Florent Fourcot Florent Fourcot ffourcot Nicolas Duhamel Gabriel Kerneis Christophe Lampin Kitof Ahmed Boussadia Ahmed Bousadia Simon Murail smurail Vincent Paredes Jean-Philippe Dutrève Baptiste Delpey bdelpey weboob-1.1/AUTHORS000066400000000000000000000216401265717027300137150ustar00rootroot00000000000000Weboob is a free software written by: Romain Bignon * Core team; * Qt Applications; * Maintainer of too many modules. Laurent Bachelier * Core team; * Citelis, Pastealacon, Pastebin, PayPal, RadioFrance and YouTube modules maintainer. Florent Fourcot * Release manager; * Maintainer of too many modules. Benjamin Carton * Core team; * Maintainer of too many modules: Julien Hebert * Developer of masstransit; * Inrocks, LeFigaro, Minutes20 and Transilien modules maintainer. Noe Rubinstein * Bototo, Eatmanga, MangaFox, MangaHere, MangaReader, Mangatoshokan and Simplyreadit modules maintainer. Julien Veyssier * Suboob, Cineoob, QCineoob and Booblyrics developer * CreditMutuel, Geolocip, Ipinfodb, IsoHunt, Kickass, Piratebay, Attilasub, Opensubtitles, Tvsubtitle, Btmon, Imdb, Seeklyrics, Parolesmusique and Parolesmania modules maintainer. Christophe Benz * Bouygues, INA, SFR and Youtube modules maintainer. * Ex-member of the core team. Vincent A. * funmooc, github, guerrillamail, imgur, lutim, mailinator, ovs, pariskiwi, pixtoilelibre, quvi, sueurdemetal, unsee modules maintainer; * Many patches on too many code parts. Roger Philibert * Ehentai, Izneo, JacquieEtMichel, OKC and Youjizz modules maintainer. Nicolas Duhamel * BP, CanalPlus and Orange modules maintainer. Clément Schreiner * MediaWiki and Newsfeed modules maintainer. François Revol * Europarl, GDCVault and Vimeo modules maintainer. * Canaplus and qvideoob fixes * Patchs for Haiku support Pierre Mazière * RockRadio module maintainer; * lcl ex-maintener; * BNPorc fixes. Xavier Guerrin * Author of the CrAgr module. Gabriel Kerneis * Boursorama module maintainer. Oleg Plakhotniuk * Maintainer of Walls Fargo and CitiBank; * Improvements on the PayPal module; * Various fixes; * Several tools. Vicnet * lacentrale module maintainer. Kevin Pouget * CreditCooperatif module maintainer. Gilles Quenot * Fortuneo module maintainer. Mathieu Jourdan * GdfSuez module maintainer. Benjamin Drieu * TricTracTV module maintainer. Jeremy Monnet * Opacwebaloes module maintainer. Lord * CappedTV module maintainer. Lucien Loiseau * GoogleTranslate module maintainer. Christophe Lampin * HelloBank, ameli and amelipro modules maintainer. * Patchs on cragr and freemobile Sébastien Monel * QHandJoob application. Alexandre Lissy * JVMalin module maintainer. Arno Renevier * Weather module maintainer. Matthieu Weber * Unpronounceable modules maintainer. * Fix on formatter encoding. Jocelyn Jaubert * SocieteGenerale module maintainer. Alexandre Morignot * residentadivsor module maintainer. * Documentation to write a module with Browser2 * Adapt munin scripts to python3 Johann Broudin * CMB module maintainer. Guilhem Bonnefille * RMLL module maintainer. Cedric Defortis * MeteoFrance module maintainer. P4ncake * Vice module maintainer. Matthieu Rakotojaona * Btdigg module maintainer. François D. * ArretsurImages module maintainer. Christophe Gouiran * EDF module maintainer. Cédric Félizard * KiwiBank module maintainer. Hervé Werner * Velib module maintainer. Thomas Lecavelier * Patches on radioob. * nihonnooto module maintainer. Clément Calmels * Patches on NoLifeTV. Gabriel Serme * Support of two-factor authentication for Boursorama. Baptiste Delpey * Fixes on bank modules. Jean-Philippe Dutrève * Fixes on bank modules. Vincent Texier * Fixes on YouJizz and Dailymotion. Ahmed Boussadia * Fixes on OKC module. John Morrow * OFX formatter in boobank. Mathieu Lordon * Fixes on bank modules. Erwan Jahier * Patches on BP. Yann Rouillard * Add kids.dailymotion.com for dailymotion Raphaël Rigo * Patch for poleemploi * support for credit card history in boursorama theo * Ergonomics enhancements. Willy Villard * Patches on modules. Alexandre Flament * Script contrib/downloadboob. BohwaZ * Script contrib/report_accounts.sh. Grmbl Frechneu * Anonymizer script. Jérôme Poisson * Patches on webcontentedit. Laurent Dufréchou * Windows support. Fabien Grumelard * Fixes in FranceTelevision. leto * AuM anti-spam updates. Vincent Paredes * Changes in Repl. * Fixes and patchs on banking modules. * Backport in browser2 for wheezy support Richard Genoud * Fixes on CrArg. Jean-Christophe Dubacq * Fix on FreeMobile. Lucas Nussbaum * Fix on Credit Mutuel. Jerem * Fix on BP authentication. Camille Baldock * Fixes on BP. Alexandre Franke * Contribution to boobank. Loic Bontonou * Fix on arretsurimages module. Olivier Schwander * Fix XDG support. Luc Didry * Fixes on LCL. Jean-Benoist Leger * Fix on Dailymotion. Stefano Zacchiroli * Patch on the build system. Adrien Kunysz * Fixes on setup.py. Michael Scherer * Contribution on weboob-config. Damien Cassou * Minor fixes on housing modules. ianux * Patches on videoob. Laurent George * Fixes on AuM. Romain Garbage * Fixes for FreeBSD. Pierre-Louis Bonicoli * Fix on bash completion script. * Fixes on documentation Philippe Fremy * Fixes for Windows. Antoine * QVideoob fixes. Ryan Nowakowski * Import error. David Jeanneteau * Fix on ING and icon of ING. Juliette Stehlé * Enable LDD and PEL accounts on Boursorama. Etienne Carriere * Fix on dailymotion Simon Murail * Contribution to bank capability and browser2. * Add deepcopy to BaseObject Alexandre Bonhomme * Fix and tests on several modules Camille Dehecq * Contributions on weboob-generic munin script Samuel Loury * Fix on the documentation Caram Dache * Patch on boobank OFX export Mickaël Thomas * Patch to use gpg by default rather than gpg James Galt * Patch to remove ids that might be non-unique * Add Account.number attribute, and use it in BNP module Edmond Van Overtveldt Julia Leven Jérémy Bossut Valentin Lefils * Tests for the browser Discover how to contribute to this great software: http://dev.weboob.org/guides/contribute weboob-1.1/COPYING000066400000000000000000001033301265717027300136750ustar00rootroot00000000000000 GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . weboob-1.1/ChangeLog000066400000000000000000004500721265717027300144240ustar00rootroot00000000000000Weboob 1.1 (2016-02-11) General * Last release with python 2.6 support * New CapShop capability (#1662) * New shopoob application * Add new 'weboob' script to find applications * New APIBrowser class * Add a contrib script to help forking weboob * New WEBOOB_DATADIR environment variable General: removed modules * Removed grooveshark module: website is closed * remove module hellobank, use bnporc instead General: new modules * New Amazon Store Card banking module (CapBank) (#1698) * New bforbank module https://www.bforbank.com (CapBank) * New kiwibank module https://www.kiwibank.co.nz (CapBank) * New s2e (Employee Savings Plans) Support for Esalia, Capeasi, "BNP Paribas epargne & Retraite Entreprises" and "HSBC Epargne et Retraite en Entreprise" (CapBank) * New Victoria's Secret store credit card module (CapBank) (#1732) * New agendaculturel module http://www.agendaculturel.fr (CapCalendar) * New residentadvisor module https://www.residentadvisor.net (CapCalendar) * New happn module https://www.happn.com (CapDating) * New freegeoip module https://freegeoip.net (CapGeolocIp) * New ipapi module http://ip-api.com (CapGeolocIp) * New entreparticuliers module http://www.entreparticuliers.com (CapHousing) * New explorimmmo module http://www.explorimmo.com (CapHousing) * New logicimmo module http://www.logic-immo.com (CapHousing) * New virginradio module http://www.virginradio.fr (CapRadio) * New Ideel module http://www.ideel.com (CapShop) (#1733) * New MyHabit module https://www.myhabit.com (CapShop) (#1734) * New Victoria's Secret module https://www.victoriassecret.com (CapShop) (#1731) * New blablacar module https://www.blablacar.fr (CapTravel) * New dhl module http://nolp.dhl.de (CapParcel) * New dpd module https://tracking.dpd.de (CapParcel) * New gls module https://gls-group.eu (CapParcel) * New itella module http://www.itella.fi (CapParcel) * New funmooc module https://www.france-universite-numerique-mooc.fr (CapVideo) * New rmll module http://video.rmll.info (CapVideo) * New vine module https://vine.co (CapVideo) * New ilmatieteenlaitos module http://ilmatieteenlaitos.fi (CapWeather) * New ldlc module https://secure.ldlc.com and https://secure.ldlc-pro.com (CapBill) * New t411 module https://www.t411.in (CapTorrent) Core * Repositories update: display a message when all modules are up-to-date * Log full backtrace on module build error * Update windows installation (#1668) * Better detection of gpgv.exe location * Fix issues when using NamedTemporaryFile on windows * Add a datadir option, handle WEBOOB_DATADIR * Use gpg by default rather than gpgv for signature verification * Create empty temporary GPG homedir * Exclude backend using instance_name instead of module_name * Try to be consistent in variable name between backends and modules * Convert StopIteration for PEP 479 Doc * Account() constructor does not take an id * Fix symlink creation in setup.rst * Use browser2 in module documentation * Add few docstrings in core and browser Filters * Add Eval filter, for arithmetic expressions * Add Slugify filter * Add a JSValue filter to look for literals * Add Decode filter, to decore urlencoded strings * CleanText: add Unicode normalization * Regexp: nth param can now be '*' to find all * Attr: fix error message * CleanText: fix paramter name "children" * DateTime: handle TypeError exception raised by parse_date * Duration: correct '_regexp' attribut name * Dict: several improvements * Join: improve it to work like join command * Join: add ,ewMone, addBefpre, addAfter parameters * Async: if AsyncLoad parameter is None, do not try to open it * CleanDecimal: convert INT, float and long (and not only str) * Attr: fix an error message * Dict: handle TypeError in parsing * Time: Update regexp to catch more values Browser * Add comments on Form class * New unit tests * New api for content, encoding, and document building * Add ChecksumPage class * Cleaner way to get rid of BOM for CsvPage * Fix wrong encoding detection logic * Detect XML encoding * Enable passing the path to a CA file to Browser.VERIFY * Add an asset method to get absolute path of module local files * Browser.VERIFY can now be a module local file * Fix compatibility with python 2.6 in HTMLPage (#1651) * TableElement: fix count columns when there is an attribute "colspan" * Do not display urllib3 warning if there is no TLS certificate verification * Add an IPhone profile * Add a GoogleBot profile * Add method Browser.set_profile * DomainBrowser: ability to give the baseurl in constructor * Add LoginBrowser.do_logout() method * Handle "Refresh" meta tag in HTMLPage, with a REFRESH_MAX option * Add an absurl method to Page * Fix crash when using HEAD on a page-matching URL * Add BrowserQuestion exception (ask user to change config when raised) * Add 'replace' xpatch function in HTMLPage * Introduce new DictElement class * Add some JSON helpers * Strip data on CsvPage * Better control of HTTP referrer * Allow changing the Session class * Pass async/sync callbacks in the same way * Bump Firefox version to next ESR (38) * Fix documentation: use HTMLPage instead of Page * Add StatesMixin class to store state of a browser * Change worker pool size after session init * Allow to force method in URL.go (pass argument to location()) * Support using id in HTMLPage.get_form() * Rename async parameter to is_async Old Browser * Do not use PROTOCOL_SSLv3 as it is deprecated, use bad named PROTOCOL_SSLv23 instead * Add BaseBrowser.get_page method (don't change the location) * Add a StateBrowser to store cookies in storage * CSVParser: catch exceptions * Disable lowsslcheck if there is a proxy, as ssl doesn't deal with it Capabilities * Add the possibility to define Field type argument as a string * Create enum. Use it in calendar and housing (code factorization) * Add a way to instantiate an object from a dict of its fields values * Add russian ruble and XOF currencies * Add SGD, BRL, JPY and MXN in currencies Capabilities: Audio * Move specific audio filters from capabilities/audio.py to tools/capabilities/audio/audio.py * Add specific filters to create audio objects id * Do not require an id in constructors Capabilities: Bank * Fix StatusField to be a BaseObject * Change quantity type to decimal number * Better explanation for Investment class * Introduce new type Account.TYPE_LIKE_INSURANCE * Add credit limit, payment due date and amount for credit card bank accounts (#1717) * Add IBAN properties * Add card number and commission in Transaction * Add original_amount and original_currency in Transaction * Add country in Transaction * Add Transaction.investments and Investment.vdate attributes * Add Account.valuation_diff attribute * Add Account.number attribute Capabilities: Bill * Inherits Detail and Bill from Currency * Remove Bill.idparent attribute * Add Bill.vat attribute Capabilities: Calendar * Add timezone parameter to calendar event in order order do get the good date/hours in ical exports * Add a field 'summary' to Query object * Add ticket status in BaseCalendarEvent * Add a ticket field to Query * Add BaseCalendarEvent.timezone attribute * Add new categories Capabilities: Cinema * A person may have now several roles in a movie Capabilities: Collection * Do not require an params in constructor Capabilities: Contact * Set default value of Contact.profile to OrderedDict() Capabilities: Dating * Fix API to store optimization name in object ID Capabilities: Gallery * Correct method name: s/search_gallery/search_galleries/ Capabilities: GeolocIp * Add osmlink field Capabilities: Housing * Support new type SHARING Capabilities: Messages * Remove _Message and _Thread and use strings in Field instead Capabilities: Recipe * Do not force to use id in object constructor Capabilities: Torrent * Remove name mandatory parameter in constructor Capabilities: Thumbnail * Thumbnail now inherits of _BaseImage Capabilities: Weather * Do not require an id in constructor * Fix default value for date * Cosmetics in temperature formatting Applications * Backport check_output function for python 2.6 * Remove wconio dependency on win32 platform * Allow ResultsCondition to compare timedelta * Encode properly output in console.py (#1673) * Fix BrowserSSLError catch in ConsoleApplication (#1702) * Handle attribute error when stdout does not habe encoding attribute * If backend name is already taken, suggest the first available one with the same base * Formatters: use weboob.tools.misc.guess_encoding instead of utf-8 * Formatters: manage tty colummns while displaying text * Use os.devnull and binary flag for windows compatibility Applications: REPL * Fix a crash when ReplApplication.do() is called with a function * Create a message for 403 errors Applications: boobank * Format: ISIN is a 12 letter word * Format integer for quantity * Sometines the full code is not available. Display description instead * Add a command 'Budgea' to export accounts and transactions * Fix investment display when some fields are empty * Identify credit card for each transaction in OFX export Applications: boobill * Use do_ls to cache objects in REPL * Add binary mode for writing. Fix file downloading on windows Applications: boobcoming * Fix crash without end_date (#1667) * Add search by summary * Print ticket status * Add search by ticket status * Handle error correctly in do_attends * Add a load command * Improve ical export (end lines with '\r\n', as RFC says) * Add timezone in ical export * Display price as float * Improve date display * Do not crash during export of an unknown event Applications: cineoob * Give roles informations in persons_in_common and movies_in_common * Support several roles in the same movie for an actor * Movies in common are now sorted by release year * Fix problem with stream parameter in request.get in python-requests v2.5 (#1683) Applications: flatboob * Display backend in city choice Applications: geolooc * Fill OpenStreetMap link Applications: havedate * Store optimization name in object ID Applications: parceloob * Clean cached objects before getting new ones Applications: qcineoob * Add 'view' and 'view in new tab' buttons for all search results * Add 'view thumbnail' for movie and person search results * Factorisation of events in search results * Persons in common implemented in movie page * Movies in common implemented in person page * Support several roles in the same movie for an actor * Better display of search results, spaces added * Increase biography field size * Movies in common are now sorted by release year * Better user input validation for same-person movies in common Applications: qcookboob * Implement tab navigation (#1290) * Fix bug when thumbnail_url is empty Applications: radioob * Can now download full album * Add file in search subcommand Applications: videoob * Fix the problem with streamed calls on requests (#1683) * Display download subcommand in debug mode Applications: weboorrent * Fix formatter for info command Applications: weboob-config * Improve info command to allow json formatting * Put all config details in a dictionnary * Format capabilities as JSON array * Add installation status in modules subcommand * Prompt user to accept an untrusted keyring (#771) * Add module_name param in add_backend to allow command line interaction * Update help of "add" command Tools * Move guess_encoding into weboob.tools.misc * Add a Javascript class * Avoid crash on UnicodeDecodeError with retry decorator Tools: bash-completion * Hide error (#1671) Tools: date * Supporting french month abbreviation without dot * Extend date_max_bump default value to 31 days in LinearDateGuesser and ChaoticDateGuesser * Add some french translation * Parse french date with DMY order by default Tools: virtkeyboard * Fix not logical arguments order * Dump of tiles: save full image too * Allow to receive a list in get_symbol_code() method * Support pollution in coords attributes Contrib * Add a gtk appindicator for boobank * Remove bashisms in report_accounts.sh * weboob-generic: fix object listing when tomonitore is not set Contrib: downloadboob * Print link message only when needed * Fix new file detection * Support download of m3u8 files * Allow passing config and section filter on command line * Replace call to 'fill_video' by 'fillobj' Modules: 750g * 750g is now working using browser2 (#1706) * Fix: Only select the first thumbnail image * Fix: Site changed * Improve instructions parsing Modules: adecco * Bump to browser2 Modules: agendadulibre * Add missing favicons * Adapt for timezone support * Do not crash when json included in webpage is not valid * Correctly retrieve start and end date Modules: allocine * Remove excessive quote_plus call on pattern to make multi-word search work again * Adapt for more informations in persons_in_common and movies_in_common * Fix: accents were causing problems in search * Handle videos from allocine * Handles showtimelist in allocine * Fix: bug while playing videos from external url * Fix: syntax error on allocine * Adapt for timezone support * Max rallocine rate is 5 * Fix unicode warning Modules: allrecipes * Adapt to new version of website * bump to browser2 Modules: amazon * Skip "In transit" orders. (#1684) * New discount: "Lightning Deal" (#1684) * Generate payment transaction if there aren't any (#1684) * Order charges xpath fix (#1684) * Amazon module: skip 'Not yet shipped' orders (#1699) * Amazon module is updated according to the website change (#1715) * Skip "On the way" orders at Amazon (#1716) * Support new version of Amazon order details header (#1721) * Retry Amazon requests after ReadTimeout exception * handle Timeout exception as ReadTimeout has been introduced in recent versions of requests * Add French Support and Shopoob compatibilities * Add french translations * Retry ConnectionError as well (#1742) * pep8 fixes * Support for a new payment layout and priceless items (#1764) * Scrape the updated website (#1808) * Update after site changes * New status to ignore * More shippings and discounts (#1853) * Retry getting an order page (#1876) * amazon bills * Fix: work with iter_resource, and use ISO currency codes instead of symbols Modules: ameli * Update after sites changes, and upgrade to new browser * Handle authentication errors * PaymentDetailsPage: use a simpler URL * Site was updated * details isn't implemented: remove dummy code * ameli: prevents crashes when no bills are available Modules: amelipro * Update after sites changes, and upgrade to new browser * Fix decimal bug Modules: americanexpress * Handling no amount on account * Add default date to beginning_debit_date * Handle new americanexpress site but only if there is only one card * Increase timedelta to guess real date * Handle US account * Amex is dumber and dumber ( increase time delta because amex have hard time to put the date in a good interval) * Fix parsing of rdate * Fixing card type * Removing useless id Modules: apec * Use https instead of http * Adapt to the new version of the website and use browser2 Modules: arretsurimages * Fix: get videos titles in h1 (#1447) * Fix: correctly implement search and add a test (#1691) Modules: arte * Fix bug id was not well filled in info command and title was not filled * Adapt to browser2 * Fix display bug during newly install * Default value must be key, not label * Fix bug when urls are not found * Fix bug when date is not available * Handle special characters in search * Fix arte concert (a fields has been removed fron json) * Handle special cases in json parsing * Do not raise 404 error while searching a video using an other site url * Fix program menu management * Fill id using a better value for arte cinema Modules: audioaddict * Fix description data removal from audioaddict API * Rename SKY FM to Radio Tunes * Add Fresca Radio Modules: aum * Search query string: replace %(lat)s and %(lng)s with position in my profile * Fix parsing of geo position Modules: axabanque * New login pages on axabanques (#1709, #1711) * account.id is now only paramNumCompte if there is not paramNumContrat * Handle expired password * Handling banned account * Do not try to recover transaction from DAT account * axabanque fix duplicate accounts id * Handling duplicate id for account using Jsp Id * Stop parsing history of investment accounts * Fixing random number formating * Add error page Modules: banqueaccord * Fix inconsistent history on loan accounts if there is no init date * Labels of login fields changed Modules: banquepopulaire * Support new authentication on some region websites * Fix login on new website (needs upper case login) * Fix crash for new cards with no debited history * Break the new protection * Support full list of accounts (#1360) * Fix crash in a particular case of navigation * Supporting new account page * Parsing last connection date correctly * Fix navigation when passable unavailable page is displayed before login * Support case where user may accept TERMS_OF_USE * No history if account has no prev_balance * Apply alsace and lorrainechampagne fusion in bpalc in banquepopulaire module * Add Investment accounts * Correctly return an iterator even if this isn't an investment account * Fix crash on empty field banquepopulaire investment * Add life insurance investment * Skip message pages to get_investment on banquepopulaire * Fix a crash on iter_accounts after an investment on banquepopulaire * Remove stored 'token' attribute from browser and fix navigation on banquepopulaire website * Correctly get token only when available * Handle error page to avoid global crashes * Fix to get token * Adding support for IBAN * Fix getting tokens on some pages * Attempt to fix cgu validation * Adding loan * Add unavailable page * Fixing useless id * Ignore \0 bytes in documents Modules: barclays * Add AssurancePage on which we don't support get_history * Fix barclays navigation * Handle suspended accounts * Fix bug when card is first account * Support more account types * Sorting transaction before returning * Fixing page payement to foreign currency * Remove print * Remove bad transactions ids Modules: biplan * Site changed * Detect invalid events * Do not crash when no time can be found * Add timezone / fix encoding and hours detection * Fix parsing error on start date Modules: bnporc * Fix to get transactions when they are ordered by type * Get IBAN of accounts * Do not try to get IBAN for delegated accounts * Add investments to bnporc module * Handle corner case * Move old code for old site in a new folder * Add support for new bnp site * Move new browser into pp/ * Parse transaction labels, and fix account's coming * bnp history not supported on life insurance * Investment not implemented for entreprise browser * bnp investment fix * Handle error message after login * bnp type life insurance on capitalisation accounts * Do not get investments from PEA Espèces * Handling account without history * bnp history always return an iterator * New bnp entreprise certhash * Switch to new website and several fixes * Correctly set IDs * Raise BrowserIncorrectPassword when user should use hellobank instead * Raise IncorrectPassword after 100 connections * WIP on new company bnp website * Adapt module to use Browser2 * Add company browser * Fall back on old website for pro accounts * Add iban field for company accounts * New certificate * Fix compatibility with python2.6 * Fix concerning banqueprivee subdomain * Handle website unavailable for history * Better handle of expired password * rename pp folder to ppold * Fix PEP8 E713 * Support lifeinsurances on new website * Add authentification error code * Skip transaction without date * Adding support iban for some pro account * Automatically update password to the same one when the 100 connections threshold is reached * Type more accounts to get history and transactions investments on those * Revert fall back on oldwebsite for pro accounts * Add a page to renew password * Support checking type * Adding loan for crédit immobilier * Calculate IBAN key if messing * Add Hellobank support * Use shorter id * Revert "[bnporc] use shorter id" * Handle investment and history on market accounts * Fix crash if bnp throws 500 HTTP status code * New connection threshold page url for hellobank * Valution_diff on market accounts * Add number to iter_accounts * Fixing bad id for coming transaction * Prevent us from crashing when bnp crashes Modules: boursorama * Add investment * Support market investments * Fix duplicate entry on card account * Cleaner way to iterate * Better explanation for Investment class * Fix website changes (virtual keyboard, accounts list) (#1696) * Ignore moneycenter accounts * Minor fix * Introduce new type Account.TYPE_LIKE_INSURANCE * Use two_authentication with BrowserToBeContinued instead of raw_input * Use StateBrowser, s/BrowserToBeContinued/BrowserQuestion/ and coding style fixes * Remove text after card number if any * Raising incorrecte password when profil is incomplete * Fix CC history for boursorama * Update hash of boursorama's certificate * Fix duplicate accounts * bourso new investment page and fix parsing * Fix crash when there is more data in the cell * Fix PEP8 E713 * Fix parsing of unit price * Fix investment link parsing * Ignore immediate debit cards * Investments on lifeinsurance transactions * Fix pagination of lifeinsurance history * Ignore promotional fake accounts * Fix parsing some special market accounts * Valuation diff on lifeinsurance accounts * Fixing bad id transactions * Do not use useless id * Fixing false id in transactions * Fix parsing of investment label * Fall back on old website if we are on the new one Modules: bouygues * Rewrite backend using browser2 (#1970 and #1978) * Add support for bill on bouygues * Avoid useless login * Handle website modifications * Home page uses https (#2510) Modules: bp * Support professional accounts * Update upstream certificate hash (#1702) * Handling when website have an error * Fix parsing of virtual keyboard url * Add a page to pro website * Catch a no online banking service at login * Set type of accounts on professional accounts * Identify credit card for each transaction * Update to new certificate * Adding IBAN support for banque postal pro * Add a regexp on withdrawal labels * Parse IBAN for personal accounts * Do not crash if there is no IBAN for an account * Iban in unicode * Fix for newer pdfminer versions * Fixing bad account type on pro website * Sorting transactions before returning them * Fix for new API * Only call initialize if needed * Fix get_pages usage for new API * Fix newapi import * Fixing fake id for transactions * Fixing pdf parse with new api * Fixing no RIB Modules: bred * Support new website of bred * Fix compatibility with Decimal of python2.6 (#1685) * The 'categorie' key isn't always in json * Detection of disabled accounts * Correctly strip currency code * Correctly deal with cookies storage * Add type Account.TYPE_DEPOSIT * Catch technical error at login * Fix duplicates accounts * Fix PEP8 E713 * Get IBAN on accounts * Dd certash * Handle multiple universes * Oops fix mistake Modules: caissedepargne * Fix getting card accounts on old website * Set type on card transactions * Support Banque BCP which uses same website than caissedepargne * Do not force TLSv1 anymore as in some cases it doesn't work * Investment on lifeinsurance and market account * Add balance on NUANCE * Fix IndexError related to investment feature * Handling website error for market place * Fixing index error when checking if we are on error page * Fix BrowserUnavailable when browser is on market pages * Iban on cassedepargne accounts * Add new certhash * Ignoring CB transaction aggregation * Try to type more accounts * Adding support for saving type * Prevent crash on market * Get more investments * Valuation_diff on market accounts * Fix crash if there are several market accounts * Fix not authorized to read market accounts * Fix accounts parsing on banquedelareunion * Adding compte titre type * Fixing leaving investment space Modules: canalplus * Correctly fix the problem with streamed calls on requests (#1683) Modules: carrefourbanque * Fix accounts parsing * Fix 404 on history and now support "compte livret" * Fix when account balance is negative Modules: cci * Update for Join filter changes * Site changes Modules: chronopost * Status guessing Modules: cic * Handle new certificate * Supporting mouvements.html and situation_financiere.html * Fix list index out of range on iter_accounts * Rewrite module to browser2 (based on creditmutuel) * Cic can have letter in login * Add IBAN on cic * Fixing cic account with "Contre-valeur" Modules: citelis * Certificate hash change Modules: citibank * Do not wait for transactions if there's none. (#1661) * Credit limit, payment due date and amount for Citibank. (#1719) * Use V8 for login (#1743) * Relogin when the website returns garbage instead of a PDF. (#1820) * Site was updated. Closes (#1820) * Parse thousands correctly in the statements. (#1984) * Backport check_output for 2.6 Modules: cmb * Fix detection of authentication fail * Add deposit type in CMB module * Fixing when login is obsolete * Fixing cmb with some pro module * Quick fix for multiple space. Modules: cmso * Add pro browser to cmso bank module * Correctly raise instance of BrowserIncorrectPassword * Correctly handle 500 error during login * Fix parsing of market accounts and factorization of the Transaction class * Fix website changes on auth page * Go to subscription page before get accounts for some users * Use a local instance of LinearDateGuesser instead of global one * Support pagination of transactions * Fix: coma are used as decimal separators * Correctly handle expired sessions * Fixing duplicate entry * Handle double site type on the pro side * Clean + blackbox compatibility on cmso pro Modules: colisprive * Rewrite for browser2 * Fix history parsing Modules: cragr * Fix parsing of labels with new crédit agricole website * Fix parsing of raw transaction text * Handle useless pages to prevent being redirected to mobile version * Get IBAN on accounts * Detect connection errors * Add new labels to market type * Fix account list parsing, skip irrelevant account * Fix getting history for card accounts * Fix import of Account * Add tdbgestion page * The type of PEL accounts is now SAVINGS instead of MARKET. * Refactor * Support life insurance accounts * Handle sessionSAG parameter * Support market accounts * Handling bad investement parsing * Handling bad value for investement * Fix parsing on cragr investment * Fix av investment parsing * Do not return NotAvailable if value == 0.0 * Support loan accounts * Fix double clean of investment amounts * Add account types * DAV PEA is a checking account * Handle new login navigation on some sub websites * Fix incorrect password on new login * Add page to fix login access * Fixing categorization * Cragr perimeters * Adding new saving account name * Fix infinite loop when a crash occurs on perimters * Fix when some perimeters are crashing * Fix broken perimeters * Fix in case of CGU poping when changing perimeters * Fix card accounts balance parsing * Fix mistake Modules: creditcooperatif * Update regexp to support SEPA transfers * Fix exception in some cases * Fix regexp for external transfer * Handle investment * Correctly return an iterator even if this isn't an investment account * Add attribute _inv to pro accounts Modules: creditdunord * Handle the case when the creditdunord CB label is "OPERATION SUR CARTE" (#1712) * Remove spaces from IDs * Handling account with no history * Handling no details for this account * Fix crash on accounts which doesn't support history * Handle duplicate accounts * courtois: we now skip transactions without date even on pro accounts * Fixing wrong id when no details for an account * Trying to avoid duplicate accounts * Fix courtois we now always return iter for investment * Handle IBAN * Fix auth fail url * Add VirtualKeybord auth * Change lifeinsurance accounts type * Removing false id for transactions * Fix life insurance accounts and add valuation_diff * Raise BrowserIncorrectPassword is password isn't digits * Fixing history for account * Fixing pro account * Fix assert for password * Avoids infinite loop in case of fail login Modules: creditmutuel * Handle new useless pages * Updat transfer method * Save and load state of browser into storage * Handle refresh on empty page * Handling already logged * Handling html page * /cmmabn/fr/ is a valid login page * If do_login() is called, force go on the login page * Handle refresh on LoginPage too * Handle disconnection * Fix accounts parsing * Fix parsing of 'soft' parts of account names * Fix parsing of balances if accounts page has been configured by user to display balance in several currencies * Clear cookies before to login * Better form detection * Increase timeout * Clean transactions label * Parse contactless payments ("PSC") transactions * Handling orignal currency * Using TableCell to handle dynamic transaction list * Ignore ELEVE CARTE line * Add account types patterns * Add type pattern for young accounts * Investment for market accounts * Fix crash when trying to find reale amount of market accounts * Fix portefeuille account parsing * Add IBAN on creditmutuel accounts * Fix parsing market accounts * Fix parsing of unitprice * Fix skipping market summary fake account * Fix parsing valuation of a market account * get more iban * Fix parsing isin codes in special cases * Handle new website * Redirect page added * Fix label * Fix parsing label of accounts on old websites * Fix wrong valuation on market accounts if several are present * Valuation_diff on market accounts and new balance for PEA * Account typing * Fix blackbox compatibility * Fetch more transactions * Fix detection if transactions are coming or not * Fix when last_debit is None * New accounts type * Life insurance on old website * Fill the rdate field on life insurances history Modules: cuisineaz * Site changed / rewritten using browser 2 Modules: dailymotion * Fix dailymotion "search" return bug message * Fix to get video url Modules: delubac * Rewrite module with browser2 on new website * Handle accounts and transactions * Website require a digit password Modules: ovh * Adding bill for ovh Modules: edf * Correctly set amount and currency on bills Modules: ehentai * original_title does not exist anymore * There is no more description available * Update cardinality field name * Use Thumbnail object Modules: feedly * Favicon transparency and remove JPEG artifacts * Use new DictElement object * Improve tests * Iimprove login management * Fix login * Do not crash when there is no title in article Modules: fortuneo * Detection of accounts type * Support investments detail * Add page to browser: pea account type * Introduce new type Account.TYPE_LIKE_INSURANCE * Update changed certificate * Fix fortuneo module now support "compte especes" * Fix support of PEA accounts * Fixing empty performance * Fixing 2nd detail line who was considered like investment * Fixing bad int values on investment * Fetch history of life insurances * compte-espaces is a AccountHistory page * Correctly set type of market accounts * Fix savings account type * Fixing closed life insurance account on fortuneo * Raise IncorrectPassword when there is new id * Throwing error when an sms is required to access information * Switching error to browser incorrect password * Fixing listing account * Fix crash when parsing accounts without balance * Fix navigation * Support deferred debit cards * Set type of card transactions * Fix new pass required detection Modules: francetelevisions * Fix "search" always return empty list * Correctly fix the problem with streamed calls on requests (#1683) * Remove "latest" feature * Fix pluzz's search (1700) * Add option to get video from an url * Handle lastest replay videos * Fix bug search date in bad balise * Fix bug: we can only search one time * Use new DictElement object * Fix: site changed (#1855) * Fix: site changed again (#1868) * Update tests * Fix bug while getting video from some url * Fix error when video url is none * Handle url from francetvinfo website Modules: freemobile * Correctly handle wrong credentials * Fix parsing of bills urls * Force UTF-8 encoding with the standard mechanism * Enable bills filtering for multi-account * Fix subscription date parsing for multi-account * Fix forfait name parsing for multi-account Modules: ganassurances * Rewrite ganassurance with browser2 and fix auth and history * Add missing date column title for cards history * Fixing statefull website with account's link changing * Fixing coming date with an other label * Change AccountsPage xpath to only get personal finances accounts * SSL is not supported anymore * Add changing pass/id page Modules: googletranslate * Fix code used by Google Translate for Greek Modules: groupamaes * Use a local instance of LinearDateGuesser instead of global one * Should now always find accounts * Fix : site changed Modules: hellobank * Fix permissions, encoding and copyrights * Do not try to get IBAN from life insurance accounts * Do not try to get history of life insurance accounts * Allow transaction parsing across multiple pages * remove module, use bnporc instead Modules: hsbc * Handling when website is gone away * Fixing shared accounts_list * Fix new list of accounts and new URLs * No history on loan accounts * Handling duplicate account id (#2114) * Submit two useless form to mimic browser * Fix date parsing * Add coming for cards * Do not use fake id for transactions from hsbc * Allow hsbc user to have more than 8 length password * Fixing credit is positive on some account Modules: hybride * Fix: site changed * Fix: Date parsing * Fix: site changed again * Fix bug when there is no end date * Iimprove end_date management * Update to support timezone * Use Decode filter to get the good id * Simplify id Modules: imdb * Fix: python datetime is locale-dependent * Fix: 'N/A' value in movie release date Modules: imgur * Port to browser2 * Implement CapGallery Modules: ina * Bump to browser2 * Handle CapAudio * Find video from url Modules: ing * Coding style * Change selection of keyboard (more generic) * Fix navigation after a transfer * Remove hack to convert decimal to int * Fix crash if there is no ':' in IDs * Update regexp * Allow birthday to be entered with separators * Support of ASV accounts * Fix switch between market and checking websites * ASV accounts don't have history * Fix detection of errors in page * Get valuation information in several locations * NotImplemented exception for history on asv and clean code * As ING website sucks, re-login to retry getting investments list * Introduce new type Account.TYPE_LIKE_INSURANCE * Fix website change * Be sure we are logout before login * Store "where" in ing browser * Fix bad login with cookie cache * Fix parsing of euro founds * Add a kind of life insurance account name * Fix parsing of ISIN code for market accounts * Fix switches between market and bank websites * Euro funds have diff equal to 0 * Fixing not avalaible value * Handling netissima page * Fix set of Investment.unitprice for market accounts * Correctly get subscriptions even if previous page was on market * Fix finding jid on some pages * Load ISIN code from details page if not available in the list * Fixing empty page in some case in investment without pl in URL * Prevent useless request since there is no history on asv accounts * Handling +infinity (best investment ever) * Fix ISIN code on asv * Do not slugify investments without ISIN codes * Fix ing bills * Parse bills dates * Skip summary bills * Fix isin on US investment * Fix when valuation is not available Modules: inrocks * Url changed * Fix url matching * Do not try to parse premium news pages Modules: kickass * New domain name * Adaptation to new browser, iter_torrents mysteriously not working * kickass now works with new browser Modules: lcl * Website change, rewrite with browser2 * Ignore summary lines in history tables * Fix stop parsing not transactions lines * Certificate updated * Fetch detail of transactions and use it in Transaction.raw * Change timeout to 30 seconds * Call default Browser.deinit() * Do not change Transaction.raw if there is no detail * Adding pagination support for lcl * Fix async bug with cards * Fixing RC4 and cert for pp browser * New certificate for LCL Espace Pro * Browser doesn't inherit 'object', so 'super' doesn't work * Handling account can't use online service when login * Fixing bad login when session expire * New transaction detail page * New certificate for lcl entreprise * Fix date parsing bug on transaction label 0/07/2015 * Wrongpass instead of BrowserUnavailable * Fix PEP8 E713 * Fix contracts selection routing * Remove validate method * Handle one case of bad login/pass * Handle investment * Fix for clients with no market investment accounts * Fix crash on asv accounts * Fix parsing of life insurance accounts with special chars in owner name * Fixing when we have some additional information * Disconnecting from bourse portal before returning the account list * Fix bugs on av accounts, double ids and disc from detail * Fix mistake in disc page * Fix life insurance accounts ids * Fix parsing of market accounts * Fix crash on enterprise websites * Adding iban info when available * Fix pro accounts iban * No permission page to fix crash * Fix crash in case life insurances are unavailables * Support a new account type * Fix parsing of some transactions on pro accounts * Adding saving account * Handling IBAN single account * Adding checking account * Fixing payement wording * Adding SAVING type for account * Handle home page so the module is blackbox compatible * Adding account type * Change page to handle specific behavior Modules: leboncoin * Add missing favicons * Fix bug while parsing date * Fix bug when area is unknown * Add regions support * Fix error when there is no price and improve description display * Improve cities display in search * Fix search city using zipcode * Fix bug when user do not choose any city * Do not crash if a select does not exist in the form * Fix title parsing in search result * Get main photo when there is no carousel * Fix bug in costs retricton for rent type * Fix bug due to other backends cities * Fix site changed * Fix regex in id detection Modules: lutim * Upgrade to Browser2 Modules: mailinator * Fix module as the api changed Modules: mareeinfo * Add missing favicons Modules: marmiton * marmiton is now working using browser2 (#1706) * Fix bugs in marmiton * xpath change (#2117) Modules: mediawiki * Update tests to use "Project:Sandbox" page * Port to browser2 * Remove useless stuff Modules: meteofrance * Adapt to browser2 * Use new DictElement object * Allow to iter forecasts using town name in addition to city id * Site changed Modules: monster * Fix and adapt to browser2 * Improve page parsing * Adapt for new Join filter * Handle adverts coming from partner websites Modules: okc * Correctly detect when login fails * Handle logged page * Make all attributes of optim start with an underscore * Fix parsing of profiles * Way used to vote has changed * Fix encoding of urls * Fix parsing of thread title * Rewrite okc module with browser2 and less ugly code * Skip empty essay fields * Add status and orientation fields * Do not remove old threads anymore * Iter_unread_messages: do not visite read threads Modules: oney * Add new hashes for virtkeyboard * Change get_balance xpath * Adding hash for virtkeyboard * Handle multiple cards Modules: orange * Adapt to website changes (#1828) * Add https urls * Update maintainer * Supporting bill capability for orange Modules: pap * Adapt to new DictElement object * Fix bug in parsing date * Fix : site changed Modules: pastealacon * Fix: url changed * Works with other pastebin sites * Revert "pastealacon: work with other pastebin sites" Modules: paypal * Handling when user can't acces account balance on main account * Supporting new paypal website * Fixing using new account page version when we are already on old account page * Handling when currency is not in right place * Fixing primary account display twice * Fixing wrong id on account * Checking website version after login * Fix crash on new accounts list (#1654) * Fix selection of table containing last file requests to be less ambiguous * When balance is zero, paypal add a class to the div * Handling new website account for individual * Paypal fix for KeyError: 'counterparty' * We now ignore transactions with no 'displayAmount' * Fix name of paypal accounts (display currency instead of balance) * Take care of transaction's net amounts (#1694) * Fix warning with adding a new home page * Handling home page on new private website * Fix paypal new activity URL * Fix paypal * Use locale.format to format amount * Do not use locale.setlocale to parse amount * Fix history on paypal, stop parsing suspended recurring payment * Get converted amount for foreign currencies * Fix crash IndexError: list index out of range (#1747) * Remove unused code, fix timeout of history fetch * We don't try to parse transactions without currencyCode anymore * New cert + fix conversion warning * Handling useless captcha page * New paypal certificate * Execute javascript convert() function on token * Paypal handle bad login/password * Add paypal new page to fix crash on history of some accounts * Fix crash on old website and inform users * Change detection of pro or perso account_type * Increase DEFAULT_TIMEOUT for accounts with a lot of transactions with foreign currency * Fix call of ads_token convert function * Fix timeout on accounts with huge transactions number * Fixing timeout for some accounts * Handling timeout when fetching old history * Fix transactions parsing * Get real amount accounting paypal's commissions * Fixing captcha * Handling promo page for new paypal application * Rewrite paypal with browser2 and fix login * Add a way to detect login errors * Pro accounts transactions amount is now returned without commission * Ignoring refound offer for paypal * Fixing paypal auth challenge * Do not supply floats to Decimal constructor * Fix login * Detect a login error * Fix parsing accounts without available balance * All personal accounts seems to be on new api. * Parse more transactions not in account currency * Try to get the activity 3 times * Discard another transaction type * Fix regexp parsing converted amount of transactions * Fix mistake of converted amount parsing * Handling payement from another bank * Fix parse_transaction return * Using original wording for payement from another bank and setting type * Check if there is a associated transaction for "Achat de" * Fixing bad return * Include archived transactions * Fix pro accounts transactions amounts not in account currency * Fix parsing converted amount from other currency * Fixing paypal using different token for conversion * Removing commande à from transaction list * English key word to skip transactions * Fcking paypal Modules: piratebay * Use new domain names Modules: playme * Add a profile walker to automatically send won challenges * Implement get_account_status() * Fix warnings * Answer only to 5 questions * Fix challenges with users who have already challenged you * Fix crash when there is no contact * Use Module.create_browser to correctly give all standard arguments (proxy, logger, etc.) Modules: poivy * Fix low balance listing Modules: popolemploi * Fix search and upgrade to browser2 * Website uses https * Site changed Modules: presseurop * Fix body selectors Modules: radiofrance * Site changed / backend rewritten using browser2 * Manage selection podcasts / improve testing * Handle podcasts * Fix indentation typo * Minor fixes * Cleanly display live in repl * Handle new francebleu website, retrieve the good player url when default player is the video player * Fix 404 errors in selection Modules: razibus * Increase timeout * Support timezone Modules: redmine * Fix crash when parsing custom fields Modules: regionsjob * Fix: site changed * Fix parsing when advert is a picture * Update to new Join filter * Do not crash while parsing an external advert Modules: sachsen * Fix parsing of flow level * Improve test for sachsen module * Partial fix of new website * Fix history with new website Modules: seloger * Remove useless condition * Fix bug on pagination * Use new DictElement object * Handle special characters (#1883) * Fix json parsing Modules: senscritique * Skip test when StopIteration is raised * Improve module code * Fix date parsing * Add Mangas missing channel * Fix bug when end_date is asked and not found * Use set_profile(Firefox()) instead of _setup_session(Firefox()) * Remove id lists * Fix channels selection * Site changed (we cannot choose channels packages anymore) Modules: societegenerale * Correctly detect when the website is unavailable * Page parsing for saving accounts * Update upstream certificate hash * Update certificate hashes * Credit card is no longer in coming * Switch rdate/date and little fixes * Update hash of soge enterprise certificate * Fix duplicate accounts on cards accounts * Adding IBAN support for pro and entreprise accounts * Setting new certificat hash * Fix greediness of a transaction pattern to avoid crash * Update certificate * Testing account true id for card * Check ssl certificate after browser construction * Support market account * Support life insurance account (Investment) * Refactor * Support life insurance account (Transaction) * Fix type of 'PEA Espèces' account * Detect and log unknown type account * Do not iterate over all available transaction * Move set_date into LifeInsuranceHistory, and do not return to transactions list * Do not store NotAvailable amounts * Do not crash on pro account * Fix investment valuation * Fixing unsuported link account * Adding PEA Especes to unsuported link * Dd an url to the crashing ones * New ssl certificate * Add reinitpassword page to prevent crash. * Fix parsing and pagination of market investments * Try to type more accounts * Adding iban number * Try to fix weird crash * Fix navigation without id transactions * Fixing fake id for investment * Fixing account type Modules: tinder * Fix warnings * Fix crash when a contact has been removed * Use APIBrowser * Do not crash when the limitation rate is reached * fix login on tinder: need to find the cookie in js * Avoid aborting profiles walker when queue is empty * Fix PEP8 E713 * use Module.create_browser to correctly give all standard arguments (proxy, logger, etc.) Modules: transilien * Fix _regexp name in RoadMapDuration filter * Fix ambiguous departure/arrival in roadmap * Use new DictElement object * Fix incorrect roadmap duration parsing (#2089) Modules: twitter * Fix: site changed * Exclude non-tweets * Fix: trendy tweets (site changed) * Fix search pagination * Fix comments parsing * Fix condition to correctly check if user is logged Modules: vimeo * There is no latest category on vimeo (#1692) * Allow to browse categories and channels * Bump to https and handle site changes * isSafeForFamily field is not always filled + correctly handle its value Modules: vlille * Fix encoding error Modules: wellsfargo * Force TLS v1.0 for Wells Fargo module. (#1647) * Credit limit, payment due date and amount for Wells Fargo bank (#1720) * Scrape minimum credit card payment and due date (#1809) * Update to new login security checks (#1999) * backport check_output for 2.6 Modules: wordreference * [wordreference] Adapt to browser2 Modules: youjizz * Min pattern size for search is 3 characters * Use UserError instead of ValueError * Videos are now hosted on another domain Modules: youporn * 'a' and 'i' pattern are not supported (404 error) * Rewrite with Browser 2 * Use UserError instead of ValueError * get_video fill the id Modules: youtube * Fix parsing of js signature (#1695) * Backported changes from youtube-dl * Fix call to _extract_signature_function() Weboob 1.0 (2014-10-17) General * New agendadulibre module http://www.agendadulibre.org/ (CapCalendarEvent) * New Citibank module https://online.citibank.com (CapBank) (#1642) * New leboncoin module http://www.leboncoin.fr/ (CapHousing) * New mareeinfo module http://maree.info/ (CapGauge) * New playme module http://goplayme.com/ (CapMessages, CapMessagesPost, CapDating) * New razibus module http://razibus.net/ (CapCalendarEvent) API Big-Bang * Rename BaseBackend to Module * Rename BACKEND to MODULE * Rename backend.py to module.py * Rename BaseApplication to Application * Rename CapBase to Capability * Rename BasePage to Page * Rename BaseBrowser to Browser * Move CleanHTML to html filters * Remove * imports in filters * Move weboob.tools.browser2 to weboob.browser * Move weboob.tools.exceptions to weboob.exceptions * Move weboob.tools.browser to weboob.deprecated.browser * Move weboob.tools.parsers to weboob.deprecated.browser.parsers * Move weboob.tools.mech to weboob.deprecated.mech * Remove the "backend" result in do() calls Core * Catch the proper exception for missing icon * Replace usage of os.mknod() by os.open(O_CREAT) * Use the print() function everywhere * WebNip.iter_backends takes a new optional parameter 'module' * Add __getitem__ on WebNip to get a loaded backend by name * Create PrintProgress class instead of using IProgress as default one * Allow to load a module with config=None * A lot of pep8 fixes Capabilities * Let get_currency guess US$ means USD * Prevent mess when copying BaseObject instances Capabilities: bank * Add Investment.description field * Add Emirati Dirham AEB currency Capabilities: calendar * Add Conference event category Capabilities: parcel * Add parcelnotfound exception Capabilities: housing * Add and handle in flatboob house_types field * Add and handle in leboncoin a new house type: UNKNOWN * Adding a url field in housing capability and management of it in flatboob Applications * Add a new debug level (-dd option) * Add a " LIMIT " keyword in conditions * Centralize encoding guesses, default to UTF-8 (#1352) * Use class attributes as much as possible for application output * Define std* in the proper class * Handle datetime in condition argument * os.isatty is now forbidden (as stream.fileno() is not implemented by StringIO) * logging: Output to stderr, not stdout * logging: better colors Applications: repl * When getting an object, if at least one is found, display errors but correctly return the found object Applications: boobmsg * Fix "show" for threads Applications: flatboob * Ask for query.type in flatboob * Add load command * Fix bug type_of_good does not exist anymore Applications: Qflatboob * Manage count to avoid problems during pagination Applications: pastoob * Add an option to set a custom file encoding Applications: parceloob * Catch parcelnotfound by untracking Applicatitons: traveloob * Fix: crash if departure time is not available Applications: videoob * Set non verbose mode for wget when downloading m3u8 (fix #1643) Applications: weboobcfg * Return correct exit status code for enable and disable commands Applications: webcontentedit * Better checks for vim usage Browser * Add a way to asynchronously handle requests and pages * Backporting mergin_hook to support hook's requests in wheezy * HTMLPage checks the inner charset and parse again document if it is not the same than Content-Type HTTP header * Add a trivial android profile * Add has-class xpath function Browser: filters * Add debug informations * Raise ParseError only with None/NotAvailable/NotLoaded values, not with empty strings * Add a way to customize sign handling for CleanDecimal * Regexp: let template be a callable * Add some javascript dedicated filters * Add an nth parameter to Regexp filter * Add __str__ to _Filters Browser: elements * handle_loaders into AbstractElement * Ability to select an ItemElement DeprecatedBrowser * Fix: certificate check on servers which don't allow SSLv3 Documentation * Update to the new API * Show base classes in documentation Tools * American amount to decimal conversion (ref #1641) * PDF decompression function (ref #1641) * Regexp-based tokenizer (ref #1641) Tools: html2text * Use the class if possible Tools: make_man * Copyright on top of file Tools: newsfeed * No need for workaround with feedparser>=5.1 Tools: tests * Allow changing modules path and adding to PYTHONPATH Tools: pyflakes * Add test to prevent usage of prints in modules * Detect deprecated has_key function Tools: values * Ability to set value to an empty string if it is available in choices Packaging: setup * Add futures, avoid Py2-only libs under Py3 * Use Python3-compatible syntax in debpydep * Add ignore dirs for flake8 Contrib: boobot * Add a check_twitter method Contrib: videoobmc * Force relative imports Contrib: weboob-generic (munin script) * Add category option Modules: alloresto * Fix: website changes (enable https and fix the form xpath) Modules: arretsurimages * Fix: site changed Modules: aum * Remove useless features of module that don't work anymore * Enable https * Import exceptions from core Modules: banqueaccord * Support canceled transactions * Increase timeout because of slow website Modules: biplan * Use the Python SkipTest if possible Modules: boursorama * Remove prints Modules: bred * Limit length of password * Remove lot of old code and keep card transactions in separate card accounts * Translating accnum description Modules: carrefourbanque * Do not try to parse useless accounts (closes #1432) * Fix: login form is now the second form on the page Modules: cic * Fix: new certificate hash * Set an unique id Modules: cmso * Fix: parsing of transaction amounts (strip nbsp) * Fix: parsing of huge account balances Modules: colissimo * Fix: return the real error message, not "label" * Raise ParcelNotFound in colissimo * Return the fullid of not found parcel * Upgrade to browser2 Modules: cragr * Remove prints * Add a regexp for checking password Modules: creditcooperatif * Add unique id to creditcooperatif (perso) * Update regexps * Use find object * Upgrade to browser2 (perso) Modules: creditmutuel * Fix: do not lock browser2 anymore (#1635) Modules: dresdenwetter * Add the debug decorator to dresdenwetter filter Modules: europarl * Remove prints Modules: feedly * Use the Python SkipTest if possible * Fix: unicode warning Modules: fortuneo * Do exactly the same thing than js to always get accounts list Modules: gazelle * Fix: infinite loop on fail login, and fix error message lookup Modules: gdcvault * Remove prints Modules: grooveshark * Fix: bug when Year field is empty in grooveshark json * Use the Python SkipTest if possible Modules: hds * Convert to browser2 and fix it Modules: hellobank * Remove prints Modules: hybride * Use the Python SkipTest if possible Modules: imgur * Restrict URL to imgur domains Modules: ing * Fix: add an Index for some accounts... * Add a test to detect loops in the history * Fix: testing of saving accounts * Fix: crash on coming operations * Add loggedPage on bourse.ingdirect.fr * Add a @ckeck_bourse decorator for a clean redirect Modules: kickass * Fix: parsing of torrent titles Modules: lacentrale * Fix: deprecated has_key Modules: lcl * Always raise instances of NotImplementedError Modules: minutes20 * Fix: parsing insolite pages Modules: nettokom * Add tests Modules: okc * Remove prints Modules: oney * Add a favicon * Add missing symbols for the virtual keyboard * Fix: do not crash on months with no transactions Modules: ouifm * Fix: new radio names Modules: ovs * Force relative import Modules: pap * Adapt to browser2 * Exclude adverts from other websites * Fix: image retrieving Modules: pastebin * Fix: crash on spam page Modules: paypal * Use AmericanTransaction.decimal_amount in PayPal module. Part of #1641 Modules: quvi * Force relative import Modules: seloger * Adapt to browser2 * Fix: pagination * Fix: obj filling Modules: societegenerale * Remove prints * PIL is a global requirement, remove the check Modules: tinder * Fix: auth on tinder by correctly set the User-Agent header Modules: transilien * Fix: crash on late departures Modules: twitter * Fix storage system * Fix purge system * Do not import Browser1 exception Modules: unsee * Restrict URL to unsee domains Modules: vlille * Better description Modules: wellsfargo * Fix: compatibility with old versions of mechanize * Add a favicon * Rewrite Wells Fargo with browser2 (closes #1624) * Improved Wells Fargo module stability. * Use AmericanTransaction.decimal_amount, closest_date, decompress_pdf and ReTokenizer in WellsFargo module. Part of #1641 Modules: youjizz * Fix: fillobj on video thumbnail Modules: youtube * Update part of the js interpreter Weboob 0.j (2014-09-03) General: * New module: feedly (CapMessages) * New module: oney (CapBank) * New module: twitter (CapMessages) * New module: wellsfargo (CapBank) (#1430) Core * Rename CapBaseObject to BaseObject (#1424) * Rename ICap to Cap (#1424) * Ability to use weboob.function as alias to weboob.do('function') (#1425) Core: repositories * Fix HTTP error handling for browser2 * Use ConfigParser in priority with python2 (#1393) * Load browser only when needed Capabilities * Move DateField/TimeField/Delta out of BaseObject * Add LBP to currencies * Add documentation on object constants Capabilities: audio * Add Playlist and Album classes Capabilities: audiostream * Fix: get_audiostream does not have pattern name (#1626) Capabilities: dating * Add iter_new_contacts method Capabilities: files * Fix repr() and str() on File-based objects Capabilities: image * Remove data field in to_dict method to avoid json crash during conversion Capabilities: messages * Remove required items in Message constructor Capabilities: travel * Do not require in id in constructor Applications * Remove default import of browser1 * Import debug modules only when needed Applications: console * Remove the import of SSL exceptions * Add the default value displayed "upper" in aliases (#1319) * Allows shortcuts for modules (#881) * Use shortcut of id in interactive mode (#881) Applications: REPL * Allow to browse subfolders with ls * Change formatter when it cannot handle all selected fields * Introduce the DISPLAYED_FIELDS in formatter * Set fields in a consistant way with do() * Introduce parse_fields function * Use fullid parameter for CapObjects * Correct multiple language error * Move format_collection from repl to ifromatter * Remove the 'inspect' command Applications: formatters * Remove the '*' special fields in formatter * Table and Json formatters can write output to a file now (#1412) * Handle format_collection with JSON formatter Applications: boobank * Do not crash if the account type isn't in list (#1542) * Write the account currency in ofx output Applications: radioob * Manage Albums and Playlists * Fix: bug when a radio id contains a dot Applications: QHaveDate * Add tab to send queries Applications: videoob * Improve m3u8 management in download Browser1 * Introduce local exception for SSL errors * Only load FirefoxCookies as needed * Update Firefox versions to latest ESR Browser2 * Add more specialized exceptions * Allow setting query string params on build_url * Matching content with url using is_here * Ability to override the flush() method * Allow for a custom element finder * Add CSV pages * Do not crash if total_seconds() is not implemented * Fix documentation of nr parameter * Update Firefox versions to latest ESR * Add support for forms with multiple "submit" elements * Allow more flexibility for the submit button parameter Browser2: ListElement * Move ItemListTable-Element outside of page.py Browser2: filters * Overload & and | operators to chain filters (#1426) * Split filters in several files * Fix filters doctest * Force unicode * New RawText filter * New Base filter * New Type filter * Date: use default value for empty input * Date: properly handle defaults that are not datetimes * MultiFilter: allow for a default argument * Dict: manage default * Dict: ability to use Dict['a']['b']['c'] instead of Dict('a/b/c') (#1426) * CleanHTML: manage basestring * CleanDecimal: possibility to set custom separators * CleanDecimal: set replace_dots default value to False * CleanDecimal: do not crash with inputs like NotAvailable * CleanText: handle the non-breaking space thanks to the re.UNICODE flag * CleanText: add an option to keep (but normalize) newlines * CleanText: \t is always in \s so no need to add it * CleanText: add tests * CleanText: fix re flags usage for Python 2.6 (#1444) * Env: add support for a default Documentation * New Home Page * Add a "How to contribute" page * Add logo/favicon * Set more customizations * Add instruction for developers missing the first steps (#868) * Define backends/modules * Add local_run in documentation for developers * Fix many docstring issues * Change module documentation to learn browser2 (#1451) * Add __repr__ on NotAvailable, NotLoaded and _NO_DEFAULT constants to be more readable on doc * Import several pages from the wiki * Add documentation to report a bug (#873) Tools: AmericanTransaction * Add a transaction amounts cleaner helper for american banks Tools: captcha * Refactor VirtKeyboard class * Add a margin attribut * Add a grid based virtual keyboard Tools: date * Add more french dates translations * Class methods to convert date[time] objects Tools: genericArticle * Fix unicode warning Tools: make_man * Tell that it was generated automatically Tools: pyflakes * Fix: call of pyflakes on Archlinux (#1404) Tools: test * Fix: call of test.py (#1403) Tools: yaml * Represent weboob date[time] objects as timestamps Misc: local_run script * Allow customizing where the modules are Misc: setup * Support python3 (#1417 #1418 #1419) * Add prettytable in dependencies (#929) * Configure isort and flake8 Misc: Windows Installer * Remove some files * Fix bugs in windows installer scripts Contrib: munin * Rename generic-munin to weboob-munin * Move all scripts in the same folder * Encode and decode ID's in weboob-munin Contrib: boobot * Add command %delquote * Fix: %searchquote on unicode strings Contrib: XBMC/Kodi * Add a xbmc/Kodi plugin that interracts with videoob Modules: arte * Fix: Do not crash if 'VDA' fields is missing in json * Use M3U8 format instead of HBBTV * Fill video.url with NotAvailable if url is not found * Improve tests * Improve video quality choice * Handle arte podcasts * Add tests for program categories Modules: aum * Implement iter_new_contacts Modules: banquepopulaire * Strip displayed balance at end of transaction labels * Display check number in label (#1027) * Fix: remove spaces in IDs (#1368) * Support loan payment type Modules: biplan * Handle summer holiday in tests Modules: bnporc * Update order regexp * Fix: transfer regexp * Remove space in ids Modules: boursorama * Some English fixes in comments * Add new certificat hash Modules: bp * Fix: new login image for virtkeyboard Modules: bred * Handle space in account number * Switch configuration description strings to unicode Modules: caissedepargne * Force use of TLSv1 on lowsslcheck as the web server support of SSLv3 is broken Modules: colissimo * Fix: New API key for collisimo (#1617) Modules: cragr * Order transactions by date to prevent LinearDateGuesser to be duped by the f*cking website Modules: creditmutuel * Fix: set of debit date for card transactions Modules: dailymotion * Fix: dailymotion mplayer error "No stream found to handle url" * Fix: use https for test Modules: francetelevisions * Use filters as classes in chain (refs #1426) Modules: freemobile * Some English fixes in comments * Fix date of subscriptions when next month as less days than excepted (#1347) Modules: gdcvault * Remove unused import of ControlNotFoundError Modules: grooveshark * Update to match Album and Playlist management in radioob * Display users playlists only when split_path length is 0 * Fix: catch exception when id is not an integer Modules: hellobank * Get default account name if the custom name is empty Modules: hybride * Fix: handle summer holiday in tests Modules: imdb * Some English fixes in comments * Use omdbapi instead of imdbapi * Fix: site changed Modules: ina * Fix: bad characters in titles (double encoded unicode) Modules: ing * Some English fixes in comments * Remove the index on ing for pagination * Support coming operations * Fix: parsing of 'tomorrow' transaction dates Modules: izneo * Fix: bug in page list Modules: lcl * Handle lcl pro https://professionnels.secure.lcl.fr * New certificate * Add transaction patterns Modules: leclercmobile * Fix: do not crash if balance is not available Modules: lefigaro * Remove dead code Modules: meteofrance * Fix: site changed (#1390) * Fix: call the url that retrieve all the search results (#1431) * Raise an exception if forecast param is not a city id (#1433) Modules: opensubtitles * Some English fixes in comments * Fix: site changed (#1295) Modules: pastealacon * Convert to Browser2 (#674) * Use specialized Browser exception Modules: pastebin * Convert to browser2 * overload & and | operators to chain filters (refs #1426) * Handle limit exceeded warning * Fix: crash with Base() and filter chaining Modules: paypal * Get more transactions on paypal (#1405) * Retrieve all transactions from the history, merchant and regular account support (#1406) * Paypal transactions history fetching with adaptive steps (#1406) * Checking if tr contains text * Make Paypal module use AmericanTransaction helper. * Fix: empty amount. (#1415) * Support french dates for last CSV request * Ignore canceled transactions Modules: popolemploi * Fix: site is now only availbe using https Modules: presseurop * Presseurop is back! (named now voxeurop) Modules: radiofrance * Fix: FIP radio does not work (#1449) Modules: sachsen * Set the datetime to NotAvailable by default Modules: senscritique * Fix: bug in network selection * Fix: set channels and programs parameters in get_event Modules: societegenerale * Fix: certificate changed * Fix: certificate updated (#1414) Modules: sueurdemetal * Fix: broken module due to departments containing letters Modules: tinder * Update recs only when needed * Fix attribute type Modules: transilien * Adapt to browser2 * Fix: site changed (#938) Modules: vimeo * Fix: site changed * Adapt to browser2 * Enable search and tests (#1082) * Catch HttpNotFound errors Modules: youjizz * Overload & and | operators to chain filters (refs #1426) * Use filters as classes in chain (refs #1426) Modules: youtube * Fix: Youtube mplayer error "No stream found to handle url" * Fix: is_logged function does not work (#1423) * Backport some youtube-dl changes (#1422) Weboob 0.i (2014-05-19) General * New Browser: browser2 is here! See below * First steps in python3 support * New GPG key for laurentb (see https://laurent.bachelier.name/gpgtransition.txt) * New module: btdigg (CapTorrent) * New module: Mailinator (CapMessage) * New module: guerrillamail (CapMessage) * New module: SensCritique (CapCalendar) * New module: imgur (CapPaste) * New module: unsee (CapPaste) * New module: lut.im (CapPaste) * New module: pixtoilelibre (CapPaste) * New module: ColisPrive (CapParcel) * New module: AlloResto (CapBank) * New module: LaCentrale (CapPriceComparison) * New module: Groupamaes (CapBank) * New module: Tinder (CapDating) Core * Import pkg_resources only when needed, to prevent a hard useless dependency Core: browser2 * Add a new browser based on python-requests * Full support of SSL * Add the option _proxy_ssl for backends * New management of Html FORMs * New URL class * Better debugging (save HTTP requests/responses) * Simple support of pagination (@pagination decorator) * Introduce ListElement and ItemElement (parser helper) * Add a lot of Filters for ItemElement * Add TableElement, to help the parsing of a table * 24 modules are already using browser2! * And a lot more... Core: browser1 * Unify no_login and nologin * Fix call of logger (can be unset) * Move exceptions in weboob.tools.exceptions (compatibility with browser2) Core: BackendCalls * Rewrite BackendCalls with queues Core: repositories * Make GPG ignore local settings Core: configuration * Support for password retrieval from any cli tools * Prompt user during configuration of a backend Core: ManPages * Escape more '-' Core: Parsers * Add a xml parser * Remove unused/obsolete parsers Core: DateTools * Add ChaoticDateGuesser Applications: base * Add version information in Debug * catch ^C on global bcall errors handler * Allow to use condition on the fullid * Do not display warning message if -n or count is set Applications: console * Fix: masked parameter wasn't considered * Fix: password encoding issues * Display backend@issues.weboob.org and not backend.EMAIL Applications: media_player * Add a play_proxy option Applications: Qt * Add keywords in .desktop files (#1356) Applications: REPL * Exclude backends that do not implement the required method (#1325) * New obj_to_filename() method (from videoob) * Do not fetch the collections when not needed * Fix selecting a field in non-interactive mode * Use a fast path for ls if -U is set * Add documentation of the "ls -d" option * Gather collections having the same path * Override comp_obj from repl in order to sort by start_date Applications: formatters * Add a json formatter that works on a line level (json_line) Applications: yamlconfig * Allow a default equal to None Application: boobcoming * Add documentation * Add icon * Use ls/cd commands to navigate into categories * Improve collection management Application: boobsize * Add icon * Display null values * Fix hints in not found error Application: boobtracker * Support colors for issues * Create/edit tickets in a text editor * Fix email address regexp * Fix crash in interactive mode * New options --tracker, --priority, --start, --due Application: parceloob * Remove trailing \n * Ignore status of not loaded backends * Always untrack if the id is in the storage Application: pastoob * Paste binary files with "post_bin FILENAME" and "get_bin ID" * Add 'info' command Application: Qhavedate * Ignore error when notes are not implemented on contacts Application: radioob * Fix audio objects search * Pick up first available stream when radio provides a playlist (#1345) Application: translaboob * Fix a typo in the documentation Application: videoob * Braces-enclosed tags are replaced with data * Play/info: ability to give several videos * Add command 'videoob playlist download' * Add command 'videoob playlist play' * Move obj_to_filename() into ReplApplication * Use wget to download m3u8 videos Application: webcontentedit * add a -r parameter to get command to precise revision id Application: wetboobs * Remove ICapGauge Capabilities: Base * Change currencies integer constants to ISO code strings * Do not require an id, because of ItemElement which constructs objects without arguments * Introduce find_object Capabilities: CapWeather * Fix: zero temperature can not be displayed (#1333) * Accept date objects for the forecast Capabilities: CapCalendar * Raise NotImplementedError on "attends" method * Add TELE category Capabilities: CapBugTracker * Fix some conversion warnings Capabilities: CapBank * Add Account.TYPE_CARD * Add TransactionsElement and TransactionElement (helpers with browser2) Capabilities: CapContact * Factorize aum's Contact.get_text() and boobmsg formatter Capabilities: CapGeoloc * Remove unused ipaddr field Capabilities: CapMessage * Avoid warnings in GenericNewspaperBackend and GenericNewsPage Capabilities: CapPast * Show a user-friendly error message for CapNotFound Capabilities: CapTracker * Add trackers and priorities fields to Project * Add start, due, tracker and priority fields to Issue Modules: banquepopulaire, bnporc, bp, cic, cragr, creditdunord, creditmutuel, ing, lcl, societegenerale * Improvements on transaction and account types detection Module: AmericanExpress * Fix wrong date guessing * Increase timedelta to 90 * Check if a card is valid * Set card balance to Account.balance instead of Account.coming Module: Apec * Updates reflecting site changes Module: Apivie * Fix getting an account from list * Fix parsing of negative transactions Module: Arte * Encode UTF-8 strings in search * Fix naming of collections * ArteLive: new website * Improve the parsing of dates * Fix bug when VDA field not found in json file * Fix problem on extension Module: AxaBanque * Adding support for sub accounts * Fix parsing of accounts without amount Module: Banque Accord * Add icon * Fix parsing of negative amount * Fix detection of card pages * Fix virtual keyboard * Add a hash for symbol 5 on virtkeymap * Adding support for Leroy Merlin * Support LOAN accounts * Upgrade to browser2 Module: Banque Populaire * Fix: parsing of accounts (site changed) * Fix: parsing of accounts on specific regions * If an account type is not supported, raise NotImplementedError Module: Biplan * Fix bug while parsing start/end time * Updates reflecting site changes * Upgrade to browser2 Module: Bnporc * New certificate * Fix encoding issues * Disable unused parameter rotating_password * Change the domain to entreprises.bnpparibas.net for BNPEnterprise Module: Boursorama * Fix crash when there is no ID on transaction * Handle card history Module: BP * New certificate * List market account (#1298) * An account type must not be None Module: Bred * Support dispobank * New certificate Module: CanalPlus * Fix browsing categories (site changed) Module: Carrefour Banque * Upgrade to browser2 * Fix: Site changed Module: CCI * Upgrade to browser2 Module: Citelis * New icon * Fix: detection of login errors Module: cmb * Change a function call to avoid useless None * Upgrade to browser2 Module: cmso * Setting encoding to iso Module: Colissimo * Add icon * Fix license Module: Cragr * Fix parsing dates in labels (compatibility with Perigord) Module: Credit Du Nord * If type is not found, set TYPE_UNKNOWN instead of None * Add "Banque Rhône-Alpes" Module: Credit Mutuel * New icon * Upgrade to browser2 * Fix parsing of user private accounts * Fix crash on unknown accounts types Module: cuisineaz * Fix cuisineaz preparation and cooking time (site changed) Module: Dailymotion * Fix empty fields in dailymotion plugin * Change extension from flv to mp4 * New icon * Add support for videos available at kids.dailymotion.com * Fix the search (site changed) Module: Delubac * Support LCR * Fix navigation Module: DLFP * Fix logout (site changed) Module: DresdenWetter * Upgrade to browser2 Module: Fortuneo * New certificate * Do not override rdate with operation date Module: France Televisions * Upgrade to browser2 Module: Freemobile * Fix date of subscriptions when next month has less days than expected (#1347) * Upgrade to browser2 Module: googletranslate * Fix : site is now only available using https Module: grooveshark * Fix: no more field AvgRate (site changed) Module: HSBC * Fix: support of the SecureKey * Upgrade to browser2 Module: hybride * Upgrade to browser2 Module: INA * Site changed Module: indeed * Upgrade to browser2 Module: ING * Update regexps used to detect categories (site changed) * Upgrade to browser2 * Support pagination in iter_bills * Do not crash on invest objects when quantities are >999 Module: Kickass * Fix title getter (site changed) Module: LeclercMobile * Do not crash if the subscription is closed Module: LeFigaro * Fix: site changed * Fix the tests Module: LCL * New maintener * Support changes in login screens * Get more history * Remove logging checking on the contract page Module: Liberation * Add icon Module: lolix * Fix the size of the icon Module: mediawiki * Fix encoding error Module: MeteoFrance * Strip the text before to return it Module: OKC * Add the visit to a profile * Add a profile walker * First sent message is configurable * Do not crash on removed contacts * Do not crash on 'like' messages Module: pastealacon * Upgrade to browser2 Module: Paypal * Certificate changed (three times) Module: piratebay * New domain (thepiratebay.se) Module: Pole Emploi * Updates reflecting site changes * Fix parsing of dates * Fix bug in url encoding * Fix place selection Module: Poivy * Upgrade to browser2 * Support pagination for the history Module: Redmine * Add Issue.fields attribute to support custom fields * Support new versions of redmine * Use the right method to get project * If a category does not exist, try to create it * Fix compatibility with redmine 2.4 * Support start/end/tracker/priority * Fix finding the control to add a note Module: RegionsJob * Add icon * Upgrade to browser2 Module: sachsen * Upgrade to browser2 Module: Société Générale * Display card as accounts (#1362) Module: Sueurdemetal * Add date_end parameter in get_concerts_date call * Fix date and category filters Module: voyagessncf * If station ID is not found, try to look for it as a name * Forge a random IP source address to avoid redirection to other website (#1327) Module: vlille * Upgrade to browser2 Module: Weather * Fix: there are not always ten days of forecast (#1343) Module: youjizz * Handle videos longer than 59 minutes * Support pagination * Upgrade to browser2 Module: youtube * Fix: site changed * Fix: unexpected argument to BrokenPageError Tools: boilerplate * Add 'cap' recipe to prepare methods * Upgrade to browser2 Tools: local_install * Run tools/stale_pyc.py before local installation Tools: pyflakes * Ignore 'except' in a comment Misc: boobot * Add quoting commands * Fix unicode issues Misc: Windows Installer * Better script to generate the .exe * Better management for 64 bits systems Weboob 0.h (2014-01-08) General * New application: boobcoming * New application: boobsize * New capability: CapCalendarEvent * New capability: CapFile * New capability: CapAudio * New capability: CapAudioStream * New capability: CapImage * New module: Apivie (CapBank) * New module: Audioaddict (CapRadio) * New module: Banqueaccord (CapBank) * New module: Biplan (CapCalendarEvent) * New module: CCI (CapJob) * New module: Collisimo (CapParcel) * New module: EDF (CapBill) (#1296) * New module: GitHub (CapBugTracker) * New module: Indeed (CapJob) * New module: Jacquieetmichel (CapVideo) * New module: jcvelaux (CapGauge) (#376) * New module: JVMalin.fr (CapTravel) * New module: Liberation (CapMessage) * New module: lhybride.org (CapCalendarEvent) * New module: Monster (CapJob) * New module: Nectarine Demoscene Music (CapRadio) * New module: Nihon no Oto (CapRadio) * New module: OVS (CapMessage, CapContact) * New module: Pariskiwi (CapCalendarEvent) * New module: Poivy (CapBill) * New module: Quvi (CapVideo) * New module: RegionsJob (CapJob) * New module: Somafm (CapRadio) * New module: Sueurdemetal (CapCalendarEvent) * New module: VoyagesSNCF (CapTravel) * Removed module: ecrans (see new liberation module) * Removed module: Isohunt (site closed) Core * Add class WebNip (Web [in] Non Interactive Programs) * Modify/factorize/add CapVideo, CapAudio, CapImage, CapFile Core: application * The "condition" system has been rewritten (and moved from bcall to reply applications) (#1289) (#1288) * repl: add <,> and | operators in conditions * repl: support date in conditions (#1308) * repl: catch error in condition evaluation * repl: sort results of "ls" * repl: add -U option to not sort result with "ls" * repl: add documentation for conditions in manpages * repl: exclude backends which does not implement 'method' in get_object * repl: restrict to 40 results in ls by default * repl: accept 0 and negative values for count in interactive mode * Base: hide FormFieldConversionWarning * JSON: fix export format (#1294) * JSON: encode all subobjects CapBank * Add Invstment in __all__ * Use raw label to calculate unique_id CapGallery * Add iter_gallery_images method CapJob * Change API: add advanced_search_job CapTravel * Add parameter 'date' to ICapTravel.iter_station_departures * Add fields to Departure (arrival_time, price, currency) CapVideo * Inherit from CapImage CapWeather * Fix htmltable display for wetboobs forecast command (#1318) Application: boobank * Truncate label in formatter 'account_list' * Add OFX export Application: boobill * Catch some errors (#1303) * Fix: documentation erros Application: handjoob * Fix: display of results * Better ls command Application: Qhandjoob * Adapt to ICapJob update Application: parceloob * Do not show "None", but an empty string Application: pastoob * Add help for "infinite" max_age Application: radioob * Let user choose his Stream to use from Radio instance (#1291) * Use CapRadio * Add support for download and streaming of BaseAudio objects * Add support for playlist of BaseAudio objects Application: traveloob * Add (colored) formatters Application: videoob * Add playlist support * Sanitize default download filename * Fix: do not return None objects on get_object * Support curl for downloading * Allow to download in a folder with generated filename Application: wetboobs * Depreciate ICapGauge commands (#1284) Tools: Application * Add mpv to default players Tools: GenericBackend * Make a real link in signature Tools: Browser * Move the test on self.insecure to catch direct calls Tools: Value * Order Choices Module: adecco * Fix: site changed Module: allocine * Implementation of the new API mechanism Module: ameli * Fix: site changes * Better handle of login Module: amelipro * Fix listing of bills Module: apec * Fix: site changed (get job offers) * Use html2text to fill description content Module: arte * Add liveweb.arte.tv url management * Update to use arte API * Fix: fully fill Artevideo in get_video method (#1312) Module: arretsurimage * Prevent to catch all urls Module: Banquepopulaire * Get list of all accounts * Fix: do not crash if there is no operations * Fix: do not crash when there is no full list page * Support loan accounts * Support accounts with empty balance * Fix: do not crash with market accounts * Fix: new authentication * Fix: sometimes it is not possible to sort by value date in history * Fix: crash on special account histories * Support defered cards * Fix: getting history on some special workflow * Fix: crash when there is the coming column with empty value Module: Barclays * New favicon Module: Bnporc * Fix: update BNP certificate fingerprint * Add transaction patterns * Support new virtual keyboard * Fix: typo in label, s/Profesionnels/Professionnels Module: Boursorama * Fix: crash when there is no link on an opening account * Remove dead code Module: BP * New Virtualkeyboard Module: Bred * New configuration option: force the selection of account * Fix: selection of accounts when there are both personal and enterprise ones * Fix: set the right debit date on card transactions * Fix: crash on page to select account Module: Caissedepargne * New certificat Module: Carrefourbannque * Removed broken regexp for login parameter. Module: CIC and Creditmutuel * Backport fixes from creditmutuel * Correctly get the accounting amount * Support coming transactions * Do not try to find coming transactions for inappropriate account * Set the right debit date on card transactions * Fix parsing card debit date when there is a link in text * Support multi-cards pages Module: CMB * Fix: parsing accounts when there are mandated ones Module: Citelis * New certificate Module: Chronopost * Do not set location to "None" if empty Module: Cragr * Do not follow spam links * Fix: parsing of card accounts in particular cases * Fix: correctly set cards' Transaction.date to the debit date * Fix: crash when there are only three columns in card transactions listi * Fix: account IDs can contain anything else than digits Module: CreditCooperatif * New favicon Module: Creditdunord * Support enterprise accounts * Fix: parameters on request to get professionnal accounts history * Support SEPA Order parsing * Fix: pagination on professional website Module: Dailymotion * Fix: dailymotion thumbmail retrieving (#1310) * Fix: found the video URL * Fix: try to get the full JSON data * Fix: bugs in video pages (#1320) Module: Delubac * New favicon Module: Dresdenwetter * New favicon Module: francetelevisions * Fix: downloading in non-interactive mode * Fix: KeyError: 'data-date' (site changed) (#1282) Module: Grooveshark * Force mp3 extension * Many code style fixes * Manage albums search * Add user playlist management * Declare user_id as an instance variable * Fix: unitialized property user_id * Fix: NoneType return value when user is not logged * Fix: typo in test * Adapt test for logged and non logged users Module: hellobank * Fix decimal parsing of account values Module: Imdb * Fix: site changed * Add some tests Module: Leclercmobile * New favicon Module: Mangago * Fix: GenericComicReaderTest import path Module: MeteoFrance * Fix: parsing of pages, site changed Module: LCL * Fix: detection of authentication errors * Support new contracts selection page * New certificate * Fix: remove all of the agency parameter (#1313) Module: Leclercmobile * Better balance information * Remove "votre solde" in history * Strip labels Module: Lolix * Fill search job method in lolix to avoid error message Module: Nettokom * Add get_balance method * Fix: encoding warnings Module: NolifeTV * Use mobile.nolife-tv.com instead of online.nolife-tv.com * Add theme/type entries * Allow anonymous surfing Module: popolemploi * Improve deep search Module: Prixcarburant * Fix sites changes (#1031) Module: ING * Use raw parser for TitrePage * Add LDD support * Get history of titre account * Do not crash if there is no operation * Raise UseError on empty reason for transfer (#1315) Module: ipinfodb * Fix: form changed from GET to POST Module: SFR * Fix: site changed * Add some tests Module: Societegenerale * Fix: parsing of cards with undefined payment date * Add transaction patterns * Fix: conversion warnings (#1304) * Fix: support new authentication system Module: TVSubtitles * Add some tests Module: Vlille * Improve method _get_sensor_by_id * Scrap webpage instead of provided xml (get more informations) Module: Wordreference * Fix: site changed Module: Youjizz * Fix: get real thumbnail Module: Youtube * Add a new YouTube video URL * Set YOUTUBE_MAX_START_INDEX to 500 Contrib: downloadboob * Fix: call to ICapVideo.search_videos (API changed) (#1301) * Fix: print help instead of crash Contrib: generic-munin * Add get_object_list command * Fix: do not crash if one value is NotAvailable Contrib: kmymoney * Fix dead lock with krosspython > 4.8 * Add a Weboob configuration tab in account configuration window * Restrict download to N transactions by updating the history Misc: packaging * Get absolute path without readlink (compatibility with BSD systems) * Add windows installer * Use more common syntax (refs #1299) * Better detection of Pillow Misc: tools * local_run: do not erase existing PYTHONPATH Weboob 0.g (2013-08-03) General * New application: handjoob * New application: parceloob * New application: qhandjoob * New capabilitie: CapJob * New capabilitie: CapParcel * New module: Citélis (CapBank) * New module: Banque Delubac (CapBank) * New module: Hello Bank! (CapBank) (#1276) * New module: Ameli (CapBill) * New module: AmeliPro (CapBill) * New module: GDF SUEZ DolceVita (CapBill) * New module: V'Lille (CapGauge) * New module: Adecco (CapJob) * New module: Apec (CapJob) * New module: Lolix (CapJob) * New module: Pôle Emploi (CapJob) * New module: Paroles.net (CapLyrics) * New module: Chronopost (CapParcel) * New module: UPS (CapParcel) * New module: Allrecipes (CapRecipe) * New module: Supertoinette (CapRecipe) * New module: podnapisi (CapSubtitle) * New module: Arrêt sur Images (CapVideo) * New module: Grooveshark (CapVideo) * New tool: stale_pyc.py * New tool: certhash.py Core * Change '_backend' setting to '_module' (#789) * Remove all compatibily glue for python 2.5 (#806) * Remove some from __future__, forbid 2.5 in setup * Do not crash when repository is invalid (#1281) * Explicit module load errors * Fix: import Pillow in core * Fix: create containing directory of backend configuration * Fix: better English sentence when Weboob refuses to start * Fix: crash if backend name contains unicode chars Core: applications * Display a message when more results are available (#1038) * Default behavior is now to unlimit results, except for explicit commands (searches or history) (#1139) * Remove useless calls to ReplApplication.flush() (#812) * Add colors in console applications * console: display collections before objects with ls command * console: fix error if there are private attributes on backend * console: better handling of "tiny" choices, allow forcing * console: Automatically create a storage if STORAGE class attribute is not empty * repl: add a new caps parameter to get_object * repl: get_object supports backend's services returning lists * repl: Invoking 'help' command from shell display only list of commands * Fix: printing of DictObj Core: browser * Add a cache for DNS requests * Implicitly convert unicode objects to str for form values Core: capabilities * Move Currency from CapBank to CapBase * Fix: problem with strftime on date.year<1900 CapBase * add method to convert currency value to text CapBank * do not crash if date in label regexp isn't valid * add Investment object and iter_investment method * add Transaction.unique_id * more help for date fields * introduce vdate * FrenchTransaction.parse takes a new optional argument 'vdate' CapBill * add attributes to Bill (#1202) * add new attributes to Detail (#1203) CapBook * remove unused parameter 'pattern' in iter_books CapGauge * add address field to GaugeSensor CapMessage * default type of threads is IS_THREADS CapRecipe * handle interval number of persons * fix comparison to None CapSubtitle * add 'ext' attribut (extension of file) CapWeather * always call base constructor of CapBaseObject to prevent shared fields Core: documentation * Fix typo and wordwrap in INSTALL * Add manpages for new applications Core: tools * Do not try to fill None * All string values are Unicode * Allow overriding delay and tries in decorated function arguments * Add parse_french_date in weboob.tools.date Application: boobank * In interactive mode, 'transfer' commands asks confirmation (#1077) * Add parameter END_DATE to 'history' and 'coming' commands (#1150) * Add investment command * Avoid blank lines between entries in (pretty_)qif formatting * Better error messages * Prevent encoding issues in __repr__ of Transactions * Fix: do not flush twice Application: booblyrics * Fix: search command needs 2 arguments Application: boobmsg * Fix: display of messages list in non interactive mode Application: cineoob * Add caps parameter to get_object (#1280) * Filmographies and castings restricted to movie/person backend * Add language abbreviations in subtitle search help * Small bug fixes Application: comparoob * Add missing docstrings to commands Application: cookboob * Handle interval number of persons * Better nb_person interval display * Check if preparation time is available * Strip newlines from descriptions in search results Application: flatboob * Add command help * Do not use limit for cities search Application: qcineoob * Check if short description is available * Encode filename when download * Add tabs navigation * ctrl+l to get focus on search edit * Do not go on middle click opened tab * Remove useless print Application: qcookboob * Handle interval number of persons * Better nb_person interval display Application: qvideoob * Use fillobj instead of get_video to complete all fields Application: suboob * Rename command 'getfile' to 'download' * Save subtitles in a better file name (#1278) * Print filename where subtitle is saved (#1279) * Add language abbreviations in subtitle search help * Do not show URL if empty Application: webcontentedit * Use NamedTemporaryFile(delete=False) instead of mkstemp Application: weboobcfg * Remove 'backends' command from help * Fix: do not crash if a module cannot be loaded Application: weboorrents * Catch empty seeders and leechers Application: wetboobs * Fix: gauges command parsing Module: 750g * Strip accents in search URL * Fix: comments and accents striping Module: allocine * Fix: gender detection Module: americanexpress * Fix: parsing of coming value * Fix: parsing of April month Module: aum * Support new fields * Logging to see profile (because of craps) * Unescape description of profiles * Disable warning when unable to get public profile from website * Fix: encoding errors * Fix: typo on 'style' field Module: arte * Add support of ArteLive * Fix: parsing on German and English pages * Fix: id is now prefixed with "--" * Fix: prevent module from catching all URLs Module: attilasub * Add attribute 'ext' Module: axabanque * Detect when there is no operations Module: banquepopulaire * Support new authentication on some regions * Sort entries by value date * Add new URL for homepage * Store vdate * Fix: go on professional accounts list page Module: bnporc * Add support of personal accounts on professional website * Add enterprise website support * Support when sometimes 'coming' value is '-' * Prevent navigation conflicts during accounts iteration * Add regexp for payback of card transactions Module: bp * Fix: support new authentication Module: boursorama * Add two factor authentication for boursorama module * Add history for saving accounts * Add PEL support * Fix: parsing on new website * Fix: new certificat * Fix: support new website Module: bred * Supports new page which asks for a code from a card * Fix: login on accounts with several subaccounts * Fix: new certificat Module: caissedepargne * Support professional website * Add support of deferred debit cards * Be more robust on logout * Clear cookies during login * Fix: detection on login failed * Fix: navigation * Fix: avoid crashes if some useless fields are missing in global form * Fix: support new version of website * Fix: import of ControlNotFound on old versions of mechanize * Fix: navigation in card accounts history Module: cmb * Use new-style classes (coding style) Module: cic * Supports new page which asks for a code from a card Module: cragr * Add support for credit cards * Ignore accounts without balance * Add new regions * Support special login URLs on some regions * Use new-style classes (coding style) * Support account where name contains the owner * Do not raise BrowserIncorrectPassword when the website displays an useless "urgent message" on login * Better detection of useful label * Fix: use web site instead of mobile website for ca-centrest, and probably others (#1035) * Fix: an account owner name can start with Mle Module: creditcooperatif * Support coming transactions on pro accounts Module: creditdunord * Fix: navigation in history calls * Fix: attach cards to the good account * Fix: encoding error to get history for accounts with special chars in name * Fix: navigation for deferred cards * Fix: crash if the date of a transaction is empty Module: creditmutuel * Fix: listing of recipients in transfer Module: cuisineaz * Temporary fix of person number range * Fix: comments and accents striping Module: dailymotion * Fix: parsing of authors Module: dlfp * Be compliant with the dlfp 1st april joke * Fix: get new threads even if there is no comment Module: dresdenwetter * Add tests * Fix: no more snow sensor Module: freemobile * Add some tests * Fix: history when internationals calls option is not subscribed (#1078) * Fix: new certificat * Fix: conversion warnings * Fix: new bill listing * Fix: bad method name in tests Module: ganassurances * Enable support to Groupama Banque (#1112) Module: gdcvault * Only logout when actually logged in Module: hsbc * Support international accounts * Add a retry if login fail * Add missing file (login.py) * Fix: update module to support last website update * Fix: new certificate Module: imdb * Replace latin2unicode by HTMLParser Module: ing * Add support of investments * Add type of accounts * Raise NotImplementedError if account type not supported * Add some tests * Fix: conversion warnings * Fix: history of accounts * Fix: new certificat * Fix: transfer Module: kickass * Use https * Fix: new URL Module: lcl * Add enterprise site * Fix: detection of bad passwords * Fix: support new auth system * Fix: do not need to logout if the browser hasn't been used Module: leclercmobile * Add real tests * Fix: history parsing * Fix: details parsing * Fix: compatibility with calibre 0.9 Module: marmiton * Fix: comments and accents striping Module: opensubtitles * Add attribute 'ext' Module: orange * Fix SMS sending (#1206) Module: ouifm * Fix: json describing current songs and artists changed Module: paypal * Fix: ignore extra-lines in accounts list * Fix: new certificate Module: piratebay * New URL * Support proxies Module: presseurop * Get newspaper source * Fix: body parsing * Fix: better check for daily links Module: redmine * Fix: missing id class on older versions Module: sachsen * Fix: string conversion * Fix: tests do not work with new CapGauge API Module: seeklyrics * Fix: parsing in some cases Module: societegenerale * Add entreprise support * Do not consider expired cards * support 'OPPOSITION' state for cards * Fix: conflicts in detection of balance * Fix: new hashes for login * Fix: new certificat Module: tvsubtitles * Add attribute 'ext' Module: youtube * Support for a silly protection (#1277) * Detect if video is forbidden * Use https * Change maintainer * Fix: encoding of pages * Fix: stop search queries if there is no more results * Fix: parsing details * Fix: crash with weird characters * Fix: credentials encoding Module: vimeo * Get authors Module: weather * Add a favicon Tools * boilerplate.py: fix encoding issues * boilerplate.py: add default license * pyflakes.sh: more code quality checks * pyflakes.sh: use only tracked Python files * pyflakes.sh: add lines number * pyflakes.sh: ban more stuff * local_install.py: no deps by default on local install * local_run.py: do not copy the backends file * local_run.py: do not capture stderr * local_run.py and run_tests.sh: remove stale .pyc files * local_run.py: allow complete paths for script * local_run.py: allow overriding WEBOOB_BACKENDS * weboob_bash_completion: fix bash completion Contrib: boobot * Support python-irclib >= 3 * Proper freenode server name * Irc 5.0+ compatibility * Display regular URL info * Support multiple channel * Fix weird/unicode URLs * Guess page encoding * Better newline handling * Support servers without HEAD * Faster timeout * Twitter support * Configuration of boobot storage path * Better handling of zero/invalid HTML * Proper ^C closing * Support ignored users Contrib: freemobile-munin * Fix SMS regexp Contrib: generic-munin * Allow float values * Do not start every graph to 0 * Use rigid Packaging * Add --nodeps option to ignore dependencies in setup.py * Rename Makefile -> build.mk to avoid spurious build attempts * Use Pillow, unless PIL is already there * Better README/INSTALL files * Workaround Debian compatibily layer Weboob 0.f (2013-03-26) General * New application: booblyrics * New application: cineoob * New application: cookboob * New application: suboob * New application: qcineoob * New application: qcookboob * New capabilitie: CapSubtitles * New capabilitie: CapCinema * New capabilitie: CapLyrics * New capabilitie: CapRecipe * New module: American Express (CapBank) * New module: Paypal (CapBank) * New module: Crédit du Nord (CapBank) * New module: Allocine (CapCinema) * New module: IMBD (CapCinema) * New module: Parole De Musique (CapLyrics) * New module: Parolesmania (CapLyrics) * New module: Seeklyrics (CapLyrics) * New module: 750g (CapRecipe) * New module: Cuisineaz (CapRecipe) * New module: Marmiton (CapRecipe) * New module: Attilasub (CapSubtitle) * New module: OpenSubtitles (CapSubtitle) * New module: tvsubtitles (CapSubtitle) * New module: Btmon (CapTorrent) * New module: DresdenWetter (CapWeather) * New script: Generic Munin Plugin Core * Do not cry if an object is not support to be filled by a backend * Add a CSV parser * Remove two old and useless debug messages (bcall) * Force updating modules after upgrade (#1066) Core: application * Fix crash when there is no selected fields * Allow infinite search with 0 * Add a JSON encoder * move to_dict to base.py (#1060, #1061) Core: browser * Ability to set a ENCODING constant to BasePage which overrides the Browser's one * Use recent firefox user agent (Firefox ESR) * Fall back on SSLv3 if TLSv1 fails * Cache the sucessful SSL protocol Core: tools * Create DateGuesser extracted from cragr Application: boobill * Improve documentation of download command Application: havedate * Display contact IDs in 'events' command output Application: pastoob * Add command-line parameters (#920) * Support "no expiration" Application: videoob * Add resume option for video downloading * Stop the video when closing with ESC Application: webcontentedit * Add non tty stdin support to edit command * Add "get" command to webcontentedit Application: Wetboobs * Add a default error message on SensorNotFound Module: aum * Handle GONE exception * Mimic mobile application (#1041) * Fix: date used may be UTC * Fix: display of summary * Support new 'favorite_food' field * Go on website to get stats and geographical position * Read field ratio * Don't stop on threads with a contact who left the website * Fix: send email when taken in a basket Module: axabanque * Remove mkdtemp in module * Fix: crash on a new tab Module: banquepopulaire * Fix: parsing of some card transactions * Update regexps Module: barclays * Update regexps * Support market page (but do not display any history) * Support when accounts are in javascript... Module: bnporc * Remove mkdtemp in modul * Support pro accounts Module: boursoram * Take id of the website for transactions * On page to update user information, raise BrowserIncorrectPassword * Get maximum history * Do not crash for special accounts * Remove mkdtemp in module Module: bp * Fix: New SSL certificat Module: bred * Fix: deferred debit cards parsing Module: caissedepargne * Update regexps * New SSL certificat * Support more history Module: cic * support pagination * support wher forced to go on change_password page * Fix: crash on pagination Module: cmso * Update regexps Module: cragr * Use LinearDateGuesser * New maintener * Support new website Module: creditmutuel * Transfer now accepts long and short IDs * Support pagination * Support wher forced to go on change_password page * Fix: transfer problem * Fix: crash on pagination Module: dailymotion * Fix search * Avoid redirects * Fix: extraction of video url Module: dlfp * Do not crash when revision is provided(#1067) Module: fortuneo * Update regexps * Support when website asks to renew password * Fix: card transaction pattern * Fix: accounts list on new version of website * Get more history * Support PRLV pattern Module: francetelevisions * Fix: search Module: freemobile * Add an id for calls * Fix get_bill * Add multi-account support for bills command Module: gdcvault * Retrieve now video, audio, slides and Dual Screen Video * Implement searching * Implement login * Handle pages with redirects to files * Fix a lot of bugs on some pages Module: hsbc * Support deferred cards * Do not support other kind of account histories than CPT Module: ing * Detect when website is unavailable * Fix: new website * Fix: generation of IDs * Merge LoginPage and Login2Page to prevent problems when the website fails with 500 * Prevent useless debug folders Module: isohunt * Fix: bug if leech or seed is empty corrected * Fillobj integration Module: kickass * Fix: downloading gziped torrents * Fix: download URL and support magnets * Return NotAvailable if needed * Fix: url correction * Fix: download URL and magnet support in all iter_torrents Module: mediawiki * Add support for the revision argument Module: lcl * Support when there is an error * Remove mkdtemp in modules Module: leclercmobile * Add an id for balance objects Module: nettokom * Fix: crash when no data available * Display validity date of subscriptions Module: piratebay * Fix: bug on empty result page corrected * fillobj integration * get_torrent return None if 404 * Unescape title Module: presseurop * Better id management * Increase RSS size Module: redmine * Add support for the revision argument (#1067) Module: sachsen * Fix: as0.gif keyerror * Better image analyse Module: societegenerale * Fix: login * Fix: Do not crash when an account is unavailable * Fix: Transfer regexp * Recipient of a transfer can be a name Module: trictractv * Add an icon Module: vimeo * Fix for no-embed videos Module: wordreference * Fix: Take the first word * Make result cleaner * Add favicon Module: youtube * Fix: detection of media url on youtube Capabilitie: CapBank * More robust currency guessing * Fix repr() on transactions with unicode labels * support empty dates for transactions Documentation * New git URL * Add missing "whatis entry" to man pages (#618) Contrib * Add a "id_regexp" parameter to filter results on video id * Exclude on case sensitive pattern * Add utf-8 support on title_exclude Tools * Add basic boilerplate script (replace gen_comic_reader.sh) * Remove storage_convert.py * Ignore Qt generated UI files (pyflakes) Packaging * Update setup.py for latest Gentoo installs * Use a central Makefile * Fast and silent building * Ensure proper building of man pages * Tell groff manpages are utf-8 * Update INSTALL Weboob 0.e (2013-01-25) General * New module: Axa Banque (CapBank) (#807). * New module: Barclays bank (CapBank). * New module: Carrefour Banque (CapBank). * New module: Credit Cooperatif (CapBank). * New module: Credit Mutuel Sud Ouest (CapBank). * New module: Gan Assurances (CapBank). * New module: Mangago (CapGallery). * New script: anonymiser.sh. Module: Arte * Fix: parsing video title (site changed). Module: Banque Populaire * Update transaction regexps. * Correctly encode login and password. * Fix: change hostname of Aquitaine Centre atlantique bank region. * Fix: parsing accounts for some specific versions of website (reported by Alain Spaite). * Get the full label of an account. * Fix: parsing banquepopulaire accounts with no link. * Fix: crash where there is no transactions for an account. * Fix: date parsing (happy new year). * Add Credit Maritime regions compatibles with Banque Populaire. Module: bnporc * Add a second SSL cert. * Support international withdrawal. Module: Boursorama * Fix: Correctly parse label of deferred card transactions. * Support of Livret A accounts. * Support new Virtual keyboard. Module: bp * Fix: compatibility with python2.6. * Add a SSL timeout. * Support page delestage. * Support deferred debit. Module: Bred * Correctly encode login and password. * Support payment in several times. * Fix: parsing accounts when there are interlines. * ignore special accounts. * Fix: crash when there is no ID on a transaction. Module: Caisse d'épargne * Handle login errors. * Support when website is unavailable. * Parse more card transactions. * Fix: parsing funding accounts. * New favicon. Module: cic * New favicon. * Fix: parsing amounts in special cases * Fix: parsing card pages in special cases Module: cmb * do not consider special accounts * Fix: parsing balance Module: CrAgr * update transaction regexps * Fix: do not crash if there is no history link for an account * correctly use iterators Module: dlfp * Allow anonyme browsing (#923) * Fix: deconnection error * Fix: Support new html structure Module: ebonics * Add favicon Module: ehentai * Fix: Support new website Module: Fortuneo * Add new certificate Module: France Télévisions * Fix: Support new website Module: Freemobile * Fix: Support the new website * Add a real id for all details objects (#932) * Add renew date (#931) * Support of multi-accounts (#890) Module: Gazelle * Fix: parsing torrents descriptions Module: HSBC * Raise exception on login error Module: ING * Add ICapBill to download monthly reports (#897) * Add support of proxy account * Add support of Livret Epargne Orange accounts * Fix: crash when there is no operation on an account * Support question page Module: INA * Try to handle more videos Module: LCL * Fix: login regexp * Add the new SSL certificat * Add a pattern to detect cards Module: Leclercmobile * Fix: Support new versions of website Module: Le Figaro * Fix: encoding * Remove some unused files (#819) * Fix: author selection Module: Nettokom * Add validity date Module: Opacwebaloes * Fix: Accept ID with 8 chars (#921) Module: pastalacon * Remove some test warnings Module: pastebin * Fix: visibility detection * Fix: login without API * Remove some test warnings Module: Piratebay * Fix: search (site changed) Module: Presseurop * Remove tweeter sharing * Use clean_relativ_urls * Fix: Support new version of daily titles Module: Sachsen * Add a favicon * Search is no more case sentitive * Use ICapGauge instead of ICapWaterLevel * Get alarm level Module: Societegenerale * Handle error when service is unavailable * Update transaction regexps * New SSL certificat * Check date of card debit to apply it * Fix: crash on special accounts Module: Taz * Remove some adds Module: Wordreference * Fix: parsing (#840, #1036) Module: youporn * Set domain to www.youporn.com Module: youtube * Fix: login CapBank * Support currencies CapBill * Rename iter_history to iter_bills_history * Add validity and renew date fields CapCollection * Declare fields to avoid warnings CapGauge * Change API to be more flexible * Add GaugeSensor objects CapVideo * Fix: CapVideo-related ConversionWarnings (dailymotion, ehentai, francetelevisions, ina, radiofrance, youjizz, youporn, youtube) CapWaterLevel * Rename it to ICapGauge Console Applications * Properly get to the previous path, not home * Add support for ls -d option (#858) * Add global "insecure" option to skip SSL validation (#930) * Allow to exclude some backends (#617) Application: boobill * Add the keyword "all" to download command Application: boobmsg * Improve documentation of export_thread * Allow "show" command in non-interactive mode * Datetime now human readable Application: comparoob * Remove double products with multiple backends * Sort results in comparoob (#934) Application: radioob * Support of rtmp Application: videoob * Add -e to rtmpdump options * Allow to use all videos players * Allow to give arguments to players * Add mplayer2 support Application: weboob-config * fix double message "Unable to load module" Application: wetboobs * Change to use ICapGauge instead of ICapWaterLevel * Add sensors command Tools: html2text * Set INLINE_LINKS to false Tools: Newsfeed * Take the creation date if no update available Tools: Messages/GenericBackend * Get the real thread of an article * Add clean_relativ_urls function Tools: VirtKeyboard * Add an overridable method to check pixel colos * Add a parameter "convert" Tools: IParser * Add a raw parser Tools: LxmlParser * Get all strings under this element Tools: tests * Save and submit test results * Better way of handling non-module tests * Guess the right builder name * Use the guessed nosetests for the core tests too Tools: pyflakes * Use flake8 if available instead of pyflakes Core * Check value of ValueBackendPassword during load * Add new exception BrowserForbidden and add handler in applications * Fix langage when the lastet version is already installed * Allow multiple CERTHASH values in a module * Ability to specify a parser to use on a page handler Installation * setup.py: print what executable we were looking for * setup.py: be less confusing when make is missing Contrib: boobank-munin * Fix: encoding issue Contrib: downloadboob * Correctly create symlink and support when one is removed * 'exclude' parameter is case insensitive Contrib: nettokom-munin * Print all labels in config mode and stack results Weboob 0.d (2012-10-28) General * New module: BanquePopulaire (CapBank). * New module: Bred (CapBank). * New module: CaisseDEpargne (CapBank). * New module: CIC (CapBank). * New module: Ebonics (CapTranslate). * New module: EuroParl (CapVideo). * New module: GDCVault (CapVideo). * New module: LeclercMobile (CapBill). * New module: Vimeo (CapVideo). * New module: Weather (CapWeather). * New script: contrib/downloadboob to automatically download vidéos matching some criteria (#838). * Add a basic system to check SSL certificates. Console Applications * Correctly check new version of the module. * Short commands for all applications (and suggestions). Module: AuM * Add a status field to display number of new visits. * Support new API (#871,#900,#902). Module: BNPorc * Strip trailing 'CARTE XXX' from card transactions labels. * Get last 100 transactions instead of 30. * Fix: website changes. Module: Boursorama * Correctly handle case that we don't support the history page of an account. * Fix: unlimited loop in case of bad credentials. Module: BP * Parse labels and detect type of transactions. * Get maximum of transactions in history. * Workaround to libssl 1.0.1c-4 bug in Debian (#863). Module: CappedTV * Fix: proper handling of No Results Found. Module: CMB * Support proxy. * Check SSL certificate. * Fix: a bug in the accounts listing. Module: CrAgr * Reworked the whole parsing for 'list' and 'history' operations. * Parse labels and detect type of transactions. Module: CreditMutuel * Support deferred debit. * Never store 'RELEVE CARTE' transactions (redundancy with card transactions). * Fix: login (skip page which warns about phishing). Module: Dailymotion * Add support for embed URLs. * Fix: parsing authors on anyclip videos. * Fix: search-then-play combination (#860). Module: Fortuneo * Fix: website changes. * Fix: check on login failure. Module: FreeMobile * Catch unit for data. * Support multiple accounts. * Fix: login (website change). * Fix: pdf downloading. * Fix: international calls. * Fix: parsing name with a dash. Module: Gazelle * Fix: parsing title on whatcd. Module: HDS * Fix: parsing dates. Module: HSBC * Support history and coming transactions. * Fix: duplicated IDs of accounts. * Fix: parsing of accounts and history. Module: ING * Transaction IDs are generated with a hash function. * Use static IDs of accounts. * Support tranfers. Module: LCL * Parse labels and detect type of transactions. * Display password renewal warning. * Support CB operations. * Support several contracts. Module: LeFigaro * Fix: parsing of live articles. Module: Minutes20 * Fix: RSS feed url has changed. Module: Nettokom * Fix: website change about authentication. Module: Newsfeed * Add a link on top of content. Module: NolifeTV * Fix: authentication and retrieve of video url (#880). Module: Nova * Fix: retrieving of current song. Module: PAP * Fix: parsing housings (#874). Module: PressEurop * Fetch last 140 entries instead of 50. Module: PrixCarburants * Fix: regexp of product name in page. Module: RadioFrance * Support franceinfo archives. Module: SocieteGenerale * Truncate password to 6 digits. * Handle error message when unable to login. * Support deferred debit cards. * Fix: follow next pages of history. * Fix: website changes about authentication (#891). Module: Transilien * Support when a train is removed (#894). * Fix: parsing time (#866). Module: Yahoo * Fix: search of cities (website change). Module: Youjizz * Fix: parsing of duration. * Fix: parsing video url. Module: Youporn * Fix: website changed. Module: Youtube * Add support for youtube-nookie.com. * Fix: login and play of nsfw videos (#918). * Fix: finding video url (website change). Application: boobank * Fix: QIF spec requires capitalized 'type' (#898). Application: boobill * New command 'balance'. Application: comparoob * Fix: selection of product. Application: freemobile-munin * Add parameter 'phonenumber'. * Fix: data parsing. Application: havedate * Add command 'events'. Application: pastoob * Abort if paste is empty. Application: QHaveDate * Nicknames are selectable (#869). Application: QVideoob * White background is not forced anymore (#823). Application: translaboob * Add 'nigger' language. Application: weboob-debug * Support more shell libs (ipython, bpython, standard python). Appliccation: wetboobs * Ability to display temperatures either on celsius or on fahrenheit. Core * Use module 'imp' instead of '__import__'. * Fix table formatter with python-prettytable 0.6. Weboob 0.c (2012-05-04) General * New capability: CapPriceComparison. * New capability: CapTranslate. * New module: ChampsLibres (CapBook). * New module: Fortuneo (CapBank). * New module: GoogleTranslate (CapTranslate). * New module: NettoKom (CapBill). * New module: Okc (CapDating). * New module: PrixCarburants (CapPriceComparison). * New module: Taz (CapMessages). * New module: WordReference (CapTranslate). * New application: comparoob (CapPriceComparison). * New application: translaboob (CapTranslate). * New script: boobot. * New script: nettokom-munin (Nettokom). * New script: report_accounts.sh (CapBank). * Application havedate now inherits commands of boobmsg. * Fix: use the right default value for XDG_DATA_DIRS. Console Applications: * Add completion on 'ls' and 'cd' commands. * When a module requests to application a password (for example if it is not stored in the backend config), display a real question, not only 'Password:'. * Use $EDITOR env variable to edit input. * Rewrite of the formatters system. * When a bug occurs in a module, suggest user to update it. Capability: CapBank * Rename Operation object to Transaction. * Rename iter_operations() to iter_coming(). * Add a field Transaction.rdate to store date of payment. * Add field Transaction.type (enum). * Add field Account.type (enum). * Create a class FrenchTransaction in weboob.tools.capabilities.bank to help parsing transactions of french banks. * Use decimal.Decimal instead of float to store amounts of money. Module: AuM * Fix: website has changed its charset. * Fix: don't crash when a message content is empty. * Fix: save IDs as integers in storage. Module: Arte * Fix: getting latest videos. Module: BNPorc * Support private messages (CapMessages). * Fetch the last 100 transactions (instead of 30). * Support CIF accounts. Module: Boursorama * Parse categories and dates. * Ignore spurious accounts. * Fix: credit and debit where inversed. Module: BP * Don't list spurious accounts. Module: CrAgr * Fix: parsing dates. * Fix: CA Centre website has changed (#850). Module: CreditMutuel * Capitalize each words in account labels. * Fix: parsing accounts list whene there is no history associated. * Fix: parsing history when there are extra columns. * Fix: use unique IDs for accounts. Module: Dailymotion * Fix: getting latest videos. * Fix: getting thumbnails. * Fix: parsing video IDs. Module: DLFP * Do not get pages with 0 comment. * Add a cleanup function to dlfp backend. Module: FranceTelevisions * Fix: getting latest videos. Module: FreeMobile * Fix: remove timer (not more used by website). * Fix: website has changed. * Fix: multiple accounts login. Module: ING * Use FrenchTransaction for parsing transactions. * Get more historical transactions. * Catch error on password/birthday/login. * Fix: website changes on livret A history. Module: LCL * Add a regexp on password field. * Fix: getting accounts. * Fix: crash when the balance is negative. * Fix: site specific fix. * Fix: parsing account labels. * Fix: always go on the history page. * Fix: when history is empty. * Fix: prevent infinite loop when password is wrong. Module: MangaFox * Fix: domain name change. Module: PressEurop * Fix: parsing of cartoon pages. * Fix: real author catching on article pages. Module: RadioFrance * Fix: crash when there is no author. Module: Sachsen * Catch “Go Up” value. Module: SocieteGenerale * Support display of history and coming transactions. * Fix: when there is no transaction for the account. Module: Transilien * Fix: roadmap when there is no confirm page. Module: YouJizz * Fix: getting video URLs. Module: YouPorn * Fix: changes on website. Application: boobank * Add a new pretty_qif formatter (use label and rdate if exist). Application: boobathon * Fix: close command. Application: boobill * Get all available subscriptions for 'details' command (#846). Application: boobmsg * New command 'photos' to display photos of a contact with cacaview. * Add an 'atom' formatter. Application: bonboob * Add a command 'once' to process retrieving of messages once. Application: QWebContentEdit * Possibility to edit an url (#619). * Add a 'History' tab. Application: weboob-config * Remove 'install' command. Script: freemobile-munin * Fix: condition to detect empty output. Script: hds/export.py * Fix: loading HDS module. Core: * Change way to describe fields of CapBaseObjects. * Add a lot of code documentation. * Warn when implicit conversions happen on CapBaseObjects. * Create UserError exception for errors raised by modules. * Scheduler: do not stop timer because of an exception. * Repositories: support gpgv2 (#837). Weboob 0.b (2012-03-14) General * New capability: CapBill. * New capability: CapBook. * New capability: CapHousing. * New capability: CapWaterLevel. * New module: CappedTV (CapVideo). * New module: FreeMobile (CapBill). * New module: OpacWebAloes (CapBook). * New module: Pap (CapHousing). * New module: PressEurop (CapMessages). * New module: Sachsen (CapWaterLevel). * New module: SeLoger (CapHousing). * New application: boobill (CapBill). * New application: boobooks (CapBook). * New application: flatoob (CapHousing). * New application: QFlatBoob (CapHousing). * New contrib script: freemobile-munin. * Rename application: havesex -> havedate. * Rename application: QHaveSex -> QHaveDate. * Remove module: MangaToShokan (website is dead). Console applications: * Improvements of 'ls' and 'cd' commands. * Fix: crash when trying to add twice a same module. Module: Boursorama * Fix: IDs of operations. Module: BNPorc * Parse categories. * Parse account types. * Fix: getting history of secondary accounts. Module: BP * Store transactions dates as datetime.date objects. * Fix: parsing of accounts in particular cases. Module: CanalPlus * Friendlier paths in canalplus. Module: CMB * Add type and label support to CMB backend. Module: CrAgr * Now handle history-less accounts, at least for Toulouse-like layouts. * Transaction objects are now created using datetime.date (#800). * Fix: balance retrieval for history-less accounts (#788). Module: CreditMutuel * Store Transaction.date as a datetime.date object. * Support loan history. * Parse type of transactions. * Fix: lot of bugs. Module: DLFP * Parse a comment only if needed (performances enhancement). * Get comments only in case of rss-comments changes. Module: Ecrans * Store only last 20 articles. Module: HSBC * Display only real accounts. Module: ING * The account listing is now more robust. * Parse types of transactions. Module: Kickass * Fix: search was broken. Module: Mangafox * Fix: crash on Comments page. Module: NolifeTV * Support authentication. * Fix: parsing of videos with missing description. Module: OuiFM * Fix: error when no artist/title. Module: Pastebin * Fix: getting pastebin paste visiblity. Module: Piratebay * Support magnets properly. Module: RadioFrance * Support replay. * Use a better source for FIP. * Fix: fetching FIP current. Module: SocieteGenerale * Check if login is failed. Module: Youtube * Fix: crash when there is no author. Application: boobank * Display types of transactions. * Add formatter 'transactions'. Application: chatoob * Removed because unused. Application: videoob-webserver * Moved to contrib/. Application: weboob-config * Fix: command 'list' can filter by capability (#786). Application: weboorrents * Support magnet URLs. Application: wetboobs * Now supports CapWaterLevel in addition to CapWeather. Core: * Big refactoring of CapCollection. * Use libyaml for faster loading and saving. * Sign modules.list. * Support gzipped responses in Browser. * Fix: retrieving third icons if module is local. Weboob 0.a (2012-02-05) General * New backend: Boursorama (CapBank). * New backend: CMB (CapBank). * New backend: HSBC (CapBank). * New backend: ING (CapBank). * New backend: Nolifetv (CapVideo). * New backend: RadioFrance (CapVideo, CapRadio) which merges FranceInter and LeMouv backends. * Support repositories to manage backends (#747). * Support XDG Base Directory Specification (#765). * Make CapCollection understandable and usable by humans. Console applications * Ability to add all supported modules at once. * With -a, try to separate saved responses by backend (#661). Qt applications * Verbose error messages (#775). Backend: AuM * Display the 'title' field on contact profiles. * Get events (baskets, charms and visits). * Add city in status message. * Add 'Sent with my iPhone' in mail signatures when needed. * Display at least one photo url in profile even if there isn't any visible. * Add a 'ratio' field. * Fix: getting contacts list. * Fix: support new API. * Fix: ipaddr is not available anymore. * Fix: do not crash if there are php errors before json. Backend: Batoto * Change .com to .net. Backend: BNP * Fix: website changed (#769). Backend: BP * Fix: website changed. * Fix: open images in memory instead of saving them in temp files. Backend: CanalPlus * Support https?://www\.canal-?plus\.fr/.*\?vid=(\d+) urls. Backend: CreditMutuel * Internal transfer implemented. * Fix: website changed. Backend: Dailymotion * Fix: support missing descriptions. Backend: DLFP * Limit feed entries by date instead of number of results. Backend: FranceTelevisions * Fix: website changed. Backend: Gazelle * Handle general errors when website is unavailable. Backend: INA * Fix: parsing of URLs. Backend: Kickass * Fix: website changed. Backend: LCL * Add support for various types of accounts. * List 45 days history by default. * Fix: website changed. Backend: LeFigaro * Better cleanup of generic articles (#725). * Fix: website changed. Backend: Orange * Fix: unicode errors. Backend: Pastebin * Handle user pages. Backend: Piratebay * Fix: website changed. Backend: SocieteGenerale * Fix: website changed. Backend: Youjizz * Fix: video URLs have changed. Backend: Youporn * Fix: website changed. Backend: Youtube * Fix: website changed. Application: QBoobMsg * When a thread is a discussion, display messages linearly. * Add a button 'Profile'. Application: QHaveSex * Add a 'Events' tab. * Add a 'Notes' tab for taking notes about a contact. Application: QVideoob * Fix: crash when there is no thumbnail on a video (#708). Application: weboob-config-qt * Ability to edit sources.list, update repositories and install modules. Weboob 0.9 (2011-10-10) General * New backend: Batoto (CapGallery). * New backend: Eatmanga (CapGallery). * New backend: FranceTelevisions (CapVideo). * New backend: HDS (CapMessages). * New backend: Izneo (CapGallery). * New backend: Mangafox (CapGallery). * New backend: Mangahere (CapGallery). * New backend: Mangareader (CapGallery). * New backend: Mangatoshokan (CapGallery). * New backend: Nova (CapRadio). * New backend: PhpBB (CapMessages, CapMessagesReply). * New backend: Simplyread.it (CapGallery). * New application: boobtracker (CapBugTracker). * New script: hds/export.py to export stories from histoires-de-sexe.net into a sqlite database. * License change to AGPLv3+. * Ability to not save backend passwords. Applications will prompt them when needed. Backend: Arte * Set duration on video results. Backend: AuM * Rewrite to use the mobile API. Backend: BNPorc * Get operation categories. Backend: CrAgr * Get full history. * Optimized operations retrieval for CA Centre. * Fix: parsing accounts list. Backend: CreditMutuel * Maine-Anjou, Basse-Normandie bank added. Backend: Dailymotion * Fix: parsing duration. * Fix: parsing of lives in search results. Backend: DLFP * Fix: disconnection URL needs to be called with POST instead of GET. * Fix: do tests on alpha.linuxfr.org. * Fix: relevance on news/diaries. Backend: Gazelle * Handle login errors. * Fix: parsing on several gazelle websites. Backend: INA * Support videos on www.ina.fr (in addition to boutique.ina.fr). Backend: IPInfoDB * Fix: no crash when there are no coordinates from server. Backend: Kickass * Fix: parsing of search results (#663). Backend: MediaWiki * Handle errors from API. Backend: MeteoFrance * Fix: website changes. Backend: Orange * Fix: handling of pages. Backend: PirateBay * Fix: parsing of search results. Backend: Redmine * Now implements CapBugTracker (#684). Backend: Transilien * Supports the roadmap feature (#681). Backend: Youtube * Support more URLs. * Support authentication. * Fix: website changes. Application: boobank * Add the 'qif' formatter. Application: boobank-munin * When handling an incorrect password error, disable backend to prevent your bank to disable your account (for example with BNP). Application: pastoob * Ability to pipe output. Application: traveloob * New command 'roadmap' to get the roadmap between to stations. It's also possible to give a departure or an arrival time (#681). Application: videoob * Do not run player in background (#664). * Command 'download' supports mms streams. Application: weboorrents * The given filename to command 'getfile' is optional (#683). Weboob 0.8 (2011-05-08) General * New backend: E-Hentai (CapGallery). * New backend: FranceInter (CapRadio). * New backend: LeMouv (CapRadio). * New backend: PasteALaCon (CapPaste). * New backend: PasteBin (CapPaste). * New application: Boobathon (CapContent). * New application: Galleroob (CapGallery). * New application: Pastoob (CapPaste). * Fix lot of unicode problems. * License changed to AGPLv3+. * FreeBSD support. Repl applications * The new CapCollection capability is supported by every REPL Application. At the moment, only few backends implement it. * Better messages and return codes in applications. Backend: AdopteUnMec * Fix: website changes (#508,#637,#638,#639). Backend: BNPorc * The 'rotating_password' parameter is now an hidden one (#627). * Ability to do transfers to external recipients. Backend: BP * Add 'comptes titres', 'comptes vies' and 'comptes retraites' to the list of accounts (#567). * Fix: website changes (#621). Backend: CanalPlus * Implement the new CapCollection capability. Backend: CrAgr * Support of a new history layout. * Fix: login issues with the Toulouse website (#629). Backend: Dailymotion * Fix: URL was not found in special cases. Backend: FourChan * Fix: support message "AMERICA FUCK YEAH" outside of a thread. Backend: Gazelle * Fix: work with broken gazelle websites. Backend: Inrocks * Fix: matching URLs. Backend: KickAss * Several fixes and enhancements (#651). Backend: LCL * Fix: websites changes. Backend: OuiFM * Implements the new CapCollection capability. Backend: Transilien * Add the PAA code for Gare de Lyon. Backend: Youtube * Support more URLs. Backend: Youporn * Correctly set the 'ext' attribute on videos. Application: monboob * Check configuration (#484). Application: weboob-config * New commands 'enable' and 'disable'. Core * Use lowercase http_proxy environment variable. * select() function has been moved into parser. * Support for xpath in LxmlHtmlParser.select. * Fragments are removed from URLs (#636). * Remove a hack from feedparser which fixes parsing of webpages with recent versions of this library. * Also log redirects when saving responses and debugging (#398). Weboob 0.7 (2011-04-01) General * New backend: Dailymotion (CapVideo). * New backend: Ecrans (CapMessages). * Now compatible with Windows (is it really a good news? :)). Console applications * Do not print escape characters (like bold) when using -O. Backend: AuM * Fix: parsing of smileys (#532). * Fix: new page (#535). Backend: BP * Fix: parsing of accounts is case there are missing sections. Backend: CreditMutuel * Compatibility with other agencies (#550). Backend: DLFP * Ability to plusse/moinse contents. * Ability to tag a content. * Support the board. * Support comments signatures. * Support wiki, forums, polls, tracker. * Now implements CapContent to edit wiki. Backend: FourChan * All messages are children of thread. Backend: Inrocks * Add support of 'InrocksTV' pages. Backend: IpInfoDB * Fix: crash when lat/long are empty (#585). Backend: LCL * Fix login, and implement CapBank methods. Backend: Newsfeed * Fix: correctly set the UNREAD flag. Backend: Orange * Fix: posting messages (#614). Backend: Redmine * Fix: support project names with '-' in. Backend: Transilien * Fix: don't keep previous results. * Change user-agent of browser and use HTTPS (#580,#583). Backend: Youjizz * Fix: crash when duration is not available. Backend: Youtube * Now correctly handle gdata errors. * Fix: get video from page URL. * Fix: get file URL of video. Application: boobmsg * New command 'export_all'. * New xhtml formatter. Application: masstransit * Works without conic or hildon (#562). * Add banner on load. Application: QWebContentEdit * Better errors management. Application: videoob * New command 'download'. Application: webcontentedit * Set a default editor (#557). Core * Split of ReplApplication to create ConsoleApplication. * Remove the 'refresh' feature from Browser (to prevent unwanted behaviors like freezes). * Browser has upgraded Firefox from 3.0.3 to 3.6.13. * Browser doesn't retry on 404 errors. * Script to generate Sphinx API documentation. Weboob 0.6 (2011-03-01) General * New backend: Inrocks (CapMessages). * New backend: LeFigaro (CapMessages). * New backend: MediaWiki (CapContent). * New backend: Minutes20 (CapMessages). * New application: QWebContentEdit (CapContent). Backend: AuM * Fix: website changed, mails.php renamed to mail.php. Backend: BNP * Fix: the captcha has been changed on their website (#461). Backend: CrAgr * Fix: the history operation works when every non-ASCII character on the bank website is replaced with two interrogation marks. * Fix: calculation of cents. Backend: CreditMutuel * Fix: negative value correctly considered by 'list' Backend: DLFP * Fix: website changed to a new version (#503). Backend: IsoHunt * Fix: website doesn't provide seed information on info page anymore (#529). Backend: KickAss * Fix: size span detection improved (fixes #497). Backend: OuiFM * Fix: website changed to get current song. Backend: PirateBay * Fix: parsing to find leecher and seeders (#458). Backend: Redmine * Adds support for previewing modifications on redmine's wiki pages. * Fix: when login/password is invalid. Backend: Yahoo * Fix: didn't load with python < 2.6 Application: boobmsg * New command 'export_thread'. * New parameter '-t' on the 'post' command to set a title. Application: monboob * Fix: catch errors when trying to bind the SMTP server (#485). Application: QBoobMsg * Fix: reload of backends list. Application: webcontentedit * New command 'log' to display all revisions of a page. Application: weboob-config * The 'edit' command can be used to interactively edit one backend, instead of opening the './weboob/backends' file with a text editor. * Checks on given backends for 'backends ' subcommands. Application: weboob-config-qt * Fix: crash when trying to add an already existing backend. Repl Applications * New parameter '-O' to set an output file. Core: * Fix: Browser.location() crashes when uri is empty (#488). * Fix: catch every exceptions when loading a backend (not only ImportError). Weboob 0.5 (2011-01-08) General * New backend: MeteoFrance (CapWeather). * New backend: Orange (CapMessages, CapMessagesPost). * A new tool, make_man.py, is used to generate manpages. Backend: Bouygues * Fix: logging issues (#444). Backend: CrAgr * Fix: do not keep accounts list in cache. * Fix: extraction of amounts >999€ and negative amounts. Backend: KickAss * Fix: website changes (#457). * Fix: size parsing. Backend: PirateBay * Fix: size parsing. Backend: Yahoo * The 'search' command is implemented. Backend: Youtube * Fix: website changes (#450). Application: boobmsg * The 'post' command can take message from command-line instead of stdin. * Fix: encoding problems. Application: videoob * Fix: playing videos in some cases (#446). Application: wetboobs * Rewrite of application to use formatters. Weboob 0.4 (2010-12-01) General * New backend: Bouygues (CapMessagesPost). * New backend: CanalPlus (CapVideo). * New backend: CreditMutuel (CapBank). * New backend: IPInfoDB (CapGeolocIp). * New backend: IsoHunt (CapTorrent). * New backend: KickAss (CapTorrent). * New backend: PirateBay (CapTorrent). * New backend: SFR (CapMessagesPost). * New backend: SocieteGenerale (CapBank). * New application: boobmsg (CapMessages, CapMessagesPost). Console applications * New command 'inspect' to open a graphical webkit browser with the current page (to help debugging). If it is not available, the page source is displayed on stdout. * In question prompts, display a bullet list when there are too many choices. * The --save-responses (-a) parameter stores now pages in a directory and save here a debug log and a list of visited URLs associated to the files. * Fix unicode issues (#436). Backend: AuM * Do not send baskets messages from left sluts. * Anti-spam is updated. * Raise an error when user is banned. * New optimization PRIORITY_CONNECTION to create fake godchilds to allow user access to website between 18h and 1h. (#319) * New optimization QUERIES_QUEUE to enqueue queries in case no charms are available. * New backend parameter 'baskets' to enable getting baskets messages. * In profiles, look for hidden photos. Backend: BNPorc * Fix: display of coming operations. * Fix: check if the password rotation has been succeed. Backend: BP * Backend has been rewritten to use BaseBrowser (#422). * Fix: backend initialization. * Fix: parsing of accounts. * Fix: handle of transfers errors. Backend: CrAgr * Support of history operations. * Support monay transfers. * Choose the agency website in a list instead of giving URL. Backend: DLFP * Store datetime from newsfeed in the Thread object (#419). * Now the session is closed at deinit. * Fix: when posting a comment, send right parameters to immediately display it. Backend: GeolocIP * Use the website www.geolocip.com instead of www.geolocalise-ip.com. It prevents authentication and limits. Backend: INA * Fix: parsing date, duration and title. Application: boobank-munin * Save cache in .weboob/munin/ and handle errors. * New option 'boobank_cumulate' to display graph as areas instead of plots. Application: havesex * The optimizations management has been rewritten. * New command 'query' to send a query to a contact (like a charm or a poke). * Fix: do not exist after displaying a profile in interactive mode. Application: monboob * New option to pipe mails to an external process instead of sending it to a SMTP server. * Fix: when domain in In-Reply-To contains a '@'. * Fix: parsing incoming mails when no charset is supplied. * Fix: unicode issues. Application: QHaveSex * Display URL of contacts. * Contacts list is now sorted. * Have a photos caroussel on profile page. Application: weboob-config * New command 'confirm'. It takes an email in stdin and call corresponding backend to go on the confirm address. It is useful to automatically confirm account register. Application: weboorrents * Ability to complete paths. Core * The 'repeat' scheduler has been rewritten. * Ability to cancel a scheduled task. * Fix parsing of path-like in INI config. * Conditions are now treated by BackendsCall instead by formatters (#372). * Backends name can now contain only letters and digits. * Add a tool to generate manpages. Weboob 0.3 (2010-11-01) General * New backend: LCL (CapBank) -- unfinished. * New backend: OuiFM (CapRadio). * New backend: Newsfeed (CapMessages). * New backend: Redmine (CapContent). * New application: radioob (CapRadio). * New application: webcontentedit (CapContent). * New application: boobank-munin is a plugin for munin (CapBank). * New tests. * New global parameter --logging-file to log into a file instead of stdout. * Logging is now colorized when printed on stdout (depending on level). Console Applications * Formatters management have been rewritten. Now each command can set its own default formatter, and user can redefine them. * If output exceed the height of term, ask user to press a key for each page. * Do not display columns when all of these values are NotLoaded or NotAvailable. * Add a CSV formatter (#350). * Command 'backends register' to register a new account (#294). * Can use '$full' and '$direct' selectors. Backend: Arte * Fix: fall-back when the wanted quality is not available. Backend: AuM * New anti-spam feature to detect, block and report spambots (#313). * Implements the capability CapAccount to register new accounts (#389). * In profile walker, when reloading sluts list from search page, do not keep the previous queue to prevent visiting sluts who have been added a long time before and who are now disconnected. * Contact status is now 'connected'/'not connected since ... hours'. * Fix: do not crash if contact list is empty. Backend: BNPorc * If password is expired, switch with the value of the new 'rotating_password' backend setting. * Support transfers (#416). * Fix: don't crash when accounts don't support 'coming' (#401). * Fix: when website is not available, raise BrowserUnavailable instead of BrowserIncorrectPassword. Backend: DLFP * Replace 'cite>' and 'tt>' to 'i>' in read messages. Application: boobank * Use 'table' as default formatter. * Output for the 'list' command is more readable (#410). * When a transfer is made, display all information instead of ID. * Fix: do not load backends twice (#405). Application: QBoobMsg * Support threads display and answers. * Support sending answers (plaintext or HTML). * Unread messages are in yellow in list, and set message as read when one is selected. * Fix: correctly reload when backends have been changed. Application: QHaveSex * Ability to display a profile from URL. Application: QVideoob * Fix: search on youtube was unlimited, so QVideoob freezed. Application: traveloob * Use 'table' as default formatter. Application: videoob * Output for the 'search' command is more readable. Application: weboob-config * Add a 'register' command (#294). Application: weboob-config-qt * Add a 'Register' button to register a new account on a backend (#390). Application: weboorrents * Output for the 'search' and 'info' commands is more readable. Core * Weboob.load_backends() takes a new 'errors' argument. * CapBaseObject has a new method 'add_field' to add a field property which forces a specific type and is set to NotLoaded by default. * Browser.readurl() can take same arguments than Browser.openurl(). * If a page is not recognized by the Browser instance, save response even if -a is not supplied. * Introduce 'Value' classes to replace BaseBackend.ConfigField and is used by ReplApplication.ask(). * Use several loggers for parts of weboob. * Fix: crash when HTTP server returns shit (#406). Weboob 0.2 (2010-10-01) * Backend 'yweather' renamed to 'yahoo'. * New capability: ICapGeolocIp to geolocalise IP addresses. * New backend Arte: for the arte.tv french TV website. * New backend GeolocIp: for the geolocalise-ip.com website. * New backend BP: for the “Banque Postale” french bank. * AuM backend: check when the account is blocked. * AuM backend: ability to register new account. * BNPorc backend: support history. * CrAgr backend fix: support of another version of Credit Agricole. * CrAgr backend fix: check if website is down. * DLFP backend: display comments link in signature. * DLFP backend fix: parsing of comments when templeet sucks. * Youtube backend: support infinite searches. * Youtube backend fix: parsing of URLs (#388). * New application geolooc: a console application to interact with ICapGeolocIp backends. * New application weboob-cli: a console application to interact with every backends. * boobank application: new command 'history'. * boobank application: new command 'transfer'. * QHaveSex application: know if a message has been read or not. * videoob application: new command 'play'. * Console applications: can be interactive (repl) when run without any command (#353). * Console applications: if no backends are loaded at startup, ask user to add them. * Console applications: -s '*' fills objects. * Qt applications: display configuration window if no backends are loaded at startup. * Core: ability to fill objects already fetched to complete them. * Core: ICapMessages has been rewritten to be more efficient. * Core: can enable or disable backends. * Core: a test architecture has been written. * Core: all loaded backends now need to be configured (#368). * Core: new pargument --save-responses to debug HTML pages (#274). * Core fix: handle read URL data failure. * Core fix: Client is merged into mechanize >= 0.2 (#362). Weboob 0.1 (2010-08-03) * First public release. * The core system can load/unload backends, supports configured backends, can do asynchronous calls to specific backends. * Capabilities are abstractions to be overloaded by backends: - ICapBank - ICapChat - ICapContact - ICapDating - ICapMessages - ICapMessagesReply - ICapTorrent - ICapTravel - ICapVideo - ICapWeather * Backends interact with websites: - AuM - BNPorc - CanalTP - CrAgr - DLFP - FourChan - Gazelle - INA - Transilien - YouJizz - YouPorn - YouTube - YWeather * Applications interact with backends: Console - boobank - chatoob - havesex - traveloob - videoob - weboob-config - weboorrents - wetboobs Nokia N900 Phones - masstransit Daemon - monboob Qt - QBoobMsg - QHaveSex - QVideoob - weboob-config-qt Web - videoob-web-server weboob-1.1/INSTALL000066400000000000000000000040071265717027300136740ustar00rootroot00000000000000Weboob installation =================== Using the packages provided by your distribution is recommended. See http://weboob.org/install for a list of available packages. Since there are many dependencies, when you install from sources, you have to handle them by hand, according to your distribution. The requirements are provided in ``setup.py``, except for: * gpgv (for secure updates). If not packaged alone, it should be in ``gnupg`` or ``gpg``. * PyQt4 (python-qt4) for graphical applications. * For more performance, ensure you have ``libyaml`` and ``simplejson`` installed. Some modules may have more dependencies. All installation procedures allow you to chose whether you want graphical applications. Add ``--no-qt --no-xdg`` to disable them; ``--qt --xdg`` to enable them. After a package or system installation, you should run ``weboob-config update`` as your login user. User installation ----------------- There is a way to install weboob locally without messing with your system. Run ``./tools/local_install.sh`` as your local user. :: $ ./tools/local_install.sh ~/bin The scripts are copied to ``~/bin``. System installation (discouraged) --------------------------------- The install mode copies files to the Python system-wide packages directory (for example ``/usr/lib/python2.5/site-packages`` for Python 2.5, or ``/usr/local/lib/python2.6/dist-packages`` for Python 2.6). :: # ./setup.py install Scripts are copied to ``/usr/bin``. Development mode ---------------- This does not actually install anything, but lets you run Weboob from the source code, while also using the modules from that source. This is only recommended if using the git source and not a release. :: $ ./tools/local_run.sh APPLICATION COMMANDS For example, instead of running ``videoob -b youtube search plop``, you would run:: $ ./tools/local_run.sh videoob -b youtube search plop Bash completion --------------- To enable bash completion, just source the ``tools/weboob_bash_completion`` file from your ``~/.bashrc`` file. weboob-1.1/MANIFEST.in000066400000000000000000000004001265717027300143720ustar00rootroot00000000000000include COPYING include INSTALL include README include AUTHORS include ChangeLog include desktop/* include icons/* include man/* recursive-include contrib * recursive-include weboob/applications Makefile recursive-include weboob/tools/application Makefile weboob-1.1/MANIFEST.in.modules000066400000000000000000000000771265717027300160530ustar00rootroot00000000000000recursive-include modules *.py recursive-include modules *.png weboob-1.1/README000066400000000000000000000022501265717027300135210ustar00rootroot00000000000000Weboob is a project which provides a core library, modules and applications. Overview -------- The core library defines capabilities: features common to various websites. For example, http://www.youtube.com/ and http://www.dailymotion.com/ both provide videos; Weboob defines the "CapVideo" capability for them. Each module interfaces with a website and implements one or many of these capabilities. Modules can be configured (becoming a "backend"), which means that the end-user can provide personal information to access the underlying website, like a login and password. Applications allow the end-user to work with many modules in parallel, in a multi-threaded way. For example, one could search a video on many websites at once. Applications are toolkit-agnostic. They can use GTK+, Qt or be text-only. The latter can be used either in an interactive way or in pipes. The core library provides base classes which help developers write modules and applications. Weboob is written in Python and is distributed under the AGPLv3+ license. For more information, please go to the official website at http://weboob.org/ Installation is described on the website or in the INSTALL file. weboob-1.1/build.mk000066400000000000000000000006241265717027300142740ustar00rootroot00000000000000core := weboob/tools/application/qt applications := qboobmsg qhavedate qwebcontentedit qflatboob qcineoob qcookboob qhandjoob ifeq ($(WIN32),) applications += qvideoob endif directories := $(core) $(applications:%=weboob/applications/%/ui) .PHONY: clean all $(directories) all: target := all all: $(directories) clean: target := clean clean: $(directories) $(directories): $(MAKE) -C $@ $(target) weboob-1.1/contrib/000077500000000000000000000000001265717027300143025ustar00rootroot00000000000000weboob-1.1/contrib/anonymiser.sh000077500000000000000000000020461265717027300170270ustar00rootroot00000000000000#!/bin/bash # A special file with the list of words to replace. The format is one word per line, with a tabulation as separation # Example: # name offuscatedname # phonenumber 111111 anonymise_list="Anonymiser" # Take the folder to anonymise as argument, and check if it is a folder if [ $# -gt 0 ] && [ -d $1 ] then dossier=$1 else echo "Usage: $0 FOLDER" echo "For example : $0 /tmp/weboob_session_NLSIls/freemobile/" exit 1 fi if [ ! -f $anonymise_list ] then echo "Please create the $anonymise_list file (see documentation)" exit 1 fi # remove potentials old files find $dossier -name \*_anonymised -delete rm -rf $dossier/Anonyme for file_to_anonymise in `find $dossier -type f` do file=$file_to_anonymise"_anonymised" cp $file_to_anonymise $file cat $anonymise_list | tr '\t' '_' | while read line do to_replace=$(echo "$line"|cut -d_ -f1) replace_with=$(echo "$line"|cut -d_ -f2) sed -i "s%$to_replace%$replace_with%Ig" $file done done mkdir $dossier/Anonyme find $dossier -name \*_anonymised -exec mv \{\} $dossier/Anonyme \; weboob-1.1/contrib/boobank_indicator/000077500000000000000000000000001265717027300177515ustar00rootroot00000000000000weboob-1.1/contrib/boobank_indicator/CHANGELOG.md000066400000000000000000000002211265717027300215550ustar00rootroot00000000000000This file will only list released and supported versions, usually skipping over very minor updates. 0.0.1 ===== * Mar 26, 2015 * First release weboob-1.1/contrib/boobank_indicator/MANIFEST.in000066400000000000000000000002471265717027300215120ustar00rootroot00000000000000include boobank-indicator/data/indicator-boobank.png include boobank-indicator/data/green_light.png include boobank-indicator/data/red_light.png exclude screenshot.pngweboob-1.1/contrib/boobank_indicator/README.md000066400000000000000000000033531265717027300212340ustar00rootroot00000000000000Weboob ========== Weboob is a project which provides a core library, modules and applications such as boobank. Overview -------- The core library defines capabilities: features common to various websites. Each module interfaces with a website and implements one or many of these capabilities. Modules can be configured (becoming a "backend"), which means that the end-user can provide personal information to access the underlying website, like a login and password. Applications allow the end-user to work with many modules in parallel, in a multi-threaded way. The core library provides base classes which help developers write modules and applications. Weboob is written in Python and is distributed under the AGPLv3+ license. For more information, please go to the official website at http://weboob.org/ ##Installation boobank_indicator is distributed as a python package. Do the following to install: ``` sh sudo pip install boobank_indicator OR sudo easy_install boobank_indicator OR #Download Source and cd to it sudo python setup.py install ``` After that, you can run `boobank_indicator` from anywhere and it will run. You can now add it to your OS dependent session autostart method. In Ubuntu, you can access it via: 1. System > Preferences > Sessions (OR) 2. System > Preferences > Startup Applications depending on your Ubuntu Version. Or put it in `~/.config/openbox/autostart` ###Dependencies - weboob >= 1.0 - gir1.2-appindicator3 >= 0.1 - gir1.2-notify >= 0.7 ###Troubleshooting If the app indicator fails to show in Ubuntu versions, consider installing python-appindicator with `sudo apt-get install python-appindicator` weboob gir1.2-appindicator3 gir1.2-notify` ##Author Information - Bezleputh () weboob-1.1/contrib/boobank_indicator/__init__.py000066400000000000000000000000001265717027300220500ustar00rootroot00000000000000weboob-1.1/contrib/boobank_indicator/boobank_indicator/000077500000000000000000000000001265717027300234205ustar00rootroot00000000000000weboob-1.1/contrib/boobank_indicator/boobank_indicator/__init__.py000066400000000000000000000000001265717027300255170ustar00rootroot00000000000000weboob-1.1/contrib/boobank_indicator/boobank_indicator/boobank_indicator.py000066400000000000000000000143251265717027300274460ustar00rootroot00000000000000#!/usr/bin/env python import os import logging from threading import Thread from signal import signal, SIGINT, SIG_DFL from pkg_resources import resource_filename from gi.repository import Gtk, GObject, Notify from gi.repository import AppIndicator3 as appindicator from weboob.core import Weboob, CallErrors from weboob.capabilities.bank import CapBank from weboob.capabilities import UserError from weboob.tools.application.base import MoreResultsAvailable from weboob.exceptions import BrowserUnavailable, BrowserIncorrectPassword, BrowserForbidden, BrowserSSLError PING_FREQUENCY = 3600 # seconds APPINDICATOR_ID = "boobank_indicator" PATH = os.path.realpath(__file__) def create_image_menu_item(label, image): item = Gtk.ImageMenuItem() img = Gtk.Image() img.set_from_file(os.path.abspath(resource_filename('boobank_indicator.data', image))) item.set_image(img) item.set_label(label) item.set_always_show_image(True) return item class BoobankTransactionsChecker(Thread): def __init__(self, weboob, menu, account): Thread.__init__(self) self.weboob = weboob self.menu = menu self.account = account def run(self): account_history_menu = Gtk.Menu() for tr in self.weboob.do('iter_history', self.account, backends=self.account.backend): label = "%s - %s: %s%s" % (tr.date, tr.label, tr.amount, self.account.currency_text) image = "green_light.png" if tr.amount > 0 else "red_light.png" transaction_item = create_image_menu_item(label, image) account_history_menu.append(transaction_item) transaction_item.show() self.menu.set_submenu(account_history_menu) class BoobankChecker(): def __init__(self): self.ind = appindicator.Indicator.new(APPINDICATOR_ID, os.path.abspath(resource_filename('boobank_indicator.data', 'indicator-boobank.png')), appindicator.IndicatorCategory.APPLICATION_STATUS) self.menu = Gtk.Menu() self.ind.set_menu(self.menu) logging.basicConfig() if 'weboob_path' in os.environ: self.weboob = Weboob(os.environ['weboob_path']) else: self.weboob = Weboob() self.weboob.load_backends(CapBank) def clean_menu(self, menu): for i in menu.get_children(): submenu = i.get_submenu() if submenu: self.clean_menu(i) menu.remove(i) def check_boobank(self): self.ind.set_status(appindicator.IndicatorStatus.ACTIVE) self.clean_menu(self.menu) total = 0 currency = '' threads = [] try: for account in self.weboob.do('iter_accounts'): balance = account.balance if account.coming: balance += account.coming total += balance currency = account.currency_text label = "%s: %s%s" % (account.label, balance, account.currency_text) image = "green_light.png" if balance > 0 else "red_light.png" account_item = create_image_menu_item(label, image) thread = BoobankTransactionsChecker(self.weboob, account_item, account) thread.start() threads.append(thread) except CallErrors as errors: self.bcall_errors_handler(errors) for thread in threads: thread.join() for thread in threads: self.menu.append(thread.menu) thread.menu.show() if len(self.menu.get_children()) == 0: Notify.Notification.new('Boobank', 'No Bank account found\n Please configure one by running boobank', 'notification-message-im').show() sep = Gtk.SeparatorMenuItem() self.menu.append(sep) sep.show() total_item = Gtk.MenuItem("%s: %s%s" % ("Total", total, currency)) self.menu.append(total_item) total_item.show() sep = Gtk.SeparatorMenuItem() self.menu.append(sep) sep.show() btnQuit = Gtk.ImageMenuItem() image = Gtk.Image() image.set_from_stock(Gtk.STOCK_QUIT, Gtk.IconSize.BUTTON) btnQuit.set_image(image) btnQuit.set_label('Quit') btnQuit.set_always_show_image(True) btnQuit.connect("activate", self.quit) self.menu.append(btnQuit) btnQuit.show() def quit(self, widget): Gtk.main_quit() def bcall_errors_handler(self, errors): """ Handler for the CallErrors exception. """ self.ind.set_status(appindicator.IndicatorStatus.ATTENTION) for backend, error, backtrace in errors.errors: notify = True if isinstance(error, BrowserIncorrectPassword): msg = 'invalid login/password.' elif isinstance(error, BrowserSSLError): msg = '/!\ SERVER CERTIFICATE IS INVALID /!\\' elif isinstance(error, BrowserForbidden): msg = unicode(error) or 'Forbidden' elif isinstance(error, BrowserUnavailable): msg = unicode(error) if not msg: msg = 'website is unavailable.' elif isinstance(error, NotImplementedError): notify = False elif isinstance(error, UserError): msg = unicode(error) elif isinstance(error, MoreResultsAvailable): notify = False else: msg = unicode(error) if notify: Notify.Notification.new('Error Boobank: %s' % backend.name, msg, 'notification-message-im').show() def main(self): self.check_boobank() GObject.timeout_add(PING_FREQUENCY * 1000, self.check_boobank) Gtk.main() def main(): signal(SIGINT, SIG_DFL) GObject.threads_init() Notify.init('boobank_indicator') BoobankChecker().main() if __name__ == "__main__": main() weboob-1.1/contrib/boobank_indicator/boobank_indicator/data/000077500000000000000000000000001265717027300243315ustar00rootroot00000000000000weboob-1.1/contrib/boobank_indicator/boobank_indicator/data/__init__.py000066400000000000000000000000001265717027300264300ustar00rootroot00000000000000weboob-1.1/contrib/boobank_indicator/boobank_indicator/data/green_light.png000066400000000000000000000022151265717027300273260ustar00rootroot00000000000000PNG  IHDRw=tEXtSoftwareAdobe ImageReadyqe</IDATxڴU]hU=333?1%Ң> bJQ{P)C%Ub҅(" 4$b}Ň4)6&ٝ?~3nl6/\g{ιoVRBQtgj$uR Z PTJT]w"& 'eB39f3_" pO<^E 5(pV#a +imA~ `A -J'A@k79"0DEʌmE;UTG7_.ԕogkncuZ*?^Ӣ:)'T4UMi=[}3F/gY{}qb)t۲Jd8$~!ɥvs/- BYh#Ff܋  #`  $<0'[P JhhHaW"<-$t$mX] EERσXhŝHTjT CNQf?^w[_۱聋) H4wtƭ 6&Z[lǔpgKI&'rw{FkoxK)}YakZ \x7qri92;P3ϾÃOhkZ_;fzdK ~xvM4EC滹̘7Vb:Xtϰ慃3eYysN$wpM'/W嫶z199$۟\@=96'Kc Iv`)I@ 4x?([X{ۓ !ɜ3՘$_s!}^0~6oاgh+AB5Ɣa$\Z=G۟ w<Һ?7o<x 0wv(IENDB`weboob-1.1/contrib/boobank_indicator/boobank_indicator/data/indicator-boobank.png000066400000000000000000000031401265717027300304220ustar00rootroot00000000000000PNG  IHDRw=tEXtSoftwareAdobe ImageReadyqe<iTXtXML:com.adobe.xmp etaFIDATxVNPnm->QV"nn]&erT' u`sɵPē{{ l6i4ZnI/ cuHa@ gHYDTI@ezxm:If䌨Erv/b(F E}> 2Q_RXnh,3 حf#Q$z1K 4tq"h?-sVQ<P ]ZX&;Oƃ`]24꽺"ǑZ$˽a'8Ai0&Rl"+v` p`&tߎ{Z #UdJ:hbͯ8]Wiˎ2B0?/ѥABr5g- lmL![8Z;<:LS-㌛[MPWϩTn6w pAz=\MTYd/rTv]v8[I`&LM.6~Gm۾f9&NZ><<!.tsIENDB`weboob-1.1/contrib/boobank_indicator/boobank_indicator/data/red_light.png000066400000000000000000000017061265717027300270040ustar00rootroot00000000000000PNG  IHDRw=tEXtSoftwareAdobe ImageReadyqe<hIDATxڴUKWnU1-ED0.˪C PAA&@wɠUp e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_I˾n;xsrIɏU2%|f>Q%eh_,6~ީ%5{l4m=xs1)g1rg=2e{HX3eRST~ 3KpY$ Ylh-4Pb|P[hbi{ GXn"ɀR@FRO2 ˏTTgUGἼR= u_Z}a^\_jS+Qd!gKxY?` =*`-y.!r=c$!ޏpΆu0oh˹0v(/~>  , P$6A-1x'^dVq]" A%D@Rɴȥ:?T1yF0c6(r]h30,c-= S)˿VQh؋nO)ˎt^of-҃3 LX;Qd?+@8x7ѕhڏI;Ɍk2h%~ʆ4Rmªⴤ瘔NR'lƠʿ!|L]z>ۭ-LAf`-t&<E#A|_6;G;gpkl225ܐˁ2ct]p穖PB3&êrpKU¢" )*96wÕVv>uHC6?G!urW=z?%,m # #YvYx  /@H'iWyi`UE+g(^BMk?DG={FUm;Z"QyGaY9X5?zeዸ4x?F; _ =0E^AÙ&/ekb˼NfU>@KOX>n=s.9%/x|"tYwβW_͌B~!.K=xc< c;| ٝ&"64Raš%[/ .,K,5H6^5F^dɀ?/;Tf1?E{ɝ+_]wοF1;WljC6ɞ;ֺةºmVbluw͐X|X(1Uv/Dy6:o|du %c- ź Oi2!H<0` [qHfeMl翍`@h9,=3ڿE`` 8 g+3b&'Y;% ~JH`ϱ+u00 Ls7A},-;H9?0 1 ϘE1oQ5[00n@Ma JHaI00s12MIENDB`weboob-1.1/contrib/boobank_indicator/setup.py000066400000000000000000000015051265717027300214640ustar00rootroot00000000000000from setuptools import setup from setuptools import find_packages setup(name='boobank_indicator', version='0.0.1', description='show your bank accounts in your System Tray', long_description='boobank_indicator will show you bank accounts and associated transactions in your system tray. Your bank accounts should be configured in boobank', keywords='weboob boobank tray icon', url='http://weboob.org/', license='GNU AGPL 3', author='Bezleputh', author_email='bezleputh@gmail.com', packages=find_packages(), package_data={ 'boobank_indicator.data': ['indicator-boobank.png', 'green_light.png', 'red_light.png'] }, entry_points={ 'console_scripts': ['boobank_indicator = boobank_indicator.boobank_indicator:main'], }, zip_safe=False) weboob-1.1/contrib/boobot.py000077500000000000000000000335371265717027300161560ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from datetime import datetime, timedelta import logging import re import os import sys from threading import Thread, Event from math import log import urlparse import urllib from random import randint, choice import itertools from irc.bot import SingleServerIRCBot from weboob.core import Weboob from weboob.exceptions import BrowserUnavailable, BrowserHTTPError from weboob.browser import Browser from weboob.browser.exceptions import HTTPNotFound from weboob.browser.pages import HTMLPage from weboob.tools.misc import get_backtrace from weboob.tools.misc import to_unicode from weboob.tools.storage import StandardStorage from weboob.tools.application.base import ApplicationStorage IRC_CHANNELS = os.getenv('BOOBOT_CHANNELS', '#weboob').split(',') IRC_NICKNAME = os.getenv('BOOBOT_NICKNAME', 'boobot') IRC_SERVER = os.getenv('BOOBOT_SERVER', 'dickson.freenode.net') IRC_IGNORE = [re.compile(i) for i in os.getenv('BOOBOT_IGNORE', '!~?irker@').split(',')] STORAGE_FILE = os.getenv('BOOBOT_STORAGE', 'boobot.storage') def fixurl(url): url = to_unicode(url) # remove javascript crap url = url.replace('/#!/', '/') # parse it parsed = urlparse.urlsplit(url) # divide the netloc further userpass, at, hostport = parsed.netloc.rpartition('@') user, colon1, pass_ = userpass.partition(':') host, colon2, port = hostport.partition(':') # encode each component scheme = parsed.scheme.encode('utf8') user = urllib.quote(user.encode('utf8')) colon1 = colon1.encode('utf8') pass_ = urllib.quote(pass_.encode('utf8')) at = at.encode('utf8') host = host.encode('idna') colon2 = colon2.encode('utf8') port = port.encode('utf8') path = '/'.join(pce.encode('utf8') for pce in parsed.path.split('/')) # while valid, it is most likely an error path = path.replace('//', '/') query = parsed.query.encode('utf8') fragment = parsed.fragment.encode('utf8') # put it back together netloc = ''.join((user, colon1, pass_, at, host, colon2, port)) return urlparse.urlunsplit((scheme, netloc, path, query, fragment)) class BoobotBrowser(Browser): TIMEOUT = 3.0 def urlinfo(self, url, maxback=2): if urlparse.urlsplit(url).netloc == 'mobile.twitter.com': url = url.replace('mobile.twitter.com', 'twitter.com', 1) try: r = self.open(url, method='HEAD') body = False except HTTPNotFound as e: if maxback and not url[-1].isalnum(): return self.urlinfo(url[:-1], maxback-1) raise e except BrowserHTTPError as e: if e.response.status_code in (501, 405): r = self.open(url) body = True else: raise e content_type = r.headers.get('Content-Type') try: size = int(r.headers.get('Content-Length')) hsize = self.human_size(size) except TypeError: size = None hsize = None is_html = ('html' in content_type) if content_type else re.match(r'\.x?html?$', url) title = None if is_html: if not body: r = self.open(url) # update size has we might not have it from headers size = len(r.content) hsize = self.human_size(size) page = HTMLPage(self, r) for title in page.doc.xpath('//head/title'): title = to_unicode(title.text_content()).strip() title = ' '.join(title.split()) if urlparse.urlsplit(url).netloc.endswith('twitter.com'): for title in page.doc.getroot().cssselect('.permalink-tweet .tweet-text'): title = to_unicode(title.text_content()).strip() title = ' '.join(title.splitlines()) return content_type, hsize, title def human_size(self, size): if size: units = ('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB') exponent = int(log(size, 1024)) return "%.1f %s" % (float(size) / pow(1024, exponent), units[exponent]) return '0 B' class MyThread(Thread): daemon = True def __init__(self, bot): Thread.__init__(self) self.weboob = Weboob(storage=StandardStorage(STORAGE_FILE)) self.weboob.load_backends() self.bot = bot self.bot.set_weboob(self.weboob) def run(self): for ev in self.bot.joined.itervalues(): ev.wait() self.weboob.repeat(300, self.check_board) self.weboob.repeat(600, self.check_dlfp) self.weboob.repeat(600, self.check_twitter) self.weboob.loop() def find_keywords(self, text): for word in [ 'weboob', 'videoob', 'havesex', 'havedate', 'monboob', 'boobmsg', 'flatboob', 'boobill', 'pastoob', 'radioob', 'translaboob', 'traveloob', 'handjoob', 'boobathon', 'boobank', 'boobtracker', 'comparoob', 'wetboobs', 'webcontentedit', 'weboorrents', 'assnet', 'budget insight', 'budget-insight', 'budgetinsight', 'budgea']: if word in text.lower(): return word return None def check_twitter(self): nb_tweets = 10 for backend in self.weboob.iter_backends(module='twitter'): for thread in list(itertools.islice(backend.iter_resources(None, ['search', 'weboob']), 0, nb_tweets)): if not backend.storage.get('lastpurge'): backend.storage.set('lastpurge', datetime.now() - timedelta(days=60)) backend.storage.save() if thread.id not in backend.storage.get('seen', default={}) and\ thread.date > backend.storage.get('lastpurge'): _item = thread.id.split('#') url = 'https://twitter.com/%s/status/%s' % (_item[0], _item[1]) for msg in self.bot.on_url(url): self.bot.send_message('%s: %s' % (_item[0], url)) self.bot.send_message(msg) backend.set_message_read(backend.fill_thread(thread, ['root']).root) def check_dlfp(self): for msg in self.weboob.do('iter_unread_messages', backends=['dlfp']): word = self.find_keywords(msg.content) if word is not None: url = msg.signature[msg.signature.find('https://linuxfr'):] self.bot.send_message('[DLFP] %s talks about %s: %s' % ( msg.sender, word, url)) self.weboob[msg.backend].set_message_read(msg) def check_board(self): def iter_messages(backend): with backend.browser: return backend.browser.iter_new_board_messages() for msg in self.weboob.do(iter_messages, backends=['dlfp']): word = self.find_keywords(msg.message) if word is not None and msg.login != 'moules': message = msg.message.replace(word, '\002%s\002' % word) self.bot.send_message('[DLFP] <%s> %s' % (msg.login, message)) def stop(self): self.weboob.want_stop() self.weboob.deinit() class Boobot(SingleServerIRCBot): def __init__(self, channels, nickname, server, port=6667): SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname) # self.connection.add_global_handler('pubmsg', self.on_pubmsg) self.connection.add_global_handler('join', self.on_join) self.connection.add_global_handler('welcome', self.on_welcome) self.mainchannel = channels[0] self.joined = dict() for channel in channels: self.joined[channel] = Event() self.weboob = None self.storage = None def set_weboob(self, weboob): self.weboob = weboob self.storage = ApplicationStorage('boobot', weboob.storage) self.storage.load({}) def on_welcome(self, c, event): for channel in self.joined.keys(): c.join(channel) def on_join(self, c, event): # irclib 5.0 compatibility if callable(event.target): channel = event.target() else: channel = event.target self.joined[channel].set() def send_message(self, msg, channel=None): for m in msg.splitlines(): self.connection.privmsg(to_unicode(channel or self.mainchannel), to_unicode(m)[:450]) def on_pubmsg(self, c, event): # irclib 5.0 compatibility if callable(event.arguments): text = ' '.join(event.arguments()) channel = event.target() nick = event.source() else: text = ' '.join(event.arguments) channel = event.target nick = event.source for ignore in IRC_IGNORE: if ignore.search(nick): return for m in re.findall('([\w\d_\-]+@\w+)', text): for msg in self.on_boobid(m): self.send_message(msg, channel) for m in re.findall(u'(https?://[^\s\xa0+]+)', text): for msg in self.on_url(m): self.send_message(msg, channel) m = re.match('^%(?P\w+)(?P.*)$', text) if m and hasattr(self, 'cmd_%s' % m.groupdict()['cmd']): getattr(self, 'cmd_%s' % m.groupdict()['cmd'])(nick, channel, m.groupdict()['args'].strip()) def cmd_addquote(self, nick, channel, text): quotes = self.storage.get(channel, 'quotes', default=[]) quotes.append({'author': nick, 'timestamp': datetime.now(), 'text': text}) self.storage.set(channel, 'quotes', quotes) self.storage.save() self.send_message('Quote #%s added' % (len(quotes) - 1), channel) def cmd_delquote(self, nick, channel, text): quotes = self.storage.get(channel, 'quotes', default=[]) try: n = int(text) except ValueError: self.send_message("Quote #%s not found gros" % text, channel) return quotes.pop(n) self.storage.set(channel, 'quotes', quotes) self.storage.save() self.send_message('Quote #%s removed' % n, channel) def cmd_searchquote(self, nick, channel, text): try: pattern = re.compile(to_unicode(text), re.IGNORECASE|re.UNICODE) except Exception as e: self.send_message(str(e), channel) return quotes = [] for quote in self.storage.get(channel, 'quotes', default=[]): if pattern.search(to_unicode(quote['text'])): quotes.append(quote) try: quote = choice(quotes) except IndexError: self.send_message('No match', channel) else: self.send_message('%s' % quote['text'], channel) def cmd_getquote(self, nick, channel, text): quotes = self.storage.get(channel, 'quotes', default=[]) if len(quotes) == 0: return try: n = int(text) except ValueError: n = randint(0, len(quotes)-1) try: quote = quotes[n] except IndexError: self.send_message('Unable to find quote #%s' % n, channel) else: self.send_message('[%s] %s' % (n, quote['text']), channel) def on_boobid(self, boobid): _id, backend_name = boobid.split('@', 1) if backend_name in self.weboob.backend_instances: backend = self.weboob.backend_instances[backend_name] for cap in backend.iter_caps(): func = 'obj_info_%s' % cap.__name__[3:].lower() if hasattr(self, func): try: for msg in getattr(self, func)(backend, _id): yield msg except Exception as e: print(get_backtrace()) yield u'Oops: [%s] %s' % (type(e).__name__, e) break def on_url(self, url): url = fixurl(url) try: content_type, hsize, title = BoobotBrowser().urlinfo(url) if title: yield u'URL: %s' % title elif hsize: yield u'URL (file): %s, %s' % (content_type, hsize) else: yield u'URL (file): %s' % content_type except BrowserUnavailable as e: yield u'URL (error): %s' % e except Exception as e: print(get_backtrace()) yield u'Oops: [%s] %s' % (type(e).__name__, e) def obj_info_video(self, backend, id): v = backend.get_video(id) if v: yield u'Video: %s (%s)' % (v.title, v.duration) def obj_info_housing(self, backend, id): h = backend.get_housing(id) if h: yield u'Housing: %s (%sm² / %s%s)' % (h.title, h.area, h.cost, h.currency) def main(): logging.basicConfig(level=logging.DEBUG) bot = Boobot(IRC_CHANNELS, IRC_NICKNAME, IRC_SERVER) thread = MyThread(bot) thread.start() try: bot.start() except KeyboardInterrupt: print("Stopped.") thread.stop() if __name__ == "__main__": sys.exit(main()) weboob-1.1/contrib/downloadboob/000077500000000000000000000000001265717027300167535ustar00rootroot00000000000000weboob-1.1/contrib/downloadboob/README000066400000000000000000000020451265717027300176340ustar00rootroot00000000000000This script can be used to automatically download videos matching some criteria. To avoid to download a video twice, all videos are stored in an unique way: .files//.avi For each entry in the configuration file, the script: - checks for new video - downloads the new videos - creates a link from /.avi to .files//.avi In each section of the configuration file : - backend: the backend to use - pattern: specify the search pattern - title_exclude: a pipe separated list. If an item in this list is a substring of the title, then the video is ignored. - id_regexp: an optional regular expression that the video id must match - max_results: maximum number of result to parse - directory: the above. Usage: downloadboob [path/to/file.conf] [section1 [section2 ...]] If /etc/downloadboob.conf or ~/downloadboob.conf is found, it will be used. If sections are specifed, only those are downloaded. By default, all sections of the config file are downloaded. weboob-1.1/contrib/downloadboob/downloadboob.conf000066400000000000000000000006011265717027300222700ustar00rootroot00000000000000[main] directory=~/Téléchargements/podcasts [zapping] backend=canalplus max_results=10 pattern=zapping title_exclude=semaine directory=Le zapping [guignol] backend=canalplus max_results=10 pattern=les guignols de l'info title_exclude=La semaine directory=Les guignols de l'info [ondar] backend=francetelevisions max_results=20 pattern=demande id_regexp=on_n.*rire directory=ONDAR weboob-1.1/contrib/downloadboob/downloadboob.py000077500000000000000000000234501265717027300220050ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2012 Alexandre Flament # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import subprocess import requests import os import re import ConfigParser from weboob.core import Weboob from weboob.capabilities.video import CapVideo # hack to workaround bash redirection and encoding problem import sys import codecs import locale if sys.stdout.encoding is None: (lang, enc) = locale.getdefaultlocale() if enc is not None: (e, d, sr, sw) = codecs.lookup(enc) # sw will encode Unicode data to the locale-specific character set. sys.stdout = sw(sys.stdout) # end of hack def removeNonAscii(s): return "".join(i for i in s if ord(i) < 128) rx = re.compile(u'[ \\/\\?\\:\\>\\<\\!\\\\\\*]+', re.UNICODE) def removeSpecial(s): return rx.sub(u' ', u'%s' % s) DOWNLOAD_DIRECTORY = ".files" class Downloadboob(object): def __init__(self, backend_name, download_directory, links_directory): self.download_directory = download_directory self.links_directory = links_directory self.backend_name = backend_name self.backend = None self.weboob = Weboob() self.weboob.load_backends(modules=[self.backend_name]) self.backend = self.weboob.get_backend(self.backend_name) def purge(self): if not os.path.isdir(self.links_directory): return dirList = os.listdir(self.links_directory) for local_link_name in dirList: link_name = self.links_directory + "/" + local_link_name if not self.check_link(link_name): print(u"Remove %s" % link_name) os.remove(link_name) else: print(u"Keep %s" % link_name) def check_link(self, link_name): if os.path.islink(link_name): file_name = os.readlink(link_name) absolute_file_name = os.path.join(self.links_directory, file_name) if os.path.isfile(absolute_file_name): return True return False else: return True def download(self, pattern=None, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None, title_exclude=[], id_regexp=None): print("For backend %s, search for '%s'" % (backend_name, pattern)) # create directory for links if not os.path.isdir(self.links_directory): print(" create link to %s" % self.links_directory) os.makedirs(self.links_directory) # search for videos videos = [] for i, video in enumerate(self.backend.search_videos(pattern, sortby, nsfw)): if i == max_results: break self.backend.fillobj(video, ('url', 'title', 'url', 'duration', 'ext')) if not self.is_downloaded(video): if not(self.is_excluded(video.title, title_exclude)) and self.id_regexp_matched(video.id, id_regexp): print(" %s\n Id:%s\n Duration:%s" % (video.title, video.id, video.duration)) videos.append(video) else: print("Already downloaded, check %s" % video.id) linkname = self.get_linkname(video) if not os.path.exists(linkname): self.remove_download(video) # download videos print("Downloading...") for video in videos: self.do_download(video) def is_excluded(self, title, title_exclude): for exclude in title_exclude: if title.find(exclude) > -1: return True return False def id_regexp_matched(self, video_id, id_regexp): if id_regexp: return re.search(id_regexp, video_id) is not None return True def get_downloaded_ext(self, video): ext = video.ext if not ext: ext = 'avi' elif ext == u'm3u8': ext = 'mp4' return ext def get_filename(self, video, relative=False): if relative: directory = os.path.join("..", DOWNLOAD_DIRECTORY, self.backend_name) else: directory = os.path.join(self.download_directory, self.backend_name) if not os.path.exists(directory): os.makedirs(directory) ext = self.get_downloaded_ext(video) return u"%s/%s.%s" % (directory, removeNonAscii(video.id), ext) def get_linkname(self, video): if not os.path.exists(self.links_directory): os.makedirs(self.links_directory) ext = self.get_downloaded_ext(video) misc = video.date if not misc: misc = video.id return u"%s/%s (%s).%s" % (self.links_directory, removeSpecial(video.title), removeSpecial(misc), ext) def is_downloaded(self, video): # check if the file is 0 byte return os.path.isfile(self.get_filename(video)) def remove_download(self, video): path = self.get_filename(video) if os.stat(path).st_size == 0: # already empty return print('Remove video %s' % video.title) # Empty it to keep information we have already downloaded it. with open(path, 'w'): pass def set_linkname(self, video): linkname = self.get_linkname(video) idname = self.get_filename(video, relative=True) absolute_idname = self.get_filename(video, relative=False) if not os.path.islink(linkname) and os.path.isfile(absolute_idname): print("%s -> %s" % (linkname, idname)) os.symlink(idname, linkname) def do_download(self, video): if not video: print('Video not found: %s' % video, file=sys.stderr) return 3 if not video.url: print('Error: the direct URL is not available.', file=sys.stderr) return 4 def check_exec(executable): with open(os.devnull, 'w') as devnull: process = subprocess.Popen(['which', executable], stdout=devnull) if process.wait() != 0: print('Please install "%s"' % executable, file=sys.stderr) return False return True dest = self.get_filename(video) if video.url.startswith('rtmp'): if not check_exec('rtmpdump'): return 1 args = ('rtmpdump', '-e', '-r', video.url, '-o', dest) elif video.url.startswith('mms'): if not check_exec('mimms'): return 1 args = ('mimms', video.url, dest) elif u'm3u8' == video.ext: _dest, _ = os.path.splitext(dest) dest = u'%s.%s' % (_dest, 'mp4') content = tuple() baseurl = video.url.rpartition('/')[0] for line in self.read_url(video.url): if not line.startswith('#'): if not line.startswith('http'): line = u'%s/%s' % (baseurl, line) content += (line,) args = ('wget', '-nv',) + content + ('-O', dest) else: if check_exec('wget'): args = ('wget', '-c', video.url, '-O', dest) elif check_exec('curl'): args = ('curl', '-C', '-', video.url, '-o', dest) else: return 1 os.spawnlp(os.P_WAIT, args[0], *args) self.set_linkname(video) def read_url(self, url): r = requests.get(url, stream=True) return r.iter_lines() config_file = 'downloadboob.conf' sections = None if len(sys.argv) >= 3: sections = sys.argv[2:] if len(sys.argv) >= 2: config_file = sys.argv[1] config = ConfigParser.ConfigParser() config.read(['/etc/downloadboob.conf', os.path.expanduser('~/downloadboob.conf'), config_file]) if sections is None: sections = config.sections() try: links_directory = os.path.expanduser(config.get('main', 'directory', '.')) except ConfigParser.NoSectionError: print("Please create a documentation file (see the README file and the downloadboob.conf example file)") sys.exit(2) links_directory = links_directory.decode('utf-8') download_directory = os.path.join(links_directory, DOWNLOAD_DIRECTORY) print("Downloading to %s" % (links_directory)) for section in config.sections(): if section != "main" and section in sections: backend_name = config.get(section, "backend") pattern = config.get(section, "pattern") if config.has_option(section, "title_exclude"): title_exclude = config.get(section, "title_exclude").decode('utf-8').split('|') else: title_exclude = [] if config.has_option(section, "id_regexp"): id_regexp = config.get(section, "id_regexp") else: id_regexp = None max_result = config.getint(section, "max_results") section_sublinks_directory = config.get(section, "directory") section_links_directory = os.path.join(links_directory, section_sublinks_directory) downloadboob = Downloadboob(backend_name, download_directory, section_links_directory) downloadboob.purge() # FIXME sortBy, title.match downloadboob.download(pattern, CapVideo.SEARCH_DATE, False, max_result, title_exclude, id_regexp) weboob-1.1/contrib/fork.py000077500000000000000000000101701265717027300156170ustar00rootroot00000000000000#! /usr/bin/python # Licensed under WTFPL. # https://linuxfr.org/users/shamanphenix/journaux/weboob-la-consecration#comment-1583941 from __future__ import print_function import os import sys import base64 import subprocess import ConfigParser scripts_tr = [('boobank','bisoubank'), ('boobathon','bisouthon'), ('boobcoming','bisoucoming'), ('boobill','bisoubill'), ('booblyrics','bisoulyrics'), ('boobmsg', 'bisoumsg'), ('boobooks', 'bisoubooks'), ('boobsize', 'bisousize'), ('boobtracker', 'bisoutracker'), ('cineoob', 'cineisou'), ('comparoob', 'comparisou'), ('cookboob', 'cookbisou'), ('flatboob', 'flatbisou'), ('galleroob', 'gallerisou'), ('geolooc', 'geolooc'), ('handjoob', 'handjisou'), ('havedate', 'havedate'), ('masstransit', 'masstransit'), ('monboob', 'monbisou'), ('parceloob', 'parcelisou'), ('pastoob', 'pastisou'), ('qboobmsg', 'qbisoumsg'), ('qcineoob', 'qcineisou'), ('qcookboob', 'qcookbisou'), ('qflatboob', 'qflatbisou'), ('qhandjoob', 'qhandjisou'), ('qhavedate', 'qhavedate'), ('qvideoob', 'qvideisou'), ('qwebcontentedit', 'qwebpasmalintentedit'), ('radioob', 'radisou'), ('suboob', 'subisou'), ('translaboob', 'translabisou'), ('traveloob', 'travelisou'), ('videoob', 'videisou'), ('webcontentedit', 'webpasmalintentedit'), ('weboob-cli', 'webisounours-cli'), ('weboob-config', 'webisounours-config'), ('weboob-config-qt', 'webisounours-config-qt'), ('weboob-debug', 'webisounours-debug'), ('weboob-repos', 'webisounours-repos'), ('weboorrents', 'webisourrents'), ('wetboobs', 'wetbisous')] icons_tr = [os.path.join('icons',i) for i in os.listdir('icons')] modules_tr = [os.path.join('modules',i,'favicon.png') for i in os.listdir('modules')] desktop_tr = [('qboobmsg.desktop','QBisoumsg'), ('qcineoob.desktop','QCineisou'), ('qcookboob.desktop','QCookbisou'), ('qflatboob.desktop','QFlatBisou'), ('qhandjoob.desktop','QHandJisou'), ('qhavedate.desktop','QHaveDate'), ('qvideoob.desktop','QVideisou'), ('qwebcontentedit.desktop','QWebPasmalinTentEdit'), ] mask = base64.b64decode('iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wEODzYzz5PthwAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAABsklEQVR42u3avyvEcRzH8adEXJKSOlFXStSVlDIow5UMBoOiDAyUwWAwSDIYlIG6EoPBYFAGSQZlUDdIKWUQJQxSIiElv7ow8K1L13V33oP35/t+1vsPeCyfu3p9wbIsy7Isy7K0FvIzvg/4BLr8iB/7wXvX7Cf83C/8J/AC1PgBv5oE7901UOYqvBDYSYH37gjIdw0fBE7SwHsXcwkfBm4zwHu34gI+Arxngfcuqhnf/Qd44rVrxA8L4Wc14meE8KMa8ctC+F5t8DxgWwAeB1q14UuBQwH8A1CvDV8NXAngz4FKbfgm4FkAvwcUacN3CD12Gxpf+kEh/IJG/KQQfkIjflEIP6ANngNs+vV/fTGwLwB/Ahq14UPAhQD+EqjShm8AHgXwB0CJNnwb8CGA3wJyteH7hR67JY0/c+NC+CmN+Hkh/JBG/JoQvlMbPADsCsBfUbjrlQOnAvgboFYbvh64E8Afo3THiwngYyje7wrIbKdzcrIKkt1eF8WhwsBbBvgRHCySJr4Hh0s1YsaBFnxQsjHzHqjDR00n4M+ACnzYOt/f6ASwLMuyLMuyLMv6x30B2yNJ8I8ofLMAAAAASUVORK5CYII=') f = open('bisoumask.png','w') f.write(mask) f.close() for i in icons_tr + modules_tr: try: subprocess.call('mogrify %s -blur 0x4 2> /dev/null > /dev/null' % i, shell=True) subprocess.call('composite bisoumask.png %s bisouresult.png 2> /dev/null > /dev/null' % i, shell=True) os.rename('bisouresult.png',i) except OSError: print("No picture named %s" % i, file=sys.stderr) for s in scripts_tr: os.rename (os.path.join('scripts',s[0]),os.path.join('scripts',s[1])) for d in desktop_tr: config = ConfigParser.ConfigParser() config.readfp(open(os.path.join('desktop',d[0]))) config.set('Desktop Entry','Name',d[1]) config.write(open(os.path.join('desktop',d[0]),'w')) weboob-1.1/contrib/hds/000077500000000000000000000000001265717027300150605ustar00rootroot00000000000000weboob-1.1/contrib/hds/export.py000077500000000000000000000113631265717027300167620ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function try: import sqlite3 as sqlite except ImportError as e: from pysqlite2 import dbapi2 as sqlite from weboob.core import Weboob from weboob.core.modules import ModuleLoadError import sys import logging level = logging.DEBUG logging.basicConfig(stream=sys.stdout, level=level) def main(filename): weboob = Weboob() try: hds = weboob.build_backend('hds') except ModuleLoadError as e: print('Unable to load "hds" module: %s' % e, file=sys.stderr) return 1 try: db = sqlite.connect(database=filename, timeout=10.0) except sqlite.OperationalError as err: print('Unable to open %s database: %s' % (filename, err), file=sys.stderr) return 1 sys.stdout.write('Reading database... ') sys.stdout.flush() try: results = db.execute('SELECT id, author FROM stories') except sqlite.OperationalError as err: print('fail!\nUnable to read database: %s' % err, file=sys.stderr) return 1 stored = set() authors = set() for r in results: stored.add(r[0]) authors.add(r[1]) stored_authors = set([s[0] for s in db.execute('SELECT name FROM authors')]) sys.stdout.write('ok\n') br = hds.browser to_fetch = set() sys.stdout.write('Getting stories list from website... ') sys.stdout.flush() for story in br.iter_stories(): if int(story.id) in stored: break to_fetch.add(story.id) authors.add(story.author.name) sys.stdout.write(' ok\n') sys.stdout.write('Getting %d new storiese... ' % len(to_fetch)) sys.stdout.flush() for id in to_fetch: story = br.get_story(id) if not story: logging.warning('Story #%d unavailable' % id) continue db.execute("""INSERT INTO stories (id, title, date, category, author, body) VALUES (?, ?, ?, ?, ?, ?)""", (story.id, story.title, story.date, story.category, story.author.name, story.body)) db.commit() sys.stdout.write('ok\n') authors = authors.difference(stored_authors) sys.stdout.write('Getting %d new authors... ' % len(authors)) sys.stdout.flush() for a in authors: author = br.get_author(a) if not author: logging.warning('Author %s unavailable\n' % id) continue db.execute("INSERT INTO authors (name, sex, description) VALUES (?, ?, ?)", (a, author.sex, author.description)) db.commit() sys.stdout.write(' ok\n') return 0 if __name__ == '__main__': if len(sys.argv) < 2: print('Syntax: %s [--help] SQLITE_FILENAME' % sys.argv[0], file=sys.stderr) sys.exit(1) if sys.argv[1] in ('-h', '--help'): print('Syntax: %s SQLITE_FILENAME' % sys.argv[0]) print('') print('Before running this software, please create the database with') print('this command:') print(' $ cat scheme.sql | sqlite3 hds.sql') print('') print('You can then run export.py with:') print(' $ %s hds.sql ' % sys.argv[0]) print('') print('It fill the database with stories and authors information') print('fetched from histoires-de-sexe.net') print('') print('You can next use SQL queries to find interesting stories, for') print('example:') print('') print('- To get all stories written by women') print(' sqlite> SELECT s.id, s.title, s.category, a.name') print(' FROM stories AS s LEFT JOIN authors AS a') print(' WHERE a.name = s.author AND a.sex = 2;') print('- To get all stories where it talks about bukkake') print(' sqlite> SELECT s.id, s.title, s.category, a.name') print(' FROM stories AS s LEFT JOIN authors AS a') print(' WHERE a.name = s.author AND s.body LIKE \'%bukkake%\';') sys.exit(0) sys.exit(main(sys.argv[1])) weboob-1.1/contrib/hds/scheme.sql000066400000000000000000000005741265717027300170530ustar00rootroot00000000000000DROP TABLE authors; CREATE TABLE authors ( name TEXT PRIMARY KEY, sex INTEGER, description ); CREATE INDEX author_idx ON authors(name, sex); DROP TABLE stories; CREATE TABLE stories ( id INTEGER PRIMARY KEY, title TEXT, date TEXT, category TEXT, author TEXT REFERENCES authors, body TEXT ); CREATE INDEX stories_idx ON stories(id, category); weboob-1.1/contrib/munin/000077500000000000000000000000001265717027300154305ustar00rootroot00000000000000weboob-1.1/contrib/munin/boobank-munin000077500000000000000000000202601265717027300201150ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import os import sys import locale import time import logging from weboob.core import Weboob, CallErrors from weboob.capabilities.bank import CapBank from weboob.exceptions import BrowserIncorrectPassword class BoobankMuninPlugin(object): def __init__(self): if 'weboob_path' in os.environ: self.weboob = Weboob(os.environ['weboob_path']) else: self.weboob = Weboob() self.monitored_accounts = None if 'boobank_monitored' in os.environ: self.monitored_accounts = os.environ['boobank_monitored'].split(' ') self.cache_expire = long(os.environ.get('boobank_cache_expire', 3600)) self.add_coming = int(os.environ.get('boobank_add_coming', 1)) self.cumulate = int(os.environ.get('boobank_cumulate', 1)) self.cache = None def display_help(self): print('boobank-munin is a plugin for munin') print('') print('Copyright(C) 2010-2011 Romain Bignon') print('') print('To use it, create a symlink /etc/munin/plugins/boobank to this script') print('and add this section in /etc/munin/plugin-conf.d/munin-node:') print('') print('[boobank]') print('user romain') print('group romain') print('env.HOME /home/romain') print('# The weboob directory path.') print('env.weboob_path /home/romain/.config/weboob/') print('# Monitored accounts. If this parameter is missing, all accounts') print('# will be displayed.') print('env.boobank_monitored 0125XXXXXXXXXXXX@bnporc 0125XXXXXXXXXXXX@bnporc') print('# To prevent mass connections to bank websites, results are cached.') print('# You can set here the expiration delay (in seconds).') print('env.boobank_cache_expire 7200') print('# If enabled, coming operations are added to the value of accounts\'') print('# balance.') print('env.boobank_add_coming 1') print('# Cumulate accounts values') print('env.boobank_cumulate 1') print('') print('When you change configuration, you can use this command to reset cache:') print('$ boobank-munin --reset') def clear_cache(self): for name in ('boobank-munin', 'boobank-munin-config'): try: os.unlink(self.cachepath(name)) except IOError: pass def cachepath(self, name): tmpdir = os.path.join(self.weboob.workdir, "munin") if not os.path.isdir(tmpdir): os.makedirs(tmpdir) return os.path.join(tmpdir, name) def check_cache(self, name): return self.print_cache(name, check=True) def print_cache(self, name, check=False): try: f = open(self.cachepath(name), 'r') except IOError: return False try: last = int(f.readline().strip()) except ValueError: return False if check and (last + self.cache_expire) < time.time(): return False for line in f: sys.stdout.write(line) return True def new_cache(self, name): os.umask(0o077) new_name = '%s.new' % name filename = self.cachepath(new_name) try: f = open(filename, 'w') except IOError as e: print('Unable to create the cache file %s: %s' % (filename, e), file=sys.stderr) return self.cache = f self.cache.write('%d\n' % time.time()) def flush_cache(self): old_name = self.cache.name new_name = self.cache.name[:-4] self.cache.close() os.rename(old_name, new_name) def write_output(self, line): sys.stdout.write('%s\n' % line) if self.cache: self.cache.write('%s\n' % line) def config(self): if self.check_cache('boobank-munin-config'): return self.new_cache('boobank-munin-config') self.weboob.load_backends(CapBank) self.write_output('graph_title Bank accounts') self.write_output('graph_vlabel balance') self.write_output('graph_category weboob') self.write_output('graph_args -l 0') try: accounts = [] if self.monitored_accounts is not None: d = {} for account in self.weboob.do('iter_accounts'): if self.monitored(account): d['%s@%s' % (account.id, account.backend)] = account for id in self.monitored_accounts: try: accounts.append(d[id]) except KeyError: pass else: accounts = reversed([a for a in self.weboob.do('iter_accounts')]) first = True for account in accounts: id = self.account2id(account) type = 'STACK' if first: type = 'AREA' first = False self.write_output('%s.label %s' % (id, account.label.encode('iso-8859-15'))) if self.cumulate: self.write_output('%s.draw %s' % (id, type)) except CallErrors as errors: self.print_errors(errors) self.print_cache('boobank-munin-config') else: self.flush_cache() def monitored(self, account): return not self.monitored_accounts or ('%s@%s' % (account.id, account.backend)) in self.monitored_accounts def account2id(self, account): return '%s_%s' % (account.backend, account.id) def print_errors(self, errors): for backend, err, backtrace in errors: print((u'%s(%s): %s' % (type(err).__name__, backend.name, err)).encode(sys.stdout.encoding or locale.getpreferredencoding(), 'replace'), file=sys.stderr) if isinstance(err, BrowserIncorrectPassword): self.weboob.backends_config.edit_backend(backend.name, backend.NAME, {'_enabled': 'false'}) def execute(self): if self.check_cache('boobank-munin'): return self.new_cache('boobank-munin') self.weboob.load_backends(CapBank) try: for account in self.weboob.do('iter_accounts'): if self.monitored(account): balance = account.balance if account.coming and self.add_coming: balance += account.coming self.write_output('%s.value %d' % (self.account2id(account), balance)) except CallErrors as errors: self.print_errors(errors) self.print_cache('boobank-munin') else: self.flush_cache() def run(self): cmd = (len(sys.argv) > 1 and sys.argv[1]) or "execute" if cmd == 'execute': self.execute() elif cmd == 'config': self.config() elif cmd == 'autoconf': print('no') sys.exit(1) elif cmd == 'suggest': sys.exit(1) elif cmd == 'help' or cmd == '-h' or cmd == '--help': self.display_help() elif cmd == 'reload' or cmd == '--reload' or \ cmd == 'reset' or cmd == '--reset': self.clear_cache() if self.cache: self.cache.close() sys.exit(0) if __name__ == '__main__': logging.basicConfig() BoobankMuninPlugin().run() weboob-1.1/contrib/munin/freemobile-munin000077500000000000000000000135131265717027300206160ustar00rootroot00000000000000#!/usr/bin/env perl # -*- perl -*- =head1 NAME freemobile - A plugin to monitor a freemobile subscription =head1 INSTALLATION Create a link to this script in /etc/munin/plugins/ : $ ln -s /path/to/freemobile-munin /etc/munin/plugins/freemobile =head1 CONFIGURATION You need to configure the plugin like that: [freemobile] user florent env.HOME /home/florent env.phonenumber 06ABCDEFGH env.freemonitored voice sms mms data specialvoice env.cache_expire 3600 timeout 30 C I: user with freemobile backend configured C I: path to user home C (optional): add your phone number if you have more than one subscription for this account. C (optional): default only 'voice sms' The full list of monitored options is : * voice sms mms data specialvoice voicetoint voiceint smsint mmsint dataint C (optional): cache interval in second, or time between two connection to the website. The cache interval is 3 hours by default. C (optional): Munin internal option. The plugin can be slow, 30s is recommended. =head1 LICENSE AGPLv3 =cut use strict; use warnings; use Carp; use English qw(-no_match_vars); use encoding 'iso-8859-1'; # Munin doesn't like utf-8 :-( use Encode; my @monitored = split / /, $ENV{'freemonitored'} || 'voice sms'; my $cachedir = $ENV{'HOME'} . '/.config/weboob/munin/'; my $cachefile = "$cachedir/freemobile-munin"; my $refreshtime = $ENV{'cache_expire'} || 10_800; my $phone = $ENV{'phonenumber'}; my $account = ''; if (length($phone) > 0) { $account = $phone . '@freemobile'; } my $weboob = 'boobill -f table -b freemobile details ' . $account; my $cache_fh; my %label = ( 'voice' => 'Voix en France (min)', 'voicetoint' => 'Voix vers l\'international (min)', 'specialvoice' => 'Numéros spéciaux (min)', 'sms' => 'SMS en France', 'mms' => 'MMS en France', 'data' => 'Data en France', 'voiceint' => 'Voix à l\'international (min)', 'smsint' => 'SMS à l\'international', 'mmsint' => 'MMS à l\'international', 'dataint' => 'Data à l\'international', ); my %linenum = ( 'voice' => 3, 'voicetoint' => 3, 'specialvoice' => 4, 'sms' => 5, 'mms' => 6, 'data' => 7, 'voiceint' => 8, 'smsint' => 9, 'mmsint' => 10, 'dataint' => 11, ); my %regexp = ( 'voice' => 'National : (\d+)h(\d+)min(\d+)s', 'voicetoint' => 'International : (\d+)h(\d+)min(\d+)s', 'specialvoice' => '\| (\d+)h(\d+) min (\d+)s', 'sms' => 'Conso SMS \s+ \| (\d+) \/ (.*)', 'mms' => 'Vous avez consommé (\d+) MMS', 'data' => 'Vous avez consommé ([\d\-\.]+) (Mo|Go)', 'voiceint' => 'Appels émis (\d+)h(\d+)min(\d+)s', 'smsint' => 'Conso SMS (international) \| (\d+)', 'mmsint' => 'Vous avez consommé (\d+) MMS', 'dataint' => 'Vous avez consommé ([\d\-\.]+) (Mo|Go)', ); my %post = ( 'voice' => 'postvoice', 'voicetoint' => 'postvoice', 'specialvoice' => 'postvoice', 'sms' => 'simplepost', 'mms' => 'simplepost', 'data' => 'datapost', 'voiceint' => 'postvoice', 'smsint' => 'simplepost', 'mmsint' => 'simplepost', 'dataint' => 'datapost', ); sub doubleprint { my $var = shift; print {$cache_fh} $var; print $var; return 0; } sub postvoice { my @args = @_; my $minutes = $args[0] * 60 + $args[1] + $args[2] / 60; doubleprint "$minutes \n"; return 0; } sub simplepost { my @args = @_; doubleprint "$args[0] \n"; return 0; } sub datapost { my @args = @_; my $multi = 1; my $unit = $args[1]; if ($unit eq "Go") { $multi = 1024; } $multi = $args[0] * $multi; doubleprint "$multi \n"; return 0; } sub config { binmode STDOUT, ':encoding(iso-8859-1)'; print <<'EOF'; graph_title Conso Free graph_vlabel Suivi conso du forfait Free Mobile graph_category weboob graph_args -l 0 EOF foreach (@monitored) { print "$_.label $label{$_}\n"; } return 0; } sub fetch { my @cache_data; # Check if cache exist and not older than the refresh threshold. if ( open $cache_fh, '<', $cachefile ) { @cache_data = <$cache_fh>; close $cache_fh or croak "unable to close: $ERRNO"; # File not empty? if ( @cache_data > 0 ) { # Data is still fresh. Display cached values and exit. if ( time - $cache_data[0] < $refreshtime ) { print join q{}, @cache_data[ 1 .. $#cache_data ]; exit 0; } } } # execute weboob open my $data, q(-|), $weboob or croak "Couldn't execute program: $ERRNO"; my @lines = <$data>; close $data or carp "unable to close: $ERRNO"; # If error output, print the cache (if exist) and exit if ( @lines == 0 ) { if ( @cache_data > 0 ) { print join q{}, @cache_data[ 1 .. $#cache_data ]; exit 0; } exit 1; } # Open cache for writing open $cache_fh, '>', $cachefile or croak "Failed to open file $cachefile"; print {$cache_fh} time . "\n"; foreach my $monit (@monitored) { doubleprint "$monit.value "; if ( my @results = $lines[ $linenum{$monit} ] =~ /$regexp{$monit}/ ) { my $postfunction = $post{$monit}; &{ \&$postfunction }(@results); } else { doubleprint "0 \n"; } } close $cache_fh or croak "unable to close: $ERRNO"; return 0; } # Create the munin cache dir if missing if ( !-d $cachedir ) { mkdir $cachedir; } if ( $ARGV[0] and $ARGV[0] eq 'config' ) { config; } else { fetch; } __END__ weboob-1.1/contrib/munin/nettokom-munin000077500000000000000000000117321265717027300203460ustar00rootroot00000000000000#!/usr/bin/env perl # -*- perl -*- =head1 NAME nettokom - A plugin to monitor a nettokom subscription =head1 INSTALLATION Create a link to this script in /etc/munin/plugins/ : $ ln -s /path/to/nettokom-munin /etc/munin/plugins/nettokom =head1 CONFIGURATION You need to configure the plugin like that: [nettokom] user florent env.HOME /home/florent env.monitored 0177-XXXXXXXX env.exclude 02 env.cache_expire 10800 timeout 30 C I: user with nettokom backend configured C I: path to user home C I: phone number to generated the weboob ID C (optional): default nothing We can exclude some boobill output. The filter is on the label. Some examples: * festnetz community sms smsinsausland O2 C (optional): cache interval in second, or time between two connection to the website. The cache interval is 3 hours by default. Be aware that the website is only daily updated C (optional): Munin internal option. The plugin can be slow, 30s is recommended. =head1 LICENSE AGPLv3 =cut use strict; use warnings; use Carp; use English qw(-no_match_vars); use encoding 'iso-8859-1'; # Munin doesn't like utf-8 :-( use Encode; my $id = $ENV{'monitored'} || ''; if ($id eq '') { print STDERR "Error: env.monitored not exist \n"; exit 2; } $id = $id . '@nettokom'; my @exclude = split / /, $ENV{'exclude'} || ''; my $cachedir = $ENV{'HOME'} . '/.config/weboob/munin/'; my $cachefile = "$cachedir/nettokom-munin"; my $cacheconfigfile = "$cachedir/nettokom-munin-config"; my $refreshtime = $ENV{'cache_expire'} || 10800; my $weboob = "/usr/bin/env boobill details $id -f table"; my @knowlabels = ("AbgehendeSMSimAusland", "AnkommendeGespr_cheimAusland", "Community", "D1", "D2", "Deutschland", "Festnetz", "FreeCall", "Mailbox", "O2", "SMS", "SMSinsAusland"); my $cache_fh; sub config { execute($cacheconfigfile, 1); } sub fetch { execute($cachefile); } sub doubleprint { my $var = shift; print {$cache_fh} $var; print $var; return 0; } sub printconfig { my @lines = @_; doubleprint <<'EOF'; graph_title Conso Nettokom graph_vlabel Nettokom Verbindungs graph_category weboob graph_args -l 0 EOF my $first = 1; for my $label (@knowlabels) { my $shortlabel = $label; if (!(grep {$_ == $shortlabel} @exclude)) { doubleprint "$shortlabel.label $label\n"; if ($first > 0) { doubleprint "$shortlabel.draw AREA\n"; $first = 0; } else { doubleprint "$shortlabel.draw STACK\n"; } } } for my $line (@lines) { if ($line =~ /nettokom \| (.*) \| (\d)(.*) \| (\d).(\d)/) { my $label = $1; my $shortlabel = $label; $shortlabel =~ s/\s+//g; if (!(grep {$_ == $shortlabel} @exclude)) { if (!(grep {$_ == $shortlabel} @knowlabels)) { doubleprint "$shortlabel.label $label\n"; doubleprint "$shortlabel.draw STACK\n"; } } } } } sub printvalue { my @lines = @_; for my $line (@lines) { if ($line =~ /nettokom \| (.*) \| (\d)(.*) \| (\d).(\d)/) { my $label = $1; my $value = $2; my $shortlabel = $label; $shortlabel =~ s/\s+//g; if (!(grep {$_ == $shortlabel} @exclude)) { doubleprint "$shortlabel.value $value\n"; } } } } sub execute { my @cache_data; my $cachefile = $_[0]; my $doconfig = $_[1]; # Check if cache exist and not older than the refresh threshold. if ( open $cache_fh, '<', $cachefile ) { @cache_data = <$cache_fh>; close $cache_fh or croak "unable to close: $ERRNO"; # File not empty? if ( @cache_data > 0 ) { # Data is still fresh. Display cached values and exit. if ( time - $cache_data[0] < $refreshtime ) { print join q{}, @cache_data[ 1 .. $#cache_data ]; exit 0; } } } # execute weboob open my $data, q(-|), $weboob or croak "Couldn't execute program: $ERRNO"; my @lines = <$data>; close $data or carp "unable to close: $ERRNO"; # If error output, print the cache (if exist) and exit if ( @lines == 0 ) { if ( @cache_data > 0 ) { print join q{}, @cache_data[ 1 .. $#cache_data ]; exit 0; } exit 1; } # Open cache for writing open $cache_fh, '>', $cachefile or croak "Failed to open file $cachefile"; print {$cache_fh} time . "\n"; if ($doconfig) { printconfig(@lines); } else { printvalue(@lines); } } # Create the munin cache dir if missing if ( !-d $cachedir ) { mkdir $cachedir; } if ( $ARGV[0] and $ARGV[0] eq 'config' ) { config; } else { fetch; } __END__ weboob-1.1/contrib/munin/weboob-generic000077500000000000000000000356571265717027300202650ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . ### Installation ### # 1) Create a symlink from /etc/munin/plugins/yourchoice to the script # 2) Configure the plugin in /etc/munin/plugin-conf.d/ See below for the options # 3) Restart/reload munin-node # 4) Note that cached values are stored in folder ~/.config/weboob/munin/ ### Configuration ### ## Mandatory options ## # env.capa: The Weboob capability to load # Example: env.capa CapBank # # env.do: The Weboob command to call. It can take more than one argument. # With two argument, the second is used as parameter for the command. # The third is used to restrict backends. # Example: env.do get_balance # # env.import: The import line to import the capabilities # Example: from weboob.capabilities.bank import CapBank # # env.attribvalue: The attribut name of objects returned by the do command. # For example, the "balance" member of Account objects # If the attribut is itself one object, a hierarchical call can be done # with the "/" operators. # Example: env.attribvalue balance # Example: env.attribvalue temp/value ## Optionals -- more configuration ## # env.id_monitored: Restrict the results to a list of ids (space is used as separator) # Example: env.id_monitored account1@backend1 account2@backend2 # # env.exclude: Exclude some results (space is used as separator) # Example: env.exclude 550810@sachsen # # env.cache_expire: To avoid site flooding, results are cached in folder # /.config/weboob/munin/. The default lifetime of a cache value is 3600s # Example: env.cache_expire 7200 # # env.cumulate: Display data in Area mode (default) or in line mode. # Example: env.cumulate 0 # # env.get_object_list: optional pre-call to get a list of objects, to applied # the do function on it. # Exemple: env.get_object_list="iter_subscriptions" # # env.attribid: Munin needs an id for each value. The default is to use the id of results, # but another attribute can be used. "/" can be used as separator for # hierarchical calls # Example: env.attribid id # # env.title: A title for the graph (default: nothing) # Example: env.title a wonderful graph # # env.vlabel: A vertical label for the graph # Example: env.vlabel Balance # # env.label: Each data in munin as a label. Per default, the script takes the # "label" attribute of objects. However, it does not always exist, # and a better choice can be possible # Example: env.label id # # env.category: set the graph category (default: weboob) # Example: env.category bank # For some running examples, see at the end of the script from __future__ import print_function import os import sys import locale import time import logging from weboob.capabilities.base import NotAvailable from weboob.core import Weboob, CallErrors from weboob.exceptions import BrowserIncorrectPassword class GenericMuninPlugin(object): def __init__(self): if 'weboob_path' in os.environ: self.weboob = Weboob(os.environ['weboob_path']) else: self.weboob = Weboob() self.cache_expire = long(os.environ.get('cache_expire', 3600)) self.cumulate = int(os.environ.get('cumulate', 1)) self.cache = None self.name = sys.argv[0] if "/" in self.name: self.name = self.name.split('/')[-1] # Capability to load self.capa = os.environ['capa'] # Command to pass to Weboob self.do = os.environ['do'].split(',') # Not easy to load modules automatically... self.mimport = os.environ["import"] exec(self.mimport) # We can monitore only some objects self.object_list = None if 'get_object_list' in os.environ: self.object_list = os.environ["get_object_list"] self.tomonitore = None if 'id_monitored' in os.environ: self.tomonitore = os.environ['id_monitored'].decode('utf-8').split(' ') self.exclude = None if 'exclude' in os.environ: self.exclude = os.environ['exclude'].split(' ') # Attribut of object to use as ID (default: id) self.attribid = "id" if 'attribid' in os.environ: self.attribid = os.environ['attribid'] self.attribvalue = os.environ['attribvalue'] self.title = '' if 'title' in os.environ: self.title = os.environ['title'].decode('utf-8') self.attriblabel = "label" if 'label' in os.environ: self.attriblabel = os.environ['label'] self.vlabel = self.attribvalue if 'vlabel' in os.environ: self.vlabel = os.environ['vlabel'].decode('utf-8') self.category = "weboob" if 'category' in os.environ: self.category = os.environ['category'].decode('utf-8') def display_help(self): print('generic-munin is a plugin for munin') print('') print('Copyright(C) 2013 Romain Bignon, Florent Fourcot') print('') print('To use it, create a symlink /etc/munin/plugins/nameyouwant to this script') print('and add this section in /etc/munin/plugin-conf.d/munin-node:') print('') print('[nameyouwant]') print('user romain') print('group romain') print('env.HOME /home/romain') print('# The weboob directory path.') print('env.weboob_path /home/romain/.config/weboob/') print('# Monitored objects. If this parameter is missing, all objects') print('# will be displayed.') print('env.id_monitored myid@backend1 otherid@backend2') print('# To prevent mass connections to websites, results are cached.') print('# You can set here the expiration delay (in seconds).') print('env.cache_expire 7200') print('# Cumulate values') print('env.cumulate 1') print('') def cachepath(self, name): tmpdir = os.path.join(self.weboob.workdir, "munin") if not os.path.isdir(tmpdir): os.makedirs(tmpdir) return os.path.join(tmpdir, name) def check_cache(self, name): return self.print_cache(name, check=True) def print_cache(self, name, check=False): try: f = open(self.cachepath(name), 'r') except IOError: return False try: last = int(f.readline().strip()) except ValueError: return False if check and (last + self.cache_expire) < time.time(): return False for line in f: sys.stdout.write(line) return True def new_cache(self, name): os.umask(0o077) new_name = '%s.new' % name filename = self.cachepath(new_name) try: f = open(filename, 'w') except IOError as e: print('Unable to create the cache file %s: %s' % (filename, e), file=sys.stderr) return self.cache = f self.cache.write('%d\n' % time.time()) def flush_cache(self): old_name = self.cache.name new_name = self.cache.name[:-4] self.cache.close() os.rename(old_name, new_name) def write_output(self, line): sys.stdout.write('%s\n' % line) if self.cache: self.cache.write('%s\n' % line) def build_do(self): if self.object_list: results = [] for result in self.weboob.do(self.object_list): results.append(result) for result in results: try: for i in self.weboob.do(self.do[0], result.id, backends=result.backend): yield i # Do not crash if one module does not implement the feature except CallErrors: pass elif len(self.do) == 1: for i in self.weboob.do(self.do[0]): yield i elif len(self.do) == 2: for i in self.weboob.do(self.do[0], self.do[1]): yield i elif len(self.do) == 3: for i in self.weboob.do(self.do[0], self.do[1], backends=self.do[2]): yield i def get_value(self, result): attribs = self.attribvalue.split('/') for attrib in attribs: result = getattr(result, attrib) if type(result) is list: result = result[0] return result def monitored(self, result): id = self.result2weboobid(result) if self.exclude and id in self.exclude: return False return not self.tomonitore or id in self.tomonitore def result2weboobid(self, result): attribs = self.attribid.split('/') id = '%s@%s' % (getattr(result, attribs[0]), result.backend) return id def result2id(self, result): attribs = self.attribid.split('/') id = result for attrib in attribs: id = getattr(id, attrib) return '%s_%s' % (result.backend, id) def config(self): if self.check_cache('%s-config' % self.name): return self.new_cache('%s-config' % self.name) self.weboob.load_backends(self.capa) self.write_output('graph_title %s' % self.title.encode('iso-8859-15')) self.write_output('graph_vlabel %s' % self.vlabel.encode('iso-8859-15')) self.write_output('graph_category %s' % self.category) self.write_output('graph_args --rigid') if self.cumulate: self.write_output('graph_total Total') try: objects = [] if self.tomonitore or self.exclude: d = {} for result in self.build_do(): if self.monitored(result): d[self.result2weboobid(result)] = result if self.tomonitore: for id in self.tomonitore: try: objects.append(d[id]) except KeyError: pass else: for id in d: objects.append(d[id]) else: objects = reversed([a for a in self.build_do()]) first = True for result in objects: id = self.result2id(result) type = 'STACK' if first: type = 'AREA' first = False self.write_output('%s.label %s' % (id.encode('iso-8859-15'), getattr(result, self.attriblabel).encode('iso-8859-15'))) if self.cumulate: self.write_output('%s.draw %s' % (id, type)) except CallErrors as errors: self.print_errors(errors) self.print_cache('%s-config' % self.name) else: self.flush_cache() def print_errors(self, errors): for backend, err, backtrace in errors: print((u'%s(%s): %s' % (type(err).__name__, backend.name, err)).encode(sys.stdout.encoding or locale.getpreferredencoding(), 'replace'), file=sys.stderr) if isinstance(err, BrowserIncorrectPassword): self.weboob.backends_config.edit_backend(backend.name, backend.NAME, {'_enabled': 'false'}) def execute(self): if self.check_cache(self.name): return self.new_cache(self.name) self.weboob.load_backends(self.capa) try: for result in self.build_do(): if self.monitored(result): value = self.get_value(result) if value is not NotAvailable: self.write_output('%s.value %f' % (self.result2id(result).encode('iso-8859-15'), value)) except CallErrors as errors: self.print_errors(errors) self.print_cache(self.name) else: self.flush_cache() def run(self): cmd = (len(sys.argv) > 1 and sys.argv[1]) or "execute" if cmd == 'execute': self.execute() elif cmd == 'config': self.config() elif cmd == 'autoconf': print('no') sys.exit(1) elif cmd == 'suggest': sys.exit(1) elif cmd == 'help' or cmd == '-h' or cmd == '--help': self.display_help() if self.cache: self.cache.close() sys.exit(0) if __name__ == '__main__': logging.basicConfig() GenericMuninPlugin().run() ### Examples ### ## Like boobank-munin does ## Only for the example, you should use boobank-munin instead #[bank] #user florent #group florent #env.cache_expire 7200 #env.HOME /home/flo #env.capa CapBank #env.do iter_accounts #env.import from weboob.capabilities.bank import CapBank #env.attribvalue balance #env.title Solde des comptes # # ## Balance of your leclercmobile subscription #[leclercmobile] #user florent #group florent #env.cache_expire 16800 #env.HOME /home/flo #env.capa CapBill #env.do get_balance,06XXXXXXXX,leclercmobile #env.import from weboob.capabilities.bill import CapBill #env.attribvalue price #env.title Forfait leclercmobile #env.vlabel Solde # #Result: http://fourcot.fr/weboob/leclercmobile-day.png # ## Monitor water level in Dresden #[leveldresden] #user florent #group florent #env.cache_expire 7200 #env.HOME /home/flo #env.capa CapGauge #env.do get_last_measure,501060-level #env.import from weboob.capabilities.gauge import CapGauge #env.attribvalue level #env.title Niveau de l'elbe #env.label id # # ## The level of the elbe in all Sachsen's cities #[levelelbesachsen] #user florent #env.cache_expire 800 #env.HOME /home/flo #env.cumulate 0 #env.capa CapGauge #env.do iter_gauges,Elbe,sachsen #env.import from weboob.capabilities.gauge import CapGauge #env.attribvalue sensors/lastvalue/level #env.title Niveau de l'elbe en Saxe #env.label name #env.vlabel Hauteur du fleuve (cm) #env.exclude 550810@sachsen # #Result: http://fourcot.fr/weboob/elbesachsen-day.png # ## Temperature in Rennes #[temprennes] #user florent #env.HOME /home/flo #env.cumulate 0 #env.capa CapWeather #env.do get_current,619163,yahoo #env.import from weboob.capabilities.weather import CapWeather #env.attribvalue temp/value #env.attribid temp/id #env.title Température à Rennes #env.vlabel Température #env.label id # #Result: http://fourcot.fr/weboob/temprennes-day.png weboob-1.1/contrib/plugin.video.videoobmc/000077500000000000000000000000001265717027300206535ustar00rootroot00000000000000weboob-1.1/contrib/plugin.video.videoobmc/addon.xml000066400000000000000000000017001265717027300224600ustar00rootroot00000000000000 video linux Plugin for Videoob [B]Videoob[/B] is an application able to handle videos on supported websites. More information available on http://videoob.org/. [B]Videoob[/B] est une application qui permet de récupérer des vidéos depuis divers sites. Pour plus d'informations à ce sujet, n'hésitez pas à visiter le site : http://videoob.org/ weboob-1.1/contrib/plugin.video.videoobmc/changelog.txt000066400000000000000000000002051265717027300233400ustar00rootroot00000000000000[B]Dependance :[B] - weboob (http://weboob.org/install) [B]Version 0.1.0[/B] -Call weboob directly [B]Version 0.0.1[/B] -First try weboob-1.1/contrib/plugin.video.videoobmc/default.py000066400000000000000000000016351265717027300226560ustar00rootroot00000000000000# -*- coding: utf-8 -*- import sys import resources.lib.base.common_xbmc as common_xbmc import resources.lib.constants as constants from resources.lib.actions import actions # Plugin constants version = "0.1.0" plugin = "videoobmc" + version addon_id = "plugin.video.videoobmc" author = "Bezleputh" mail = "carton_ben@yahoo.fr" #import lxml.html import Element #print Element.__file__ #TODO gestion du logger, gestion des modules via XBMC (activation/desactivation) #Bug encodge des categories #corriger version 1 pour que v2 et v1 donctionnent if (__name__ == "__main__"): if not (sys.argv[2]): actions[constants.DISPLAY_MENU]()._do() else: params = common_xbmc.parse_params(sys.argv[2]) action = params.get("action") if (action): actions[action]()._do(params) else: common_xbmc.display_error(" ARGV Nothing done.. verify params " + repr(params)) weboob-1.1/contrib/plugin.video.videoobmc/default_test.py000077500000000000000000000011011265717027300237040ustar00rootroot00000000000000#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import print_function import sys import resources.lib.test.common_test as common_xbmc import resources.lib.constants as constants from resources.lib.actions import actions print(sys.argv) if len(sys.argv) < 2: actions[constants.DISPLAY_MENU]()._do() else: params = common_xbmc.parse_params(sys.argv[1]) #print params action = params.get("action") if (action): actions[action]()._do(params) else: common_xbmc.display_error(" ARGV Nothing done.. verify params " + repr(params)) weboob-1.1/contrib/plugin.video.videoobmc/icon.png000066400000000000000000000174271265717027300223240ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs B(xtIME V tEXtCommentCreated with GIMPWrIDATx{wWuo>sh$F,!؆ BIHy=V^Hx-d!(@v ;nXݪ۾~~q=E1!u-;}_Ը8^a_|IJ A(@IC ݩ4Y>pMwWUTl"I$b%&"ijBC9̗ wVcұLjkv3قc8k1 D=;O;:;F| @`I@h i `]^DsmOgMT*iR fMVJAkU=3t\Jxzۀ_~>]@R!/N阮R R=?)ܩlwo%6:6&յd[v!+bkm R QjuNLN:Q8fN;y\>/3/ufI jפۍ֦7kaX ! PP:8;nG|x+w;N.~=nzuͲnmAD$ff$:vlj|lfgO?:9~M^w.6|h A [(f);m' a℃_ ?;7[>Wf6gۯ}vMMMMmƅ^`fD `V BRxz<~l\S_Wg~u;Дtϛt. ? 3DE<4rԬTHHwO0[monm]׮sRLdaI `1X3Hkzյ;<e/>8] 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R8R_Mٿzz%^duhƭSE~rɌrα Vm9u7ox^#.`sg\AUSnF3Qc`6k" =V;bDQybOḏV^r+>oq$ENC `zf>3zVs\r105#a`Q.`-oq'TZՓ8(5sk|y:)O'W3J'3aΰY ( XRnnDFatSA[n yV\q'󶐲vc7,WB":oӛ}7W@z{< x&{:?]'8Qr jydzKBkú+>z|reC+eC AVErm-=C=]Gq2s@ > G/*]U ~x `Yo-pI/^?8 ,fSӧgZkb),lөn~Xll*vSJ 3೦U{6܌w>t/]Phjk[ڽ&*J 63L"2HZ i@J#B$BH.pZ w ׽缏$~*>őLL I$GĈ)=O7QmJeԤ4kBH`hx $*׽o7HFG.>jK;R,aEsɇРF:@"&( (9K`XucI{*BUQݍ@4; MD%(fp " "D2FNb<3_:GUhCyISºe!L`!8(4D QF`Ylڟc;S_{޹\*׷2)˥~/.-Q@ҬTD̎'_z_'gl@eona ޵YJeSNcX%C=zUI g/!W?GοvsOn]5 ˚Kl9e-0b愕+8 g>A-H^7}9P!lA)TV鼐 Vq^5f[Gy|@?Z ȍIENDB`weboob-1.1/contrib/plugin.video.videoobmc/resources/000077500000000000000000000000001265717027300226655ustar00rootroot00000000000000weboob-1.1/contrib/plugin.video.videoobmc/resources/__init__.py000066400000000000000000000000571265717027300250000ustar00rootroot00000000000000# Dummy file to make this directory a package. weboob-1.1/contrib/plugin.video.videoobmc/resources/language/000077500000000000000000000000001265717027300244505ustar00rootroot00000000000000weboob-1.1/contrib/plugin.video.videoobmc/resources/language/english/000077500000000000000000000000001265717027300261015ustar00rootroot00000000000000weboob-1.1/contrib/plugin.video.videoobmc/resources/language/english/strings.xml000066400000000000000000000013751265717027300303220ustar00rootroot00000000000000 Search Search: Download Information Error! Information Download started Download succeed Download folder: Number of videos per backends: Display Non Safe For Work videos: Enable debug mode: weboob-1.1/contrib/plugin.video.videoobmc/resources/language/french/000077500000000000000000000000001265717027300257155ustar00rootroot00000000000000weboob-1.1/contrib/plugin.video.videoobmc/resources/language/french/strings.xml000066400000000000000000000015121265717027300301270ustar00rootroot00000000000000 Recherche Recherche: Télécharger Information Erreur! Information Lancement du téléchargement Fichier téléchargé avec succès Répertoire de Téléchargement: Nombre de vidéos par backends: Afficher les vidéos interdites aux moins de 18 ans : Enable debug mode : weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/000077500000000000000000000000001265717027300234335ustar00rootroot00000000000000weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/__init__.py000066400000000000000000000000571265717027300255460ustar00rootroot00000000000000# Dummy file to make this directory a package. weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/actions.py000066400000000000000000000075341265717027300254560ustar00rootroot00000000000000# -*- coding: utf-8 -*- from __future__ import print_function import sys from . import constants from .base.actions import BaseAction from .menu import MenuItem, MenuItemVideo, MenuItemPath from threading import Thread from .videoobmc import Videoobmc if hasattr(sys.modules["__main__"], "common_xbmc"): common_xbmc = sys.modules["__main__"].common_xbmc else: import common_xbmc class VideoobBaseAction(BaseAction): def __init__(self): count = common_xbmc.get_settings('nbVideoPerBackend') numbers = ["10", "25", "50", "100"] self.videoobmc = Videoobmc(count=numbers[int(count)], nsfw=common_xbmc.get_settings('nsfw')) class DisplayMenuAction(VideoobBaseAction): def _do(self, param={}): backends = self.videoobmc.backends if backends: MenuItem(common_xbmc.get_translation('30000'), constants.SEARCH).add_to_menu() for backend in backends: icon = self.videoobmc.get_backend_icon(backend) MenuItem(backend, constants.DISPLAY_BACKENDS, backend=backend, iconimage=icon).add_to_menu() common_xbmc.end_of_directory(False) else: common_xbmc.display_error(" Please install and configure weboob") class DisplayCollectionMenuAction(VideoobBaseAction): def _do(self, param={}): path = param.get('path') if 'path' in param.keys() else '' collections, videos = self.videoobmc.ls(param.get('backend'), path=path) threads = [] for col in collections: MenuItemPath(col).add_to_menu() for video in videos: aThread = Thread(target=self.add_videos, args=(video, video.backend)) threads.append(aThread) aThread.start() for t in threads: t.join() common_xbmc.end_of_directory(False) def add_videos(self, _video, backend): print(_video) video = self.videoobmc.get_video(_video, backend) if video: MenuItemVideo(video).add_to_menu() class DownloadAction(VideoobBaseAction): def _do(self, param={}): _id = param.get('id') backend = param.get('backend') if _id: aThread = Thread(target=self.download, args=(_id, backend)) aThread.start() common_xbmc.display_info(common_xbmc.get_translation('30301')) common_xbmc.end_of_directory(False) def download(self, _id, backend): dl_dir = common_xbmc.get_settings('downloadPath') self.videoobmc.download(_id, dl_dir if dl_dir else common_xbmc.get_addon_dir(), backend) common_xbmc.display_info(common_xbmc.get_translation('30302')) class SearchAction(VideoobBaseAction): def _do(self, param={}): pattern = common_xbmc.ask_user('', common_xbmc.get_translation('30001')) if pattern: for video in self.videoobmc.search(pattern, param.get('backend')): MenuItemVideo(video).add_to_menu() common_xbmc.end_of_directory(False) class DisplayBackendsAction(VideoobBaseAction): def _do(self, param={}): backend = param.get('backend') if backend: MenuItem('Search', constants.SEARCH, backend=backend).add_to_menu() DisplayCollectionMenuAction()._do(param) else: common_xbmc.end_of_directory(False) class UpdateWeboobAction(VideoobBaseAction): def _do(self, param={}): common_xbmc.display_info(common_xbmc.get_translation('30551')) self.videoobmc.update() common_xbmc.display_info(common_xbmc.get_translation('30552')) actions = {constants.DISPLAY_MENU: DisplayMenuAction, constants.DISPLAY_COLLECTION_MENU: DisplayCollectionMenuAction, constants.SEARCH: SearchAction, constants.DOWNLOAD: DownloadAction, constants.DISPLAY_BACKENDS: DisplayBackendsAction, constants.UPDATE: UpdateWeboobAction} weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/base/000077500000000000000000000000001265717027300243455ustar00rootroot00000000000000weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/base/__init__.py000066400000000000000000000000571265717027300264600ustar00rootroot00000000000000# Dummy file to make this directory a package. weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/base/actions.py000066400000000000000000000005121265717027300263550ustar00rootroot00000000000000# -*- coding: utf-8 -*- from abc import ABCMeta, abstractmethod class BaseAction(): __metaclass__ = ABCMeta @abstractmethod def _do(self, param=None): """ Overload this method in application type subclass if you want to associate an action to the menu """ pass actions = {} weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/base/common_xbmc.py000066400000000000000000000110411265717027300272150ustar00rootroot00000000000000# -*- coding: utf-8 -*- from __future__ import print_function import xbmc import xbmcgui import xbmcplugin import xbmcaddon import urllib import sys from traceback import print_exc def get_addon(): if hasattr(sys.modules["__main__"], "addon_id"): _id = sys.modules["__main__"].addon_id return xbmcaddon.Addon(id=_id) def get_translation(key): addon = get_addon() if addon: return addon.getLocalizedString(int(key)) def get_settings(key): addon = get_addon() if addon: return addon.getSetting(key) def get_addon_dir(): addon = get_addon() if addon: addonDir = addon.getAddonInfo("path") else: addonDir = xbmc.translatePath("special://profile/addon_data/") return addonDir def display_error(msg): xbmc.executebuiltin("XBMC.Notification(%s, %s)" % (get_translation('30200').decode('utf-8'), msg)) print(msg) print_exc(msg) def display_info(msg): xbmc.executebuiltin("XBMC.Notification(%s, %s, 3000, DefaultFolder.png)" % (get_translation('30300').encode('utf-8'), msg.encode('utf-8'))) #print msg print_exc() def parse_params(param_str): param_dic = {} # Parameters are on the 3rd arg passed to the script param_str = sys.argv[2] if len(param_str) > 1: param_str = param_str.replace('?', '') # Ignore last char if it is a '/' if param_str[len(param_str) - 1] == '/': param_str = param_str[0:len(param_str) - 2] # Processing each parameter splited on '&' for param in param_str.split('&'): try: # Spliting couple key/value key, value = param.split('=') except: key = param value = '' key = urllib.unquote_plus(key) value = urllib.unquote_plus(value) # Filling dictionnary param_dic[key] = value return param_dic def ask_user(content, title): keyboard = xbmc.Keyboard(content, title) keyboard.doModal() if keyboard.isConfirmed() and keyboard.getText(): return keyboard.getText() return "" def create_param_url(param_dic, quote_plus=False): """ Create an plugin URL based on the key/value passed in a dictionary """ url = sys.argv[0] sep = '?' try: for param in param_dic: if quote_plus: url = url + sep + urllib.quote_plus(param) + '=' + urllib.quote_plus(param_dic[param]) else: url = "%s%s%s=%s" % (url, sep, param, param_dic[param]) sep = '&' except Exception as msg: display_error("create_param_url %s" % msg) url = None return url def create_list_item(name, itemInfoType="Video", itemInfoLabels=None, iconimage="DefaultFolder.png", c_items=None, isPlayable=False): lstItem = xbmcgui.ListItem(label=name, iconImage=iconimage, thumbnailImage=iconimage) if c_items: lstItem.addContextMenuItems(c_items, replaceItems=True) if itemInfoLabels: iLabels = itemInfoLabels else: iLabels = {"Title": name, } lstItem.setInfo(type=itemInfoType, infoLabels=iLabels) if isPlayable: lstItem.setProperty('IsPlayable', "true") return lstItem def add_menu_item(params={}): url = create_param_url(params) if params.get('name'): if params.get('iconimage'): lstItem = create_list_item(params.get('name'), iconimage=params.get('iconimage')) else: lstItem = create_list_item(params.get('name')) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=lstItem, isFolder=True) else: display_error('add_menu_item : Fail to add item to menu') def add_menu_link(params={}): if params.get('name') and params.get('iconimage') and params.get('url') and \ params.get('itemInfoLabels') and params.get('c_items'): url = params.get('url') lstItem = create_list_item(params.get('name'), iconimage=params.get('iconimage'), itemInfoLabels=params.get('itemInfoLabels'), c_items=params.get('c_items'), isPlayable=True) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=lstItem) else: display_error('add_menu_link : Fail to add item to menu') def end_of_directory(update=False): xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True, updateListing=update) # , cacheToDisc=True) weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/base/menu.py000066400000000000000000000020541265717027300256640ustar00rootroot00000000000000# -*- coding: utf-8 -*- import sys if hasattr(sys.modules["__main__"], "common_xbmc"): common_xbmc = sys.modules["__main__"].common_xbmc else: import common_xbmc class BaseMenuItem(): def __init__(self, name, action, iconimage="DefaultFolder.png"): self.params = {} self.params['name'] = name self.params['action'] = action self.params['iconimage'] = iconimage def get(self, element): return self.params[element] def add_to_menu(self): common_xbmc.add_menu_item(self.params) class BaseMenuLink(BaseMenuItem): def __init__(self, name, url, action, iconimage="DefaultFolder.png"): BaseMenuItem.__init__(self, name, action, iconimage) self.params["url"] = url def createVideoContextMenu(self): return "" def create_info_labels(self): return "" def add_to_menu(self): self.params["itemInfoLabels"] = self.create_info_labels() self.params["c_items"] = self.createVideoContextMenu() common_xbmc.add_menu_link(self.params) weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/base/weboobmc.py000066400000000000000000000045161265717027300265220ustar00rootroot00000000000000#!/usr/bin/python # -*- coding: utf-8 -*- import sys import os import re import subprocess import simplejson as json if hasattr(sys.modules["__main__"], "common_xbmc"): common_xbmc = sys.modules["__main__"].common_xbmc else: import common_xbmc class Weboobmc(): def __init__(self, count=10): self.count = count def update(self): #weboob-config update self._call_weboob('weboob-config', 'update') def _call_weboob(self, application, command, options={}, argument=""): if '-n' not in options.keys(): options['-n'] = self.count _opt = " ".join(["%s %s " % (k, v) for k, v in options.items()]) _cmd = "%s %s %s %s" % (application, _opt, command, argument) #print _cmd.encode('utf-8') return subprocess.check_output(_cmd, shell=True) def _json_call_weboob(self, application, command, options={}, argument=""): options['-f'] = 'json' try: result = self._call_weboob(application, command, options, argument) m = re.search(r"(\[{.+\}])", result) if m: result = u'%s' % m.group(1) #print result return json.loads(result) if result else [] except subprocess.CalledProcessError as e: common_xbmc.display_error(" Error while calling weboob : %s " % e) def get_loaded_backends(self, caps): #weboob-config list ICapVideo -f json backends = self._json_call_weboob('weboob-config', 'list', argument=caps) for backend in backends: if "_enabled=0" not in backend['Configuration']: yield backend['Name'] # , self.get_backend_icon(backend['Module']) def get_backend_icon(self, module): if 'WEBOOB_DATADIR' in os.environ: datadir = os.environ['WEBOOB_DATADIR'] elif 'WEBOOB_WORKDIR' in os.environ: datadir = os.environ['WEBOOB_WORKDIR'] else: datadir = os.path.join(os.environ.get('XDG_DATA_HOME', os.path.join(os.path.expanduser('~'), '.local', 'share') ), 'weboob') icons_dir = os.path.join(datadir, 'icons') return os.path.join(icons_dir, '%s.png' % module) def is_category(self, obj): return 'split_path' in obj.keys() weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/base/weboobmc2.py000066400000000000000000000054551265717027300266070ustar00rootroot00000000000000#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import print_function from weboob.tools.application.base import Application import os import re import subprocess class Weboobmc(Application): def __init__(self, count=10): Application.__init__(self) self.count = int(count) self._is_default_count = False def update(self): self.weboob.update() def get_backend_icon(self, module): minfo = self.weboob.repositories.get_module_info(module) return self.weboob.repositories.get_module_icon_path(minfo) def obj_to_filename(self, obj, dest=None, default=None): """ This method can be used to get a filename from an object, using a mask filled by information of this object. All patterns are braces-enclosed, and are name of available fields in the object. :param obj: object type obj: BaseObject param dest: dest given by user (default None) type dest: str param default: default file mask (if not given, this is :'{id}-{title}.{ext}') type default: str rtype: str """ if default is None: default = '{id}-{title}.{ext}' if dest is None: dest = '.' if os.path.isdir(dest): dest = os.path.join(dest, default) def repl(m): field = m.group(1) if hasattr(obj, field): return re.sub('[?:/]', '-', '%s' % getattr(obj, field)) else: return m.group(0) return re.sub(r'\{(.+?)\}', repl, dest) def download_obj(self, obj, dest): def check_exec(executable): with open('/dev/null', 'w') as devnull: process = subprocess.Popen(['which', executable], stdout=devnull) if process.wait() != 0: print('Please install "%s"' % executable) return False return True dest = self.obj_to_filename(obj, dest) if obj.url.startswith('rtmp'): if not check_exec('rtmpdump'): return 1 args = ('rtmpdump', '-e', '-r', obj.url, '-o', dest) elif obj.url.startswith('mms'): if not check_exec('mimms'): return 1 args = ('mimms', '-r', obj.url, dest) elif u'm3u8' == obj.ext: _dest, _ = os.path.splitext(dest) dest = u'%s.%s' % (_dest, 'mp4') args = ('wget',) + tuple(line for line in self.read_url(obj.url) if not line.startswith('#')) + ('-O', dest) else: if check_exec('wget'): args = ('wget', '-c', obj.url, '-O', dest) elif check_exec('curl'): args = ('curl', '-C', '-', obj.url, '-o', dest) else: return 1 os.spawnlp(os.P_WAIT, args[0], *args) weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/constants.py000066400000000000000000000003341265717027300260210ustar00rootroot00000000000000# -*- coding: utf-8 -*- DISPLAY_MENU = "display_menu" DISPLAY_COLLECTION_MENU = "display_collection_menu" DISPLAY_BACKENDS = "display_backends" SEARCH = "search" VIDEO = "video" DOWNLOAD = "download" UPDATE = "update" weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/menu.py000066400000000000000000000047551265717027300247640ustar00rootroot00000000000000# -*- coding: utf-8 -*- import sys from . import constants from datetime import datetime, timedelta from .base.menu import BaseMenuItem, BaseMenuLink if hasattr(sys.modules["__main__"], "common_xbmc"): common_xbmc = sys.modules["__main__"].common_xbmc else: import common_xbmc class MenuItem(BaseMenuItem): params = {} def __init__(self, name, action, iconimage="DefaultFolder.png", backend=''): BaseMenuItem.__init__(self, name, action, iconimage) self.params['backend'] = backend class MenuItemPath(MenuItem): def __init__(self, collection, action=constants.DISPLAY_COLLECTION_MENU, iconimage="DefaultFolder.png"): MenuItem.__init__(self, collection.title, action, iconimage, collection.fullid.split('@')[-1]) self.params["path"] = '/'.join(collection.split_path) class MenuItemVideo(BaseMenuLink): def __init__(self, video, iconimage="DefaultFolder.png"): name = '[%s] %s' % (video.backend, video.title) BaseMenuLink.__init__(self, name, video.url, constants.VIDEO, video.thumbnail.url if video.thumbnail.url else iconimage) self.video = video self.params["id"] = self.video.id def createVideoContextMenu(self): cm = [] #Information cm.append((common_xbmc.get_translation('30110'), "XBMC.Action(Info)")) #Téléchargement url = "%s?action=%s&id=%s&backend=%s" % (sys.argv[0], constants.DOWNLOAD, self.video.id, self.video.backend) cm.append((common_xbmc.get_translation('30100'), "XBMC.PlayMedia(%s)" % (url))) return cm def create_info_labels(self): date, year = self.format_date(self.video.date) duration = 0 if self.video.duration: duration = u'%s' % str(self.video.duration.total_seconds()/60) if isinstance(self.video.duration, timedelta) else self.video.duration description = u'%s' % self.video.description return {"Title": self.video.title, "Year": year, "Plot": description, "PlotOutline": description[0:30] if len(description) > 30 else description, "Director": self.video.author if self.video.author else 'Unknown', "Duration": duration, "Date": date} def format_date(self, video_date): date = datetime.now().strftime("%d/%m/%Y") if video_date: date = video_date.strftime("%d/%m/%Y") year = date.split('/')[-1] return date, year weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/test/000077500000000000000000000000001265717027300244125ustar00rootroot00000000000000weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/test/__init__.py000066400000000000000000000000571265717027300265250ustar00rootroot00000000000000# Dummy file to make this directory a package. weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/test/common_test.py000066400000000000000000000054541265717027300273230ustar00rootroot00000000000000# -*- coding: utf-8 -*- from __future__ import print_function import urllib def get_addon(): pass def get_translation(key): translation = {'30000': 'Recherche', '30001': 'Recherche :', '30100': 'Télécharger', '30110': 'Information', '30200': 'Erreur!', '30300': 'Information', '30301': 'Lancement du téléchargement', '30302': 'Fichier téléchargé avec succès', '30551': 'Debut de la mise à jour', '30552': 'Weboob est maintenant à jour'} return translation.get(key) def get_addon_dir(): return '/home/benjamin' def get_settings(key): settings = {'downloadPath': get_addon_dir(), 'nbVideoPerBackend': '0', 'nsfw': 'False'} return settings.get(key) def display_error(error): print("%s: %s" % ("ERROR", error)) def display_info(msg): print("%s: %s" % ("INFO", msg)) def parse_params(paramStr): paramDic = {} # Parameters are on the 3rd arg passed to the script if len(paramStr) > 1: paramStr = paramStr.replace('?', '') # Ignore last char if it is a '/' if paramStr[len(paramStr) - 1] == '/': paramStr = paramStr[0:len(paramStr) - 2] # Processing each parameter splited on '&' for param in paramStr.split('&'): try: # Spliting couple key/value key, value = param.split('=') except: key = param value = '' key = urllib.unquote_plus(key) value = urllib.unquote_plus(value) # Filling dictionnary paramDic[key] = value return paramDic def ask_user(content, title): return raw_input(title) def create_param_url(paramsDic, quote_plus=False): #url = sys.argv[0] url = '' sep = '?' try: for param in paramsDic: if quote_plus: url = url + sep + urllib.quote_plus(param) + '=' + urllib.quote_plus(paramsDic[param]) else: url = "%s%s%s=%s" % (url, sep, param, paramsDic[param]) sep = '&' except Exception as msg: display_error("create_param_url %s" % msg) url = None return url def add_menu_item(params={}): print('%s => "%s"' % (params.get('name'), create_param_url(params))) def add_menu_link(params={}): print('[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url'))) #print params.get('itemInfoLabels') #print params.get('c_items') def end_of_directory(update=False): print('******************************************************') def download_video(url, name, dir='./'): print('Downlaod a video %s from %s' % (name, url)) weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/videoobmc.py000066400000000000000000000071421265717027300257600ustar00rootroot00000000000000#!/usr/bin/python # -*- coding: utf-8 -*- import time import re from datetime import timedelta, datetime from .base.weboobmc import Weboobmc from weboob.capabilities.video import BaseVideo from weboob.capabilities.image import BaseImage from weboob.capabilities.collection import Collection class Videoobmc(Weboobmc): def __init__(self, count=10, nsfw=False): Weboobmc.__init__(self, count=count) self.backends = list(self.get_loaded_backends('CapVideo')) _nsfw = 'on' if nsfw else 'off' self._call_weboob('videoob', 'nsfw', argument=_nsfw) def search(self, pattern, backend=''): #videoob search pattern -f json options = {'--select': 'id,title,date,description,author,duration,thumbnail,url'} if backend: options['-b'] = backend _videos = self._json_call_weboob('videoob', 'search', argument=pattern, options=options) if _videos: for _video in _videos: yield self.create_video_from_json(_video) def create_video_from_json(self, _video): video = BaseVideo() video.id = u'%s' % _video['id'] video.backend = u'%s' % _video['id'].split('@')[-1] if 'url' in _video.keys(): video.url = u'%s' % _video['url'] if 'thumbnail' in _video.keys() and _video['thumbnail'] and 'url' in _video['thumbnail'].keys(): video.thumbnail = BaseImage() video.thumbnail.url = u'%s' % _video['thumbnail']['url'] else: video.thumbnail.url = u'' video.title = u'%s' % _video['title'] if _video['date']: _date = re.search('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*', _video['date']) try: datetime.strptime(_date.group(1), '%Y-%m-%d %H:%M:%S') except TypeError: datetime(*(time.strptime(_date.group(1), '%Y-%m-%d %H:%M:%S')[0:6])) video.description = u'%s' % _video['description'] video.author = u'%s' % _video['author'] if _video['duration']: _duration = _video['duration'].split(':') video.duration = timedelta(hours=int(_duration[0]), minutes=int(_duration[1]), seconds=int(_duration[2])) return video def get_video(self, video, backend): #videoob info _id -f json _video = self._json_call_weboob('videoob', 'info', argument=video.id) if _video and len(_video) > 0: return self.create_video_from_json(_video[0]) def ls(self, backend, path=''): options = {'-b': backend, '-n': 50} result = self._json_call_weboob('videoob', 'ls', options=options, argument=path) return self.separate_collections_and_videos(result) def separate_collections_and_videos(self, objs): videos = [] categories = [] for obj in objs: if self.is_category(obj): categories.append(self.create_category_from_json(obj)) else: video = BaseVideo() video.id = obj['id'].split('@')[0] video.backend = obj['id'].split('@')[-1] videos.append(video) return categories, videos def create_category_from_json(self, obj): collection = Collection(obj['split_path'].split('/')) collection.title = obj['title'] collection.id = obj['id'].split('@')[0] collection.backend = obj['id'].split('@')[1] return collection def download(self, _id, path, backend): #videoob download _id path options = {'-b': backend} self._call_weboob('videoob', 'download', options=options, argument=u'%s %s' % (_id, path)) weboob-1.1/contrib/plugin.video.videoobmc/resources/lib/videoobmc2.py000066400000000000000000000040511265717027300260360ustar00rootroot00000000000000#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import print_function from .base.weboobmc2 import Weboobmc from weboob.capabilities.video import BaseVideo, CapVideo from weboob.capabilities.collection import CapCollection, Collection class Videoobmc(Weboobmc): def __init__(self, count=10, nsfw=False): Weboobmc.__init__(self, count=count) self.backends = self.weboob.load_backends(CapVideo) self.nsfw = nsfw def search(self, pattern, backend=''): kwargs = {'pattern': pattern, 'nsfw': self.nsfw, 'backends': backend} fields = ['id', 'title', 'date', 'description', 'author', 'duration', 'thumbnail', 'url'] try: for video in self.weboob.do(self._do_complete, self.count, fields, 'search_videos', **kwargs): yield video except Exception as e: print(e) def get_video(self, video, _backend): backend = self.weboob.get_backend(_backend) fields = ['id', 'title', 'date', 'description', 'author', 'duration', 'thumbnail', 'url'] return backend.fillobj(video, fields) def ls(self, backend, path=''): kwargs = {'split_path': path.split('/') if path else [], 'caps': CapCollection, 'objs': (BaseVideo, ), 'backends': backend} fields = [] # ['id', 'title', 'date', 'description', 'author', 'duration', 'thumbnail', 'url'] result = self.weboob.do(self._do_complete, self.count, fields, 'iter_resources', **kwargs) return self.separate_collections_and_videos(result) def separate_collections_and_videos(self, objs): videos = [] categories = [] for obj in objs: if isinstance(obj, Collection): categories.append(obj) else: videos.append(obj) return categories, videos def download(self, _id, dest, backend): for _video in self.weboob.do('get_video', _id, backends=backend): self.download_obj(_video, dest) weboob-1.1/contrib/plugin.video.videoobmc/resources/settings.xml000066400000000000000000000010471265717027300252510ustar00rootroot00000000000000 weboob-1.1/contrib/report_accounts.sh000077500000000000000000000030431265717027300200530ustar00rootroot00000000000000#!/bin/bash # Rapport des comptes bancaires # Liste l'intégralité des comptes dans Boobank, leurs dernières opérations et les opérations à venir # et envoie ça par mail si --mail machin@example.tld est spécifié, sinon ça affiche # (Compatible Debian Squeze) # Public domain SUBJECT="[Bank] Accounts report" TMPSTORAGE=`mktemp -d` boobank -q -f table list > ${TMPSTORAGE}/account_list ACCOUNTS=`awk '/@/ {print $2}' ${TMPSTORAGE}/account_list` for i in $ACCOUNTS do boobank -q -f table history "$i" > ${TMPSTORAGE}/account_history_${i} boobank -q -f table coming "$i" > ${TMPSTORAGE}/account_coming_${i} done printf "Bank accounts report, generated by boobank\n" > ${TMPSTORAGE}/account_mail cat ${TMPSTORAGE}/account_list >> ${TMPSTORAGE}/account_mail printf "\n" >> ${TMPSTORAGE}/account_mail for i in $ACCOUNTS do printf "Last operations for account $i \n" >> ${TMPSTORAGE}/account_mail cat ${TMPSTORAGE}/account_history_${i} >> ${TMPSTORAGE}/account_mail printf >> ${TMPSTORAGE}/account_mail if [ -s ${TMPSTORAGE}/account_coming_${i} ] then printf "Coming operations for account $i \n" >> ${TMPSTORAGE}/account_mail cat ${TMPSTORAGE}/account_coming_${i} >> ${TMPSTORAGE}/account_mail printf >> ${TMPSTORAGE}/account_mail else printf "No coming operation for $i \n" >> ${TMPSTORAGE}/account_mail fi done if [ "$1" = "--mail" ] then cat ${TMPSTORAGE}/account_mail | mail -s "$SUBJECT" -a "Content-type: text/plain; charset=UTF-8" "$2" else cat ${TMPSTORAGE}/account_mail fi rm -rf ${TMPSTORAGE} weboob-1.1/contrib/videoob_web/000077500000000000000000000000001265717027300165665ustar00rootroot00000000000000weboob-1.1/contrib/videoob_web/videoob-webserver000077500000000000000000000016221265717027300221460ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from videoob_web import VideoobWeb if __name__ == '__main__': VideoobWeb.run() weboob-1.1/contrib/videoob_web/videoob_web/000077500000000000000000000000001265717027300210525ustar00rootroot00000000000000weboob-1.1/contrib/videoob_web/videoob_web/__init__.py000066400000000000000000000014401265717027300231620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .videoob_web import VideoobWeb __all__ = ['VideoobWeb'] weboob-1.1/contrib/videoob_web/videoob_web/public/000077500000000000000000000000001265717027300223305ustar00rootroot00000000000000weboob-1.1/contrib/videoob_web/videoob_web/public/style.css000066400000000000000000000000761265717027300242050ustar00rootroot00000000000000.video-item { margin-bottom: 5ex; margin-left: 2em; } weboob-1.1/contrib/videoob_web/videoob_web/templates/000077500000000000000000000000001265717027300230505ustar00rootroot00000000000000weboob-1.1/contrib/videoob_web/videoob_web/templates/base.mako000066400000000000000000000006221265717027300246330ustar00rootroot00000000000000## -*- coding: utf-8 -*- <%def name="title()" filter="trim"> Videoob Web ${self.title()} ${next.css()} ${next.body()} weboob-1.1/contrib/videoob_web/videoob_web/templates/index.mako000066400000000000000000000017511265717027300250340ustar00rootroot00000000000000## -*- coding: utf-8 -*- <%inherit file="base.mako"/> <%def name="css()" filter="trim"> <%def name="video_item(item)"> <%def name="body()">

Videoob Web

% if merge: % for item in results: ${video_item(item)} % endfor % else: % for backend, items in sorted(results.iteritems()):

${backend}

% for item in items: ${video_item(item)} % endfor % endfor % endif
weboob-1.1/contrib/videoob_web/videoob_web/videoob_web.py000066400000000000000000000105421265717027300237120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import os from mako.lookup import TemplateLookup from mako.runtime import Context from routes import Mapper from StringIO import StringIO from webob.dec import wsgify from webob import exc from wsgiref.simple_server import make_server from weboob.capabilities.video import CapVideo from weboob.tools.application.base import Application __all__ = ['VideoobWeb'] template_lookup = TemplateLookup(directories=[os.path.join(os.path.dirname(__file__), 'templates')], output_encoding='utf-8', encoding_errors='replace') class VideoobWeb(Application): APPNAME = 'videoob-webserver' VERSION = '0.j' COPYRIGHT = 'Copyright(C) 2010-2011 Christophe Benz' DESCRIPTION = 'WSGI web server application allowing to search for videos on various websites.' CAPS = CapVideo CONFIG = dict(host='localhost', port=8080) @wsgify def make_app(self, req): map = Mapper() map.connect('index', '/', method='index') results = map.routematch(environ=req.environ) if results: match, route = results req.urlvars = ((), match) kwargs = match.copy() method = kwargs.pop('method') return getattr(self, method)(req, **kwargs) else: public_path = os.path.join(os.path.dirname(__file__), 'public') if not os.path.exists(public_path): return exc.HTTPNotFound() path = req.path if path.startswith('/'): path = path[1:] public_file_path = os.path.join(public_path, path) if os.path.exists(public_file_path): if path.endswith('.css'): req.response.content_type = 'text/css' elif path.endswith('.js'): req.response.content_type = 'text/javascript' return open(public_file_path, 'r').read().strip() else: return exc.HTTPNotFound() def main(self, argv): self.load_config() self.weboob.load_backends(CapVideo) print('Web server created. Listening on http://%s:%s' % ( self.config.get('host'), int(self.config.get('port')))) srv = make_server(self.config.get('host'), int(self.config.get('port')), self.make_app) srv.serve_forever() def index(self, req): c = {} nsfw = req.params.get('nsfw') nsfw = False if not nsfw or nsfw == '0' else True q = req.params.get('q', u'') merge = req.params.get('merge') merge = False if not merge or merge == '0' else True c['merge'] = merge c['form_data'] = dict(q=q) c['results'] = [] if merge else {} if q: for backend in self.weboob.iter_backends(): videos = [dict(title=video.title, page_url=video.page_url, url=video.url if video.url else '/download?id=%s' % video.id, thumbnail_url=video.thumbnail.url, ) for video in backend.search_videos(pattern=q, nsfw=nsfw)] if videos: if merge: c['results'].extend(videos) else: c['results'][backend.name] = videos if merge: c['results'] = sorted(c['results'], key=lambda video: video['title'].lower()) template = template_lookup.get_template('index.mako') buf = StringIO() ctx = Context(buf, **c) template.render_context(ctx) return buf.getvalue().strip() weboob-1.1/contrib/windows-install/000077500000000000000000000000001265717027300174405ustar00rootroot00000000000000weboob-1.1/contrib/windows-install/HOW_TO.txt000066400000000000000000000010361265717027300212400ustar00rootroot000000000000001. Generate and Replace weboob egg file (./setup.py install --qt bdist_egg) 2. update settings.cmd 3. Download http://www.f2ko.de/downloads/Bat_To_Exe_Converter.zip extrat 32 and 64bit version and respectivly rename to Bat_To_Exe_Converter_x32.exe and Bat_To_Exe_Converter_x64.exe 4. Download http://nebm.ist.utl.pt/~glopes/wget/wget-1.11.4-x64.zip, unzip and rename to => wget-x64.exe 5. Download http://nebm.ist.utl.pt/~glopes/wget/wget-1.11.4-x86.zip, unzip and rename to => wget-x32.exe 6. run create-exe-setup-weboob.bat weboob-1.1/contrib/windows-install/ICON/000077500000000000000000000000001265717027300201705ustar00rootroot00000000000000weboob-1.1/contrib/windows-install/ICON/weboobtxt.ico000066400000000000000000013226261265717027300227150ustar00rootroot00000000000000 hf 00 %v@@ (B; (F} ( n(  @N%N/[MɆS-7@kJC=I:(!I:(1I:'7I:(UI:(CI:(Kэ[CŃQQSJ:ٖB=Q(-"/"U"."I:([I:(I:(mI:(iI:(cI:(ÃQUҎ\ǼKLy4ߒ?Rg0C"/""/";I9'EI:(?I:(aI:(_I:(II:(Kؓ`+ˈV̉WOSBERf2="/"_"/"ŃPЌYỶWsśWCCEEB uC ÂOS!s(2( @ o& C!N!L`K)\?IOT7]^+\*![(1\;|/96;K^ ]* ڔa3v=ƄQCd1AD[D\ZIm<3̉UuKwE֑^oŃQSF+8oYo%w+ӔABUM I:(I9'%I9(I:(+I:(I:(I:(I:([I:(I:(I:(ߙf%{I}Ր^yGݖds@Y9oS;^ӎ=Pa5%!/!"/""/""."KI:(I:(I:(I:(I:(I:(kI:(SI9(I:(I:(1I:(Ɖ\/~Loؒ`ɸxFMuGePLo1<RC2{}0}SCHOҎ['|IvY~EŃP%Y?[/_1T#|0 OyFЌY3|I+S! u* 5u* ^0_1(0` %D}YBzo%9!CA5s(O)_/_1_+\N b H)^7ZID]DWX9_\X% X%W$ x,]1TOu)t)z-u)AI_]W$n;3{H9j8?[)/u@}[m;_N7KW;YcUѪRs(ŨPwEU;#"/""/""/""."I9'I9(I:(MI:'UI9(I:' I:(I9(I9(I9(I9(I:(QI:(I9(I:(I9(I:(ƒP~Ci7o~uCȆSՑ^e@YQQ9Q{.^\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~;~=~=??~?~?~=~;~9~7~5~1z/͊W9tAAo>;o=3b0#e5^0 ]55p9uC~ Zp(z.#z,'{,+~1+7+C%Q![_^_^]WI!:%0'{-%y/!z0z-h ?za1`0_1 Rl9)o=3o=;wE;Ր]5r/}/~1~3~5~7~7~7~7~7~7~5~3~3y1h5}I?p=Cp=;o=3b0#m< ^/ \37r;uAz `q+x-z,#z+'z,)y,+|.+1)4)5'3'0)|-'{+'z,%y/!y1z.t(Y =s\5]3`2 Le2#n<1o<9p>=|I;ЌY7j3|/~/~1~3~33~3~1~1{1i5ƄP=vBCp=Ap=;o>5`/%p> ^/^1 `57o8s=wL aq)x.y.!z.#z-#y-%{,%z,%z-%{-#z.!y/z0z/v*i! L~ 7m]6]2_2 n= X'l:+o=3o=;q>=tB?|H?ɇT9ڔa5l3s1s1l3ܔb7ɆT=zHAuACq=Cp>?p=9o<3]-#l; ^/]1 a19p8r>wI U g!s*w.w/x0x0x0y/z.w,p'a O@w]5]1 _0 sA^,k9+o=3o=7o==o=?o=Cp9p=5i6)Na3^0]0 ]/1i6p8r;u;w?z R ^ b ] W K @v9r6q2dZ8]3 ^0 a1|HZ)f5)n=1p>5p=7p=;p=;o==p==p=;p=;q>9p=5g5+Y'!r@_0^/ ]1 _2:n4j7n9q9r>8,0,0, 22,0,0,0)) #bitmap-size*4,22B-offset*4 #image BITMAPINFOHEADER(ref5) a.extend((40,0,0,0)) #size of data(contains header)*4 a.extend((size,0,0,0, size*2,0,0,0))#w*4, (h+h)*4 (!shit hack! XOR+AND) a.extend((1,0, bpp,0, 0,0,0,0, 0,0,0,0)) #1 plane*2, 24 bits*2, no compress*4, rawBMPsize(no compress so 0)*4 a.extend((0,1,0,0, 0,1,0,0)) #horizontal*4/vertical*4 resolution pixels/meter(WTF?) a.extend((0,0,0,0, 0,0,0,0)) #colors fully used, all are important #!no planes #image content(ref1&5), XOR+AND bitmaps AND = array('B') vand = 0 vcnt = 0 #remember that bitmap format is reversed in y-axis for x in range(size-1,-1,-1): for y in range(0, size): b,g,r,t_or_a = data[y*size+x] a.extend((r,g,b)) if bpp == 32: a.append(t_or_a) vcnt+=1 vand<<=1 if (bpp==24 and t_or_a) or (bpp==32 and t_or_a<128): vand |= 1 if vcnt==8: AND.append(vand) vcnt=0 vand=0 #!hack! AND bits align to 32 bits per line, !shit! MSDN says nothing about this AND.extend([0] * ((32-size%32)%32/8)) a.extend(AND) return a # x,y indicate the hotspot position # simply set the type/hotspot(x&y) after generates the icon def gencur(data, size=16, bpp=24, x=0, y=0): a = genico(data, size, bpp) a[3], a[10], a[12] = 2, x, y return a #C:\Python27\Lib\site-packages\weboob-0.g-py2.7.egg\share\icons\hicolor\64x64\apps if __name__ == "__main__": if len(sys.argv) == 2: png_file = sys.argv[1] f, e = os.path.splitext(png_file) ico_file = f + ".ico" im = Image.open(r"%s" % png_file) wh = 64 rgba = im.convert("RGBA") data = [] for i in range(wh): for j in range(wh): data.append(rgba.getpixel((i,j))) icoflow = genico(data, wh, 32) _file = open(ico_file, "wb") icoflow.tofile(_file) _file.close() weboob-1.1/contrib/windows-install/create-exe-setup-weboob.bat000066400000000000000000000005611265717027300245650ustar00rootroot00000000000000@echo off call settings.cmd "Bat_To_Exe_Converter_%LOCAL_ARCHITECTURE%.exe" -bat "setup-weboob.bat" -save "setup-weboob-%WEBOOB_VERSION%-%ARCHITECTURE%.exe" -icon "ICON\weboobtxt.ico" -include "Bat_To_Exe_Converter_%ARCHITECTURE%.exe" -include "wget-%ARCHITECTURE%.exe" -include "%WEBOOB%" -include "convertPNG2ICO.py" -include "ez_setup.py" -include "settings.cmd" weboob-1.1/contrib/windows-install/ez_setup.py000066400000000000000000000271251265717027300216570ustar00rootroot00000000000000#!python """Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools, set a download mirror, or use an alternate download directory, you can do so by supplying the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ import os import shutil import sys import tempfile import tarfile import optparse import subprocess import platform from distutils import log try: from site import USER_SITE except ImportError: USER_SITE = None DEFAULT_VERSION = "1.1.6" DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" def _python_cmd(*args): args = (sys.executable,) + args return subprocess.call(args) == 0 def _check_call_py24(cmd, *args, **kwargs): res = subprocess.call(cmd, *args, **kwargs) class CalledProcessError(Exception): pass if not res == 0: msg = "Command '%s' return non-zero exit status %d" % (cmd, res) raise CalledProcessError(msg) vars(subprocess).setdefault('check_call', _check_call_py24) def _install(tarball, install_args=()): # extracting the tarball tmpdir = tempfile.mkdtemp() log.warn('Extracting in %s', tmpdir) old_wd = os.getcwd() try: os.chdir(tmpdir) tar = tarfile.open(tarball) _extractall(tar) tar.close() # going in the directory subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) os.chdir(subdir) log.warn('Now working in %s', subdir) # installing log.warn('Installing Setuptools') if not _python_cmd('setup.py', 'install', *install_args): log.warn('Something went wrong during the installation.') log.warn('See the error message above.') # exitcode will be 2 return 2 finally: os.chdir(old_wd) shutil.rmtree(tmpdir) def _build_egg(egg, tarball, to_dir): # extracting the tarball tmpdir = tempfile.mkdtemp() log.warn('Extracting in %s', tmpdir) old_wd = os.getcwd() try: os.chdir(tmpdir) tar = tarfile.open(tarball) _extractall(tar) tar.close() # going in the directory subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) os.chdir(subdir) log.warn('Now working in %s', subdir) # building an egg log.warn('Building a Setuptools egg in %s', to_dir) _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir) finally: os.chdir(old_wd) shutil.rmtree(tmpdir) # returning the result log.warn(egg) if not os.path.exists(egg): raise IOError('Could not build the egg.') def _do_download(version, download_base, to_dir, download_delay): egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg' % (version, sys.version_info[0], sys.version_info[1])) if not os.path.exists(egg): tarball = download_setuptools(version, download_base, to_dir, download_delay) _build_egg(egg, tarball, to_dir) sys.path.insert(0, egg) # Remove previously-imported pkg_resources if present (see # https://bitbucket.org/pypa/setuptools/pull-request/7/ for details). if 'pkg_resources' in sys.modules: del sys.modules['pkg_resources'] import setuptools setuptools.bootstrap_install_from = egg def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15): # making sure we use the absolute path to_dir = os.path.abspath(to_dir) was_imported = 'pkg_resources' in sys.modules or \ 'setuptools' in sys.modules try: import pkg_resources except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: pkg_resources.require("setuptools>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( "The required version of setuptools (>=%s) is not available,\n" "and can't be installed while this script is running. Please\n" "install a more recent version first, using\n" "'easy_install -U setuptools'." "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok return _do_download(version, download_base, to_dir, download_delay) except pkg_resources.DistributionNotFound: # NOQA return _do_download(version, download_base, to_dir, download_delay) def download_file_powershell(url, target): """ Download the file at url to target using Powershell (which will validate trust). Raise an exception if the command cannot complete. """ target = os.path.abspath(target) cmd = [ 'powershell', '-Command', "(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(), ] subprocess.check_call(cmd) def has_powershell(): if platform.system() != 'Windows': return False cmd = ['powershell', '-Command', 'echo test'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return True download_file_powershell.viable = has_powershell def download_file_curl(url, target): cmd = ['curl', url, '--silent', '--output', target] subprocess.check_call(cmd) def has_curl(): cmd = ['curl', '--version'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return True download_file_curl.viable = has_curl def download_file_wget(url, target): cmd = ['wget', url, '--quiet', '--output-document', target] subprocess.check_call(cmd) def has_wget(): cmd = ['wget', '--version'] devnull = open(os.path.devnull, 'wb') try: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except: return False finally: devnull.close() return False download_file_wget.viable = has_wget def download_file_insecure(url, target): """ Use Python to download the file, even though it cannot authenticate the connection. """ try: from urllib.request import urlopen except ImportError: from urllib2 import urlopen src = dst = None try: src = urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = src.read() dst = open(target, "wb") dst.write(data) finally: if src: src.close() if dst: dst.close() download_file_insecure.viable = lambda: True def get_best_downloader(): downloaders = [ download_file_powershell, download_file_curl, download_file_wget, download_file_insecure, ] for dl in downloaders: if dl.viable(): return dl def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. ``downloader_factory`` should be a function taking no arguments and returning a function for downloading a URL to a target. """ # making sure we use the absolute path to_dir = os.path.abspath(to_dir) tgz_name = "setuptools-%s.tar.gz" % version url = download_base + tgz_name saveto = os.path.join(to_dir, tgz_name) if not os.path.exists(saveto): # Avoid repeated downloads log.warn("Downloading %s", url) downloader = downloader_factory() downloader(url, saveto) return os.path.realpath(saveto) def _extractall(self, path=".", members=None): """Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by getmembers(). """ import copy import operator from tarfile import ExtractError directories = [] if members is None: members = self for tarinfo in members: if tarinfo.isdir(): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. if sys.version_info < (2, 4): def sorter(dir1, dir2): return cmp(dir1.name, dir2.name) directories.sort(sorter) directories.reverse() else: directories.sort(key=operator.attrgetter('name'), reverse=True) # Set correct owner, mtime and filemode on directories. for tarinfo in directories: dirpath = os.path.join(path, tarinfo.name) try: self.chown(tarinfo, dirpath) self.utime(tarinfo, dirpath) self.chmod(tarinfo, dirpath) except ExtractError: e = sys.exc_info()[1] if self.errorlevel > 1: raise else: self._dbg(1, "tarfile: %s" % e) def _build_install_args(options): """ Build the arguments to 'python setup.py install' on the setuptools package """ install_args = [] if options.user_install: if sys.version_info < (2, 6): log.warn("--user requires Python 2.6 or later") raise SystemExit(1) install_args.append('--user') return install_args def _parse_args(): """ Parse the command line for options """ parser = optparse.OptionParser() parser.add_option( '--user', dest='user_install', action='store_true', default=False, help='install in user site package (requires Python 2.6 or later)') parser.add_option( '--download-base', dest='download_base', metavar="URL", default=DEFAULT_URL, help='alternative URL from where to download the setuptools package') parser.add_option( '--insecure', dest='downloader_factory', action='store_const', const=lambda: download_file_insecure, default=get_best_downloader, help='Use internal, non-validating downloader' ) options, args = parser.parse_args() # positional arguments are ignored return options def main(version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" options = _parse_args() tarball = download_setuptools(download_base=options.download_base, downloader_factory=options.downloader_factory) return _install(tarball, _build_install_args(options)) if __name__ == '__main__': sys.exit(main()) weboob-1.1/contrib/windows-install/settings.cmd000066400000000000000000000005051265717027300217650ustar00rootroot00000000000000set WEBOOB_VERSION=1.0 set WEBOOB=weboob-1.0-py2.7.egg set LIST_APPLIQUATIONS_QT=qboobmsg qcineoob qcookboob qflatboob qhandjoob qhavedate qvideoob qwebcontentedit weboob-config-qt REM x32 | x64 set ARCHITECTURE=x64 set LOCAL_ARCHITECTURE=x64 REM version required for WEBOOB set PYTHON_VERSION=2.7 set PYTHON_MINOR_VERSION=6 weboob-1.1/contrib/windows-install/setup-weboob.bat000066400000000000000000000125321265717027300225460ustar00rootroot00000000000000@echo off setlocal enableextensions enabledelayedexpansion call settings.cmd echo. echo 0.Set proxy set/P HTTP_PROXY=Enter HTTP_PROXY if needed : set/P HTTPS_PROXY=Enter HTTPS_PROXY if needed : echo. echo 1.GNU/WGET Init set WGET=wget-%ARCHITECTURE%.exe echo. echo 2.Check Python Installation rem check first possible key set KEY_NAME=HKLM\Software\Python\PythonCore\2.7\InstallPath if %ARCHITECTURE% == x64 ( set KEY_NAME=HKLM\SOFTWARE\Python\PythonCore\2.7\InstallPath ) set IsPythonInstalled=0 REG QUERY !KEY_NAME! >NUL 2>NUL if %ERRORLEVEL% EQU 0 ( set IsPythonInstalled=1 ) else ( rem first key doesn't exist, test the second possible key set KEY_NAME=HKCU\Software\Python\PythonCore\2.7\InstallPath REG QUERY !KEY_NAME! >NUL 2>NUL if %ERRORLEVEL% EQU 0 ( set IsPythonInstalled=1 ) ) if %IsPythonInstalled% EQU 1 ( rem check installed python version for /F "tokens=4" %%A IN ('REG QUERY !KEY_NAME!') do ( set PythonPath=%%A ) !PythonPath!python.exe --version 2>&1 | find /i "!PYTHON_VERSION!" > tmp.txt if %ERRORLEVEL% EQU 1 ( set IsPythonInstalled=0 ) else ( FOR /F "eol=; tokens=3 delims=." %%i in (tmp.txt) do set minor_version=%%i if !minor_version! LSS !PYTHON_MINOR_VERSION! ( set IsPythonInstalled=0 ) ) del tmp.txt ) if %IsPythonInstalled% EQU 0 ( rem Python is not installed set PYTHON_MSI=python-!PYTHON_VERSION!.msi if %ARCHITECTURE% == x64 ( set PYTHON_MSI=python-!PYTHON_VERSION!.amd64.msi ) echo 2.1 Download !PYTHON_MSI! "%WGET%" -o python_donwload --no-check-certificate "http://www.python.org/ftp/python/!PYTHON_VERSION!/!PYTHON_MSI!" echo 2.2 Setup !PYTHON_MSI! !PYTHON_MSI! del !PYTHON_MSI! del python_donwload ) for /F "tokens=4" %%A IN ('REG QUERY !KEY_NAME!') do ( set PythonPath=%%A ) echo. echo 3.Check PyQt4 Installation set KEY_NAME=HKLM\Software\PyQt4\Py2.7\InstallPath REG QUERY %KEY_NAME% > nul || ( echo 3.1 Download PyQt4 "%WGET%" -o qt_download http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.3/PyQt4-4.11.3-gpl-Py2.7-Qt4.8.6-%ARCHITECTURE%.exe echo 3.2 Setup PyQt4 PyQt4-4.11.3-gpl-Py2.7-Qt4.8.6-%ARCHITECTURE%.exe del PyQt4-4.11.3-gpl-Py2.7-Qt4.8.6-%ARCHITECTURE%.exe del qt_download ) echo. echo 4.Check Gpg4win Installation set ShouldReboot=0 set KEY_NAME=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\GPG4Win REG QUERY %KEY_NAME% > nul || ( echo 4.1 Download Gpg4win "%WGET%" -o gpg4win_download http://files.gpg4win.org/gpg4win-2.2.2.exe echo 4.2 Setup Gpg4win gpg4win-2.2.2.exe set ShouldReboot=1 del gpg4win-2.2.2.exe del gpg4win_download ) echo. echo 5.Check EasyInstall if exist "%PythonPath%Scripts\easy_install.exe" ( goto :InstallWeboobDependances ) else ( echo 5.1 Setup setuptools %PythonPath%python.exe ez_setup.py || goto :InstallFailed del setuptools-1.1.6.tar.gz goto :InstallWeboobDependances ) :InstallWeboobDependances echo. echo 6.Install Weboob Dependances echo. echo -- cssselect %PythonPath%Scripts\easy_install.exe cssselect || goto :InstallFailed echo. echo -- lxml %PythonPath%Scripts\easy_install.exe lxml==3.2.5 || goto :InstallFailed echo. echo -- dateutils %PythonPath%Scripts\easy_install.exe dateutils || goto :InstallFailed echo. echo -- pyyaml %PythonPath%Scripts\easy_install.exe pyyaml || goto :InstallFailed echo. echo -- html2text %PythonPath%Scripts\easy_install.exe html2text || goto :InstallFailed echo. echo -- mechanize %PythonPath%Scripts\easy_install.exe mechanize || goto :InstallFailed echo. echo -- gdata %PythonPath%Scripts\easy_install.exe gdata || goto :InstallFailed echo. echo -- feedparser %PythonPath%Scripts\easy_install.exe feedparser || goto :InstallFailed echo. echo -- pillow %PythonPath%Scripts\easy_install.exe pillow==2.3.0 || goto :InstallFailed echo. echo -- requests %PythonPath%Scripts\easy_install.exe requests==2.3.0 || goto :InstallFailed echo. echo 6.Install WeBoob %PythonPath%Scripts\easy_install.exe %WEBOOB% || goto :InstallFailed set StartupFolder=%AppData%\Microsoft\Windows\Start Menu\Programs if exist "%StartupFolder%" Goto :FoundStartup set StartupFolder=%UserProfile%\Start Menu\Programs if exist "%StartupFolder%" Goto :FoundStartup echo Cannot find Startup folder. echo do not create launchers goto :InstallSucceed :FoundStartup if exist "%StartupFolder%\Weboob" ( goto :CreateLauncher ) else ( md "%StartupFolder%\Weboob" goto :CreateLauncher ) :CreateLauncher for %%i in (%LIST_APPLIQUATIONS_QT%) do ( echo Process %%i ( echo @echo off echo start %PythonPath%pythonw.exe %PythonPath%Scripts\%%i ) > %%i.bat %PythonPath%python.exe convertPNG2ICO.py "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.png" > nul if exist "%StartupFolder%\Weboob\%%i.exe" ( del "%StartupFolder%\Weboob\%%i.exe" ) "Bat_To_Exe_Converter_%ARCHITECTURE%.exe" -bat "%%i.bat" -save "%StartupFolder%\Weboob\%%i.exe" -icon "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.ico" "%%i" del "%%i.bat" del "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.ico" ) goto :InstallSucceed :InstallSucceed echo. echo INSTALLATION PROCESS SUCCEED if %ShouldReboot% EQU 1 ( echo. echo YOU SHOULD REBOOT BEFORE USING WEBOOB ) goto :Quit :InstallFailed echo. echo INSTALLATION PROCESS FAILED goto :Quit :Quit del "%WEBOOB%" del ez_setup.py del convertPNG2ICO.py del settings.cmd pause weboob-1.1/desktop/000077500000000000000000000000001265717027300143135ustar00rootroot00000000000000weboob-1.1/desktop/masstransit.desktop000066400000000000000000000003711265717027300202570ustar00rootroot00000000000000[Desktop Entry] Name=Masstransit Comment=Search for train stations and departure times Exec=masstransit Icon=masstransit Terminal=false Type=Application StartupNotify=true Categories=Network;GTK; Keywords=departures;train;stations;timetable;travel; weboob-1.1/desktop/qboobmsg.desktop000066400000000000000000000003331265717027300175160ustar00rootroot00000000000000[Desktop Entry] Name=QBoobmsg Comment=Send and receive messages from various websites Exec=qboobmsg Icon=qboobmsg Terminal=false Type=Application StartupNotify=true Categories=Network;Qt; Keywords=messaging;chat;forum; weboob-1.1/desktop/qcineoob.desktop000066400000000000000000000004361265717027300175100ustar00rootroot00000000000000[Desktop Entry] Name=QCineoob Comment=Search for movies, persons, torrents and subtitles on many websites, and get info about them Exec=qcineoob Icon=qcineoob Terminal=false Type=Application StartupNotify=true Categories=Network;Qt; Keywords=video;movie;cinema;subtitles;torrent;media; weboob-1.1/desktop/qcookboob.desktop000066400000000000000000000003551265717027300176670ustar00rootroot00000000000000[Desktop Entry] Name=QCookboob Comment=Search for recipes on many websites, and get info about them Exec=qcookboob Icon=qcookboob Terminal=false Type=Application StartupNotify=true Categories=Network;Qt; Keywords=recipes;eating;cooking; weboob-1.1/desktop/qflatboob.desktop000066400000000000000000000003071265717027300176570ustar00rootroot00000000000000[Desktop Entry] Name=QFlatBoob Comment=Search housings Exec=qflatboob Icon=qflatboob Terminal=false Type=Application StartupNotify=true Categories=Network;Qt; Keywords=housing;flat;apartment;rental; weboob-1.1/desktop/qhandjoob.desktop000066400000000000000000000002741265717027300176560ustar00rootroot00000000000000[Desktop Entry] Name=QHandJoob Comment=Search for jobs Exec=qhandjoob Icon=qhandjoob Terminal=false Type=Application StartupNotify=true Categories=Network;Qt; Keywords=job;offers;working; weboob-1.1/desktop/qhavedate.desktop000066400000000000000000000004101265717027300176430ustar00rootroot00000000000000[Desktop Entry] Name=QHaveDate Comment=Optimize your probabilities to have sex on dating websites Exec=qhavedate Icon=qhavedate Terminal=false Type=Application StartupNotify=true Categories=Network;Chat;ContactManagement;Qt; Keywords=dating;sex;girls;boys;tinder; weboob-1.1/desktop/qvideoob.desktop000066400000000000000000000003611265717027300175160ustar00rootroot00000000000000[Desktop Entry] Name=QVideoob Comment=Search for videos on many websites, and get info about them Exec=qvideoob Icon=qvideoob Terminal=false Type=Application StartupNotify=true Categories=AudioVideo;Qt; Keywords=movies;video;youtube;player; weboob-1.1/desktop/qwebcontentedit.desktop000066400000000000000000000003251265717027300211050ustar00rootroot00000000000000[Desktop Entry] Name=QWebContentEdit Comment=Edit website contents Exec=qwebcontentedit Icon=qwebcontentedit Terminal=false Type=Application StartupNotify=true Categories=Network;Qt; Keywords=wikipedia;wiki;edit; weboob-1.1/desktop/weboob-config-qt.desktop000066400000000000000000000003521265717027300210500ustar00rootroot00000000000000[Desktop Entry] Name=Weboob backends configuration Comment=Configure Weboob backends Exec=weboob-config-qt Icon=weboob-config-qt Terminal=false Type=Application StartupNotify=true Categories=Utility;Qt; Keywords=configuration;weboob; weboob-1.1/docs/000077500000000000000000000000001265717027300135725ustar00rootroot00000000000000weboob-1.1/docs/Makefile000066400000000000000000000060721265717027300152370ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Weboob.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Weboob.qhc" latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." weboob-1.1/docs/make.bat000066400000000000000000000060031265717027300151760ustar00rootroot00000000000000@ECHO OFF REM Command file for Sphinx documentation set SPHINXBUILD=sphinx-build set BUILDDIR=build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Weboob.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Weboob.ghc goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end weboob-1.1/docs/source/000077500000000000000000000000001265717027300150725ustar00rootroot00000000000000weboob-1.1/docs/source/_static/000077500000000000000000000000001265717027300165205ustar00rootroot00000000000000weboob-1.1/docs/source/_static/architecture.png000066400000000000000000002700731265717027300217210ustar00rootroot00000000000000PNG  IHDRݗXsRGBbKGDC pHYs B(xtIME 'UtEXtCommentCreated with GIMPW IDATxyս7zYw1(q"F*H/(kzEܒhDn4ƛMb47QDw{(`T *n( 3{/UmUw(33uϩ.xs,ԄcbjI +J&L`0}i̞=4o8cƌ1Ӂ>@#]u| "kƏK@DDDwjjjN7 V˲NPe҇|ljT[3H1aYjU= 缚 DDDDB4 `FUY˲^˲z@)r>?Ow\la, )^m^"""*Ti"rt&f9+Jݴi\صk!;w|0H<uuuuK,QVV֭|+"dʋȥ5 Z/Dѩp}^^"""6FDl?~ZCCHUpϦ1heegp뭷ʉ'˔IC]]M^z+KDDD!b e! [5=HĉߊRkU7=v7eY=/*"?2 ѺxϲF"n0SglP(,YgwjPU+6r36t @ӿKz[K׉Up8Q[[=J-P;2t挹w{Ϯ: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^yeY֩ѣGn"˲R#] Dii)2>pX)u̶pm۩t:}\mSVVFEEEBxm#887zcXvɒ%PM4!D@Lj׿UJ)"r1""={϶}glr-z34M0 DRjI2ntBADd !RQ vZcqnV1|߯ANGMR` àD"۽;w^7oAiRJ)]Q4 uww;t萷k.U1VViavxIENDB`weboob-1.1/docs/source/_static/favicon.ico000066400000000000000000000263311265717027300206460ustar00rootroot00000000000000PNG  IHDRPQEM!sRGBbKGD pHYs B(xtIME :]htEXtCommentCreated with GIMPW IDATxُeə"~{V־f7Cq`FֱlX"d Y3a136v3r_nlលy+{[ PB8//|#~:AЂaAF//>`c0$4x/3Al@VQ|`ArW(V\um!dìTf0:)D k/$s)V}|$!#쩙Ejz/Kp% `aF&_†،tBs<l uY(s[oMS':6meۓ-1Jk{`w3544~g r_\V\חsRCc`R~Xɥqd@:ўVI [Fx5j>mȹ+Xӓ ~.({dIA2 D`&X b (Z_ k)g/W^{_l۝?/O C!Z;w vy`N㝷5P1jio'߾D(-3g|c!f-iwu}mIT%`c&1$Aѭ#|_~Oڵdp J.^|)t\W2&yP͍Uy{yf޼&}YGGo?'P71XedUBȇs6m=7mN%@Q>>xCGZdgrο0i[NyiBz%-b0lٰ!4(+8i`'@$*Fzs zQR).-\*TU"/kx5i $wst(+^J$Qs\ǧ|fIOxZL&m)]hvvO7 (UY&(i4B̛+} غt,ǧ3ӧ|H]NҖeg% - Q-$e@J&a^麮GWT㝽_K/]y9x^ƴNh?G5SMD;1ZiE^;?9 es窶W8b? 4\8rzIXDPD'viRX7^:I^q.OL~}R=DscG4n\鿬jNڅwjZͱr6O-\x" DBXvI,|A7Y7'\ZP(՗/S gx'n~\۬[< !\ldb,A!9ߒ*M(~/j%ؼ&.~^yΜU :6 =}%@2:l\YBJE$-FCP_kON,x@ 9u7`N`'JBEjJc+ Vj@a@@= nxm!>l?.NN·TW_I_* O,潕wח`u>6U~>!NncT,11^ߺw>6{(5 !jI^a+S>K]xeZXV'/\x! ;8NQ)7d~7ǵMYQ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  "dW舵BfuDp>ܷ|D[]Abz IxU(#}ӭGs]ꥎIW}Z,/@n2{,! 2hl0ܟBCc8ĤMo,|'B=l"A&TKilӜλTŐRBŋxq 8&)E2ffc#sýS Ҝ+M1_Ep *  4|9kBD*3s,IZ9W"""8&*+Q ! XD~ ) J@!S W]UDs:TUUHW7Ĝ6˶ d>%Ɯob?]ECnk(#jbuG.g5+1 cLTlJt$3sTUWO@TTCB"X_DӋ9M2$!1f3ݮR{!):PPsWgO2@$ c:<XiJC,(C?r< @& Ǩ0cΌ1UbW[ez^jfH b :Jr)? :y@IENDB`weboob-1.1/docs/source/_templates/000077500000000000000000000000001265717027300172275ustar00rootroot00000000000000weboob-1.1/docs/source/_templates/indexcontent.html000066400000000000000000000127261265717027300226270ustar00rootroot00000000000000{% extends "defindex.html" %} {% block tables %}

Note

This is the developer documentation. If you are not a developer and you are looking for information about the project, check the official website.

Hello world:

>>> from weboob.core import Weboob
>>> from weboob.capabilities.bank import CapBank
>>> w = Weboob()
>>> w.load_backends(CapBank)
{'societegenerale': <Backend 'societegenerale'>, 'creditmutuel': <Backend 'creditmutuel'>}
>>> pprint(list(w.iter_accounts()))
[<Account id='7418529638527412' label=u'Compte de ch\xe8ques'>,
 <Account id='9876543216549871' label=u'Livret A'>,
 <Account id='123456789123456789123EUR' label=u'C/C Eurocompte Confort M Roger Philibert'>]
>>> acc = next(iter(w.iter_accounts()))
>>> acc.balance
Decimal('87.32')

Concepts:

Guides:

Indices and tables:

{% endblock %} weboob-1.1/docs/source/_templates/indexsidebar.html000066400000000000000000000005261265717027300225610ustar00rootroot00000000000000

Other resources

weboob-1.1/docs/source/conf.py000066400000000000000000000146611265717027300164010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Weboob documentation build configuration file, created by # sphinx-quickstart on Thu Nov 25 11:56:52 2010. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import os import time os.system('./genapi.py') # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.coverage'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8' # The master toctree document. #master_doc = 'index' # General information about the project. project = u'Weboob' copyright = '2010-%s, The Weboob Team' % time.strftime('%Y') # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '1.1' # The full version, including alpha/beta/rc tags. release = '1.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directory, that shouldn't be searched # for source files. exclude_trees = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {'collapsiblesidebar': True} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = 'Weboob development' # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. html_logo = '_static/logo.png' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. html_favicon = 'favicon.ico' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. html_use_smartypants = True # Custom sidebar templates, maps document names to template names. html_sidebars = { 'index': 'indexsidebar.html' } # Additional templates that should be rendered to pages, maps page names to # template names. html_additional_pages = { 'index': 'indexcontent.html' } # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. html_split_index = False # If true, links to the reST sources are added to the pages. html_show_sourcelink = False # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'weboob' + release.replace('.', '') # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'Weboob.tex', u'Weboob Documentation', u'Weboob Team', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True weboob-1.1/docs/source/contents.rst000066400000000000000000000002131265717027300174550ustar00rootroot00000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Weboob Documentation contents %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. toctree:: guides/index api/index weboob-1.1/docs/source/genapi.py000077500000000000000000000026461265717027300167220ustar00rootroot00000000000000#!/usr/bin/env python import os def genapi(): os.system('rm -rf api') os.system('mkdir api') os.chdir('api') for root, dirs, files in os.walk('../../../weboob/'): root = root.split('/', 4)[-1] if root.startswith('applications'): continue if root.strip(): os.system('mkdir -p %s' % root) module = '.'.join(['weboob'] + root.split('/')) else: module = 'weboob' subs = set() for f in files: if '.' not in f: continue f, ext = f.rsplit('.', 1) if ext != 'py' or f == '__init__': continue subs.add(f) with open(os.path.join(root, '%s.rst' % f), 'w') as fp: fmod = '.'.join([module, f]) fp.write(""":mod:`%(module)s` ======%(equals)s= .. automodule:: %(module)s :show-inheritance: :members: :undoc-members:""" % {'module': fmod, 'equals': '=' * len(fmod)}) for d in dirs: subs.add('%s/index' % d) with open(os.path.join(root, 'index.rst'), 'w') as fp: if module == 'weboob': m = 'API' else: m = ':mod:`%s`' % module fp.write("""%s %s Contents: .. toctree:: :maxdepth: 3 %s""" % (m, '=' * len(m), '\n '.join(sorted(subs)))) if __name__ == '__main__': genapi() weboob-1.1/docs/source/guides/000077500000000000000000000000001265717027300163525ustar00rootroot00000000000000weboob-1.1/docs/source/guides/application.rst000066400000000000000000000000601265717027300214030ustar00rootroot00000000000000Application development ======================= weboob-1.1/docs/source/guides/capability.rst000066400000000000000000000026751265717027300212370ustar00rootroot00000000000000Create a capability =================== A method can raise only its own exceptions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When you want to return an error, you **must** raise only your own exceptions defined in the capability module. Never let Python raise his exceptions, for example ``KeyError`` if a parameter given to method isn't found in a local list. Prefer returning objects ^^^^^^^^^^^^^^^^^^^^^^^^ Python is an object-oriented language, so when your capability supports entities (for example :class:`weboob.capabilities.video.BaseVideo` with the :class:`weboob.capabilities.video.CapVideo` capability), you have to create a class derived from :class:`weboob.capabilities.base.BaseObject`, and create an unique method to get it (for example :func:`get_video() `), instead of several methods like ``get_video_url()``, ``get_video_preview()``, etc. An object has an unique ID. Filled objects ^^^^^^^^^^^^^^ When an object is fetched, all of its fields are not necessarily loaded. For example, on a video search, if the *backend* gets information from the search page, the direct URL of the video isn't available yet. A field which isn't loaded can be set to :class:`weboob.capabilities.base.NotLoaded`. By default, in the object constructor, every fields should be set to :class:`NotLoaded `, and when the backend loads them, it replaces them with the new values. weboob-1.1/docs/source/guides/contribute.rst000066400000000000000000000062301265717027300212630ustar00rootroot00000000000000How to contribute ================= By coding ********* Write a patch ------------- Help yourself with the `documentation `_. Find an opened issue on this website, or write you own bugfix or feature. Then, once it is necessary, commit with:: $ git commit -a Do not forget to write a helpful commit message. Check your patch ---------------- You can run these scripts to be sure your patch doesn't break anything:: $ tools/pyflakes.sh $ tools/run_tests.sh yourmodulename # or without yourmodulename to test everything Perhaps you should also write or fix tests. Send a patch ------------ :: $ git format-patch -n -s origin Then, send them with this command:: $ git send-email --to=weboob@weboob.org *.patch You can also send the files by yourself if you haven't any configured MTA on your system. Ask for a public repository on git.symlink.me --------------------------------------------- If you think you'll contribute to Weboob regularly, you can ask for a public repository. You'll also be able to push your commits in, and they'll be merged into the main repository easily. All git branch are listed here: http://git.symlink.me/ By hosting a buildbot slave *************************** To be sure weboob works fine on lot of architectures, OS and configurations, but also that websites haven't changed and backends still support them, it's important to have enough buildbot slaves. If you are interested by hosting a buildbot slave, follow these instructions: Create a slave -------------- Firstly, you have to install ``pyflakes``, ``nose`` and `buildbot `_. Run:: $ buildslave create-slave buildbot.weboob.org:9080 .. note:: if you use an old version of buildbot, run ``buildbot`` instead of ``buildslave``. Parameters are: * **dirname** — the path where you want to setup your slave on your host. * **name** — the name of your slave. It would be for example your name, your nickname, your hostname. Check on http://buildbot.weboob.org the name you want to use isn't already taken. * **password** — choose a password to login on the master. For example:: $ buildslave create-slave /home/me/buildbot buildbot.weboob.org:9080 me secret123 Then, edit files in ``/home/me/buildbot/info/`` and run the slave:: $ buildslave start /home/me/buildbot Contact us ---------- To connect your slave to our master, you can send us an email on admin@weboob.org with the following information: * The name of your slave; * The IP address of the host; * The password of your slave; * Indicate if you want to run tests for every merges (three times a day) or only do a nightly build. When your slave will be accepted, you will see it on http://buildbot.weboob.org/waterfall. How it works ------------ When a build is requested by master, your slave updates its local git repository, and run ``tools/run_tests.sh``. To work correctly, we suggest you to add as many as possible backends with the user of the slave. No private information will be sent to master, and it's better to have tests on backends which need authentication, because not every developers have accounts on them. weboob-1.1/docs/source/guides/index.rst000066400000000000000000000001771265717027300202200ustar00rootroot00000000000000Guides ====== Contents: .. toctree:: :maxdepth: 2 setup contribute module capability application tests weboob-1.1/docs/source/guides/module.rst000066400000000000000000000465621265717027300204060ustar00rootroot00000000000000Write a new module ================== This guide aims to learn how to write a new module for `Weboob `_. Before read it, you should :doc:`setup your development environment `. What is a module **************** A module is an interface between a website and Weboob. It represents the python code which is stored in repositories. Weboob applications need *backends* to interact with websites. A *backend* is an instance of a *module*, usually with several parameters like your username, password, or other options. You can create multiple *backends* for a single *module*. Select capabilities ******************* Each module implements one or many :doc:`capabilities ` to tell what kind of features the website provides. A capability is a class derived from :class:`weboob.capabilities.base.Capability` and with some abstract methods (which raise ``NotImplementedError``). A capability needs to be as generic as possible to allow a maximum number of modules to implement it. Anyway, if you really need to handle website specificities, you can create more specific sub-capabilities. For example, there is the :class:`CapMessages ` capability, with the associated :class:`CapMessagesPost ` capability to allow answers to messages. Pick an existing capability --------------------------- When you want to create a new module, you may have a look on existing capabilities to decide which one can be implemented. It is quite important, because each already existing capability is supported by at least one application. So if your new module implements an existing capability, it will be usable from the existing applications right now. Create a new capability ----------------------- If the website you want to manage implements some extra-features which are not implemented by any capability, you can introduce a new capability. You should read the related guide to know :doc:`how to create a capability `. The module tree *************** Create a new directory in ``modules/`` with the name of your module. In this example, we assume that we want to create a module for a bank website which URL is http://www.example.com. So we will call our module **example**, and the selected capability is :class:`CapBank `. It is recommended to use the helper tool ``tools/boilerplate.py`` to build your module tree. There are several templates available: * **base** - create only base files * **comic** - create a comic module * **cap** - create a module for a given capability For example, use this command:: $ tools/boilerplate.py cap example CapBank In a module directory, there are commonly these files: * **__init__.py** - needed in every python modules, it exports your :class:`Module ` class. * **module.py** - defines the main class of your module, which derives :class:`Module `. * **browser.py** - your browser, derived from :class:`Browser `, is called by your module to interact with the supported website. * **pages.py** - all website's pages handled by the browser are defined here * **test.py** - functional tests * **favicon.png** - a 64x64 transparent PNG icon Update modules list ------------------- As you are in development mode, to see your new module in ``weboob-config``'s list, you have to update ``modules/modules.list`` with this command:: $ weboob-config update To be sure your module is correctly added, use this command:: $ weboob-config info example .------------------------------------------------------------------------------. | Module example | +-----------------.------------------------------------------------------------' | Version | 201405191420 | Maintainer | John Smith | License | AGPLv3+ | Description | Example bank website | Capabilities | CapBank, CapCollection | Installed | yes | Location | /home/me/src/weboob/modules/example '-----------------' If the last command does not work, check your :doc:`repositories setup `. Module class ************* Edit ``module.py``. It contains the main class of the module derived from :class:`Module ` class:: class ExampleModule(Module, CapBank): NAME = 'example' # The name of module DESCRIPTION = u'Example bank website' # Description of your module MAINTAINER = u'John Smith' # Name of maintainer of this module EMAIL = 'john.smith@example.com' # Email address of the maintainer LICENSE = 'AGPLv3+' # License of your module VERSION = '0.i' # Version of weboob In the code above, you can see that your ``ExampleModule`` inherits :class:`CapBank `, as we have selected it for the supported website. Configuration ------------- When a module is instanced as a backend, you probably want to ask parameters to user. It is managed by the ``CONFIG`` class attribute. It supports key/values with default values and some other parameters. The :class:`Value ` class is used to define a value. Available parameters of :class:`Value ` are: * **label** - human readable description of a value * **required** - if ``True``, the backend can't loaded if the key isn't found in its configuration * **default** - an optional default value, used when the key is not in config. If there is no default value and the key is not found in configuration, the **required** parameter is implicitly set * **masked** - if ``True``, the value is masked. It is useful for applications to know if this key is a password * **regexp** - if specified, on load the specified value is checked against this regexp, and an error is raised if it doesn't match * **choices** - if this parameter is set, the value must be in the list .. note:: There is a special class, :class:`ValueBackendPassword `, which is used to manage private parameters of the config (like passwords or sensible information). For example:: from weboob.tools.value import Value, ValueBool, ValueInt, ValueBackendPassword from weboob.tools.backend import BackendConfig # ... class ExampleModule(Module, CapBank): # ... CONFIG = BackendConfig(Value('username', label='Username', regexp='.+'), ValueBackendPassword('password', label='Password'), ValueBool('get_news', label='Get newspapers', default=True), Value('choice', label='Choices', choices={'value1': 'Label 1', 'value2': 'Label 2'}, default='1'), Value('regexp', label='Birthday', regexp='^\d+/\d+/\d+$'), ValueInt('integer', label='A number', required=True)) Implement capabilities ---------------------- You need to implement each method of all of the capabilities your module implements. For example, in our case:: # ... class ExampleModule(Module, CapBank): # ... def iter_accounts(self): raise NotImplementedError() def get_account(self, id): raise NotImplementedError() def iter_history(self, account): raise NotImplementedError() def iter_coming(self, account): raise NotImplementedError() If you ran the ``boilerplate`` script command ``cap``, every methods are already in ``module.py`` and documented. Read :class:`documentation of the capability ` to know what are types of arguments, what are expected returned objects, and what exceptions it may raises. Browser ******* Most of modules use a class derived from :class:`PagesBrowser ` or :class:`LoginBrowser ` (for authenticated websites) to interact with a website. Edit ``browser.py``:: # -*- coding: utf-8 -*- from weboob.browser import PagesBrowser __all__ = ['ExampleBrowser'] class ExampleBrowser(PagesBrowser): BASEURL = 'https://www.example.com' There are several possible class attributes: * **BASEURL** - base url of website used for absolute paths given to :class:`open() ` or :class:`location() ` * **PROFILE** - defines the behavior of your browser against the website. By default this is Firefox, but you can import other profiles * **TIMEOUT** - defines the timeout for requests (defaults to 10 seconds) * **VERIFY** - SSL verification (if the protocol used is **https**) Pages ----- For each page you want to handle, you have to create an associated class derived from one of these classes: * :class:`HTMLPage ` - a HTML page * :class:`XMLPage ` - a XML document * :class:`JsonPage ` - a Json object * :class:`CsvPage ` - a CSV table In the file ``pages.py``, you can write, for example:: # -*- coding: utf-8 -*- from weboob.browser.pages import HTMLPage __all__ = ['IndexPage', 'ListPage'] class IndexPage(HTMLPage): pass class ListPage(HTMLPage): def iter_accounts(): return iter([]) ``IndexPage`` is the class we will use to get information from the home page of the website, and ``ListPage`` will handle pages which list accounts. Then, you have to declare them in your browser, with the :class:`URL ` object:: from weboob.browser import PagesBrowser, URL from .pages import IndexPage, ListPage # ... class ExampleBrowser(PagesBrowser): # ... home = URL('/$', IndexPage) accounts = URL('/accounts$', ListPage) Easy, isn't it? The first parameters are regexps of the urls (if you give only a path, it uses the ``BASEURL`` class attribute), and the last one is the class used to handle the response. Each time you will go on the home page, ``IndexPage`` will be instanced and set as the ``page`` attribute. For example, we can now implement some methods in ``ExampleBrowser``:: class ExampleBrowser(PagesBrowserr): # ... def go_home(self): self.home.go() assert self.home.is_here() def iter_accounts_list(self): self.accounts.stay_or_go() return self.page.iter_accounts() When calling the :func:`go() ` method, it reads the first regexp url of our :class:`URL ` object, and go on the page. :func:`stay_or_go() ` is used when you want to relocate on the page only if we aren't already on it. Once we are on the ``ListPage``, we can call every methods of the ``page`` object. Use it in backend ----------------- Now you have a functional browser, you can use it in your class ``ExampleModule`` by defining it with the ``BROWSER`` attribute:: from .browser import ExampleBrowser # ... class ExampleModule(Module, CapBank): # ... BROWSER = ExampleBrowser You can now access it with member ``browser``. The class is instanced at the first call to this attribute. For example, we can now implement :func:`CapBank.iter_accounts `:: class ExampleModule(Module, CapBank): # ... def create_default_browser(self): return self.create_browser(self.config['username'].get(), self.config['password'].get()) On the browser side, you need to inherit from :func:`LoginBrowser ` and to implement the function :func:`do_login `:: class ExampleBrowser(LoginBrowser): login = URL('/login', LoginPage) # ... def do_login(self): self.login.stay_or_go() self.page.login(self.username, self.password) if self.login_error.is_here(): raise BrowserIncorrectPassword(self.page.get_error()) Also, your ``LoginPage`` may look like:: class LoginPage(HTMLPage): def login(self, username, password): form = self.get_form(name='auth') form['username'] = username form['password'] = password form.submit() Then, each method on your browser which need your user to be authenticated may be decorated by :func:`need_login `:: class ExampleBrowser(LoginBrowser): accounts = URL('/accounts$', ListPage) @need_login def iter_accounts(self): self.accounts.stay_or_go() return self.page.get_accounts() The last thing to know is that :func:`need_login ` checks if the current page is a logged one by reading the attribute :func:`logged ` of the instance. You can either define it yourself, as a class boolean attribute or as a property, or to inherit your class from :class:`LoggedPage `. Parsing of pages **************** .. note:: Depending of the base class you use for your page, it will parse html, json, csv, etc. In our case, it will be only html documents. When your browser locates on a page, an instance of the class related to the :class:`URL ` attribute which matches the url is created. You can declare methods on your class to allow your browser to interact with it. The first thing to know is that page parsing is done in a descriptive way. You don't have to loop on HTML elements to construct the object. Just describe how to get correct data to construct it. It is the Browser class work to actually construct the object. For example:: from weboob.browser.filters.html import Attr from weboob.browser.filters.standard import CleanDecimal, CleanText from weboob.capabilities.bank import Account class ListPage(LoggedPage, HTMLPage): @method class get_accounts(ListElement): item_xpath = '//ul[@id="list"]/li' class item(ItemElement): klass = Account() obj_id = Attr('id') obj_label = CleanText('./td[@class="name"]') obj_balance = CleanDecimal('./td[@class="balance"]') As you see, we first set ``item_xpath`` which is the xpath string used to iterate over elements to access data. In a second time we define ``klass`` which is the real class of our object. And then we describe how to fill each object's attribute using what we call filters. Some example of filters: * :class:`Attr `: extract a tag attribute * :class:`CleanText `: get a cleaned text from an element * :class:`CleanDecimal `: get a cleaned Decimal value from an element * :class:`Date `: read common date formats * :class:`Link `: get the link uri of an element * :class:`Regexp `: apply a regex * :class:`Time `: read common time formats * :class:`Type `: get a cleaned value of any type from an element text Filters can be combined. For example:: obj_id = Link('./a[1]') & Regexp(r'id=(\d+)') & Type(type=int) This code do several things, in order: #) extract the href attribute of our item first ``a`` tag child #) apply a regex to extract a value #) convert this value to int type .. note:: All objects ID must be unique, and useful to get more information later Your module is now functional and you can use this command:: $ boobank -b example list Tests ***** Every modules must have a tests suite to detect when there are changes on websites, or when a commit breaks the behavior of the module. Edit ``test.py`` and write, for example:: # -*- coding: utf-8 -*- from weboob.tools.test import BackendTest __all__ = ['ExampleTest'] class ExampleTest(BackendTest): MODULE = 'example' def test_iter_accounts(self): accounts = list(self.backend.iter_accounts()) self.assertTrue(len(accounts) > 0) To try running test of your module, launch:: $ tools/run_tests.sh example For more information, look at the :doc:`tests` guides. Advanced topics *************** Filling objects --------------- An object returned by a method of a capability can be not fully completed. The class :class:`Module ` provides a method named :func:`fillobj `, which can be called by an application to fill some unloaded fields of a specific object, for example with:: backend.fillobj(video, ['url', 'author']) The ``fillobj`` method will check on the object what fields, in the ones given in list, which are not loaded (equal to ``NotLoaded``, which is the default value), to reduce the list to the real uncompleted fields, and call the method associated to the type of the object. To define what objects are supported to be filled, and what method to call, define the ``OBJECTS`` class attribute in your ``ExampleModule``:: class ExampleModule(Module, CapVideo): # ... OBJECTS = {Video: fill_video} The prototype of the function might be:: func(self, obj, fields) Then, the function might, for each requested fields, fetch the right data and fill the object. For example:: class ExampleModule(Module, CapVideo): # ... def fill_video(self, video, fields): if 'url' in fields: return self.backend.get_video(video.id) return video Here, when the application has got a :class:`Video ` object with :func:`search_videos `, in most cases, there are only some meta-data, but not the direct link to the video media. As our method :func:`get_video ` will get all of the missing data, we just call it with the object as parameter to complete it. Storage ------- The application can provide a storage to let your backend store data. So, you can define the structure of your storage space:: STORAGE = {'seen': {}} To store and read data in your storage space, use the ``storage`` attribute of your :class:`Module ` object. It implements the methods of :class:`BackendStorage `. weboob-1.1/docs/source/guides/setup.rst000066400000000000000000000033161265717027300202470ustar00rootroot00000000000000Setup your development environment ================================== To develop on Weboob, you have to setup a development environment. Git installation ---------------- Clone a git repository with this command:: $ git clone git://git.symlink.me/pub/weboob/devel.git We don't want to install Weboob on the whole system, so we create local directories where we will put symbolic links to sources:: $ mkdir ~/bin/ $ export PATH=$PATH:$HOME/bin/ $ mkdir ~/python/ $ export PYTHONPATH=$PYTHONPATH:$HOME/python/ All executables in ~/bin/ will be accessible in console, and all python modules in ~/python/ will be loadable. Add symbolic links:: $ ln -s $HOME/src/weboob/weboob ~/python/ $ find $HOME/src/weboob/scripts -type f -exec ln -s \{\} ~/bin/ \; Repositories setup ------------------ As you may know, Weboob installs modules from `remote repositories `_. As you probably want to use modules in sources instead of stable ones, because you will change them, or create a new one, you have to add this line at end of ``~/.config/weboob/sources.list``:: file:///home/me/src/weboob/modules Then, run this command:: $ weboob-config update Run Weboob without installation ------------------------------- This does not actually install anything, but lets you run Weboob from the source code, while also using the modules from that source:: $ ./tools/local_run.sh APPLICATION COMMANDS For example, instead of running `videoob -b youtube search plop`, you would run:: $ ./tools/local_run.sh videoob -b youtube search plop Conclusion ---------- You can now edit sources, :doc:`create a module ` or :doc:`an application `. weboob-1.1/docs/source/guides/tests.rst000066400000000000000000000042361265717027300202530ustar00rootroot00000000000000Automated tests =============== Summary ******* Weboob is a wide project which has several backends and applications, and changes can impact a lot of subsystems. To be sure that everything works fine after an important change, it's necessary to have automated tests on each subsystems. How it works ************ You need `nose `_ installed. To run the automated tests, use this script:: $ tools/run_tests.sh It looks for every files named ``test.py``, and find classes derivated from ``TestCase`` of ``BackendTest`` (in :class:`weboob.tools.test`). Then, it run every method which name starts with ``test_``. Write a test case ***************** Normal test ----------- Use the class :class:`TestCase ` to derivate it into your new test case. Then, write methods which name starts with ``test_``. A test fails when an assertion error is raised. Also, when an other kind of exception is raised, this is an error. You can use ``assert`` to check something, or the base methods ``assertTrue``, ``assertIf``, ``failUnless``, etc. Read the `unittest documentation `_ to know more. Backend test ------------ Create a class derivated from :class:`BackendTest `, and set the ``BACKEND`` class attribute to the name of the backend to test. Then, in your test methods, the ``backend`` attribute will contain the loaded backend. When the class is instancied, it loads every configured backends of the right type, and randomly choose one. If no one is found, the tests are skipped. Example:: from weboob.tools.test import BackendTest class YoutubeTest(BackendTest): MODULE = 'youtube' def test_youtube(self): l = [v for v in self.backend.iter_search_results('lol')] self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) Note: ``BackendTest`` inherits ``TestCase``, so the checks work exactly the same, and you can use the same base methods. weboob-1.1/icons/000077500000000000000000000000001265717027300137555ustar00rootroot00000000000000weboob-1.1/icons/allomatch.png000066400000000000000000000043201265717027300164260ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDC pHYs  tIME*(atEXtCommentCreated with GIMPW+IDATxmlGsh$EĮ hrnɱT_!QCPJN BXhS‹p@s! DQus>l>ܸ]/ݻ5 ϝlDGw&Ӣ $`U;*|(l$$uUm=o^_.@ϲ 3Q"y;5".5Xݠaq9BqڀJxaIv 8!aT 5”M+ `6ubyO$, KU ȶ5 pYznHx\1}?>]Վ6a}(ircuUl"ўZ!B U 9lwpO8oX#@݅U^2yfرChll~Y ~hkkӳD"`Huuuɩm۶uVL;"`dSSSI=EQػwqX,mܸREs5>0)Ky[^Pk'`hhd (++.E {%` ˢlJHYPMdwࠛuuuJpiϓMY&] !(N\Te9g%E.Wm+.]t@ ]xў#(#7ϮjR Ø{S]v]r0@*߿cž2pȑ#L|Ga~Ba!3y4ӆabjjJ^qeqY!ZZZDee=Oͧ$E*drg92Cd%N" UWW'А!sssT*O;w.}A>pŖx[ " J93l ]$ q)QSS#hoohT 8 0D"`PAH$a"z)@-lW{#8p3d>SY @,#SQQA,X,V/#]}UILTdMt|;Ԯ7H" ϗ^~QUU~zrddd]=n9QS*W(Ї1 O!y 'YIENDB`weboob-1.1/icons/banquepopulaire.png000066400000000000000000000024201265717027300176550ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME .X1IDATx[}Hg~ƚCdkn-+hYJYt+6 v[Z(:6Ơ0velS em~Ykj/wleֻ&w{̓w!q =PLyė)OWB׶i)x|kmjW]|WvlPA5lP9ۈ"՝|m;Xy٠`݃c8oa$زA ~ m44~iBEs>Fṇ-m3snII*}, :hu]@pDžkЫBmo|2V.n&sdl0*+3AQC!46M4ՒMfٕ,4|%xQhK> ZO>DbcpL-&rlݜNú=BPxM-+W]vo&d=?hRB,qX- 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) rw|f6)Zvf\ lɵ7N^KHuI6 cdttS|DhRJ#v[muIY"XfK}/"":_Z3 G٦F}dadhL:HDY 昁ɩ3Gð(6L{^rb?0'z^n]p*8q쐧8"B@@(%u̽985kk_qzˎ p ^Lt +XkLܜ#@g&N6dߓ`Gbfm|EQN1[:}xx-_v^[@m!U6\&4u|v\3 LjHˍr`ff{)2NqGEx1}o=U|vEHmDqv\AZ˅Cz8ǖHЍc WѱTr媫oou^E 4Ӱ53_ V{iA&'OھsuO*?"!75sf]_Xص`JXF` wy/G?XY6֬YVu֒n-(ecr&ˮ\ܱ[ÃDTW]z^'3lL"2e-J&&R]"$YЩӇ]|*)􄐡2Rr;cg?[󄔝|W=׃FyՊqUE (|^Fk%!QFɴMS㿎~ /OP \|wNK5!JEg``+H `Y156f1Iv^Oo T SHse._&K,bq{o;l̯nlIENDB`weboob-1.1/icons/cineoob.png000066400000000000000000000213501265717027300161020ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs B(xtIME &8qtEXtCommentCreated with GIMPW IDATx͛idqYU~}wOϱsA%4((- .R AӦ-۴eY"pHLAmYx A'DZ `}tOw2a))Dy*3I۰+hP׈Jc \l>q4+QS đ8N,\n#`O^0K2fXnϕf-TQ\GQѤ<^7nv<eYE 6SWU @WL]TcӵFsk5֡RD@ <6KGhm)EQd. Ve˟^<  PbF=1_p#OcWDtZmFP8.L)%@']5 vjFݝfsr#埇8|rٔ+J"Q[GZcScZiOVg_lt(haP&M f}bH\ľߚa +~>tzzWLy;K>Ad{5J0""ΖeWQhwG':z,\}o4;͉9==skmR "d HD@i׶ O͋K״Z$7#2|#ƆIg6ZnO!"hbO-.HSlos~뾿LpgySdcqor %^B4@ ,( W z[3_?zdz{̌}- ^8vLMM~ʋwu^WMy0 ǵR0 @& ;^vVKeu灷-dk*;rX{_kbA^b!D4D@"nSFuC峟-?u@~=@ .\JBSSS>?O >Jcꖛ>o>&beMu@y18np@сko7љi?~k& $ PQ@Q?sOM}hwcZև^w66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&ja7(jb!`0)%KgS@8U$ kՈ\1M詾l=[Efm([ZkT[X5ڭii2'ZZ+rO~n[k8Z025Zs.[^\Z+"JGJih;5(Xk;^zLJk@qs„!"mRZF0;$!dtuBADe3cgbZ ʵy͌=̜(53lzĞ4s鴵iǛp>zb쎗bGkQG. iz|_0>fiUhDH9Q5'[]ۄK~pt-5Fkb"0sǫGCt|3EDq6 D bӴR #:GJ.ϟB1Ͼ0le|8<<ʄ豽%Tùע8l;w,Z%0~hW߼RGsWώ6kHYImtl]6{3BbD`} whc}|Ps}c9D~i6yZD'N>7l ϶2+gqZi$yPkNnoQŁx30naqfjzJPtˬC&\92ݭia1X2kUhMFg?|moʰebWq {;q,'nCoJ :N&wurMwt~l}-koKs@ױLH mV28`rvmLg#(ff䶙nxU&aD/_`(" !ۅBw3s@!krwu_Aݳ_n_Ph w~o>_]Og[ xʼn'̂L# CBx?q?}<&4On&Om׳/ <7ߪWwٜx􃟼±O!:'߸vl{[v-/_ygv_J=#ع} Dov'K}~ {z[?ϾӳO|wO" zpeV]Q*J)koȓ8Qi٭|E$c{ޟʅ)=U,x ?߯?c| [':~}/}v'h=TGv(@_}cu&~0CBv瞃/?5 S%R [L}W<}_|@(@?_9G_٩$?w {aG . N>M{*8pz9uު˿pɃm?wО;x]Cw Ә}'!V$=w?֦cMOSfugrrw̕Ue|O tL ~}g?4FaKukc{oDSw LMckghtpYRwW= 5Y+J%I,/_յ$۝hvvdOqݜfKd&AXGϞҾTqx*HS|T]~ࡽBf> }m:6 a$%P:ac+^ ב̗iq2- IYUƱN>G{=aIENDB`weboob-1.1/icons/cookboob.png000066400000000000000000000230351265717027300162630ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs B(xtIME 14HtEXtCommentCreated with GIMPW IDATx{geGyUI7};陞Q @ 5 6IeD02 ,&x < #B& #!H!48ɡs} U=HXwysOs޷ToU~ֺ Ӹo:."<k@)Y\q40woFs<p,yCn!IJJB$k@ۺ5qdaL$ jKsWw&]m=^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n{,[ĬѸߛ4^O (" ztD}a6}??}wBSo_.6n[[dkh^/ɳ]MPҬTh?LJد ogsZkAw]N+n* zVf nFӅuJC IgϯjߛRqx*H^uϧ󟯌 QW1k"5;\ѱM&!LbdY't(|KkU+^= B if ҴMYJ$*ث%lI{i_78r(fgIENDB`weboob-1.1/icons/geolooc.png000066400000000000000000000206721265717027300161210ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs B(xtIME5q\tEXtCommentCreated with GIMPW IDATx{geGu淫߽ܯsPnJ` [$ c@c`MN.[@Wb]G^6_pBW0L8=y6 FlcM>ƟJ@J@-C`l ?c pz/z2JW)r%% b5֚c\n~/xg|QUzdONV)m Ճ<68/)}]7NV^S_^)W,rK2R$D $m&c'OO/3:?ԉks=jȆ-xK cTĩ ѝ uwkئfUJW+7]V)G b޻k&G/N1iVJ[V;:n>?># R8vdK宂 rsF ņ5GI(°.9p~aqB|? w{uVRiVڻ֭ =v7kkg.&- AlgT<`7KxqP"js2%=]#R|n &ᱳZuFQY~Mz< .`-wu䕫.2lya}~u~l,!=йzscLԭV$( `R)9{I cfN]С|!Mx=ؔՆ+koo[j^ڟ}+L'J@Z!O`Ãbgp! !Z\(Tz[喻 > 3x +ּRc`zpp9u_[ L c'&<~rs\o`G D.L D@*^xRHVq˓ \w@UhٲUd-w_G֤ U.P(kv&rTݫ}ZݹhK]ExY Dt`x5Mlm x\"@2C$(2 ºBͻWfpJmlLmC|[g\wv$n&ˤ o`@#bd(`D$ n&(K&&. KlqI! HKAL8CJa,otXg^}fV:ϗlA٬H2 }? "H%}+ wB*: $p 1Û8kж # -=Za @J)x~ eaa0Z hW(٥ɳIhfl)I3M=0 5x#O3;YJHHK˔2ŶV\u$S7?=^+4`L1`XJ@ !- B6\e T4;c-F |Mg `&"$K!;V뺊[MNu$<qP[̌ii"R+;-9BƀdhIВ`Lj%!s6/lAlpBr,P}`rgfAD !t>W AQb c n@9:`*-::{hM835uي` Ա45FXkɤXg  03T , Aĵ6""?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I9҈GN5$nv*A/:l*[f SuEQ茜9޾{{oxHxv)-ͧ=3?h Oj7r)&Ga8#3D2sy}ttIEvE~tj@4R{4+տMA֬je b@(њށrsD" 5YG$/⹫y󳎓2/tEot1|b߁iV*  COh#RȨ}}՘: !C[[+6u62iQVy^x1b0K]OX/`fiZ9kJs4;q?9%4ɔ jX'`J4# CZJ=U)ery$4e҅BZ"1VMI)ʅ|L&]~#YJe:frjl5sP`#o]MLiId~Kkl[[O4eό#74*[.]P|V޿kK.:Yr~it6==3 JHQ*޸=Tʬ""$ң':4TuE(&luxkepfXSEL0#p4 z{הI" no_'Nog^ai[tɉ^nLՌƷw.RK. IJ@HJM#[7߰KYc13"É3n^ u cBK-^T6[7-5K>jh"2@-dX<OT=U|랚#7+RD-?އΉZDcv)3+$ElN{݉ CZ+OȽK߸ȠyfM)Oh!(ckK__8y[(}) 9o DP/2=H{>if[9-L lD\/Ju*-ǿg=[4Skٟ>2fo5 S* I?|n7'x u{[k&~_eٯNѹJek@ |.'yAYt׮ ʮ۵dπbvvgíSNS~_k8?>}""?Ioҧ޼2QO}vW~w˦o]_XE&&#F2t{p0'b>}TS\=@(Ski>UK(lCqT9yPG- רž߈j8>6{ޡ'v5X/uD{.NUX p9% G'NV&5zloR`Նu7} wʓZX-JIè!㐎1H !74R/xJwU[OX+V!~q~[dj&UQC.(f$ ` Y\ϊǖA?L#RgC\9A" "?#  ~]Z, ~=xN ;Oٺf|c- W֧@xg<4)"@ JWn%'χٗ.7&RjJl${AX^'5? |YFdG8Jֽwy xx(_).#অhd-8i~ۤ[lu@LSWmIt930)(L JETf?_N[,9[LquwxttDMkJRI%9ObV?xǟ&_-02_fM{E߆amt:;vZ ah!U8koT$ G?-[e^;/BLX()fNXH+/qkAIMق4mS8nVy!!0Z25 *N$IENDB`weboob-1.1/icons/qwebcontentedit.png000066400000000000000000000216601265717027300176670ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs B(xtIME +2NdCtEXtCommentCreated with GIMP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/DH5@j G6"! nG:N!iѣGLh.|`(*}*c:k^+EG^|csa* 3GQcǟ/լUlZD !Sg_!6-Y)ɗ8>Wp\.."X$DH }g?J CiZNPMs˕J$8O?R"? )bt>&K(\K|T6qod'aKC~6S2dHDVI)担lv \/Fl^MO˾ޡD3 6 r<2;;q~vv&Zrw`4e$؟ϟ+3?sMrf:C1Zk j~|fqi!!2&!b-nzs`V1i멙SeLkںA ZEf/> * `DMyjD(8Q(I#O  !Ƕ\+h9.a''wO*xH$DD"%I)i;{[ !:aF p40ZupI&ĊkC_ǟ{U"禁Ih.Z:fffsDBB" I'jk'O8c4qܖ,દN]4ƿ5ȄeJ+am=/eg}a!d3GDaӧ`L6Ti(}_l|7p@S'_tJ !;BLA yI`͌TJ4MzĉCe,^+NիDpaq>?uZˎ۲`iF47,CPJwl'D@.4Z fffRTΏn~_ۓH"/3~w c9cWm;hD^7'WE/UI"hf]dfVZ>—vuWȃ-++fZHU a57-o>Ow_}U(R|[h^F_d&aز\MD&F^;-jmfN~{~ ֖~S:H mV3wޙ^zx[J,^z]e6޴J h$DL$B)f>_زMt$܆F;b}E=?s6<.Ʊ%oao~8wՒV e]ˣ1?).Q@ҬT$/.ͤIl̿đY~rA?yQ]*놷 lnVg2ı3JC IT'~A4U/W'~_'~ t8_"3\ڦc !L0`SV*J88J}0ވwt,C4mS8nNz VI$~3`Sſo30`IENDB`weboob-1.1/man/000077500000000000000000000000001265717027300134155ustar00rootroot00000000000000weboob-1.1/man/boobank.1000066400000000000000000000232741265717027300151220ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBANK 1 "11 February 2016" "boobank 1\&.1" .SH NAME boobank \- manage bank accounts .SH SYNOPSIS .B boobank [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B boobank [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to list your bank accounts and get their balance, display accounts history and coming bank operations, and transfer money from an account to another (if available). .SS Supported websites: * alloresto (Allo Resto) .br * amazonstorecard (Amazon Store Card) .br * americanexpress (American Express) .br * apivie (Apivie) .br * axabanque (AXA Banque) .br * banqueaccord (Banque Accord) .br * banquepopulaire (Banque Populaire) .br * barclays (Barclays) .br * bforbank (BforBank) .br * bnporc (BNP Paribas) .br * boursorama (Boursorama) .br * bp (La Banque Postale) .br * bred (Bred) .br * caissedepargne (Caisse d'Épargne) .br * carrefourbanque (Carrefour Banque) .br * cic (CIC) .br * citelis (Citélis) .br * citibank (Citibank) .br * cmb (Crédit Mutuel de Bretagne) .br * cmso (Crédit Mutuel Sud\-Ouest) .br * cragr (Crédit Agricole) .br * creditcooperatif (Crédit Coopératif) .br * creditdunord (Crédit du Nord, Banque Courtois, Kolb, Tarneaud) .br * creditmutuel (Crédit Mutuel) .br * delubac (Banque Delubac & Cie) .br * fortuneo (Fortuneo) .br * ganassurances (Groupama) .br * groupamaes (Groupama Épargne Salariale) .br * hsbc (HSBC France) .br * ing (ING Direct) .br * kiwibank (Kiwibank) .br * lcl (LCL) .br * oney (Oney) .br * paypal (PayPal) .br * s2e (Esalia, Capeasi, BNP PERE, HSBC ERE) .br * societegenerale (Société Générale) .br * vicseccard (Victoria's Secret Angel Card) .br * wellsfargo (Wells Fargo) .SH BOOBANK COMMANDS .TP \fBbudgea\fR \fIUSERNAME\fR \fIPASSWORD\fR .br Export your bank accounts and transactions to Budgea. .br .br Budgea is an online web and mobile application to manage your bank .br accounts. To avoid giving your credentials to this service, you can use .br this command. .br .br https://www.budgea.com .TP \fBcoming\fR \fIID\fR [\fIEND_DATE\fR] .br Display future transactions. .br .br If END_DATE is supplied, show all transactions until this date. .br .br Default is limited to 10 results. .TP \fBhistory\fR \fIID\fR [\fIEND_DATE\fR] .br Display history of transactions. .br .br If END_DATE is supplied, list all transactions until this date. .br .br Default is limited to 10 results. .TP \fBinvestment\fR \fIID\fR .br Display investments of an account. .TP \fBlist\fR [\-\fIU\fR] .br List accounts. .br Use \-U to disable sorting of results. .TP \fBtransfer\fR \fIACCOUNT\fR [\fIRECIPIENT\fR \fIAMOUNT\fR [\fIREASON\fR]] .br Make a transfer beetwen two account .br \- ACCOUNT the source account .br \- RECIPIENT the recipient .br \- AMOUNT amount to transfer .br \- REASON reason of transfer .br .br If you give only the ACCOUNT parameter, it lists all the .br available recipients for this account. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (account_list, csv, htmltable, investment_list, json, json_line, multiline, ofx, ops_list, pretty_qif, qif, recipient_list, simple, table, transfer, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon, Christophe Benz .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/boobank weboob-1.1/man/boobathon.1000066400000000000000000000177011265717027300154600ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBATHON 1 "11 February 2016" "boobathon 1\&.1" .SH NAME boobathon \- participate in a Boobathon .SH SYNOPSIS .B boobathon [\-dqv] [\-b \fIbackends\fR] [\-cnfs] \fIboobathon\fR .br .B boobathon [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application to participate to a Boobathon. .SS Supported websites: * dlfp (Da Linux French Page news website) .br * mediawiki (Wikis running MediaWiki, like Wikipedia) .br * redmine (The Redmine project management web application) .SH BOOBATHON COMMANDS .TP \fBaddtask\fR \fIBACKEND\fR \fICAPABILITY\fR .br Add a new task. .TP \fBcancel\fR .br Cancel the current task. .TP \fBclose\fR \fIWINNER\fR .br Close the event and set the winner. .TP \fBdone\fR .br Set the current task as done. .TP \fBedit\fR [event | me] .br Edit information about you or about event. .TP \fBinfo\fR .br Display information about this event. .TP \fBjoin\fR .br Join this event. .TP \fBleave\fR .br Leave this event. .TP \fBmembers\fR .br Display members information. .TP \fBprogress\fR .br Display progress of members. .TP \fBremtask\fR \fITASK_ID\fR .br Remove a task. .TP \fBstart\fR [\fITASK_ID\fR] .br Start a task. If you don't give a task ID, the first available .br task will be taken. .TP \fBtasks\fR .br Display all tasks of members. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2011-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/boobathon weboob-1.1/man/boobcoming.1000066400000000000000000000211401265717027300156130ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBCOMING 1 "11 February 2016" "boobcoming 1\&.1" .SH NAME boobcoming \- see upcoming events .SH SYNOPSIS .B boobcoming [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B boobcoming [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application to see upcoming events. .SS Supported websites: * agendaculturel (agendaculturel website) .br * agendadulibre (agendadulibre website) .br * allocine (AlloCiné French cinema database service) .br * biplan (lebiplan.org website) .br * hybride (hybride website) .br * pariskiwi (ParisKiwi website) .br * razibus (site annonçant les évènements attendus par les punks a chiens) .br * residentadvisor (residentadvisor website) .br * senscritique (senscritique website) .br * sueurdemetal (SueurDeMetal French concerts list website) .SH BOOBCOMING COMMANDS .TP \fBattends\fR \fIID\fR1 [\fIID\fR2 \fIID\fR3 ...] .br Register as participant of an event. .br ID is the identifier of the event. .TP \fBexport\fR \fIFILENAME\fR [\fIID\fR1 \fIID\fR2 \fIID\fR3 ...] .br ID is the identifier of the event. If no ID every events are exported .br .br FILENAME is where to write the file. If FILENAME is '\-', the file is written to stdout. .br .br Export event in ICALENDAR format .TP \fBinfo\fR \fIID\fR .br Get information about an event. .TP \fBlist\fR [\fIPATTERN\fR]List upcoming events, pattern can be an english or french week day, 'today' or a date (dd/mm/yy[yy]) .br .br Default is limited to 10 results. .TP \fBload\fR [query name]without query name : list loadable queries .br with query name laod query .br .br Default is limited to 10 results. .TP \fBsearch\fR .br search for an event. Parameters interactively asked .br .br Default is limited to 10 results. .TP \fBunattends\fR \fIID\fR1 [\fIID\fR2 \fIID\fR3 ...] .br Unregister you participation for an event. .br ID is the identifier of the event. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, ical_formatter, json, json_line, multiline, simple, simple_upcoming, table, upcoming, upcoming_list, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2012-2016 Bezleputh .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/boobcoming weboob-1.1/man/boobill.1000066400000000000000000000212601265717027300151220ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBILL 1 "11 February 2016" "boobill 1\&.1" .SH NAME boobill \- get and download bills .SH SYNOPSIS .B boobill [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B boobill [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to get and download bills. .SS Supported websites: * amazon (Amazon) .br * ameli (Ameli website: French Health Insurance) .br * amelipro (Ameli website: French Health Insurance for Professionals) .br * bouygues (Bouygues Télécom French mobile phone provider) .br * edf (Edf website: French power provider) .br * freemobile (Free Mobile website) .br * gdfsuez (GDF\-Suez French energy provider) .br * ing (ING Direct) .br * ldlc (ldlc website) .br * leclercmobile (Leclerc Mobile website) .br * nettokom (Nettokom website) .br * orange (Orange French mobile phone provider) .br * ovh (ovh website) .br * poivy (Poivy website) .SH BOOBILL COMMANDS .TP \fBbalance\fR [\fIID\fR] .br Get balance of subscriptions. .br If no ID given, display balance of all backends. .TP \fBbills\fR [\fIID\fR] .br Get the list of bills documents for subscriptions. .br If no ID given, display bills of all backends .br .br Default is limited to 10 results. .TP \fBdetails\fR [\fIID\fR] .br Get details of subscriptions. .br If no ID given, display all details of all backends. .TP \fBdownload\fR [\fIID\fR | all] [\fIFILENAME\fR] .br download ID [FILENAME] .br .br download the bill .br id is the identifier of the bill (hint: try bills command) .br FILENAME is where to write the file. If FILENAME is '\-', .br the file is written to stdout. .br .br download all [ID] .br .br You can use special word "all" and download all bills of .br subscription identified by ID. .br If Id not given, download bills of all subscriptions. .TP \fBhistory\fR [\fIID\fR] .br Get the history of subscriptions. .br If no ID given, display histories of all backends. .br .br Default is limited to 10 results. .TP \fBsubscriptions\fR .br List all subscriptions. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, subscriptions, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2012-2016 Florent Fourcot .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/boobill weboob-1.1/man/booblyrics.1000066400000000000000000000167701265717027300156610ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBLYRICS 1 "11 February 2016" "booblyrics 1\&.1" .SH NAME booblyrics \- search and display song lyrics .SH SYNOPSIS .B booblyrics [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B booblyrics [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to search for song lyrics on various websites. .SS Supported websites: * parolesmania (Paroles Mania lyrics website) .br * parolesmusique (paroles\-musique lyrics website) .br * parolesnet (paroles.net lyrics website) .br * seeklyrics (SeekLyrics lyrics website) .SH BOOBLYRICS COMMANDS .TP \fBget\fR \fIID\fR .br Display lyrics of the song. .TP \fBsearch\fR [artist | song] [\fIPATTERN\fR] .br Search lyrics by artist name or by song title. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, lyrics_get, lyrics_list, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013-2016 Julien Veyssier .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/booblyrics weboob-1.1/man/boobmsg.1000066400000000000000000000221561265717027300151350ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBMSG 1 "11 February 2016" "boobmsg 1\&.1" .SH NAME boobmsg \- send and receive message threads .SH SYNOPSIS .B boobmsg [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B boobmsg [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to send messages on various websites and to display message threads and contents. .SS Supported websites: * aum ("Adopte un Mec" French dating website) .br * bnporc (BNP Paribas) .br * bouygues (Bouygues Télécom French mobile phone provider) .br * dlfp (Da Linux French Page news website) .br * feedly (handle the popular RSS reading service Feedly) .br * fourchan (4chan image board) .br * guerrillamail (GuerrillaMail temp mailbox) .br * happn (Happn dating mobile application) .br * hds (Histoires de Sexe French erotic novels) .br * inrocks (Les Inrocks French news website) .br * lefigaro (Le Figaro French newspaper website) .br * liberation (Libération newspaper website) .br * mailinator (mailinator temp mailbox) .br * minutes20 (2 Minutes French newspaper website) .br * newsfeed (Loads RSS and Atom feeds from any website) .br * okc (OkCupid) .br * orange (Orange French mobile phone provider) .br * ovs (OnVaSortir website. Handles private messages only) .br * phpbb (phpBB forum) .br * playme (PlayMe dating mobile application) .br * presseurop (Presseurop website) .br * sfr (SFR French mobile phone provider) .br * taz (Taz newspaper website) .br * tinder (Tinder dating mobile application) .br * twitter (twitter website) .SH BOOBMSG COMMANDS .TP \fBexport_all\fR .br Export All threads .TP \fBexport_thread\fR \fIID\fR .br Export the thread identified by ID .TP \fBlist\fR .br Display all threads. .br .br Default is limited to 10 results. .TP \fBphotos\fR \fIID\fR .br Display photos of a profile .TP \fBpost\fR \fIRECEIVER\fR@\fIBACKEND\fR[,\fIRECEIVER\fR@\fIBACKEND\fR[...]] [\fITEXT\fR] .br Post a message to the specified receivers. .br Multiple receivers are separated by a comma. .br .br If no text is supplied on command line, the content of message is read on stdin. .TP \fBprofile\fR \fIID\fR .br Display a profile .TP \fBshow\fR \fIMESSAGE\fR .br Read a message .TP \fBstatus\fR .br Display status information about a backend. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH BOOBMSG OPTIONS .TP \fB\-E\fR, \fB\-\-accept\-empty\fR Send messages with an empty body. .TP \fB\-t TITLE\fR, \fB\-\-title=TITLE\fR For the "post" command, set a title to message .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (atom, csv, htmltable, json, json_line, msg, msglist, multiline, profile, simple, table, webkit, xhtml) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Christophe Benz .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/boobmsg weboob-1.1/man/boobooks.1000066400000000000000000000164311265717027300153210ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBOOKS 1 "11 February 2016" "boobooks 1\&.1" .SH NAME boobooks \- manage rented books .SH SYNOPSIS .B boobooks [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B boobooks [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to list your books rented or booked at the library, book and search new ones, get your booking history (if available). .SS Supported websites: * champslibres (Champs Libres (Rennes) Library) .br * opacwebaloes (Aloes Library software) .SH BOOBOOKS COMMANDS .TP \fBrenew\fR \fIID\fR .br Renew a book .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, rented_list, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2012-2016 Jeremy Monnet .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/boobooks weboob-1.1/man/boobsize.1000066400000000000000000000200561265717027300153160ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBSIZE 1 "11 February 2016" "boobsize 1\&.1" .SH NAME boobsize \- display sensors and gauges values .SH SYNOPSIS .B boobsize [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B boobsize [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to display various sensors and gauges values. .SS Supported websites: * dresdenwetter (Private wetter station Dresden) .br * jcvelaux (City bike renting availability information. Cities: Paris, Rouen, Toulouse, Luxembourg, Valence, Stockholm, Goteborg, Santander, Amiens, Lillestrom, Mulhouse, Lyon, Ljubljana, Seville, Namur, Nancy, Creteil, Bruxelles\-Capitale, Cergy\-Pontoise, Vilnius, Toyama, Kazan, Marseille, Nantes, Besancon) .br * mareeinfo (Un module qui permet d' aller a la pêche aux moules totalement informé) .br * sachsen (Level of Sachsen river) .br * vlille (Lille bike renting availability information) .SH BOOBSIZE COMMANDS .TP \fBdetails\fR \fIGAUGE_ID\fR .br Display details of all sensors of the gauge. .TP \fBhistory\fR \fISENSOR_ID\fR .br Get history of a specific sensor (use 'search' to find a gauge, and sensors GAUGE_ID to list sensors attached to the gauge). .TP \fBlast_sensor_measure\fR \fISENSOR_ID\fR .br Get last measure of a sensor. .TP \fBsearch\fR [\fIPATTERN\fR] .br Display all gauges. If PATTERN is specified, search on a pattern. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, gauge_list, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013-2016 Florent Fourcot .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/Boobsize weboob-1.1/man/boobtracker.1000066400000000000000000000213511265717027300157760ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH BOOBTRACKER 1 "11 February 2016" "boobtracker 1\&.1" .SH NAME boobtracker \- manage bug tracking issues .SH SYNOPSIS .B boobtracker [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B boobtracker [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to create, edit, view bug tracking issues. .SS Supported websites: * github (GitHub issues tracking) .br * redmine (The Redmine project management web application) .SH BOOBTRACKER COMMANDS .TP \fBattach\fR \fIISSUE\fR \fIFILENAME\fR .br Attach a file to an issue (Not implemented yet). .TP \fBcomment\fR \fIISSUE\fR [\fITEXT\fR] .br Comment an issue. If no text is given, enter it in standard input. .TP \fBedit\fR \fIISSUE\fR [\fIKEY\fR [\fIVALUE\fR]] .br Edit an issue. .br If you are not in interactive mode, you can use these parameters: .br \-\-title TITLE .br \-\-assignee ASSIGNEE .br \-\-target\-version VERSION .br \-\-category CATEGORY .br \-\-status STATUS .TP \fBget\fR \fIISSUE\fR .br Get an issue and display it. .TP \fBlogtime\fR \fIISSUE\fR \fIHOURS\fR [\fITEXT\fR] .br Log spent time on an issue. .TP \fBpost\fR \fIPROJECT\fR .br Post a new issue. .br .br If you are not in interactive mode, you can use these parameters: .br \-\-title TITLE .br \-\-assignee ASSIGNEE .br \-\-target\-version VERSION .br \-\-category CATEGORY .br \-\-status STATUS .TP \fBremove\fR \fIISSUE\fR .br Remove an issue. .TP \fBsearch\fR \fIPROJECT\fR .br List issues for a project. .br .br You can use these filters from command line: .br \-\-author AUTHOR .br \-\-title TITLE_PATTERN .br \-\-assignee ASSIGNEE .br \-\-target\-version VERSION .br \-\-category CATEGORY .br \-\-status STATUS .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH BOOBTRACKER OPTIONS .TP \fB\-\-author=AUTHOR\fR .TP \fB\-\-title=TITLE\fR .TP \fB\-\-assignee=ASSIGNEE\fR .TP \fB\-\-target\-version=VERSION\fR .TP \fB\-\-tracker=TRACKER\fR .TP \fB\-\-category=CATEGORY\fR .TP \fB\-\-status=STATUS\fR .TP \fB\-\-priority=PRIORITY\fR .TP \fB\-\-start=START\fR .TP \fB\-\-due=DUE\fR .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, issue_info, issues_list, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2011-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/boobtracker weboob-1.1/man/cineoob.1000066400000000000000000000306271265717027300151250ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH CINEOOB 1 "11 February 2016" "cineoob 1\&.1" .SH NAME cineoob \- search movies and persons around cinema .SH SYNOPSIS .B cineoob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B cineoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to search for movies and persons on various cinema databases , list persons related to a movie, list movies related to a person and list common movies of two persons. .SH CINEOOB COMMANDS .TP \fBbiography\fR person\fI_ID\fR .br Show the complete biography of a person. .TP \fBcasting\fR movie\fI_ID\fR [\fIROLE\fR] .br List persons related to a movie. .br If ROLE is given, filter by ROLE .TP \fBfilmography\fR person\fI_ID\fR [\fIROLE\fR] .br List movies of a person. .br If ROLE is given, filter by ROLE .TP \fBgetfile_subtitle\fR subtitle\fI_ID\fR [\fIFILENAME\fR] .br Get the subtitle or archive file. .br FILENAME is where to write the file. If FILENAME is '\-', .br the file is written to stdout. .TP \fBgetfile_torrent\fR \fIID\fR [\fIFILENAME\fR] .br Get the .torrent file. .br FILENAME is where to write the file. If FILENAME is '\-', .br the file is written to stdout. .TP \fBinfo_movie\fR movie\fI_ID\fR .br Get information about a movie. .TP \fBinfo_person\fR person\fI_ID\fR .br Get information about a person. .TP \fBinfo_subtitle\fR subtitle\fI_ID\fR .br Get information about a subtitle. .TP \fBinfo_torrent\fR \fIID\fR .br Get information about a torrent. .TP \fBmovies_in_common\fR person\fI_ID\fR person\fI_ID\fR .br Get the list of common movies between two persons. .TP \fBpersons_in_common\fR movie\fI_ID\fR movie\fI_ID\fR .br Get the list of common persons between two movies. .TP \fBreleases\fR movie\fI_ID\fR [\fICOUNTRY\fR] .br Get releases dates of a movie. .br If COUNTRY is given, show release in this country. .TP \fBsearch_movie\fR [\fIPATTERN\fR] .br Search movies. .br .br Default is limited to 10 results. .TP \fBsearch_movie_subtitle\fR language movie\fI_ID\fR .br Search subtitles of movie_ID. .br .br Language Abbreviation .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br Arabic ar Esperanto eo Irish ga Russian ru .br Afrikaans af Estonian et Italian it Serbian sr .br Albanian sq Filipino tl Japanese ja Slovak sk .br Armenian hy Finnish fi Kannada kn Slovenian sl .br Azerbaijani az French fr Korean ko Spanish es .br Basque eu Galician gl Latin la Swahili sw .br Belarusian be Georgian ka Latvian lv Swedish sv .br Bengali bn German de Lithuanian lt Tamil ta .br Bulgarian bg Greek gr Macedonian mk Telugu te .br Catalan ca Gujarati gu Malay ms Thai th .br Chinese zh Haitian ht Maltese mt Turkish tr .br Croatian hr Hebrew iw Norwegian no Ukrainian uk .br Czech cz Hindi hi Persian fa Urdu ur .br Danish da Hungaric hu Polish pl Vietnamese vi .br Dutch nl Icelandic is Portuguese pt Welsh cy .br English en Indonesian id Romanian ro Yiddish yi .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br .br Default is limited to 10 results. .TP \fBsearch_movie_torrent\fR movie\fI_ID\fR .br Search torrents of movie_ID. .br .br Default is limited to 10 results. .TP \fBsearch_person\fR [\fIPATTERN\fR] .br Search persons. .br .br Default is limited to 10 results. .TP \fBsearch_subtitle\fR language [\fIPATTERN\fR] .br Search subtitles. .br .br Language Abbreviation .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br Arabic ar Esperanto eo Irish ga Russian ru .br Afrikaans af Estonian et Italian it Serbian sr .br Albanian sq Filipino tl Japanese ja Slovak sk .br Armenian hy Finnish fi Kannada kn Slovenian sl .br Azerbaijani az French fr Korean ko Spanish es .br Basque eu Galician gl Latin la Swahili sw .br Belarusian be Georgian ka Latvian lv Swedish sv .br Bengali bn German de Lithuanian lt Tamil ta .br Bulgarian bg Greek gr Macedonian mk Telugu te .br Catalan ca Gujarati gu Malay ms Thai th .br Chinese zh Haitian ht Maltese mt Turkish tr .br Croatian hr Hebrew iw Norwegian no Ukrainian uk .br Czech cz Hindi hi Persian fa Urdu ur .br Danish da Hungaric hu Polish pl Vietnamese vi .br Dutch nl Icelandic is Portuguese pt Welsh cy .br English en Indonesian id Romanian ro Yiddish yi .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br .br Default is limited to 10 results. .TP \fBsearch_torrent\fR [\fIPATTERN\fR] .br Search torrents. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, movie_info, movie_list, movie_releases, multiline, person_bio, person_info, person_list, simple, subtitle_info, subtitle_list, table, torrent_info, torrent_list, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013-2016 Julien Veyssier .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/cineoob weboob-1.1/man/comparoob.1000066400000000000000000000165541265717027300154730ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH COMPAROOB 1 "11 February 2016" "comparoob 1\&.1" .SH NAME comparoob \- compare products .SH SYNOPSIS .B comparoob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B comparoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application to compare products. .SS Supported websites: * lacentrale (Vehicule prices at LaCentrale.fr) .br * prixcarburants (French governement website to compare fuel prices) .SH COMPAROOB COMMANDS .TP \fBinfo\fR \fIID\fR .br Get information about a product. .TP \fBprices\fR [\fIPATTERN\fR] .br Display prices for a product. If a pattern is supplied, do not prompt .br what product to compare. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, price, prices, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2012-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/comparoob weboob-1.1/man/cookboob.1000066400000000000000000000172771265717027300153120ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH COOKBOOB 1 "11 February 2016" "cookboob 1\&.1" .SH NAME cookboob \- search and consult recipes .SH SYNOPSIS .B cookboob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B cookboob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to search for recipes on various websites. .SS Supported websites: * 750g (750g French recipe website) .br * allrecipes (Allrecipes English recipe website) .br * cuisineaz (Cuisine AZ French recipe website) .br * marmiton (Marmiton French recipe website) .br * supertoinette (Super Toinette, la cuisine familiale French recipe website) .SH COOKBOOB COMMANDS .TP \fBexport\fR \fIID\fR [\fIFILENAME\fR] .br Export the recipe to a KRecipes XML file .br FILENAME is where to write the file. If FILENAME is '\-', .br the file is written to stdout. .TP \fBinfo\fR \fIID\fR .br Get information about a recipe. .TP \fBsearch\fR [\fIPATTERN\fR] .br Search recipes. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, recipe_info, recipe_list, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013-2016 Julien Veyssier .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/cookboob weboob-1.1/man/flatboob.1000066400000000000000000000172211265717027300152720ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH FLATBOOB 1 "11 February 2016" "flatboob 1\&.1" .SH NAME flatboob \- search for housing .SH SYNOPSIS .B flatboob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B flatboob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application to search for housing. .SS Supported websites: * entreparticuliers (entreparticuliers.com website) .br * explorimmo (explorimmo website) .br * leboncoin (search house on leboncoin website) .br * logicimmo (logicimmo website) .br * pap (French housing website) .br * seloger (French housing website) .SH FLATBOOB COMMANDS .TP \fBinfo\fR \fIID\fR .br Get information about a housing. .TP \fBload\fR [query name]without query name : list loadable queries .br with query name laod query .br .br Default is limited to 10 results. .TP \fBsearch\fR .br Search for housing. Parameters are interactively asked. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, housing, housing_list, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2012-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" "~/.config/weboob/flatboob" .SH SEE ALSO Home page: http://weboob.org/applications/flatboob weboob-1.1/man/galleroob.1000066400000000000000000000175451265717027300154610ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH GALLEROOB 1 "11 February 2016" "galleroob 1\&.1" .SH NAME galleroob \- browse and download web image galleries .SH SYNOPSIS .B galleroob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B galleroob [\-\-help] [\-\-version] .SH DESCRIPTION .LP galleroob browses and downloads web image galleries .SS Supported websites: * batoto (Batoto manga reading website) .br * eatmanga (EatManga manga reading website) .br * ehentai (E\-Hentai galleries) .br * imgur (imgur image upload service) .br * izneo (Izneo digital comics) .br * mangafox (Manga Fox manga reading website) .br * mangago (Mangago manga reading site) .br * mangahere (Manga Here manga reading website) .br * mangareader (MangaReader manga reading website) .br * simplyreadit (SimplyReadIt manga reading website) .SH GALLEROOB COMMANDS .TP \fBdownload\fR \fIID\fR [\fIFIRST\fR [\fIFOLDER\fR]] .br Download a gallery. .br .br Begins at page FIRST (default: 0) and saves to FOLDER (default: title) .TP \fBinfo\fR \fIID\fR .br Get information about a gallery. .TP \fBsearch\fR \fIPATTERN\fR .br List galleries matching a PATTERN. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, gallery_list, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2011-2014 Noé Rubinstein .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/galleroob weboob-1.1/man/geolooc.1000066400000000000000000000163641265717027300151400ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH GEOLOOC 1 "11 February 2016" "geolooc 1\&.1" .SH NAME geolooc \- geolocalize IP addresses .SH SYNOPSIS .B geolooc [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B geolooc [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to geolocalize IP addresses. .SS Supported websites: * freegeoip (public API to search the geolocation of IP addresses) .br * geolocip (GeolocIP IP addresses geolocation service) .br * ipapi (IP\-API Geolocation API) .br * ipinfodb (IPInfoDB IP addresses geolocation service) .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/geolooc weboob-1.1/man/handjoob.1000066400000000000000000000162611265717027300152710ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH HANDJOOB 1 "11 February 2016" "handjoob 1\&.1" .SH NAME handjoob \- search for a job .SH SYNOPSIS .B handjoob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B handjoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application to search for a job. .SS Supported websites: * adecco (adecco website) .br * apec (apec website) .br * cci (cci website) .br * indeed (indeed website) .br * lolix (Lolix French free software employment website) .br * monster (monster website) .br * popolemploi (Pole Emploi website) .br * regionsjob (regionsjob website) .SH HANDJOOB COMMANDS .TP \fBinfo\fR \fIID\fR .br Get information about an advert. .TP \fBsearch\fR \fIPATTERN\fR .br Search for an advert matching a PATTERN. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR .br advanced search .br .br Search for an advert matching to advanced filters. .br .br Default is limited to 10 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, job_advert, job_advert_list, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2012-2016 Bezleputh .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/handjoob weboob-1.1/man/havedate.1000066400000000000000000000214701265717027300152640ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH HAVEDATE 1 "11 February 2016" "havedate 1\&.1" .SH NAME havedate \- interact with dating websites .SH SYNOPSIS .B havedate [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B havedate [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to interact with various dating websites and to optimize seduction algorithmically. .SS Supported websites: * aum ("Adopte un Mec" French dating website) .br * happn (Happn dating mobile application) .br * okc (OkCupid) .br * playme (PlayMe dating mobile application) .br * tinder (Tinder dating mobile application) .SH HAVEDATE COMMANDS .TP \fBevents\fR .br Display dating events. .TP \fBexport_all\fR .br Export All threads .TP \fBexport_thread\fR \fIID\fR .br Export the thread identified by ID .TP \fBlist\fR .br Display all threads. .br .br Default is limited to 10 results. .TP \fBoptim\fR [list | start | edit | stop] \fIBACKEND\fR [\fIOPTIM\fR1 [\fIOPTIM\fR2 ...]] .br All dating backends offer optimization services. This command can be .br manage them. .br Use * us BACKEND value to apply command to all backends. .br .br Commands: .br * list list all available optimizations of a backend .br * start start optimization services on a backend .br * edit configure an optimization service for a backend .br * stop stop optimization services on a backend .TP \fBphotos\fR \fIID\fR .br Display photos of a profile .TP \fBpost\fR \fIRECEIVER\fR@\fIBACKEND\fR[,\fIRECEIVER\fR@\fIBACKEND\fR[...]] [\fITEXT\fR] .br Post a message to the specified receivers. .br Multiple receivers are separated by a comma. .br .br If no text is supplied on command line, the content of message is read on stdin. .TP \fBprofile\fR \fIID\fR .br Display a profile .TP \fBquery\fR \fIID\fR .br Send a query to someone. .TP \fBshow\fR \fIMESSAGE\fR .br Read a message .TP \fBstatus\fR .br Display status information about a backend. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH HAVEDATE OPTIONS .TP \fB\-E\fR, \fB\-\-accept\-empty\fR Send messages with an empty body. .TP \fB\-t TITLE\fR, \fB\-\-title=TITLE\fR For the "post" command, set a title to message .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (atom, csv, events, htmltable, json, json_line, msg, msglist, multiline, profile, simple, table, webkit, xhtml) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/havedate weboob-1.1/man/masstransit.1000066400000000000000000000024311265717027300160470ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .TH MASSTRANSIT 1 "09 March 2013" "masstransit 0\&.f" .SH NAME masstransit \- search for train stations and departures .SH SYNOPSIS .B masstransit [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B masstransit [\-\-help] [\-\-version] .SH DESCRIPTION .LP Maemo application allowing to search for train stations and get departure times. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH COPYRIGHT Copyright(C) 2010-2011 Julien Hébert .LP For full COPYRIGHT see COPYING file with weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/masstransit weboob-1.1/man/monboob.1000066400000000000000000000133411265717027300151340ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH MONBOOB 1 "11 February 2016" "monboob 1\&.1" .SH NAME monboob \- daemon to send and check messages .SH SYNOPSIS .B monboob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B monboob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Daemon allowing to regularly check for new messages on various websites, and send an email for each message, and post a reply to a message on a website. .SS Supported websites: * aum ("Adopte un Mec" French dating website) .br * bnporc (BNP Paribas) .br * bouygues (Bouygues Télécom French mobile phone provider) .br * dlfp (Da Linux French Page news website) .br * feedly (handle the popular RSS reading service Feedly) .br * fourchan (4chan image board) .br * guerrillamail (GuerrillaMail temp mailbox) .br * happn (Happn dating mobile application) .br * hds (Histoires de Sexe French erotic novels) .br * inrocks (Les Inrocks French news website) .br * lefigaro (Le Figaro French newspaper website) .br * liberation (Libération newspaper website) .br * mailinator (mailinator temp mailbox) .br * minutes20 (2 Minutes French newspaper website) .br * newsfeed (Loads RSS and Atom feeds from any website) .br * okc (OkCupid) .br * orange (Orange French mobile phone provider) .br * ovs (OnVaSortir website. Handles private messages only) .br * phpbb (phpBB forum) .br * playme (PlayMe dating mobile application) .br * presseurop (Presseurop website) .br * sfr (SFR French mobile phone provider) .br * taz (Taz newspaper website) .br * tinder (Tinder dating mobile application) .br * twitter (twitter website) .SH MONBOOB COMMANDS .TP \fBonce\fR .br Send mails only once, then exit. .TP \fBpost\fR .br Pipe with a mail to post message. .TP \fBrun\fR .br Run the fetching daemon. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH MONBOOB OPTIONS .TP \fB\-S SMTPD\fR, \fB\-\-smtpd=SMTPD\fR run a fake smtpd server and set the port .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" "~/.config/weboob/monboob" .SH SEE ALSO Home page: http://weboob.org/applications/monboob weboob-1.1/man/parceloob.1000066400000000000000000000170431265717027300154520ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH PARCELOOB 1 "11 February 2016" "parceloob 1\&.1" .SH NAME parceloob \- manage your parcels .SH SYNOPSIS .B parceloob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B parceloob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application to track your parcels. .SS Supported websites: * chronopost (Chronopost website) .br * colisprive (Colisprive parcel tracking website) .br * colissimo (Colissimo parcel tracking website) .br * dhl (DHL website) .br * dpd (DPD website) .br * gls (GLS website) .br * itella (Itella website) .br * ups (UPS website) .SH PARCELOOB COMMANDS .TP \fBinfo\fR \fIID\fR .br Get information about a parcel. .TP \fBstatus\fR .br Display status for all of the tracked parcels. .TP \fBtrack\fR \fIID\fR .br Track a parcel. .TP \fBuntrack\fR \fIID\fR .br Stop tracking a parcel. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, history, htmltable, json, json_line, multiline, simple, status, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/parceloob weboob-1.1/man/pastoob.1000066400000000000000000000203131265717027300151450ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH PASTOOB 1 "11 February 2016" "pastoob 1\&.1" .SH NAME pastoob \- post and get pastes from pastebins .SH SYNOPSIS .B pastoob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B pastoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to post and get pastes from pastebins. .SS Supported websites: * imgur (imgur image upload service) .br * lutim (lutim website) .br * pastealacon (Paste à la con text sharing tool) .br * pastebin (Pastebin text sharing service) .br * pixtoilelibre (toile\-libre image hosting website) .br * unsee (unsee.cc expiring image hosting) .SH PASTOOB COMMANDS .TP \fBget\fR \fIID\fR .br Get a paste contents. .TP \fBget_bin\fR \fIID\fR .br Get a paste contents. .br File will be downloaded from binary services. .TP \fBinfo\fR \fIID\fR [\fIID\fR2 [...]] .br Get information about pastes. .TP \fBpost\fR [\fIFILENAME\fR] .br Submit a new paste. .br The filename can be '\-' for reading standard input (pipe). .br If 'bin' is passed, file will be uploaded to binary services. .TP \fBpost_bin\fR [\fIFILENAME\fR] .br Submit a new paste. .br The filename can be '\-' for reading standard input (pipe). .br File will be uploaded to binary services. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH PASTOOB OPTIONS .TP \fB\-p\fR, \fB\-\-public\fR Make paste public. .TP \fB\-t TITLE\fR, \fB\-\-title=TITLE\fR Paste title .TP \fB\-m MAX_AGE\fR, \fB\-\-max\-age=MAX_AGE\fR Maximum age (duration), default "1 month", "never" for infinite .TP \fB\-E ENCODING\fR, \fB\-\-encoding=ENCODING\fR Input encoding .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2011-2016 Laurent Bachelier .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/pastoob weboob-1.1/man/qboobmsg.1000066400000000000000000000110041265717027300153040ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH QBOOBMSG 1 "17 October 2014" "qboobmsg 1\&.0" .SH NAME qboobmsg \- send and receive message threads .SH SYNOPSIS .B qboobmsg [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B qboobmsg [\-\-help] [\-\-version] .SH DESCRIPTION .LP Qt application allowing to read messages on various websites and reply to them. .SS Supported websites: * aum ("Adopte un Mec" French dating website) .br * bnporc (BNP Paribas) .br * bouygues (Bouygues Télécom French mobile phone provider) .br * dlfp (Da Linux French Page news website) .br * feedly (handle the popular RSS reading service Feedly) .br * fourchan (4chan image board) .br * guerrillamail (GuerrillaMail temp mailbox) .br * hds (Histoires de Sexe French erotic novels) .br * hellobank (Hello Bank!) .br * inrocks (Les Inrocks French news website) .br * lefigaro (Le Figaro French newspaper website) .br * liberation (Libération newspaper website) .br * mailinator (mailinator temp mailbox) .br * minutes20 (2 Minutes French newspaper website) .br * newsfeed (Loads RSS and Atom feeds from any website) .br * okc (OkCupid dating website) .br * orange (Orange French mobile phone provider) .br * ovs (OnVaSortir website. Handles private messages only) .br * phpbb (phpBB forum) .br * playme (PlayMe dating mobile application) .br * presseurop (Presseurop website) .br * sfr (SFR French mobile phone provider) .br * taz (Taz newspaper website) .br * tinder (Tinder dating mobile application) .br * twitter (twitter website) .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2011 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/qboobmsg weboob-1.1/man/qcineoob.1000066400000000000000000000066351265717027300153100ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH QCINEOOB 1 "17 October 2014" "qcineoob 1\&.0" .SH NAME qcineoob \- search movies, people, torrent and subtitles .SH SYNOPSIS .B qcineoob [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B qcineoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Qt application allowing to search movies, people, torrent and subtitles. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013 Julien Veyssier .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" "~/.config/weboob/qcineoob" .SH SEE ALSO Home page: http://weboob.org/applications/qcineoob weboob-1.1/man/qcookboob.1000066400000000000000000000072151265717027300154620ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH QCOOKBOOB 1 "17 October 2014" "qcookboob 1\&.0" .SH NAME qcookboob \- search recipes .SH SYNOPSIS .B qcookboob [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B qcookboob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Qt application allowing to search recipes. .SS Supported websites: * 750g (750g French recipe website) .br * allrecipes (Allrecipes English recipe website) .br * cuisineaz (Cuisine AZ French recipe website) .br * marmiton (Marmiton French recipe website) .br * supertoinette (Super Toinette, la cuisine familiale French recipe website) .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013 Julien Veyssier .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" "~/.config/weboob/qcookboob" .SH SEE ALSO Home page: http://weboob.org/applications/qcookboob weboob-1.1/man/qflatboob.1000066400000000000000000000067741265717027300154660ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH QFLATBOOB 1 "17 October 2014" "qflatboob 1\&.0" .SH NAME qflatboob \- search for housing .SH SYNOPSIS .B qflatboob [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B qflatboob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Qt application to search for housing. .SS Supported websites: * leboncoin (search house on leboncoin website) .br * pap (French housing website) .br * seloger (French housing website) .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2012 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" "~/.config/weboob/qflatboob" .SH SEE ALSO Home page: http://weboob.org/applications/qflatboob weboob-1.1/man/qhandjoob.1000066400000000000000000000072141265717027300154500ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH QHANDJOOB 1 "17 October 2014" "qhandjoob 1\&.0" .SH NAME qhandjoob \- search for job .SH SYNOPSIS .B qhandjoob [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B qhandjoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Qt application to search for job. .SS Supported websites: * adecco (adecco website) .br * apec (apec website) .br * cci (cci website) .br * indeed (indeed website) .br * lolix (Lolix French free software employment website) .br * monster (monster website) .br * popolemploi (Pole Emploi website) .br * regionsjob (regionsjob website) .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013 Sébastien Monel .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" "~/.config/weboob/qhandjoob" .SH SEE ALSO Home page: http://weboob.org/applications/qhandjoob weboob-1.1/man/qhavedate.1000066400000000000000000000070741265717027300154510ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH QHAVEDATE 1 "17 October 2014" "qhavedate 1\&.0" .SH NAME qhavedate \- interact with dating websites .SH SYNOPSIS .B qhavedate [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B qhavedate [\-\-help] [\-\-version] .SH DESCRIPTION .LP Qt application allowing to interact with various dating websites. .SS Supported websites: * aum ("Adopte un Mec" French dating website) .br * okc (OkCupid dating website) .br * playme (PlayMe dating mobile application) .br * tinder (Tinder dating mobile application) .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2012 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/qhavedate weboob-1.1/man/qvideoob.1000066400000000000000000000106241265717027300153120ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH QVIDEOOB 1 "17 October 2014" "qvideoob 1\&.0" .SH NAME qvideoob \- search and play videos .SH SYNOPSIS .B qvideoob [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B qvideoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Qt application allowing to search videos on various websites and play them. .SS Supported websites: * arretsurimages (arretsurimages website) .br * arte (Arte French and German TV) .br * canalplus (Canal Plus French TV) .br * cappedtv (Capped.tv demoscene website) .br * dailymotion (Dailymotion video streaming website) .br * europarl (Europarl parliamentary video streaming website) .br * francetelevisions (France Télévisions video website) .br * gdcvault (Game Developers Conferences Vault video streaming website) .br * ina (INA French TV video archives) .br * jacquieetmichel (Jacquie et Michel TV) .br * nolifetv (NolifeTV French video streaming website) .br * quvi (Multi\-website video helper with quvi. Handles Youtube, BBC, and a lot more) .br * radiofrance (Radios of Radio France: Inter, Info, Bleu, Culture, Musique, FIP, Le Mouv') .br * trictractv (TricTrac.tv video website) .br * vimeo (Vimeo video streaming website) .br * youjizz (YouJizz pornographic video streaming website) .br * youporn (YouPorn pornographic video streaming website) .br * youtube (YouTube video streaming website) .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2011 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" "~/.config/weboob/qvideoob" .SH SEE ALSO Home page: http://weboob.org/applications/qvideoob weboob-1.1/man/qwebcontentedit.1000066400000000000000000000071121265717027300166770ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH QWEBCONTENTEDIT 1 "17 October 2014" "qwebcontentedit 1\&.0" .SH NAME qwebcontentedit \- manage websites content .SH SYNOPSIS .B qwebcontentedit [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B qwebcontentedit [\-\-help] [\-\-version] .SH DESCRIPTION .LP Qt application allowing to manage content of various websites. .SS Supported websites: * dlfp (Da Linux French Page news website) .br * mediawiki (Wikis running MediaWiki, like Wikipedia) .br * redmine (The Redmine project management web application) .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2011 Clément Schreiner .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/qwebcontentedit weboob-1.1/man/radioob.1000066400000000000000000000167171265717027300151320ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH RADIOOB 1 "11 February 2016" "radioob 1\&.1" .SH NAME radioob \- search, show or listen to radio stations .SH SYNOPSIS .B radioob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B radioob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to search for web radio stations, listen to them and get information like the current song. .SH RADIOOB COMMANDS .TP \fBdownload\fR \fIID\fR [\fIDIRECTORY\fR] .br Download an audio file .TP \fBinfo\fR \fIID\fR .br Get information about a radio or an audio file. .TP \fBplay\fR \fIID\fR [stream\fI_\fRid] .br Play a radio or a audio file with a found player (optionnaly specify the wanted stream). .TP \fBplaylist\fR cmd [args]playlist add ID [ID2 ID3 ...] .br playlist remove ID [ID2 ID3 ...] .br playlist export [FILENAME] .br playlist display .TP \fBsearch\fR (radio|song|file|album|playlist) \fIPATTERN\fR .br List (radio|song|file|album|playlist) matching a PATTERN. .br .br If PATTERN is not given, this command will list all the (radio|song|album|playlist). .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR .br List radios .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (album_tracks_list_info, csv, htmltable, json, json_line, multiline, playlist_tracks_list_info, radio_list, simple, song_list, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon Copyright(C) 2016 Pierre Maziere .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/radioob weboob-1.1/man/shopoob.1000066400000000000000000000170301265717027300151510ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH SHOPOOB 1 "11 February 2016" "shopoob 1\&.1" .SH NAME shopoob \- Obtain details and status of e-commerce orders .SH SYNOPSIS .B shopoob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B shopoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application to obtain details and status of e\-commerce orders. .SS Supported websites: * amazon (Amazon) .br * ideel (Ideel) .br * myhabit (MYHABIT) .br * vicsec (Victoria's Secret) .SH SHOPOOB COMMANDS .TP \fBitems\fR [\fIID\fR] .br Get items of orders. .TP \fBorders\fR [\fIBACKEND_NAME\fR] .br Get orders of a backend. .br If no BACKEND_NAME given, display all orders of all backends. .br .br Default is limited to 10 results. .TP \fBpayments\fR [\fIID\fR] .br Get payments of orders. .br If no ID given, display payment of all backends. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, items, json, json_line, multiline, orders, payments, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2015 Christophe Lampin .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/shopoob weboob-1.1/man/suboob.1000066400000000000000000000223271265717027300147760ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH SUBOOB 1 "11 February 2016" "suboob 1\&.1" .SH NAME suboob \- search and download subtitles .SH SYNOPSIS .B suboob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B suboob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to search for subtitles on various services and download them. .SS Supported websites: * attilasub ("Attila's Website 2.0" French subtitles) .br * opensubtitles (Opensubtitles subtitle website) .br * podnapisi (Podnapisi movies and tv series subtitle website) .br * tvsubtitles (Tvsubtitles subtitle website) .SH SUBOOB COMMANDS .TP \fBdownload\fR \fIID\fR [\fIFILENAME\fR] .br Get the subtitle or archive file. .br FILENAME is where to write the file. If FILENAME is '\-', .br the file is written to stdout. .TP \fBinfo\fR \fIID\fR .br Get information about a subtitle. .TP \fBsearch\fR language [\fIPATTERN\fR] .br Search subtitles. .br .br Language Abbreviation .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br Arabic ar Esperanto eo Irish ga Russian ru .br Afrikaans af Estonian et Italian it Serbian sr .br Albanian sq Filipino tl Japanese ja Slovak sk .br Armenian hy Finnish fi Kannada kn Slovenian sl .br Azerbaijani az French fr Korean ko Spanish es .br Basque eu Galician gl Latin la Swahili sw .br Belarusian be Georgian ka Latvian lv Swedish sv .br Bengali bn German de Lithuanian lt Tamil ta .br Bulgarian bg Greek gr Macedonian mk Telugu te .br Catalan ca Gujarati gu Malay ms Thai th .br Chinese zh Haitian ht Maltese mt Turkish tr .br Croatian hr Hebrew iw Norwegian no Ukrainian uk .br Czech cz Hindi hi Persian fa Urdu ur .br Danish da Hungaric hu Polish pl Vietnamese vi .br Dutch nl Icelandic is Portuguese pt Welsh cy .br English en Indonesian id Romanian ro Yiddish yi .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, subtitle_info, subtitle_list, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2013-2016 Julien Veyssier .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/suboob weboob-1.1/man/translaboob.1000066400000000000000000000220451265717027300160100ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH TRANSLABOOB 1 "11 February 2016" "translaboob 1\&.1" .SH NAME translaboob \- translate text from one language to another .SH SYNOPSIS .B translaboob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B translaboob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application to translate text from one language to another .SS Supported websites: * ebonics (English to Ebonics translation service) .br * googletranslate (Google translation web service) .br * wordreference (Free online translator) .SH TRANSLABOOB COMMANDS .TP \fBtranslate\fR \fIFROM\fR \fITO\fR [\fITEXT\fR] .br Translate from one language to another. .br * FROM : source language .br * TO : destination language .br * TEXT : language to translate, standard input if \- is given .br .br Language Abbreviation .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br Arabic ar Esperanto eo Irish ga Russian ru .br Afrikaans af Estonian et Italian it Serbian sr .br Albanian sq Filipino tl Japanese ja Slovak sk .br Armenian hy Finnish fi Kannada kn Slovenian sl .br Azerbaijani az French fr Korean ko Spanish es .br Basque eu Galician gl Latin la Swahili sw .br Belarusian be Georgian ka Latvian lv Swedish sv .br Bengali bn German de Lithuanian lt Tamil ta .br Bulgarian bg Greek gr Macedonian mk Telugu te .br Catalan ca Gujarati gu Malay ms Thai th .br Chinese zh Haitian ht Maltese mt Turkish tr .br Croatian hr Hebrew iw Norwegian no Ukrainian uk .br Czech cz Hindi hi Persian fa Urdu ur .br Danish da Hungaric hu Polish pl Vietnamese vi .br Dutch nl Icelandic is Portuguese pt Welsh cy .br English en Indonesian id Romanian ro Yiddish yi .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, translation, webkit, xmltrans) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2012-2016 Lucien Loiseau .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/translaboob weboob-1.1/man/traveloob.1000066400000000000000000000202351265717027300154760ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH TRAVELOOB 1 "11 February 2016" "traveloob 1\&.1" .SH NAME traveloob \- search for train stations and departures .SH SYNOPSIS .B traveloob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B traveloob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to search for train stations and get departure times. .SS Supported websites: * blablacar (blablacar website) .br * canaltp (French trains) .br * jvmalin (Multimodal public transportation for whole Région Centre, France) .br * transilien (Public transportation in the Paris area) .br * voyagessncf (Voyages SNCF) .SH TRAVELOOB COMMANDS .TP \fBdepartures\fR \fISTATION\fR [\fIARRIVAL\fR [\fIDATE\fR]]] .br List all departures for a given station. .br The format for the date is "yyyy\-mm\-dd HH:MM" or "HH:MM". .br .br Default is limited to 10 results. .TP \fBroadmap\fR \fIDEPARTURE\fR \fIARRIVAL\fR .br Display the roadmap to travel from DEPARTURE to ARRIVAL. .br .br Command\-line parameters: .br \-\-departure\-time TIME requested departure time .br \-\-arrival\-time TIME requested arrival time .br .br TIME might be in form "yyyy\-mm\-dd HH:MM" or "HH:MM". .br .br Example: .br > roadmap Puteaux Aulnay\-sous\-Bois \-\-arrival\-time 22:00 .TP \fBstations\fR \fIPATTERN\fR .br Search stations. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH TRAVELOOB OPTIONS .TP \fB\-\-departure\-time=DEPARTURE_TIME\fR .TP \fB\-\-arrival\-time=ARRIVAL_TIME\fR .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, departures, htmltable, json, json_line, multiline, simple, stations, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/traveloob weboob-1.1/man/videoob.1000066400000000000000000000221071265717027300151300ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH VIDEOOB 1 "11 February 2016" "videoob 1\&.1" .SH NAME videoob \- search and play videos .SH SYNOPSIS .B videoob [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B videoob [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to search for videos on various websites, play and download them and get information. .SS Supported websites: * allocine (AlloCiné French cinema database service) .br * arretsurimages (arretsurimages website) .br * arte (Arte French and German TV) .br * canalplus (Canal Plus French TV) .br * cappedtv (Capped.tv demoscene website) .br * dailymotion (Dailymotion video streaming website) .br * europarl (Europarl parliamentary video streaming website) .br * francetelevisions (France Télévisions video website) .br * funmooc (France\-Université\-Numérique MOOC website) .br * gdcvault (Game Developers Conferences Vault video streaming website) .br * ina (INA French TV video archives) .br * jacquieetmichel (Jacquie et Michel TV) .br * nolifetv (NolifeTV French video streaming website) .br * quvi (Multi\-website video helper with quvi. Handles Youtube, BBC, and a lot more) .br * rmll (Videos from RMLL) .br * trictractv (TricTrac.tv video website) .br * vimeo (Vimeo video streaming website) .br * vine (vine website) .br * youjizz (YouJizz pornographic video streaming website) .br * youporn (YouPorn pornographic video streaming website) .br * youtube (YouTube video streaming website) .SH VIDEOOB COMMANDS .TP \fBdownload\fR \fIID\fR [\fIFILENAME\fR] .br Download a video .br .br Braces\-enclosed tags are replaced with data fields. Use the 'info' .br command to see what fields are available on a given video. .br .br Example: download KdRRge4XYIo@youtube '{title}.{ext}' .TP \fBinfo\fR \fIID\fR [\fIID\fR2 [...]] .br Get information about a video. .TP \fBnsfw\fR [on | off] .br If argument is given, enable or disable the non\-suitable for work behavior. .br .br If no argument is given, print the current behavior. .TP \fBplay\fR \fIID\fR .br Play a video with a found player. .TP \fBplaylist\fR cmd [args] .br playlist add ID [ID2 ID3 ...] .br playlist remove ID [ID2 ID3 ...] .br playlist export [FILENAME] .br playlist display .br playlist download [PATH] .br playlist play .TP \fBsearch\fR \fIPATTERN\fR .br Search for videos matching a PATTERN. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, video_list, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Christophe Benz, Romain Bignon, John Obbele .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/videoob weboob-1.1/man/webcontentedit.1000066400000000000000000000170171265717027300165230ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH WEBCONTENTEDIT 1 "11 February 2016" "webcontentedit 1\&.1" .SH NAME webcontentedit \- manage websites content .SH SYNOPSIS .B webcontentedit [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B webcontentedit [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to display and edit contents on various websites. .SS Supported websites: * dlfp (Da Linux French Page news website) .br * mediawiki (Wikis running MediaWiki, like Wikipedia) .br * redmine (The Redmine project management web application) .SH WEBCONTENTEDIT COMMANDS .TP \fBedit\fR \fIID\fR [\fIID\fR...] .br Edit a content with $EDITOR, then push it on the website. .TP \fBget\fR \fIID\fR [\-r revision] .br Get page contents .TP \fBlog\fR \fIID\fR .br Display log of a page .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/webcontentedit weboob-1.1/man/weboob-cli.1000066400000000000000000000104361265717027300155250ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH WEBOOB-CLI 1 "11 February 2016" "weboob-cli 1\&.1" .SH NAME weboob-cli \- call a method on backends .SH SYNOPSIS .B weboob\-cli [\-dqv] [\-b \fIbackends\fR] [\-cnfs] \fIcapability\fR \fImethod\fR [\fIarguments\fR..] .br .B weboob\-cli [\-\-help] [\-\-version] .SH DESCRIPTION .LP Weboob\-Cli is a console application to call a specific method on backends which implement the given capability. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/weboob-cli weboob-1.1/man/weboob-config-qt.1000066400000000000000000000067251265717027300166530ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH WEBOOB-CONFIG-QT 1 "17 October 2014" "weboob-config-qt 1\&.0" .SH NAME weboob-config-qt \- manage backends or register new accounts .SH SYNOPSIS .B weboob\-config\-qt [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B weboob\-config\-qt [\-\-help] [\-\-version] .SH DESCRIPTION .LP weboob\-config\-qt is a graphical application to add/edit/remove backends, and to register new website accounts. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2011 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/qweboobcfg weboob-1.1/man/weboob-config.1000066400000000000000000000126241265717027300162240ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH WEBOOB-CONFIG 1 "11 February 2016" "weboob-config 1\&.1" .SH NAME weboob-config \- manage backends or register new accounts .SH SYNOPSIS .B weboob\-config [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B weboob\-config [\-\-help] [\-\-version] .SH DESCRIPTION .LP Weboob\-Config is a console application to add/edit/remove backends, and to register new website accounts. .SH WEBOOB\-CONFIG COMMANDS .TP \fBadd\fR \fIMODULE_NAME\fR [\fIBACKEND_NAME\fR] [\fIPARAMETERS\fR ...] .br Create a backend from a module. By default, if BACKEND_NAME is omitted, .br that's the module name which is used. .br .br You can specify parameters from command line in form "key=value". .TP \fBapplications\fR .br Show applications. .TP \fBconfirm\fR \fIBACKEND\fR .br For a backend which support CapAccount, parse a confirmation mail .br after using the 'register' command to automatically confirm the .br subscribe. .br .br It takes mail from stdin. Use it with postfix for example. .TP \fBdisable\fR \fIBACKEND\fR .br Disable a backend .TP \fBedit\fR \fIBACKEND\fR .br Edit a backend .TP \fBenable\fR \fIBACKEND\fR .br Enable a disabled backend .TP \fBinfo\fR \fINAME\fR .br Display information about a module. .TP \fBlist\fR [\fICAPS\fR ..] .br Show backends. .TP \fBmodules\fR [\fICAPS\fR ...] .br Show available modules. .TP \fBregister\fR \fIMODULE\fR .br Register a new account on a module. .TP \fBremove\fR \fINAME\fR .br Remove a backend. .TP \fBupdate\fR .br Update weboob. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, info_formatter, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Christophe Benz, Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/weboob-config weboob-1.1/man/weboob-debug.1000066400000000000000000000071271265717027300160470ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH WEBOOB-DEBUG 1 "11 February 2016" "weboob-debug 1\&.1" .SH NAME weboob-debug \- debug backends .SH SYNOPSIS .B weboob\-debug [\-h] [\-dqv] [\-b \fIbackends\fR] ... .br .B weboob\-debug [\-\-help] [\-\-version] .SH DESCRIPTION .LP Weboob\-Debug is a console application to debug backends. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH WEBOOB\-DEBUG OPTIONS .TP \fB\-B\fR, \fB\-\-bpython\fR Prefer bpython over ipython .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Christophe Benz .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/weboobdebug weboob-1.1/man/weboob-repos.1000066400000000000000000000121631265717027300161050ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH WEBOOB-REPOS 1 "11 February 2016" "weboob-repos 1\&.1" .SH NAME weboob-repos \- manage a weboob repository .SH SYNOPSIS .B weboob\-repos [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B weboob\-repos [\-\-help] [\-\-version] .SH DESCRIPTION .LP Weboob\-repos is a console application to manage a Weboob Repository. .SH WEBOOB\-REPOS COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBbuild\fR \fISOURCE\fR \fIREPOSITORY\fR .br Build backends contained in SOURCE to REPOSITORY. .br .br Example: .br $ weboob\-repos build $HOME/src/weboob/modules /var/www/updates.weboob.org/0.a/ .TP \fBcreate\fR \fINAME\fR [\fIPATH\fR] .br Create a new repository. If PATH is missing, create repository .br on the current directory. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2012-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/weboob-repos weboob-1.1/man/weboorrents.1000066400000000000000000000173541265717027300160620ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH WEBOORRENTS 1 "11 February 2016" "weboorrents 1\&.1" .SH NAME weboorrents \- search and download torrents .SH SYNOPSIS .B weboorrents [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B weboorrents [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to search for torrents on various trackers and download .torrent files. .SS Supported websites: * btdigg (The BitTorrent DHT search engine.) .br * btmon (BTMon BitTorrent database) .br * gazelle (Gazelle\-based BitTorrent trackers) .br * kickass (Kickass Torrents BitTorrent tracker) .br * piratebay (The Pirate Bay BitTorrent tracker) .br * t411 (T411 BitTorrent tracker) .SH WEBOORRENTS COMMANDS .TP \fBgetfile\fR \fIID\fR [\fIFILENAME\fR] .br Get the .torrent file. .br FILENAME is where to write the file. If FILENAME is '\-', .br the file is written to stdout. .TP \fBinfo\fR \fIID\fR .br Get information about a torrent. .TP \fBsearch\fR [\fIPATTERN\fR] .br Search torrents. .br .br Default is limited to 10 results. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (csv, htmltable, json, json_line, multiline, simple, table, torrent_info, torrent_list, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/weboorrents weboob-1.1/man/wetboobs.1000066400000000000000000000171601265717027300153300ustar00rootroot00000000000000.\" -*- coding: utf-8 -*- .\" This file was generated automatically by tools/make_man.sh. .TH WETBOOBS 1 "11 February 2016" "wetboobs 1\&.1" .SH NAME wetboobs \- display weather and forecasts .SH SYNOPSIS .B wetboobs [\-dqv] [\-b \fIbackends\fR] [\-cnfs] [\fIcommand\fR [\fIarguments\fR..]] .br .B wetboobs [\-\-help] [\-\-version] .SH DESCRIPTION .LP Console application allowing to display weather and forecasts in your city. .SS Supported websites: * ilmatieteenlaitos (Get forecasts from the Ilmatieteenlaitos.fi website) .br * meteofrance (Get forecasts from the MeteoFrance website) .br * weather (Get forecasts from weather.com) .br * yahoo (Yahoo!) .SH WETBOOBS COMMANDS .TP \fBcities\fR \fIPATTERN\fR .br Search cities. .br .br Default is limited to 10 results. .TP \fBcurrent\fR \fICITY_ID\fR .br Get current weather for specified city. Use the 'cities' command to find them. .TP \fBforecasts\fR \fICITY_ID\fR .br Get forecasts for specified city. Use the 'cities' command to find them. .SH WEBOOB COMMANDS .TP \fBbackends\fR [\fIACTION\fR] [\fIBACKEND_NAME\fR]... .br Select used backends. .br .br ACTION is one of the following (default: list): .br * enable enable given backends .br * disable disable given backends .br * only enable given backends and disable the others .br * list list backends .br * add add a backend .br * register register a new account on a website .br * edit edit a backend .br * remove remove a backend .br * list\-modules list modules .TP \fBcd\fR [\fIPATH\fR] .br Follow a path. .br ".." is a special case and goes up one directory. .br "" is a special case and goes home. .TP \fBcondition\fR [\fIEXPRESSION\fR | off] .br If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. .br If the "off" value is given, conditional filtering is disabled. .br .br If no argument is given, print the current condition expression. .TP \fBcount\fR [\fINUMBER\fR | off] .br If an argument is given, set the maximum number of results fetched. .br NUMBER must be at least 1. .br "off" value disables counting, and allows infinite searches. .br .br If no argument is given, print the current count value. .TP \fBformatter\fR [list | \fIFORMATTER\fR [\fICOMMAND\fR] | option \fIOPTION_NAME\fR [on | off]] .br If a FORMATTER is given, set the formatter to use. .br You can add a COMMAND to apply the formatter change only to .br a given command. .br .br If the argument is "list", print the available formatters. .br .br If the argument is "option", set the formatter options. .br Valid options are: header, keys. .br If on/off value is given, set the value of the option. .br If not, print the current value for the option. .br .br If no argument is given, print the current formatter. .TP \fBlogging\fR [\fILEVEL\fR] .br Set logging level. .br .br Availables: debug, info, warning, error. .br * quiet is an alias for error .br * default is an alias for warning .TP \fBls\fR [\-d] [\-\fIU\fR] [\fIPATH\fR] .br List objects in current path. .br If an argument is given, list the specified path. .br Use \-U option to not sort results. It allows you to use a "fast path" to .br return results as soon as possible. .br Use \-d option to display information about a collection (and to not .br display the content of it). It has the same behavior than the well .br know UNIX "ls" command. .br .br Default is limited to 40 results. .TP \fBquit\fR .br Quit the application. .TP \fBselect\fR [\fIFIELD_NAME\fR]... | "$direct" | "$full" .br If an argument is given, set the selected fields. .br $direct selects all fields loaded in one http request. .br $full selects all fields using as much http requests as necessary. .br .br If no argument is given, print the currently selected fields. .SH OPTIONS .TP \fB\-\-version\fR show program's version number and exit .TP \fB\-h\fR, \fB\-\-help\fR show this help message and exit .TP \fB\-b BACKENDS\fR, \fB\-\-backends=BACKENDS\fR what backend(s) to enable (comma separated) .TP \fB\-e EXCLUDE_BACKENDS\fR, \fB\-\-exclude\-backends=EXCLUDE_BACKENDS\fR what backend(s) to exclude (comma separated) .TP \fB\-I\fR, \fB\-\-insecure\fR do not validate SSL .SH LOGGING OPTIONS .TP \fB\-d\fR, \fB\-\-debug\fR display debug messages. Set up it twice to more verbosity .TP \fB\-q\fR, \fB\-\-quiet\fR display only error messages .TP \fB\-v\fR, \fB\-\-verbose\fR display info messages .TP \fB\-\-logging\-file=LOGGING_FILE\fR file to save logs .TP \fB\-a\fR, \fB\-\-save\-responses\fR save every response .SH RESULTS OPTIONS .TP \fB\-c CONDITION\fR, \fB\-\-condition=CONDITION\fR filter result items to display given a boolean expression. See CONDITION section for the syntax .TP \fB\-n COUNT\fR, \fB\-\-count=COUNT\fR limit number of results (from each backends) .TP \fB\-s SELECT\fR, \fB\-\-select=SELECT\fR select result item keys to display (comma separated) .SH FORMATTING OPTIONS .TP \fB\-f FORMATTER\fR, \fB\-\-formatter=FORMATTER\fR select output formatter (cities, csv, current, forecasts, htmltable, json, json_line, multiline, simple, table, webkit) .TP \fB\-\-no\-header\fR do not display header .TP \fB\-\-no\-keys\fR do not display item keys .TP \fB\-O OUTFILE\fR, \fB\-\-outfile=OUTFILE\fR file to export result .SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\fBfield operator value\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \fBgrep\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \fB" AND "\fR, \fB" OR "\fR an \fB" LIMIT "\fR. .LP The \fBLIMIT\fR keyword can be used to limit the number of items upon which running the expression. \fBLIMIT\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions .SH COPYRIGHT Copyright(C) 2010-2016 Romain Bignon .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" .SH SEE ALSO Home page: http://weboob.org/applications/wetboobs weboob-1.1/modules/000077500000000000000000000000001265717027300143125ustar00rootroot00000000000000weboob-1.1/modules/.keys/000077500000000000000000000000001265717027300153435ustar00rootroot00000000000000weboob-1.1/modules/.keys/florent.asc000066400000000000000000000054451265717027300175140ustar00rootroot00000000000000-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2.0.22 (GNU/Linux) mQGiBEZvDQMRBACcSc5xvGE7EnAFonjB9P2U66xk3kL7grVJTvxdiY6ErwaqfRU0 XFSzwTnRoaQQFk//l+ctVaZ/Ex39y9lmivJLF4ME2RghIXTenJqbr6NQfnYIcPbx fKo+SUt91Yf7cei1j22Qz6UdfdFgbllJ/JHcNMA0Qvjn+lLhk+YaB34rswCgqU2p E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AJBGB+5FencPTS1/A4IgiZY9DYzJmw+MG1cPukMJU l356MN2jc15anXp8qFmbsJRuPQME5Km1awZG+jJBoLqLtJoCPORObSq583VlFKVO MHOelAo/y9IDxM4iE165Wi3J+ZQrolcF4ST/p+faeSaHW4pqOCgM5LrGnUF4SKqG ZYPrYMWgyaGZvbOH0Q2PRwdHzHR+mlYSGj/1X/Nx77lWZ29T5WVt4LGwbGFF9Wz4 zQf0ZdhPa1roVnXyUBJCCiukyKmsy02A51iniEkEGBECAAkFAkZvDRMCGwwACgkQ 5Y0WuYomQc7VogCdG/u6WJn2c5TC+VJhOS8J8qhY/a8AoJzT2FNtArRFFeH4hLqx g+aY0iqx =aGSj -----END PGP PUBLIC KEY BLOCK----- weboob-1.1/modules/.keys/laurentb.asc000066400000000000000000000151511265717027300176520ustar00rootroot00000000000000-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2.0.22 (GNU/Linux) mQINBFLlrhYBEAC/oKbgDYYHfH0DJ/y9cb8aoUyvswiGlgDdf13fbCDEHXnrlmVC TvAgxR0/RHiXFzjKntu0lI9aXvFEBJxPIfGzyWswLEUKU8Ewf1W1d6ERfFJ3v7wJ 3A3i0NjZrq2bv7eEd17JtlujNBIp4X4TTnVtCE32GCrn8IMS6d2Yg1nNCSZfgqKu 9Pc5PnGQVOCevFk5Q7yGHHk5AiBe2C8NxaQFOr3zB8Yb3dvnlWW30KeulxsQPHZ9 c+Mlb+sbhz2eV8CAUY07tg9H2rsRUx/mgpqzMTIk+6VF+uiV4sQtBdwnmdrhPKqu 6Ol9YwukFKNbwXaQapT+1SOO2iqYQEuth1oLUgHwgFLo9Yg+ZYX74mRpoJ0CKOaz /sErFc833j1rbpt9+hDI7YqXJ5d46lq/bDfpSNgQcU1iTjcWayUbTzv6g56flatH iizuVDJBtey4Dhol/0Gfrr6VWK3JPPtRgBKXHCe/BQMtVPZMO2mUpC8F/cbnSuCS Ha9igP7NOht4nds9Cm81kkP818SUA/1nkeSNWX4+i+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9BNtghbv6mV4YHwLuWl07esp67U/KDwbOYu3LWw7ELVvhMP4IZy3M PMdyM1b5Epcr1ZXrPrW7kEMIHl2Yle4PSYKQiFbs0q7oOvOk/ImB0Vv+rjBsp6JN MUy88RbS7y26YXPgTjMPkml7+U1lL5t9iu3jESyBXJrqPCCa91vnblPludMad06M +HBCIw9Y0dcGGISOWyPDgisoHYZetGp7pFT/S8kbRgPh0mZATxgAjHhbEhtxOypU o53JveMZiP68R4eEAjnGm3lrtCjXG9PrIJ1HU282ZgOEwLSOL3UEiLPjVNiqRhL+ WiYIN8/1x5QUIGxQT2ZG8i1VVhFazZ99XNQtO3c0XEXvU+k1ExG9go0ktSrDQ4Zt Z4zHxAxyiQEuytdt5vjvOuuWcvhip9Jpq634Fo6X/MJxYqSmg2d6MLRcQb5bc1MM 8WRMTWql46OvSIqSPI0wjLrAndSQ8lDvpybEquVqzHAH8BJpXdvbL2gm3SmOmsUv 9JaJi2hyJnpt+FbzkHZnZ9NM5ggbNPCJ7rn0wgxq9aa90ttPglJWo2O3EMHgfzZK 4z/DGBVlUZ60SgJZxRYIlyqWdVTa9rmxEOImjGNlwk7eEGtjOXCHSAUbJlOLX6vP FHIy6Bn5CTgFpVA= =Rjwq -----END PGP PUBLIC KEY BLOCK----- weboob-1.1/modules/.keys/romain.asc000066400000000000000000000035621265717027300173260ustar00rootroot00000000000000-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2.0.17 (GNU/Linux) mQENBEoOr78BCADAsCwWXDvedstjc9L3YSlXJ6KDd12WVD+iEiVGUqToJkWwp05k uVvvibhNxjDJzZqfWxBvfhFXkf/APF8PoTvkA4l51WOfPGSZejiKMcenij+3HjKa GCPjLlY9rlTUjA5Alw533WP4Wja0EILXy0xjS9eXN2/Vbtrh7sbwU3cs9KOgDjEH dcR/ZgRGrqiLuVd83L2rlyoWZ5KM2KCkMjtpPBFUXOf5pyCV683wd+grdsHzL8Lm MAyVPPCmwrCKdkrG4/xjlBo0Ghjwq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XK1SgIbLwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQ8a5s CGs03G2b6Qf/VjmEs0pBdpg/Ewj7HmikxIQ7lvX5um1YHjLyLNdp6W6wylmzh3u5 dsaajEWmPbUhaDre7gTtxPNJFs6FXksfquUiZySXA45R+XH8Qh/TWJAY8FjdaZwB tgOn4rka+n0rQeG1fklHw4Z3AREm/GmfeA63nkmS5SvdXskAz1iXB20Hyb6bGy5b Y7ZJNhJ8Ocz2THizc2od3Bx8Pzw3DHs+NaW5sK/NJJN9QgpdLA4lo0KeidCALEXF CReDEaT4Cs/Ds3u8QkuR+s+8qN5BOYcIWz79T/hLFw46SezEz9gjJ+NR1nIMd2um bwnyciYEGVOfG4DsU/IRwnbk+HWcLNTFnw== =mTlW -----END PGP PUBLIC KEY BLOCK----- weboob-1.1/modules/750g/000077500000000000000000000000001265717027300147745ustar00rootroot00000000000000weboob-1.1/modules/750g/__init__.py000066400000000000000000000014531265717027300171100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import SevenFiftyGramsModule __all__ = ['SevenFiftyGramsModule'] weboob-1.1/modules/750g/browser.py000066400000000000000000000030221265717027300170260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.exceptions import BrowserHTTPNotFound from weboob.browser import PagesBrowser, URL from .pages import RecipePage, ResultsPage __all__ = ['SevenFiftyGramsBrowser'] class SevenFiftyGramsBrowser(PagesBrowser): BASEURL = 'http://www.750g.com/' search = URL('recettes_(?P.*).htm', ResultsPage) recipe = URL('(?P.*).htm', RecipePage) def iter_recipes(self, pattern): return self.search.go(pattern=pattern.replace(' ', '_')).iter_recipes() def get_recipe(self, id, recipe=None): try: recipe = self.recipe.go(id=id).get_recipe(obj=recipe) comments = list(self.page.get_comments()) if comments: recipe.comments = comments return recipe except BrowserHTTPNotFound: return weboob-1.1/modules/750g/favicon.png000066400000000000000000000026251265717027300171340ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME: <&`MIDATxKEU=Oz(&j' ºAI؋H xp\5K0 b`]!ȒQfg{ʃ5Rhhƙ^# n$EҼۋNr:7C@&+i7LŻNuº ۷늀8%4G'MB*D q!Im4O,SG]䠀G !OdUD2S+܏.aRDHjs=y߯+qUJk~SeW=w>Y.TR)'Qϟ Î}v:RՖ}&~(Vq0"әLC`ol#a B!]xVu7 |MBk`\x4_֚7 1!xlC CfcaY"%{\ Ԛ 7p\UcF@Ek>($eﱁ|iUN(cϷV{מk Ak* y޴f!KOb#jݎSŨr`P\>7,wˋýc ILEڸul&RrK+U7hԞ Rrl.Xk2'1NY;jiy\+,1TY@k&,]wQ)~RZ8dld,)AcF]TCA^z!XҚWPڳZd1 9cg<687)hOsG*AcB.ϸ.3߽)eELR0dTҺ-vx R u͌^К0&%;LjE۞GIkpLzO4. from weboob.capabilities.recipe import CapRecipe, Recipe from weboob.tools.backend import Module from .browser import SevenFiftyGramsBrowser import unicodedata def strip_accents(s): return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn') __all__ = ['SevenFiftyGramsModule'] class SevenFiftyGramsModule(Module, CapRecipe): NAME = '750g' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = u'750g French recipe website' LICENSE = 'AGPLv3+' BROWSER = SevenFiftyGramsBrowser def get_recipe(self, id): return self.browser.get_recipe(id) def iter_recipes(self, pattern): return self.browser.iter_recipes(strip_accents(unicode(pattern)).encode('utf-8')) def fill_recipe(self, recipe, fields): if 'nb_person' in fields or 'instructions' in fields: recipe = self.browser.get_recipe(recipe.id, recipe) return recipe OBJECTS = { Recipe: fill_recipe, } weboob-1.1/modules/750g/pages.py000066400000000000000000000067701265717027300164570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.recipe import Recipe, Comment from weboob.capabilities.base import NotAvailable from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import CleanText, Regexp, Env, Type, Filter from weboob.browser.filters.html import CleanHTML class Time(Filter): def filter(self, el): if el: if 'h' in el: return 60*int(el.split()[0]) return int(el.split()[0]) class ResultsPage(HTMLPage): """ Page which contains results as a list of recipies """ @pagination @method class iter_recipes(ListElement): item_xpath = '//li[@data-type="recette"]' def next_page(self): return CleanText('//li[@class="suivante"]/a/@href')(self) class item(ItemElement): klass = Recipe obj_id = Regexp(CleanText('./div[has-class("text")]/h2/a/@href'), '(.*).htm') obj_title = CleanText('./div[has-class("text")]/h2/a') obj_thumbnail_url = CleanText('./div[has-class("image")]/a/img[1]/@src') obj_short_description = CleanText('./div[has-class("text")]/p') obj_author = CleanText('./div[has-class("text")]/h3[@class="auteur"]/a', default=NotAvailable) class RecipePage(HTMLPage): """ Page which contains a recipe """ @method class get_comments(ListElement): item_xpath = '//section[@class="commentaires_liste"]/article' class item(ItemElement): klass = Comment obj_id = CleanText('./@data-id') obj_author = CleanText('./div[@class="column"]/p[@class="commentaire_info"]/span') obj_text = CleanText('./div[@class="column"]/p[1]') @method class get_recipe(ItemElement): klass = Recipe obj_id = Env('id') obj_title = CleanText('//h1[@class="fn"]') def obj_ingredients(self): ingredients = [] for el in self.page.doc.xpath('//section[has-class("recette_ingredients")]/ul/li'): ingredients.append(CleanText('.')(el)) return ingredients obj_cooking_time = Time(CleanText('//span[@class="cooktime"]')) obj_preparation_time = Time(CleanText('//span[@class="preptime"]')) def obj_nb_person(self): return [Type(CleanText('//span[@class="yield"]'), type=int, default=0)(self)] obj_instructions = CleanHTML('//article[@class="recette_etape"]/h3|//article[@class="recette_etape"]/div[@class="recette_etape_texte"]/*[not(self::article)]') obj_picture_url = CleanText('//section[has-class("recette_infos")]/div/img[@class="photo"]/@src') obj_author = CleanText('//span[@class="author"]', default=NotAvailable) weboob-1.1/modules/750g/test.py000066400000000000000000000023161265717027300163270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest import itertools class SevenFiftyGramsTest(BackendTest): MODULE = '750g' def test_recipe(self): recipes = list(itertools.islice(self.backend.iter_recipes('fondue'), 0, 20)) for recipe in recipes: full_recipe = self.backend.get_recipe(recipe.id) assert full_recipe.instructions assert full_recipe.ingredients assert full_recipe.title assert full_recipe.preparation_time weboob-1.1/modules/adecco/000077500000000000000000000000001265717027300155305ustar00rootroot00000000000000weboob-1.1/modules/adecco/__init__.py000066400000000000000000000014321265717027300176410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AdeccoModule __all__ = ['AdeccoModule'] weboob-1.1/modules/adecco/browser.py000066400000000000000000000042051265717027300175660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import SearchPage, AdvertPage import urllib __all__ = ['AdeccoBrowser'] class AdeccoBrowser(PagesBrowser): BASEURL = 'http://www.adecco.fr/' search_page = URL('trouver-un-emploi/Pages/Offres-d-emploi.aspx\?(?P.*)', SearchPage) advert_page = URL('trouver-un-emploi/Pages/Details-de-l-Offre/(?P.*)/(?P.*).aspx\?IOF=(?P.*)', AdvertPage) def search_job(self, pattern=None): query = {'keywords': urllib.quote_plus(pattern)} return self.search_page.go(query=urllib.urlencode(query)).iter_job_adverts() def advanced_search_job(self, publication_date=None, contract_type=None, conty=None, region=None, job_category=None, activity_domain=None): data = { 'publicationDate': publication_date, 'department': conty, 'region': region, 'jobCategory': job_category, 'activityDomain': activity_domain, 'contractTypes': contract_type, } return self.search_page.go(query=urllib.urlencode(data)).iter_job_adverts() def get_job_advert(self, _id, advert): splitted_id = _id.split('/') return self.advert_page.go(part1=splitted_id[0], part2=splitted_id[1], part3=splitted_id[2]).get_job_advert(obj=advert) weboob-1.1/modules/adecco/favicon.png000066400000000000000000000121561265717027300176700ustar00rootroot00000000000000PNG  IHDR??W_sBIT|d pHYsodIDAThu?]ξq8!93$EVuMb;I  p/]~H]@ @"hpM)R$K%"M-&%qrf8Y{Iy9{gyF\ ܢ"oU VoU VoU VoU7d(a8SzJN޸RSD{ 2%TL#@A^X!1ey_җL \cmJƕ0Q(ډޔB^(8Qf<.*| 4//}OO{ RǗ\GTJiT KOʵL<+o$\ORO^ ''rN"3ʇePj(Q(=*XP! }oflVsisZC|Q-JoE8N.Y^^B/Rҗ9@pN7-X8PE 2peVK'$'JGtUdQ7T(}>P&$s3Qբ]JY2ܤ'Y}'`E% hڿ;='=9 \/`FKVB+;S@lNJ&+~xgXt^2l0V[^C'J֞\ԵRr 1KE=үt22"/KA+W/ Jo҇ zMIJ@74KuDNP+#eYzͨ-]#p!īlV\dB@RHI$]#ي%m#ɥDv,Q޳B"Cw)2@{ :1xt˭'D^MGUWBK\*:=~tڣD,=+''˞`-%7`F8YV`A фE,"hڌ M*LS [Vj\ ֤@ 5}BrI+fsȊAc2Oj0B@P^H($Ж"F;BDYF#cBDlİ:V ;ws뱢i e M"Ӭus< qqܱ#1RD;Z\& DU0RNDJRkE;"9"xr&FF < '62hyϖwlYK:LRAA;677R"PZCȮQʪsKh ؐFCMb`u"F^csA-yhd*NQ!JÕ+K(&3db41tàj) JF7MQUjBhY*sPuj}hG "j}$hSCMȡޏcjeT:!T£0~+1Nwo`8wJh UL N]J"b=^j^D73⤆r^d!58#VrRKEzJYU6i5ym18.HYVI֔H9orq `ӱL /H_  g".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Z5&huVFC&=hW+}P(RĊv"(fƠzK%FH" }F&]QZ#}@ @ A!!r+56-znc*UYRUZ` ") lNyJU2 ɕ T"@: 0{Ԃc"|NW \ RG!"<jBWx1'K2!BzAɄ.Z5! 0Std0B"R HYq_"F!-" i4Z(8BYP"#C{pSDlѐ$J ((ʬH*QdF(ExBs-"#Gr-}@RP1n(f .4mNb=P!Ѵ KEk`!/0J9(Plg&@lȔ#sPD^ (:BiM5k-}ReL&%1<R"C.-d^ .҄pB+U%[  E93V,/qTHc xF@zG,iQ9M-QoR,f%%Q婉a*1Nl(0B$q [hysvDZa2Oq"Z U(P%)8&BA MZ#wK,8 j(9(DA[ 9uDJ Ky|,,( H8)pJ ňommm- &- umIENDB`weboob-1.1/modules/adecco/module.py000066400000000000000000000411311265717027300173670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import Value from weboob.capabilities.job import CapJob, BaseJobAdvert from .browser import AdeccoBrowser __all__ = ['AdeccoModule'] class AdeccoModule(Module, CapJob): NAME = 'adecco' DESCRIPTION = u'adecco website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' VERSION = '1.1' BROWSER = AdeccoBrowser publicationDate_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '000000': u'-- Indifférent --', '1': u'Moins de 48 heures', '2': u'Moins de 1 semaine', '4': u'Moins de 2 semaines', '3': u'Moins de 5 semaines', }.iteritems())]) type_contract_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '000000': u'--Indifferent--', '1': u'CDD', '2': u'CDI', '3': u'Intérim', '4': u'Emploi formation', '5': u'Emploi saisonnier', '6': u'Stage', '7': u'Autre', }.iteritems())]) places_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '100|REGION_0|DEPARTEMENT_0': u'--Indifferent--', '101|REGION_1': u'Alsace', '102|REGION_1|DEPARTEMENT_1': u'-- Rhin (Bas) (67)', '103|REGION_1|DEPARTEMENT_2': u'-- Rhin (Haut) (68)', '104|REGION_2': u'Aquitaine', '105|REGION_2|DEPARTEMENT_3': u'-- Dordogne (24)', '106|REGION_2|DEPARTEMENT_4': u'-- Gironde (33)', '107|REGION_2|DEPARTEMENT_5': u'-- Landes (40)', '108|REGION_2|DEPARTEMENT_6': u'-- Lot et Garonne (47)', '109|REGION_2|DEPARTEMENT_7': u'-- Pyrénées Atlantiques (64)', '110|REGION_3': u'Auvergne', '111|REGION_3|DEPARTEMENT_8': u'-- Allier (03)', '112|REGION_3|DEPARTEMENT_9': u'-- Cantal (15)', '113|REGION_3|DEPARTEMENT_10': u'-- Loire (Haute) (43)', '114|REGION_3|DEPARTEMENT_11': u'-- Puy de Dôme (63)', '115|REGION_5': u'Bourgogne', '116|REGION_5|DEPARTEMENT_15': u'-- Côte d\'Or (21)', '117|REGION_5|DEPARTEMENT_16': u'-- Nièvre (58)', '118|REGION_5|DEPARTEMENT_17': u'-- Saône et Loire (71)', '119|REGION_5|DEPARTEMENT_18': u'-- Yonne (89)', '120|REGION_6': u'Bretagne', '121|REGION_6|DEPARTEMENT_19': u'-- Côtes d\'Armor (22)', '122|REGION_6|DEPARTEMENT_20': u'-- Finistère (29)', '123|REGION_6|DEPARTEMENT_21': u'-- Ille et Vilaine (35)', '124|REGION_6|DEPARTEMENT_22': u'-- Morbihan (56)', '125|REGION_7': u'Centre', '126|REGION_7|DEPARTEMENT_23': u'-- Cher (18)', '127|REGION_7|DEPARTEMENT_24': u'-- Eure et Loir (28)', '128|REGION_7|DEPARTEMENT_25': u'-- Indre (36)', '129|REGION_7|DEPARTEMENT_26': u'-- Indre et Loire (37)', '130|REGION_7|DEPARTEMENT_27': u'-- Loir et Cher (41)', '131|REGION_7|DEPARTEMENT_28': u'-- Loiret (45)', '132|REGION_8': u'Champagne Ardenne', '133|REGION_8|DEPARTEMENT_29': u'-- Ardennes (08)', '134|REGION_8|DEPARTEMENT_30': u'-- Aube (10)', '135|REGION_8|DEPARTEMENT_31': u'-- Marne (51)', '136|REGION_8|DEPARTEMENT_32': u'-- Marne (Haute) (52)', '137|REGION_9': u'Corse', '138|REGION_9|DEPARTEMENT_33': u'-- Corse du Sud (2A)', '139|REGION_9|DEPARTEMENT_34': u'-- Haute Corse (2B)', '140|REGION_11': u'Franche Comté', '141|REGION_11|DEPARTEMENT_43': u'-- Belfort (Territoire de) (90)', '142|REGION_11|DEPARTEMENT_40': u'-- Doubs (25)', '143|REGION_11|DEPARTEMENT_41': u'-- Jura (39)', '144|REGION_11|DEPARTEMENT_42': u'-- Saône (Haute) (70)', '145|REGION_13': u'Ile de France', '146|REGION_13|DEPARTEMENT_49': u'-- Essonne (91)', '147|REGION_13|DEPARTEMENT_50': u'-- Hauts de Seine (92)', '148|REGION_13|DEPARTEMENT_46': u'-- Paris (Dept.) (75)', '149|REGION_13|DEPARTEMENT_51': u'-- Seine Saint Denis (93)', '150|REGION_13|DEPARTEMENT_47': u'-- Seine et Marne (77)', '151|REGION_13|DEPARTEMENT_53': u'-- Val d\'Oise (95)', '152|REGION_13|DEPARTEMENT_52': u'-- Val de Marne (94)', '153|REGION_13|DEPARTEMENT_48': u'-- Yvelines (78)', '154|REGION_14': u'Languedoc Roussillon', '155|REGION_14|DEPARTEMENT_54': u'-- Aude (11)', '156|REGION_14|DEPARTEMENT_55': u'-- Gard (30)', '157|REGION_14|DEPARTEMENT_56': u'-- Hérault (34)', '158|REGION_14|DEPARTEMENT_57': u'-- Lozère (48)', '159|REGION_14|DEPARTEMENT_58': u'-- Pyrénées Orientales (66)', '160|REGION_15': u'Limousin', '161|REGION_15|DEPARTEMENT_59': u'-- Corrèze (19)', '162|REGION_15|DEPARTEMENT_60': u'-- Creuse (23)', '163|REGION_15|DEPARTEMENT_61': u'-- Vienne (Haute) (87)', '164|REGION_16': u'Lorraine', '165|REGION_16|DEPARTEMENT_62': u'-- Meurthe et Moselle (54)', '166|REGION_16|DEPARTEMENT_63': u'-- Meuse (55)', '167|REGION_16|DEPARTEMENT_64': u'-- Moselle (57)', '168|REGION_16|DEPARTEMENT_65': u'-- Vosges (88)', '169|REGION_17': u'Midi Pyrénées', '170|REGION_17|DEPARTEMENT_66': u'-- Ariège (09)', '171|REGION_17|DEPARTEMENT_67': u'-- Aveyron (12)', '172|REGION_17|DEPARTEMENT_68': u'-- Garonne (Haute) (31)', '173|REGION_17|DEPARTEMENT_69': u'-- Gers (32)', '174|REGION_17|DEPARTEMENT_70': u'-- Lot (46)', '175|REGION_17|DEPARTEMENT_71': u'-- Pyrénées (Hautes) (65)', '176|REGION_17|DEPARTEMENT_72': u'-- Tarn (81)', '177|REGION_17|DEPARTEMENT_73': u'-- Tarn et Garonne (82)', '178|REGION_18': u'Nord Pas de Calais', '179|REGION_18|DEPARTEMENT_74': u'-- Nord (59)', '180|REGION_18|DEPARTEMENT_75': u'-- Pas de Calais (62)', '181|REGION_4': u'Normandie (Basse)', '182|REGION_4|DEPARTEMENT_12': u'-- Calvados (14)', '183|REGION_4|DEPARTEMENT_13': u'-- Manche (50)', '184|REGION_4|DEPARTEMENT_14': u'-- Orne (61)', '185|REGION_12': u'Normandie (Haute)', '186|REGION_12|DEPARTEMENT_44': u'-- Eure (27)', '187|REGION_12|DEPARTEMENT_47': u'-- Seine Maritime (76)', '188|REGION_19': u'Pays de la Loire', '189|REGION_19|DEPARTEMENT_76': u'-- Loire Atlantique (44)', '190|REGION_19|DEPARTEMENT_77': u'-- Maine et Loire (49)', '191|REGION_19|DEPARTEMENT_78': u'-- Mayenne (53)', '192|REGION_19|DEPARTEMENT_79': u'-- Sarthe (72)', '193|REGION_19|DEPARTEMENT_80': u'-- Vendée (85)', '194|REGION_20': u'Picardie', '195|REGION_20|DEPARTEMENT_81': u'-- Aisne (02)', '196|REGION_20|DEPARTEMENT_83': u'-- Oise (60)', '197|REGION_20|DEPARTEMENT_84': u'-- Somme (80)', '198|REGION_21': u'Poitou Charentes', '199|REGION_21|DEPARTEMENT_85': u'-- Charente (16)', '200|REGION_21|DEPARTEMENT_86': u'-- Charente Maritime (17)', '201|REGION_21|DEPARTEMENT_87': u'-- Sèvres (Deux) (79)', '202|REGION_21|DEPARTEMENT_88': u'-- Vienne (86)', '203|REGION_22': u'Provence Alpes Côte d\'Azur', '204|REGION_22|DEPARTEMENT_90': u'-- Alpes (Hautes) (05)', '205|REGION_22|DEPARTEMENT_91': u'-- Alpes Maritimes (06)', '206|REGION_22|DEPARTEMENT_89': u'-- Alpes de Haute Provence (04)', '207|REGION_22|DEPARTEMENT_92': u'-- Bouches du Rhône (13)', '208|REGION_22|DEPARTEMENT_93': u'-- Var (83)', '209|REGION_22|DEPARTEMENT_94': u'-- Vaucluse (84)', '210|REGION_23': u'Rhône Alpes', '211|REGION_23|DEPARTEMENT_95': u'-- Ain (01)', '212|REGION_23|DEPARTEMENT_96': u'-- Ardèche (07)', '213|REGION_23|DEPARTEMENT_97': u'-- Drôme (26)', '214|REGION_23|DEPARTEMENT_98': u'-- Isère (38)', '215|REGION_23|DEPARTEMENT_99': u'-- Loire (42)', '216|REGION_23|DEPARTEMENT_100': u'-- Rhône (69)', '217|REGION_23|DEPARTEMENT_101': u'-- Savoie (73)', '218|REGION_23|DEPARTEMENT_102': u'-- Savoie (Haute) (74)', '219|REGION_10': u'DOM TOM', '220|REGION_10|DEPARTEMENT_35': u'-- Guadeloupe (971)', '221|REGION_10|DEPARTEMENT_37': u'-- Guyane (973)', '222|REGION_10|DEPARTEMENT_38': u'-- La Réunion (974)', '223|REGION_10|DEPARTEMENT_36': u'-- Martinique (972)', '224|REGION_10|DEPARTEMENT_108': u'-- Mayotte (976)', '225|REGION_10|DEPARTEMENT_109': u'-- Nouvelle Calédonie (988)', '226|REGION_10|DEPARTEMENT_108': u'-- Polynésie (987)', '227|REGION_10|DEPARTEMENT_107': u'-- Saint Pierre et Miquelon (975)', '228|REGION_24': u'International', '229|REGION_24|DEPARTEMENT_104': u'-- Andorre', '230|REGION_24|DEPARTEMENT_105': u'-- Monaco', '231|REGION_24|DEPARTEMENT_106': u'-- Suisse', }.iteritems())]) activityDomain_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '100|DOMAIN_0': u'Tous domaines d\'activité', '101|DOMAIN_1': u'Accueil - Secrétariat - Fonctions Administratives', '102|DOMAIN_1|ACTIVITY_1': u'-- Accueil', '103|DOMAIN_1|ACTIVITY_2': u'-- Secrétariat - Assistanat', '104|DOMAIN_1|ACTIVITY_3': u'-- Autres Fonctions Administratives', '105|DOMAIN_2': u'Achats - Juridique - Qualité - RH - Direction', '106|DOMAIN_2|ACTIVITY_4': u'-- Achats ', '107|DOMAIN_2|ACTIVITY_5': u'-- Juridique', '108|DOMAIN_2|ACTIVITY_6': u'-- Qualité', '109|DOMAIN_2|ACTIVITY_7': u'Ressources Humaines - Formation', '110|DOMAIN_2|ACTIVITY_8': u'-- Direction Générale', '111|DOMAIN_3': u'Agriculture - Viticulture - Pêche - Espaces Verts', '112|DOMAIN_3|ACTIVITY_9': u'-- Agriculture - Viticulture - Pêche ', '113|DOMAIN_3|ACTIVITY_10': u'-- Espaces Verts - Exploitation Forestière', '114|DOMAIN_4': u'Automobile', '115|DOMAIN_5': u'Banque - Finance - Gestion Comptabilité - Assurance', '116|DOMAIN_5|ACTIVITY_11': u'-- Banque - Finance ', '117|DOMAIN_5|ACTIVITY_12': u'-- Gestion - Comptabilité', '118|DOMAIN_5|ACTIVITY_13': u'-- Assurance', '119|DOMAIN_6': u'Bâtiment - Travaux Publics - Architecture - Immobilier', '120|DOMAIN_6|ACTIVITY_14': u'-- Bâtiment - Travaux Publics', '121|DOMAIN_6|ACTIVITY_15': u'-- Architecture - Immobilier ', '122|DOMAIN_13': u'Bureaux d\'Etudes - Méthodes', '123|DOMAIN_8': u'Commerce - Vente - Grande Distribution', '124|DOMAIN_8|ACTIVITY_20': u'-- Commerce - Vente', '125|DOMAIN_8|ACTIVITY_21': u'-- Grande et Moyenne Distribution', '126|DOMAIN_9': u'Environnement - Nettoyage - Sécurité', '127|DOMAIN_9|ACTIVITY_22': u'-- Environnement - HSE - Développement durable', '128|DOMAIN_9|ACTIVITY_23': u'-- Nettoyage - Assainissement - Pressing', '129|DOMAIN_9|ACTIVITY_24': u'-- Sécurité - Premiers secours', '130|DOMAIN_10': u'Hôtellerie - Restauration - Métiers de Bouche', '131|DOMAIN_10|ACTIVITY_25': u'-- Hôtellerie', '132|DOMAIN_10|ACTIVITY_27': u'-- Métiers de bouche', '133|DOMAIN_10|ACTIVITY_26': u'-- Restauration', '134|DOMAIN_11': u'Industrie', '135|DOMAIN_11|ACTIVITY_32': u'-- Aéronautique - Navale', '136|DOMAIN_11|ACTIVITY_33': u'-- Agroalimentaire', '137|DOMAIN_11|ACTIVITY_58': u'-- Chimie - Pétrochimie', '138|DOMAIN_11|ACTIVITY_28': u'-- Electricité - Electronique - Automatisme', '139|DOMAIN_11|ACTIVITY_29': u'-- Maintenance - Entretien - SAV ', '140|DOMAIN_11|ACTIVITY_30': u'-- Mécanique Générale', '141|DOMAIN_11|ACTIVITY_31': u'-- Production - Fabrication ', '142|DOMAIN_11|ACTIVITY_36': u'-- Sidérurgie - Métallurgie - Tuyauterie - Soudure', '143|DOMAIN_11|ACTIVITY_34': u'-- Nucléaire - Production d\'énergie', '144|DOMAIN_11|ACTIVITY_35': u'-- Plasturgie - Bois - Papier - Verre - Cuir - Textile', '145|DOMAIN_12': u'Informatique - Technologie de l\'Information', '146|DOMAIN_12|ACTIVITY_37': u'-- Direction informatique encadrement', '147|DOMAIN_12|ACTIVITY_38': u'-- Etude et développement', '148|DOMAIN_12|ACTIVITY_39': u'-- Exploitation, maintenance et support ', '149|DOMAIN_12|ACTIVITY_40': u'-- Systèmes et réseaux informatique et télécom', '150|DOMAIN_14': u'Logistique - Manutention - Transport', '151|DOMAIN_14|ACTIVITY_42': u'-- Conduite de véhicule', '152|DOMAIN_14|ACTIVITY_43': u'-- Exploitation de logistique - supply chain', '153|DOMAIN_14|ACTIVITY_44': u'-- Manutention', '154|DOMAIN_14|ACTIVITY_45': u'-- Transport', '155|DOMAIN_15': u'Marketing - Communication - Imprimerie - Edition', '156|DOMAIN_15|ACTIVITY_47': u'-- Imprimerie - Edition - Arts Graphiques', '157|DOMAIN_15|ACTIVITY_46': u'-- Marketing - Communication - Medias', '158|DOMAIN_16': u'Médical - Paramédical - Esthétique', '159|DOMAIN_16|ACTIVITY_59': u'-- Commerce Appareillage', '160|DOMAIN_16|ACTIVITY_50': u'-- Directions, Cadres et Enseignement', '161|DOMAIN_16|ACTIVITY_49': u'-- Rééducation, Radiologie, Appareillage, LAM', '162|DOMAIN_16|ACTIVITY_51': u'-- Secrétariat, Dentaire, Social, Esthétique et Autres', '163|DOMAIN_16|ACTIVITY_48': u'-- Soignants - Auxiliaires', '164|DOMAIN_7': u'Pharmacie (Industrie, Officine) - Recherche clinique', '165|DOMAIN_7|ACTIVITY_16': u'-- Industrie Pharmaceutique / Cosmétologique - Biotech', '166|DOMAIN_7|ACTIVITY_17': u'-- Recherche Clinique', '167|DOMAIN_7|ACTIVITY_18': u'-- Pharmacie Officine / Hospit / Para-pharmacie', '168|DOMAIN_7|ACTIVITY_19': u'-- Vente, information et promotion du médicament', '169|DOMAIN_17': u'Télémarketing - Téléservices', '170|DOMAIN_17|ACTIVITY_52': u'-- Téléconseil - Télévente - Autres', '171|DOMAIN_17|ACTIVITY_53': u'-- Direction, Encadrement', '172|DOMAIN_18': u'Tourisme - Loisirs - Spectacle - Audiovisuel', '173|DOMAIN_18|ACTIVITY_54': u'-- Tourisme - Loisirs', '174|DOMAIN_18|ACTIVITY_55': u'-- Spectacle - Audiovisuel', }.iteritems())]) CONFIG = BackendConfig(Value('publication_date', label=u'Publication Date', choices=publicationDate_choices), Value('place', label=u'Place', choices=places_choices), Value('contract', labe=u'Contract type', choices=type_contract_choices), Value('activity_domain', label=u'Activity Domain', choices=activityDomain_choices), ) def search_job(self, pattern=None): for advert in self.browser.search_job(pattern): yield advert def decode_choice(self, place): splitted_choice = place.split('|') part1 = splitted_choice[1].split('_')[1] if len(splitted_choice) == 3: part2 = splitted_choice[2].split('_')[1] return part1, part2 else: return part1, 0 def advanced_search_job(self): region, departement = self.decode_choice(self.config['place'].get()) domain, category = self.decode_choice(self.config['activity_domain'].get()) for advert in self.browser.advanced_search_job(publication_date=int(self.config['publication_date'].get()), contract_type=int(self.config['contract'].get()), conty=departement, region=region, job_category=category, activity_domain=domain ): yield advert def get_job_advert(self, _id, advert=None): return self.browser.get_job_advert(_id, advert) def fill_obj(self, advert, fields): return self.get_job_advert(advert.id, advert) OBJECTS = {BaseJobAdvert: fill_obj} weboob-1.1/modules/adecco/pages.py000066400000000000000000000061651265717027300172110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import CleanText, Regexp, DateTime from weboob.browser.filters.html import CleanHTML from weboob.capabilities.job import BaseJobAdvert from weboob.tools.date import DATE_TRANSLATE_FR class SearchPage(HTMLPage): @pagination @method class iter_job_adverts(ListElement): item_xpath = '//div[has-class("resultContain")]' def next_page(self): next_page = CleanText('(//a[@class="next enabled"])[1]/@href', default=None)(self) if next_page: return next_page class item(ItemElement): klass = BaseJobAdvert def validate(self, obj): return obj.id obj_id = Regexp(CleanText('./div/h3/a/@href'), 'http://www.adecco.fr/trouver-un-emploi/Pages/Details-de-l-Offre/(.*)/(.*)\.aspx\?IOF=(.*)', '\\1/\\2/\\3', default=None) obj_title = CleanText('./div/h3/a') obj_place = CleanText('./div/h3/span[@class="offreLocalisation"]') obj_publication_date = DateTime(Regexp(CleanText('./div/span[@class="offreDatePublication"]'), u'Publiée le (.*)'), translations=DATE_TRANSLATE_FR) class AdvertPage(HTMLPage): @method class get_job_advert(ItemElement): klass = BaseJobAdvert obj_id = Regexp(CleanText('//meta[@property="og:url"]/@content'), 'http://www.adecco.fr/trouver-un-emploi/Pages/Details-de-l-Offre/(.*)/(.*)\.aspx\?IOF=(.*)', '\\1/\\2/\\3', default=None) obj_title = CleanText('//span[@class="titleContainer"]') obj_place = CleanText('//div[@class="jobGreyContain"]/div/div[1]/span[@class="value"]') obj_contract_type = CleanText('//div[@class="jobGreyContain"]/div/div[2]/span[@class="value"]') obj_pay = CleanText('//div[@class="jobGreyContain"]/div/div[4]/span[@class="value"]') obj_job_name = CleanText('//span[@class="titleContainer"]') obj_description = CleanHTML('//p[@itemprop="responsibilities"]') obj_url = CleanText('//meta[@property="og:url"]/@content') weboob-1.1/modules/adecco/test.py000066400000000000000000000025561265717027300170710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class AdeccoTest(BackendTest): MODULE = 'adecco' def test_adecco_search(self): l = list(self.backend.search_job(u'valet de chambre')) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) def test_adecco_advanced_search(self): l = list(self.backend.advanced_search_job()) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) weboob-1.1/modules/agendaculturel/000077500000000000000000000000001265717027300173115ustar00rootroot00000000000000weboob-1.1/modules/agendaculturel/__init__.py000066400000000000000000000014521265717027300214240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AgendaculturelModule __all__ = ['AgendaculturelModule'] weboob-1.1/modules/agendaculturel/browser.py000066400000000000000000000041371265717027300213530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import BasePage from urlparse import urlparse import re class AgendaculturelBrowser(PagesBrowser): BASEURL = '' base = URL('http://www.agendaculturel.fr/search_bw', 'http://(?P\d{2}).agendaculturel.fr/(?P<_id>.*).html', 'http://\d{2}.agendaculturel.fr/.*', BasePage) def __init__(self, place, *args, **kwargs): self.default_place = place PagesBrowser.__init__(self, *args, **kwargs) def set_base_url(self, place): if not place: place = self.default_place self.base.go(data={'query': place}) parsed_uri = urlparse(self.page.url) self.BASEURL = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_uri) def list_events(self, place, date_from, date_to, categories=None): self.set_base_url(place) query_date_from = date_from.strftime('%Y%m') self.page.search_events(query_date_from) region = re.match('http://(\d{2}).agendaculturel.fr/.*', self.page.url).group(1) return self.page.list_events(region=region, date_from=date_from, date_to=date_to, categories=categories) def get_event(self, id, event=None): splitted_id = id.split('.') region = splitted_id[0] _id = splitted_id[1] return self.base.go(_id=_id, region=region).get_event(obj=event) weboob-1.1/modules/agendaculturel/calendar.py000066400000000000000000000020451265717027300214350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS class AgendaculturelEvent(BaseCalendarEvent): def __init__(self): BaseCalendarEvent.__init__(self) self.sequence = 1 self.transp = TRANSP.TRANSPARENT self.status = STATUS.CONFIRMED self.timezone = u'Europe/Paris' weboob-1.1/modules/agendaculturel/favicon.png000077500000000000000000000253561265717027300214620ustar00rootroot00000000000000PNG  IHDR<<:rsRGBgAMA a pHYs B4*IDAThCuwxW}sdqwƞlrƀ1&9`2H" %r4EB(,r: (>2'EwݫvڵK?}` +F3Zz.]֥N]#hyN}t[CwG0@ot]~iwm#WSK}_7zvMG_Mƻl=yw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zM>PX\@VVٙWQNNKY2H*?M?O]~npkE+jNQaJ T#"i^Kߩn$8BCj6HO@Jp*|DgCoٜ8uu0f<Ḹ"^EHH9 khd2Y񄬡G"lv}fFJ6ȧŬO,Ȕb !6.HqV$hHJSA979O Īp7(ijlwC4W 4֫}Ǥ}ramHP8WӦPҥ5g}c$m*")"ܨR) ^4ZR]FRfq 20C" J8<߷"5M*7C$ˬD+++Dj ??iFf A >в~zcu6_K{UZMuB5U-Jz)^I>оq\Zf4HMƱj@TeW9,mf JVTkjTK)W5ݜluSZ0Ͳ&Zd16+Q 9HvgIENDB`weboob-1.1/modules/agendaculturel/module.py000066400000000000000000000043721265717027300211560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES from .browser import AgendaculturelBrowser from .calendar import AgendaculturelEvent __all__ = ['AgendaculturelModule'] class AgendaculturelModule(Module, CapCalendarEvent): NAME = 'agendaculturel' DESCRIPTION = u'agendaculturel website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' ASSOCIATED_CATEGORIES = [CATEGORIES.CONCERT, CATEGORIES.THEATRE, CATEGORIES.EXPO, CATEGORIES.AUTRE, CATEGORIES.FEST] BROWSER = AgendaculturelBrowser CONFIG = BackendConfig(Value('place', label='Default place')) def create_default_browser(self): return self.create_browser(self.config['place'].get()) def get_event(self, _id): return self.browser.get_event(_id) def list_events(self, date_from, date_to=None): default_place = self.config['place'].get() return self.browser.list_events(default_place, date_from, date_to) def search_events(self, query): if self.has_matching_categories(query): return self.browser.list_events(query.city, query.start_date, query.end_date, query.categories) def fill_obj(self, event, fields): return self.browser.get_event(event.id, event) OBJECTS = {AgendaculturelEvent: fill_obj} weboob-1.1/modules/agendaculturel/pages.py000066400000000000000000000132241265717027300207640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import CleanText, Date, Regexp, Filter, Env, Format, Decode, Time, Type from weboob.browser.filters.html import CleanHTML, XPath from weboob.browser.filters.json import Dict from weboob.capabilities.calendar import CATEGORIES from .calendar import AgendaculturelEvent from datetime import datetime, time class AgendaculturelCategory(Filter): def filter(self, text): if text == u'MusicEvent': return CATEGORIES.CONCERT elif text == u'TheaterEvent': return CATEGORIES.THEATRE elif text == u'VisuelArtsEvent': return CATEGORIES.EXPO elif text == u'Festival': return CATEGORIES.FEST else: return CATEGORIES.AUTRE class AgendaculturelDate(Filter): def filter(self, text): return datetime.strptime(text, "%Y-%m-%d") class BasePage(HTMLPage): def search_events(self, query_date_from): form = self.get_form(nr=0) form['search_month'] = query_date_from form.submit() @method class get_event(ItemElement): klass = AgendaculturelEvent def parse(self, el): _json = CleanText('.')(XPath('//script[@type="application/ld+json"][1]')(el)[0]) try: from weboob.tools.json import json self.env['_json'] = json.loads(_json) except ValueError: self.env['_json'] = {} def validate(self, obj): return self.env['_json'] obj_id = Format('%s.%s', Env('region'), Decode(Env('_id'))) obj_summary = CleanText('//h1') def obj_description(self): desc = CleanHTML('//div[@class="description"]')(self) if not desc: desc = CleanText('//meta[@name="description"]/@content')(self) return desc def obj_start_date(self): if not self.env['_json']: return _time = Time(CleanText('//div[@class="hours"]'), default=None)(self) if not _time: _time = time.min date = AgendaculturelDate(Dict('startDate'))(self.env['_json']) return datetime.combine(date, _time) def obj_end_date(self): if not self.env['_json']: return date = AgendaculturelDate(Dict('endDate'))(self.env['_json']) return datetime.combine(date, time.max) def obj_url(self): if not self.env['_json']: return return Dict('url')(self.env['_json']) def obj_city(self): if not self.env['_json']: return return Dict('location/address/addressLocality')(self.env['_json']) def obj_category(self): if not self.env['_json']: return return AgendaculturelCategory(Dict('@type'))(self.env['_json']) def obj_location(self): if not self.env['_json']: return return Format('%s, %s', Dict('location/name'), Dict('location/address/streetAddress'))(self.env['_json']) def obj_price(self): if not self.env['_json']: return return Type(CleanText(Dict('offers/price', default="0")), type=float, default=0)(self.env['_json']) @method class list_events(ListElement): item_xpath = '//ul[has-class("list-event")]/li' class item(ItemElement): klass = AgendaculturelEvent def validate(self, obj): return self.check_date(obj) and self.check_category(obj) def check_date(self, obj): if self.env['date_from'] and obj.start_date >= self.env['date_from']: if not self.env['date_to']: return True elif obj.end_date and obj.end_date <= self.env['date_to']: return True elif self.env['date_to'] >= obj.start_date: return True return False def check_category(self, obj): return (not self.env['categories'] or obj.category in self.env['categories']) obj_id = Format('%s.%s', Env('region'), Regexp(CleanText('./div/a[@itemprop="url"]/@href'), '/(.*).html')) obj_summary = CleanText('./div/a[@itemprop="url"]') def obj_start_date(self): _date = Date(CleanText('./meta[@itemprop="startDate"]/@content'))(self) return datetime.combine(_date, time.min) obj_category = AgendaculturelCategory(Regexp(CleanText('./@itemtype'), 'http://schema.org/(.*)')) weboob-1.1/modules/agendaculturel/test.py000066400000000000000000000021571265717027300206470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from datetime import datetime class AgendaculturelTest(BackendTest): MODULE = 'agendaculturel' def test_agendaculturel(self): l = list(self.backend.list_events(datetime.now())) assert len(l) event = self.backend.get_event(l[0].id) self.assertTrue(event.url, 'URL for event "%s" not found: %s' % (event.id, event.url)) weboob-1.1/modules/agendadulibre/000077500000000000000000000000001265717027300171005ustar00rootroot00000000000000weboob-1.1/modules/agendadulibre/__init__.py000066400000000000000000000014501265717027300212110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AgendadulibreModule __all__ = ['AgendadulibreModule'] weboob-1.1/modules/agendadulibre/browser.py000066400000000000000000000037241265717027300211430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import EventListPage, EventPage from datetime import timedelta, date class AgendadulibreBrowser(PagesBrowser): event_list_page = URL('events\?start_date=(?P.*)(?P.*)', EventListPage) event_page = URL('events/(?P<_id>.*)', EventPage) def __init__(self, website, region, *args, **kwargs): self.BASEURL = u'%s/' % website self.region = '®ion=%s' % region if region else '' PagesBrowser.__init__(self, *args, **kwargs) def list_events(self, date_from, date_to, city=None, categories=None, max_date=None): _max_date = date_from + timedelta(days=365) max_date = date(year=_max_date.year, month=_max_date.month, day=_max_date.day) return self.event_list_page.go(date_from=date_from.strftime("%Y-%m-%d"), region=self.region)\ .list_events(date_from=date_from, date_to=date_to, city=city, categories=categories, max_date=max_date) def get_event(self, event_id, event=None): _id = event_id.split('#')[-1] return self.event_page.go(_id=_id).get_event(obj=event) weboob-1.1/modules/agendadulibre/calendar.py000066400000000000000000000020701265717027300212220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS, CATEGORIES class AgendaDuLibreCalendarEvent(BaseCalendarEvent): def __init__(self): BaseCalendarEvent.__init__(self) self.sequence = 1 self.transp = TRANSP.TRANSPARENT self.status = STATUS.CONFIRMED self.category = CATEGORIES.CONF weboob-1.1/modules/agendadulibre/favicon.png000066400000000000000000000034311265717027300212340ustar00rootroot00000000000000PNG  IHDR@@iqgAMA a pHYsodtEXtAuthorJakub Steiner/!tEXtSourcehttp://jimmac.musichall.czif^ItEXtCopyrightPublic Domain http://creativecommons.org/licenses/publicdomain/YtEXtSoftwarepaint.net 4.0.3PIDATx^OIg!TSPKN9TApzA0HuXdo+~X_WV6=̑igO.zz8Ç>|#J HCCCyY"%Hyy:uJ̙3 !2dggKII(ƍjSSSKrE(ZDwQ]]-Sy Kggtuu%W^+WH~~ܾ}}%=zTPS .4illt"$vGAAr@nn -{tJ80++DIr1G^kî04iҞ$ZDwA0Pw F_C]Q 89tw0 999+X?|<"c11;;{ I'C. 9߽{=%I%Z;7G>cftO̹gϔ c"v~6lGVVT]ō??/ hݩ90ۙNt7 hݩ90wQ+j  hݩ9ɓ'27"Єݩ9ɝu)?J@`7}( W@$ .?3鄃 D֢hu˃?~,yyyS@kkpH0T\*@/21vMMM|Jɀ|?֯>R/`[#v$SXؕtBFMVlBM JɌmuV?`ccC%Ev"uA D'p!>Êh`fҳا"#Dg7sqJcm|h ; ΀߿/*پ "=p UMנȲrݤQ{UY^^9u'`phHەlSx*f!?Q1%?i2*@@ pP7>~,pNd5 c2u+N%3RbRׯs)pg %%%6Na?ʇݻw"o߾7oׯeiiIeaaA]/^% * rɓ'*>gffdzzZ6GÇebbB˽{N[wܑ[n͛7 nUZrP @ ,B9̹y ky9|"Tp )XU"M!655)r(녨zeZEBRU!f0{xVd@?b/bb.VRTEIzhmMܓqd!4JxFMyj' !F5GZ{ %א;QȈ,DLcƒhWY/i*;3NT|Jb$WbOVӸzxޜ͹DNEn,O8Ç>|#G~ >scZIENDB`weboob-1.1/modules/agendadulibre/module.py000066400000000000000000000150371265717027300207450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import Value from .browser import AgendadulibreBrowser __all__ = ['AgendadulibreModule'] class AgendadulibreModule(Module, CapCalendarEvent): NAME = 'agendadulibre' DESCRIPTION = u'agendadulibre website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' ASSOCIATED_CATEGORIES = [CATEGORIES.CONF] BROWSER = AgendadulibreBrowser region_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ "http://www.agendadulibre.org": u'--France--', "http://www.agendadulibre.org#1": u'Alsace', "http://www.agendadulibre.org#2": u'Aquitaine', "http://www.agendadulibre.org#3": u'Auvergne', "http://www.agendadulibre.org#4": u'Basse-Normandie', "http://www.agendadulibre.org#5": u'Bourgogne', "http://www.agendadulibre.org#6": u'Bretagne', "http://www.agendadulibre.org#7": u'Centre', "http://www.agendadulibre.org#8": u'Champagne-Ardenne', "http://www.agendadulibre.org#9": u'Corse', "http://www.agendadulibre.org#10": u'Franche-Comté', "http://www.agendadulibre.org#23": u'Guadeloupe', "http://www.agendadulibre.org#24": u'Guyane', "http://www.agendadulibre.org#11": u'Haute-Normandie', "http://www.agendadulibre.org#12": u'Île-de-France', "http://www.agendadulibre.org#13": u'Languedoc-Roussillon', "http://www.agendadulibre.org#14": u'Limousin', "http://www.agendadulibre.org#15": u'Lorraine', "http://www.agendadulibre.org#25": u'Martinique', "http://www.agendadulibre.org#16": u'Midi-Pyrénées', "http://www.agendadulibre.org#17": u'Nord-Pas-de-Calais', "http://www.agendadulibre.org#18": u'Pays de la Loire', "http://www.agendadulibre.org#19": u'Picardie', "http://www.agendadulibre.org#20": u'Poitou-Charentes', "http://www.agendadulibre.org#21": u'Provence-Alpes-Côte d\'Azur', "http://www.agendadulibre.org#26": u'Réunion', "http://www.agendadulibre.org#22": u'Rhône-Alpes', "http://www.agendadulibre.be": u'--Belgique--', "http://www.agendadulibre.be#11": u'Antwerpen', "http://www.agendadulibre.be#10": u'Brabant wallon', "http://www.agendadulibre.be#9": u'Bruxelles-Capitale', "http://www.agendadulibre.be#8": u'Hainaut', "http://www.agendadulibre.be#7": u'Liege', "http://www.agendadulibre.be#6": u'Limburg', "http://www.agendadulibre.be#5": u'Luxembourg', "http://www.agendadulibre.be#4": u'Namur', "http://www.agendadulibre.be#3": u'Oost-Vlaanderen', "http://www.agendadulibre.be#2": u'Vlaams-Brabant', "http://www.agendadulibre.be#1": u'West-Vlaanderen', "http://www.agendadulibre.ch": u'--Suisse--', "http://www.agendadulibre.ch#15": u'Appenzell Rhodes-Extérieures', "http://www.agendadulibre.ch#16": u'Appenzell Rhodes-Intérieures', "http://www.agendadulibre.ch#19": u'Argovie', "http://www.agendadulibre.ch#13": u'Bâle-Campagne', "http://www.agendadulibre.ch#12": u'Bâle-Ville', "http://www.agendadulibre.ch#2": u'Berne', "http://www.agendadulibre.ch#10": u'Fribourg', "http://www.agendadulibre.ch#25": u'Genève', "http://www.agendadulibre.ch#8": u'Glaris', "http://www.agendadulibre.ch#18": u'Grisons', "http://www.agendadulibre.ch#26": u'Jura', "http://www.agendadulibre.ch#3": u'Lucerne', "http://www.agendadulibre.ch#24": u'Neuchâtel', "http://www.agendadulibre.ch#7": u'Nidwald', "http://www.agendadulibre.ch#6": u'Obwald', "http://www.agendadulibre.ch#17": u'Saint-Gall', "http://www.agendadulibre.ch#14": u'Schaffhouse', "http://www.agendadulibre.ch#5": u'Schwytz', "http://www.agendadulibre.ch#11": u'Soleure', "http://www.agendadulibre.ch#21": u'Tessin', "http://www.agendadulibre.ch#20": u'Thurgovie', "http://www.agendadulibre.ch#4": u'Uri', "http://www.agendadulibre.ch#23": u'Valais', "http://www.agendadulibre.ch#22": u'Vaud', "http://www.agendadulibre.ch#9": u'Zoug', "http://www.agendadulibre.ch#1": u'Zurich', }.iteritems())]) CONFIG = BackendConfig(Value('region', label=u'Region', choices=region_choices)) def create_default_browser(self): choice = self.config['region'].get().split('#') selected_region = '' if len(choice) < 2 else choice[-1] return self.create_browser(website=choice[0], region=selected_region) def search_events(self, query): return self.browser.list_events(query.start_date, query.end_date, query.city, query.categories) def list_events(self, date_from, date_to=None): return self.browser.list_events(date_from, date_to) def get_event(self, event_id): return self.browser.get_event(event_id) def fill_obj(self, event, fields): event = self.browser.get_event(event.id, event) choice = self.config['region'].get().split('#') selected_region = '' if len(choice) < 2 else choice[-1] if selected_region == '23': event.timezone = 'America/Guadeloupe' elif selected_region == '24': event.timezone = 'America/Guyana' elif selected_region == '26': event.timezone = 'Indian/Reunion' elif selected_region == '25': event.timezone = 'America/Martinique' else: event.timezone = 'Europe/Paris' return event OBJECTS = {AgendadulibreBrowser: fill_obj} weboob-1.1/modules/agendadulibre/pages.py000066400000000000000000000147731265717027300205650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import Regexp, CleanText, DateTime, Env, Format, BrowserURL from weboob.browser.filters.html import Link, XPath, CleanHTML from .calendar import AgendaDuLibreCalendarEvent from datetime import time, datetime, date import re class EventPage(HTMLPage): @method class get_event(ItemElement): klass = AgendaDuLibreCalendarEvent obj_id = Env('_id') obj_url = BrowserURL('event_page', _id=Env('_id')) obj_summary = Format('%s %s', CleanText('//meta[@name="geo:placename"]/@content'), CleanText('//meta[@name="DC:title"]/@content')) obj_description = CleanHTML('//div[@class="description"]') obj_location = CleanText('//p[@class="full_address"]/span[1]') obj_city = CleanText('//meta[@name="geo:placename"]/@content') def obj_start_date(self): m = re.findall(u'(\w* \w* \d?\d \w* \d{4} \w* \d{2}h\d{2})', (CleanText('(//p)[1]')(self))) if m: return DateTime(Regexp(CleanText('(//p)[1]'), '\w* \w* (\d?\d \w* \d{4}) \w* (\d{2}h\d{2})', '\\1 \\2'))(self) def obj_end_date(self): m = re.findall(u'(\w* \w* \d?\d \w* \d{4} \w* \d{2}h\d{2})', (CleanText('(//p)[1]')(self))) if m: if len(m) == 1: return DateTime(Regexp(CleanText('(//p)[1]'), '\w* \w* (\d?\d \w* \d{4}) \w* \d{2}h\d{2} \w* (\d{2}h\d{2})', '\\1 \\2'))(self) else: return DateTime(Regexp(Regexp(CleanText('(//p)[1]'), '(\w* \w* \d?\d \w* \d{4} \w* \d{2}h\d{2})', nth=-1), '\w* \w* (\d?\d \w* \d{4}) \w* (\d{2}h\d{2})', '\\1 \\2'))(self) class EventListPage(HTMLPage): @pagination @method class list_events(ListElement): item_xpath = '//td[starts-with(@class, "day")]/ul/li' def next_page(self): m = re.match('.*/events\?start_date=(\d{4})-(\d{2})-(\d{2})(®ion=.*)?', self.page.url) if m: start = date(year=int(m.group(1)), month=int(m.group(2)), day=1) region = m.group(4) if m.group(4) else '' try: next_month = start.replace(month=start.month + 1) except ValueError: if start.month == 12: next_month = start.replace(year=start.year + 1, month=1) else: raise if (self.env['date_to'] is None and start < self.env['max_date']) or\ (self.env['date_to'] is not None and datetime.combine(next_month, time.min) < self.env['date_to']): return '/events?start_date=%s%s' % (next_month.strftime("%Y-%m-%d"), region) class item(ItemElement): klass = AgendaDuLibreCalendarEvent def condition(self): return len(XPath('.')(self.el)) > 0 and \ ('current-month' in XPath('./ancestor::td/@class')(self.el)[0]) obj_id = Format('%s#%s', CleanText('./ancestor::td/div[@class="day_number"]'), Regexp(Link('./a'), '/events/(.*)')) obj_city = CleanText('./a/strong[@class="city"]') obj_summary = CleanText('./a') def obj_start_date(self): m = re.findall(u'(\w* \w* \d?\d \w* \d{4} \w* \d{2}h\d{2})', (CleanText('./@title')(self))) if m: return DateTime(Regexp(CleanText('./@title'), '\w* \w* (\d?\d \w* \d{4}) \w* (\d{2}h\d{2})', '\\1 \\2'))(self) def obj_end_date(self): m = re.findall(u'(\w* \w* \d?\d \w* \d{4} \w* \d{2}h\d{2})', (CleanText('./@title')(self))) if m: if len(m) == 1: return DateTime(Regexp(CleanText('./@title'), '\w* \w* (\d?\d \w* \d{4}) \w* \d{2}h\d{2} \w* (\d{2}h\d{2})', '\\1 \\2'))(self) else: return DateTime(Regexp(Regexp(CleanText('./@title'), '(\w* \w* \d?\d \w* \d{4} \w* \d{2}h\d{2})', nth=-1), '\w* \w* (\d?\d \w* \d{4}) \w* (\d{2}h\d{2})', '\\1 \\2'))(self) def validate(self, obj): return (self.is_valid_event(obj, self.env['city'], self.env['categories']) and self.is_event_in_valid_period(obj.start_date, self.env['date_from'], self.env['date_to'])) def is_valid_event(self, event, city, categories): if city and city != '' and city.upper() != event.city.upper(): return False if categories and len(categories) > 0 and event.category not in categories: return False return True def is_event_in_valid_period(self, event_date, date_from, date_to): if event_date >= datetime.combine(date_from, time.min): if not date_to: return True else: if event_date <= date_to: return True return False weboob-1.1/modules/agendadulibre/test.py000066400000000000000000000021541265717027300204330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from datetime import datetime class AgendadulibreTest(BackendTest): MODULE = 'agendadulibre' def test_agendadulibre(self): l = list(self.backend.list_events(datetime.now())) assert len(l) event = self.backend.get_event(l[0].id) self.assertTrue(event.url, 'URL for event "%s" not found: %s' % (event.id, event.url)) weboob-1.1/modules/allocine/000077500000000000000000000000001265717027300161005ustar00rootroot00000000000000weboob-1.1/modules/allocine/__init__.py000066400000000000000000000014351265717027300202140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AllocineModule __all__ = ['AllocineModule'] weboob-1.1/modules/allocine/browser.py000066400000000000000000000606441265717027300201470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS, CATEGORIES from weboob.capabilities.collection import Collection from weboob.capabilities.video import BaseVideo from weboob.capabilities.image import BaseImage from weboob.capabilities.base import NotAvailable, NotLoaded, find_object from weboob.capabilities.cinema import Movie, Person from weboob.deprecated.browser import Browser from weboob.tools.json import json import base64 import hashlib from datetime import datetime, date, timedelta import time import urllib __all__ = ['AllocineBrowser'] class AllocineBrowser(Browser): DOMAIN = 'api.allocine.fr' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = 'Dalvik/1.6.0 (Linux; U; Android 4.2.2; Nexus 4 Build/JDQ39E)' PARTNER_KEY = '100043982026' SECRET_KEY = '29d185d98c984a359e6e6f26a0474269' def __do_request(self, method, params): params_encode = urllib.urlencode(params) sed = time.strftime('%Y%m%d', time.localtime()) sig = base64.b64encode(hashlib.sha1(self.SECRET_KEY + params_encode + '&sed=' + sed).digest()) query_url = 'http://api.allocine.fr/rest/v3/' + method + '?' + params_encode + '&sed=' + sed + '&sig=' + sig return self.readurl(query_url) def iter_movies(self, pattern): params = [('partner', self.PARTNER_KEY), ('q', pattern), ('format', 'json'), ('filter', 'movie')] res = self.__do_request('search', params) if res is None: return jres = json.loads(res) if 'movie' not in jres['feed']: return for m in jres['feed']['movie']: tdesc = u'' if 'title' in m: tdesc += '%s' % m['title'] if 'productionYear' in m: tdesc += ' ; %s' % m['productionYear'] elif 'release' in m: tdesc += ' ; %s' % m['release']['releaseDate'] if 'castingShort' in m and 'actors' in m['castingShort']: tdesc += ' ; %s' % m['castingShort']['actors'] short_description = tdesc.strip('; ') thumbnail_url = NotAvailable if 'poster' in m: thumbnail_url = unicode(m['poster']['href']) movie = Movie(m['code'], unicode(m['originalTitle'])) movie.other_titles = NotLoaded movie.release_date = NotLoaded movie.duration = NotLoaded movie.short_description = short_description movie.pitch = NotLoaded movie.country = NotLoaded movie.note = NotLoaded movie.roles = NotLoaded movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url yield movie def iter_persons(self, pattern): params = [('partner', self.PARTNER_KEY), ('q', pattern), ('format', 'json'), ('filter', 'person')] res = self.__do_request('search', params) if res is None: return jres = json.loads(res) if 'person' not in jres['feed']: return for p in jres['feed']['person']: thumbnail_url = NotAvailable if 'picture' in p: thumbnail_url = unicode(p['picture']['href']) person = Person(p['code'], unicode(p['name'])) desc = u'' if 'birthDate' in p: desc += '(%s), ' % p['birthDate'] if 'activity' in p: for a in p['activity']: desc += '%s, ' % a['$'] person.real_name = NotLoaded person.birth_place = NotLoaded person.birth_date = NotLoaded person.death_date = NotLoaded person.gender = NotLoaded person.nationality = NotLoaded person.short_biography = NotLoaded person.short_description = desc.strip(', ') person.roles = NotLoaded person.thumbnail_url = thumbnail_url yield person def get_movie(self, id): params = [('partner', self.PARTNER_KEY), ('code', id), ('profile', 'large'), ('mediafmt', 'mp4-lc'), ('filter', 'movie'), ('striptags', 'synopsis,synopsisshort'), ('format', 'json')] res = self.__do_request('movie', params) if res is not None: jres = json.loads(res) if 'movie' in jres: jres = jres['movie'] else: return None else: return None title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'originalTitle' not in jres: return title = unicode(jres['originalTitle'].strip()) if 'poster' in jres: thumbnail_url = unicode(jres['poster']['href']) if 'genre' in jres: for g in jres['genre']: genres.append(g['$']) if 'runtime' in jres: nbsecs = jres['runtime'] duration = nbsecs / 60 if 'release' in jres: dstr = str(jres['release']['releaseDate']) tdate = dstr.split('-') day = 1 month = 1 year = 1901 if len(tdate) > 2: year = int(tdate[0]) month = int(tdate[1]) day = int(tdate[2]) release_date = datetime(year, month, day) if 'nationality' in jres: country = u'' for c in jres['nationality']: country += '%s, ' % c['$'] country = country.strip(', ') if 'synopsis' in jres: pitch = unicode(jres['synopsis']) if 'statistics' in jres and 'userRating' in jres['statistics']: note = u'%s/5 (%s votes)' % (jres['statistics']['userRating'], jres['statistics']['userReviewCount']) if 'castMember' in jres: for cast in jres['castMember']: if cast['activity']['$'] not in roles: roles[cast['activity']['$']] = [] person_to_append = (u'%s' % cast['person']['code'], cast['person']['name']) roles[cast['activity']['$']].append(person_to_append) movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie def get_person(self, id): params = [('partner', self.PARTNER_KEY), ('code', id), ('profile', 'large'), ('mediafmt', 'mp4-lc'), ('filter', 'movie'), ('striptags', 'biography,biographyshort'), ('format', 'json')] res = self.__do_request('person', params) if res is not None: jres = json.loads(res) if 'person' in jres: jres = jres['person'] else: return None else: return None name = NotAvailable short_biography = NotAvailable biography = NotAvailable short_description = NotAvailable birth_place = NotAvailable birth_date = NotAvailable death_date = NotAvailable real_name = NotAvailable gender = NotAvailable thumbnail_url = NotAvailable roles = {} nationality = NotAvailable if 'name' in jres: name = u'' if 'given' in jres['name']: name += jres['name']['given'] if 'family' in jres['name']: name += ' %s' % jres['name']['family'] if 'biographyShort' in jres: short_biography = unicode(jres['biographyShort']) if 'birthPlace' in jres: birth_place = unicode(jres['birthPlace']) if 'birthDate' in jres: df = jres['birthDate'].split('-') birth_date = datetime(int(df[0]), int(df[1]), int(df[2])) if 'deathDate' in jres: df = jres['deathDate'].split('-') death_date = datetime(int(df[0]), int(df[1]), int(df[2])) if 'realName' in jres: real_name = unicode(jres['realName']) if 'gender' in jres: gcode = jres['gender'] if gcode == '1': gender = u'Male' else: gender = u'Female' if 'picture' in jres: thumbnail_url = unicode(jres['picture']['href']) if 'nationality' in jres: nationality = u'' for n in jres['nationality']: nationality += '%s, ' % n['$'] nationality = nationality.strip(', ') if 'biography' in jres: biography = unicode(jres['biography']) if 'participation' in jres: for m in jres['participation']: if m['activity']['$'] not in roles: roles[m['activity']['$']] = [] pyear = '????' if 'productionYear' in m['movie']: pyear = m['movie']['productionYear'] movie_to_append = (u'%s' % (m['movie']['code']), u'(%s) %s' % (pyear, m['movie']['originalTitle'])) roles[m['activity']['$']].append(movie_to_append) person = Person(id, name) person.real_name = real_name person.birth_date = birth_date person.death_date = death_date person.birth_place = birth_place person.gender = gender person.nationality = nationality person.short_biography = short_biography person.biography = biography person.short_description = short_description person.roles = roles person.thumbnail_url = thumbnail_url return person def iter_movie_persons(self, movie_id, role_filter): params = [('partner', self.PARTNER_KEY), ('code', movie_id), ('profile', 'large'), ('mediafmt', 'mp4-lc'), ('filter', 'movie'), ('striptags', 'synopsis,synopsisshort'), ('format', 'json')] res = self.__do_request('movie', params) if res is not None: jres = json.loads(res) if 'movie' in jres: jres = jres['movie'] else: return else: return if 'castMember' in jres: for cast in jres['castMember']: if (role_filter is None or (role_filter is not None and cast['activity']['$'].lower().strip() == role_filter.lower().strip())): id = cast['person']['code'] name = unicode(cast['person']['name']) short_description = unicode(cast['activity']['$']) if 'role' in cast: short_description += ', %s' % cast['role'] thumbnail_url = NotAvailable if 'picture' in cast: thumbnail_url = unicode(cast['picture']['href']) person = Person(id, name) person.short_description = short_description person.real_name = NotLoaded person.birth_place = NotLoaded person.birth_date = NotLoaded person.death_date = NotLoaded person.gender = NotLoaded person.nationality = NotLoaded person.short_biography = NotLoaded person.roles = NotLoaded person.thumbnail_url = thumbnail_url yield person def iter_person_movies(self, person_id, role_filter): params = [('partner', self.PARTNER_KEY), ('code', person_id), ('profile', 'medium'), ('filter', 'movie'), ('format', 'json')] res = self.__do_request('filmography', params) if res is not None: jres = json.loads(res) if 'person' in jres: jres = jres['person'] else: return else: return for m in jres['participation']: if (role_filter is None or (role_filter is not None and m['activity']['$'].lower().strip() == role_filter.lower().strip())): prod_year = '????' if 'productionYear' in m['movie']: prod_year = m['movie']['productionYear'] short_description = u'(%s) %s' % (prod_year, m['activity']['$']) if 'role' in m: short_description += ', %s' % m['role'] movie = Movie(m['movie']['code'], unicode(m['movie']['originalTitle'])) movie.other_titles = NotLoaded movie.release_date = NotLoaded movie.duration = NotLoaded movie.short_description = short_description movie.pitch = NotLoaded movie.country = NotLoaded movie.note = NotLoaded movie.roles = NotLoaded movie.all_release_dates = NotLoaded movie.thumbnail_url = NotLoaded yield movie def iter_person_movies_ids(self, person_id): params = [('partner', self.PARTNER_KEY), ('code', person_id), ('profile', 'medium'), ('filter', 'movie'), ('format', 'json')] res = self.__do_request('filmography', params) if res is not None: jres = json.loads(res) if 'person' in jres: jres = jres['person'] else: return else: return for m in jres['participation']: yield unicode(m['movie']['code']) def iter_movie_persons_ids(self, movie_id): params = [('partner', self.PARTNER_KEY), ('code', movie_id), ('profile', 'large'), ('mediafmt', 'mp4-lc'), ('filter', 'movie'), ('striptags', 'synopsis,synopsisshort'), ('format', 'json')] res = self.__do_request('movie', params) if res is not None: jres = json.loads(res) if 'movie' in jres: jres = jres['movie'] else: return else: return if 'castMember' in jres: for cast in jres['castMember']: yield unicode(cast['person']['code']) def get_movie_releases(self, id, country): return def get_person_biography(self, id): params = [('partner', self.PARTNER_KEY), ('code', id), ('profile', 'large'), ('mediafmt', 'mp4-lc'), ('filter', 'movie'), ('striptags', 'biography,biographyshort'), ('format', 'json')] res = self.__do_request('person', params) if res is not None: jres = json.loads(res) if 'person' in jres: jres = jres['person'] else: return None else: return None biography = NotAvailable if 'biography' in jres: biography = unicode(jres['biography']) return biography def get_categories_movies(self, category): params = [('partner', self.PARTNER_KEY), ('format', 'json'), ('mediafmt', 'mp4'), ('filter', category) ] res = self.__do_request('movielist', params) if res is None: return result = json.loads(res) for movie in result['feed']['movie']: if 'trailer' not in movie or 'productionYear' not in movie: continue yield self.parse_movie(movie) def get_categories_videos(self, category): params = [('partner', self.PARTNER_KEY), ('format', 'json'), ('mediafmt', 'mp4'), ('filter', category) ] res = self.__do_request('videolist', params) if res is None: return result = json.loads(res) if 'feed' in result and 'media' in result['feed']: for episode in result['feed']['media']: if 'title' in episode: yield self.parse_video(episode, category) def parse_video(self, _video, category): video = BaseVideo(u'%s#%s' % (_video['code'], category)) video.title = unicode(_video['title']) video._video_code = unicode(_video['code']) video.ext = u'mp4' if 'runtime' in _video: video.duration = timedelta(seconds=int(_video['runtime'])) if 'description' in _video: video.description = unicode(_video['description']) renditions = sorted(_video['rendition'], key=lambda x: 'bandwidth' in x and x['bandwidth']['code'], reverse=True) video.url = unicode(max(renditions, key=lambda x: 'bandwidth' in x)['href']) return video def parse_movie(self, movie): video = BaseVideo(u'%s#%s' % (movie['code'], 'movie')) video.title = unicode(movie['trailer']['name']) video._video_code = unicode(movie['trailer']['code']) video.ext = u'mp4' if 'poster' in movie: video.thumbnail = BaseImage(movie['poster']['href']) video.thumbnail.url = unicode(movie['poster']['href']) tdate = movie['release']['releaseDate'].split('-') day = 1 month = 1 year = 1901 if len(tdate) > 2: year = int(tdate[0]) month = int(tdate[1]) day = int(tdate[2]) video.date = date(year, month, day) if 'userRating' in movie['statistics']: video.rating = movie['statistics']['userRating'] elif 'pressRating' in movie['statistics']: video.rating = movie['statistics']['pressRating'] * 2 video.rating_max = 5 if 'synopsis' in movie: video.description = unicode(movie['synopsis'].replace('

', '').replace('

', '')) elif 'synopsisShort' in movie: video.description = unicode(movie['synopsisShort'].replace('

', '').replace('

', '')) if 'castingShort' in movie: if 'directors' in movie['castingShort']: video.author = unicode(movie['castingShort']['directors']) if 'runtime' in movie: video.duration = timedelta(seconds=int(movie['runtime'])) return video def get_movie_from_id(self, _id): params = [('partner', self.PARTNER_KEY), ('format', 'json'), ('mediafmt', 'mp4'), ('filter', 'movie'), ('code', _id), ] res = self.__do_request('movie', params) if res is None: return result = json.loads(res) return self.parse_video(result['movie']) def get_video_from_id(self, _id, category): return find_object(self.get_categories_videos(category), id=u'%s#%s' % (_id, category)) def get_video_url(self, code): params = [('partner', self.PARTNER_KEY), ('format', 'json'), ('mediafmt', 'mp4'), ('code', code), ('profile', 'large'), ] res = self.__do_request('media', params) if res is None: return result = json.loads(res) renditions = sorted(result['media']['rendition'], key=lambda x: 'bandwidth' in x and x['bandwidth']['code'], reverse=True) return max(renditions, key=lambda x: 'bandwidth' in x)['href'] def get_emissions(self, basename): params = [('partner', self.PARTNER_KEY), ('format', 'json'), ('filter', 'acshow'), ] res = self.__do_request('termlist', params) if res is None: return result = json.loads(res) for emission in result['feed']['term']: yield Collection([basename, unicode(emission['nameShort'])], unicode(emission['$'])) def search_events(self, query): params = [('partner', self.PARTNER_KEY), ('format', 'json'), ('zip', query.city) ] if query.summary: movie = self.iter_movies(query.summary).next() params.append(('movie', movie.id)) res = self.__do_request('showtimelist', params) if res is None: return result = json.loads(res) for event in self.create_event(result): if (not query.end_date or event.start_date <= query.end_date)\ and event.start_date >= query.start_date: yield event def get_event(self, _id): split_id = _id.split('#') params = [('partner', self.PARTNER_KEY), ('format', 'json'), ('theaters', split_id[0]), ('zip', split_id[1]), ('movie', split_id[2]), ] res = self.__do_request('showtimelist', params) if res is None: return result = json.loads(res) for event in self.create_event(result): if event.id.split('#')[-1] == split_id[-1]: event.description = self.get_movie(split_id[2]).pitch return event def create_event(self, data): sequence = 1 transp = TRANSP.TRANSPARENT status = STATUS.CONFIRMED category = CATEGORIES.CINE if 'theaterShowtimes' not in data['feed']: return for items in data['feed']['theaterShowtimes']: cinema = items['place']['theater'] city = unicode(cinema['city']) location = u'%s, %s' % (cinema['name'], cinema['address']) postalCode = cinema['postalCode'] cinemaCode = cinema['code'] for show in items['movieShowtimes']: summary = unicode(show['onShow']['movie']['title']) movieCode = show['onShow']['movie']['code'] for jour in show['scr']: tdate = jour['d'].split('-') year = int(tdate[0]) month = int(tdate[1]) day = int(tdate[2]) for seance in jour['t']: ttime = seance['$'].split(':') heure = int(ttime[0]) minute = int(ttime[1]) start_date = datetime(year=year, month=month, day=day, hour=heure, minute=minute) seanceCode = seance['code'] _id = u'%s#%s#%s#%s' % (cinemaCode, postalCode, movieCode, seanceCode) event = BaseCalendarEvent() event.id = _id event.sequence = sequence event.transp = transp event.status = status event.category = category event.city = city event.location = location event.start_date = start_date event.summary = summary event.timezone = u'Europe/Paris' yield event weboob-1.1/modules/allocine/favicon.png000066400000000000000000000070211265717027300202330ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME%Qt=tEXtCommentCreated with GIMPW lIDATx{pT}?ܻoi%'@xc0`ccnku34N>2OƭֱS2MRO+&ۀ󊍍00!@Үݽ{w=݋$"h{y|~;Jəq|[ @ @ @ @ 繙-u5Gٟ<0@kF.zpp|B5LEig$1b@kL2wK)Gc7h-Aİ 2n%,~s?*5Wz.%ӗŲǢT%4ypQG>3 E 4ǿEoj 'd-( QQ40e հȒQ:nnzPZ2zT[DO>c}HEy "!f! ^H&Dq_AB 58@"R< PY>:c!+Y0KHц2/`t iqFp4_ 7aqD=0?+XƦ ]0d{x W>\čyf4V+sQf3hC+D2Ig-r܄OwEkdJJp Ǚox˪%hĝK^B(!r3i +GڶZ_C>3 aPu^f&p{,Ū~H$ЅV8dƠ\汇iv%lXn~9 b x'y;E@**UpDԿ[DTcc[6(KaZ]D@# o< R vmWF w.)?%l/YLOFh'6RD8RdQ8@%NZ''g'_y^f+Zka?7v;;>湟͢"͉lMjηH PSAן[S߿p?cjm5\*2LʮmSTGy ݬ]>љ7 S 0]@\kplT$wM^˧74q}Bw9bv)W2X0/@8crPWgrâ㾽3jL `lk2 e@,y}Xt]vWE'BPY)0ro! wKu5wYΓ[Cmms[w1 hE Br, mk*/k׿H'?}51*N7^e>;EbXL1}?H*vPoPUe?-Awwniek2 ][8 jj ׷%߄_Ǻ*&ܾ!B ?9arL=}͚4 [ww<׷mO;R]|d M?mSZH/rFpœOxߗy_(+Cʠ\v8I~&CX"/7dL-\?>,ô>x;>~(s<_UipâBz&VG/cgt'j!<kq9x0Zþ(q&ͳmIr/ pe_)::\x+9+ ɒ~$^14.^Zj@28swswxyV۝Z>`0{<|-:: mh`0d2ΓJOU+\&^-\6MX=(\kn rE={-_pxyP`ǵOPHd2p~ %mR?8.VpX0^-KqL&UfϺaV`Ppc-6] FZ"? bZl.?t$M޼;"3pl.wvk70X`mo<9Ľ8P(NqUU DaeN|!yL]|rdhq]~_WP^.~?}3g2l'JMA,Ҽz/]>Pl\.>O9|$M*Lho$9P<΅QC縚|.tT!Jx3!b_džS^iwl3>z{| _ 3#Zחs9Ͽ5. import re from weboob.capabilities.base import UserError from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES, BaseCalendarEvent from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound, Collection from weboob.capabilities.cinema import CapCinema, Person, Movie from weboob.tools.backend import Module from .browser import AllocineBrowser __all__ = ['AllocineModule'] class AllocineModule(Module, CapCinema, CapVideo, CapCalendarEvent, CapCollection): NAME = 'allocine' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = u'AlloCiné French cinema database service' LICENSE = 'AGPLv3+' BROWSER = AllocineBrowser ASSOCIATED_CATEGORIES = [CATEGORIES.CINE] def get_movie(self, id): return self.browser.get_movie(id) def get_person(self, id): return self.browser.get_person(id) def iter_movies(self, pattern): return self.browser.iter_movies(pattern.encode('utf-8')) def iter_persons(self, pattern): return self.browser.iter_persons(pattern.encode('utf-8')) def iter_movie_persons(self, id, role=None): return self.browser.iter_movie_persons(id, role) def iter_person_movies(self, id, role=None): return self.browser.iter_person_movies(id, role) def iter_person_movies_ids(self, id): return self.browser.iter_person_movies_ids(id) def iter_movie_persons_ids(self, id): return self.browser.iter_movie_persons_ids(id) def get_person_biography(self, id): return self.browser.get_person_biography(id) def get_movie_releases(self, id, country=None): return self.browser.get_movie_releases(id, country) def fill_person(self, person, fields): if 'real_name' in fields or 'birth_place' in fields\ or 'death_date' in fields or 'nationality' in fields\ or 'short_biography' in fields or 'roles' in fields\ or 'birth_date' in fields or 'thumbnail_url' in fields\ or 'biography' in fields\ or 'gender' in fields or fields is None: per = self.get_person(person.id) person.real_name = per.real_name person.birth_date = per.birth_date person.death_date = per.death_date person.birth_place = per.birth_place person.gender = per.gender person.nationality = per.nationality person.short_biography = per.short_biography person.short_description = per.short_description person.roles = per.roles person.biography = per.biography person.thumbnail_url = per.thumbnail_url return person def fill_movie(self, movie, fields): if 'other_titles' in fields or 'release_date' in fields\ or 'duration' in fields or 'country' in fields\ or 'roles' in fields or 'note' in fields\ or 'thumbnail_url' in fields: mov = self.get_movie(movie.id) movie.other_titles = mov.other_titles movie.release_date = mov.release_date movie.duration = mov.duration movie.pitch = mov.pitch movie.country = mov.country movie.note = mov.note movie.roles = mov.roles movie.genres = mov.genres movie.short_description = mov.short_description movie.thumbnail_url = mov.thumbnail_url if 'all_release_dates' in fields: movie.all_release_dates = self.get_movie_releases(movie.id) return movie def fill_video(self, video, fields): if 'url' in fields: with self.browser: if not isinstance(video, BaseVideo): video = self.get_video(self, video.id) if hasattr(video, '_video_code'): video.url = unicode(self.browser.get_video_url(video._video_code)) if 'thumbnail' in fields and video and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) return video def get_video(self, _id): with self.browser: split_id = _id.split('#') if split_id[-1] == 'movie': return self.browser.get_movie_from_id(split_id[0]) return self.browser.get_video_from_id(split_id[0], split_id[-1]) def iter_resources(self, objs, split_path): with self.browser: if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield Collection([u'comingsoon'], u'Films prochainement au cinéma') yield Collection([u'nowshowing'], u'Films au cinéma') yield Collection([u'acshow'], u'Émissions') yield Collection([u'interview'], u'Interviews') if collection.path_level == 1: if collection.basename == u'acshow': emissions = self.browser.get_emissions(collection.basename) if emissions: for emission in emissions: yield emission elif collection.basename == u'interview': videos = self.browser.get_categories_videos(collection.basename) if videos: for video in videos: yield video else: videos = self.browser.get_categories_movies(collection.basename) if videos: for video in videos: yield video if collection.path_level == 2: videos = self.browser.get_categories_videos(':'.join(collection.split_path)) if videos: for video in videos: yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if collection.path_level == 1 and (collection.basename in [u'comingsoon', u'nowshowing', u'acshow', u'interview']): return if collection.path_level == 2 and collection.parent_path == [u'acshow']: return raise CollectionNotFound(collection.split_path) def search_events(self, query): with self.browser: if CATEGORIES.CINE in query.categories: if query.city and re.match('\d{5}', query.city): events = list(self.browser.search_events(query)) events.sort(key=lambda x: x.start_date, reverse=False) return events raise UserError('You must enter a zip code in city field') def get_event(self, id): return self.browser.get_event(id) def fill_event(self, event, fields): if 'description' in fields: movieCode = event.id.split('#')[2] movie = self.get_movie(movieCode) event.description = movie.pitch return event OBJECTS = { Person: fill_person, Movie: fill_movie, BaseVideo: fill_video, BaseCalendarEvent: fill_event } weboob-1.1/modules/allocine/test.py000066400000000000000000000107641265717027300174410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo from weboob.capabilities.calendar import Query, CATEGORIES from datetime import datetime import re class AllocineTest(BackendTest): MODULE = 'allocine' def test_search_movie(self): movies = list(self.backend.iter_movies('usual suspects')) assert len(movies) > 0 for movie in movies: assert movie.id def test_get_movie(self): movie = self.backend.get_movie('5032') assert movie assert movie.id assert movie.original_title def test_search_person(self): persons = list(self.backend.iter_persons('patrick dewaere')) assert len(persons) > 0 for person in persons: assert person.id def test_get_person(self): person = self.backend.get_person('1115') assert person assert person.id assert person.name assert person.birth_date def test_movie_persons(self): persons = list(self.backend.iter_movie_persons('5032')) assert len(persons) > 0 for person in persons: assert person.id assert person.name def test_person_movies(self): movies = list(self.backend.iter_person_movies('1115')) assert len(movies) > 0 for movie in movies: assert movie.id assert movie.original_title def test_get_person_biography(self): bio = self.backend.get_person_biography('1115') assert bio != '' assert bio is not None assert re.match(r'^Patrick Dewaere, fils.*', bio) def test_get_movie_releases(self): rel = self.backend.get_movie_releases('5032', 'fr') assert rel != '' assert rel is not None def test_iter_person_movies_ids(self): movies_ids = list(self.backend.iter_person_movies_ids('1115')) assert len(movies_ids) > 0 for movie_id in movies_ids: assert movie_id def test_iter_movie_persons_ids(self): persons_ids = list(self.backend.iter_movie_persons_ids('5032')) assert len(persons_ids) > 0 for person_id in persons_ids: assert person_id def test_emissions(self): l = list(self.backend.iter_resources([BaseVideo], [u'acshow'])) assert len(l) l1 = list(self.backend.iter_resources([BaseVideo], l[0].split_path)) assert len(l1) v = l1[0] self.backend.fillobj(v, 'url') self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) def test_interview(self): l = list(self.backend.iter_resources([BaseVideo], [u'interview'])) assert len(l) v = l[0] self.backend.fillobj(v, 'url') self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) def test_comingsoon(self): l = list(self.backend.iter_resources([BaseVideo], [u'comingsoon'])) assert len(l) v = l[0] self.backend.fillobj(v, 'url') self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) def test_nowshowing(self): l = list(self.backend.iter_resources([BaseVideo], [u'nowshowing'])) assert len(l) v = l[0] self.backend.fillobj(v, 'url') self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) def test_showtimelist(self): query = Query() query.city = u'59000' query.categories = [CATEGORIES.CINE] query.start_date = datetime.now() l = self.backend.search_events(query) assert len(l) e = l[0] self.backend.fillobj(e, 'description') self.assertTrue(e.description, 'Description of "%s" not found' % (e.id)) e = self.backend.get_event(e.id) self.assertTrue(e.description, 'Description of "%s" not found' % (e.id)) weboob-1.1/modules/alloresto/000077500000000000000000000000001265717027300163165ustar00rootroot00000000000000weboob-1.1/modules/alloresto/__init__.py000066400000000000000000000014361265717027300204330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AlloRestoModule __all__ = ['AlloRestoModule'] weboob-1.1/modules/alloresto/browser.py000066400000000000000000000037411265717027300203600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, AccountsPage __all__ = ['AlloRestoBrowser'] class AlloRestoBrowser(LoginBrowser): BASEURL = 'https://www.alloresto.fr' login = URL('/identification-requise.*', LoginPage) accounts = URL('/chez-moi/releve-compte-miams', AccountsPage) def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.accounts.stay_or_go() self.page.login(self.username, self.password) if self.login.is_here(): raise BrowserIncorrectPassword() @need_login def get_accounts_list(self): return self.accounts.stay_or_go().iter_accounts() @need_login def get_account(self, id): assert isinstance(id, basestring) for a in self.get_accounts_list(): if a.id == id: return a return None @need_login def get_history(self, account): return self.accounts.stay_or_go().get_transactions(type='consommable') @need_login def get_coming(self, account): return self.accounts.stay_or_go().get_transactions(type='acquisition') weboob-1.1/modules/alloresto/favicon.png000066400000000000000000000044201265717027300204510ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME16tEXtCommentCreated with GIMPWxIDATxYkp~.5VA^h3u"U; -El6ժculN;jE#NG+:ZuP+Wi*TB II̍$\7˷w?on6{={Ç>|Ç>|);w-7u ;gzJ)wU_8DǑ=Ā)2gݴmN0?c4F$C5vvzx"bCW-wl>><9_|Q^7M9S|9ODB ͛/80m ~-kN'"@"czˠ,zfl ׌3of< `q 0a`S@WE wx:{cMpLO(&3a_$'t} ,vFbcҥb m;9'8 RJZqq`@1zĮ ~7hTL& ~m[u /]$]Z-՝4*2锗3f7?hlU+8!Z5>Y p5~>x"130Й  .X ?N :KPR.@$z;|Pޜ  Lآ s@[[XB˲.F3l *Rx7tt@`8#  ;;%Ix|Z|}zsꚼcrW.%%OG}̂C68F䇑HdR\")aoZ3,]JO2d @60Ǚ9R9X6NTZW]5a\'OĦMswkd2c~Hd[9Junv&N8׍سW:oxs21-ۇIrEEE0/}}b,T')@öԤcen<谼\1Vu#۷"uI3 Ι#n y{u+lׇ=ndNK45Ƕ+X7lǔxa}h@'$pi @@/JO[#VMjX4nD`%coÇ>|Ç>| UuAIENDB`weboob-1.1/modules/alloresto/module.py000066400000000000000000000037011265717027300201560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import AlloRestoBrowser __all__ = ['AlloRestoModule'] class AlloRestoModule(Module, CapBank): NAME = 'alloresto' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Allo Resto' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe')) BROWSER = AlloRestoBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): return self.browser.get_history(account) def iter_coming(self, account): return self.browser.get_coming(account) weboob-1.1/modules/alloresto/pages.py000066400000000000000000000053611265717027300177740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from decimal import Decimal from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.elements import ItemElement, method from weboob.browser.filters.standard import CleanDecimal, CleanText, Filter, TableCell from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction class LoginPage(HTMLPage): def login(self, username, password): form = self.get_form(xpath='//form[has-class("form_o")]') form['uname'] = username form['pass'] = password form.submit() class AccountsPage(LoggedPage, HTMLPage): @method class iter_accounts(ItemElement): def __call__(self): return self klass = Account obj_id = '0' obj_label = u'Compte miams' obj_balance = CleanDecimal('//div[@class="compteur"]//strong', replace_dots=True) obj_currency = u'MIAM' obj_coming = CleanDecimal('//table[@id="solde_acquisition_lignes"]//th[@class="col_montant"]', default=Decimal('0'), replace_dots=True) class MyDate(Filter): MONTHS = ['janv', u'févr', u'mars', u'avr', u'mai', u'juin', u'juil', u'août', u'sept', u'oct', u'nov', u'déc'] def filter(self, txt): day, month, year = txt.split(' ') day = int(day) year = int(year) month = self.MONTHS.index(month.rstrip('.')) + 1 return datetime.date(year, month, day) def get_transactions(self, type='consommable'): class get_history(Transaction.TransactionsElement): head_xpath = '//table[@id="solde_%s_lignes"]//thead//tr/th/text()' % type item_xpath = '//table[@id="solde_%s_lignes"]//tbody/tr' % type col_date = u"Date de valeur" col_raw = u"Motif" class item(Transaction.TransactionElement): obj_amount = Transaction.Amount('./td[last()]') obj_date = AccountsPage.MyDate(CleanText(TableCell('date'))) return get_history(self)() weboob-1.1/modules/alloresto/test.py000066400000000000000000000017671265717027300176620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class AlloRestoTest(BackendTest): MODULE = 'alloresto' def test_alloresto(self): l = list(self.backend.iter_accounts()) a = l[0] list(self.backend.iter_history(a)) list(self.backend.iter_coming(a)) weboob-1.1/modules/allrecipes/000077500000000000000000000000001265717027300164355ustar00rootroot00000000000000weboob-1.1/modules/allrecipes/__init__.py000066400000000000000000000014411265717027300205460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AllrecipesModule __all__ = ['AllrecipesModule'] weboob-1.1/modules/allrecipes/browser.py000066400000000000000000000026261265717027300205000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import ResultsPage, RecipePage __all__ = ['AllrecipesBrowser'] class AllrecipesBrowser(PagesBrowser): BASEURL = 'http://allrecipes.com' results = URL('search/results/\?wt=(?P.*)\&sort=re', 'recipes/.*', ResultsPage) recipe = URL('recipe/(?P<_id>.*)/', RecipePage) def iter_recipes(self, pattern): return self.results.go(pattern=pattern).iter_recipes() def get_recipe(self, _id, obj=None): recipe = self.recipe.go(_id=_id).get_recipe(obj=obj) comments = list(self.page.get_comments()) if comments: recipe.comments = comments return recipe weboob-1.1/modules/allrecipes/favicon.png000066400000000000000000000024621265717027300205740ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME0*IDATxhU??ZVQihfT0) 4(9Ċ"%+Dd߃n2aiia4ÌHj.y}ny{`9{g(-BΨ4ϔ|sib(=Fi@(D"@HS*)gPt2FJ\Yn!_z@'o@ D"e-#u`Ψ@30+#j&=h.[:# xS^/L\'zw["u!B`1[i^~>ׄeKk< xU[[[pF]< ꁯ%(=?8M(`z?劒x!/K[,_ + Dٿ pp,x,am}:W[g`^Z˖-"p>߿]`;%x4W'J j;[bj3bRt{I\6$''{@S4L?m@+V̽%uv$dr3Xj@I. l(¹"io8ҤoHӖhIlV/dXlV ΨJ~piw $W[cJZ!^򒇵?Iş_Vm?Ψ3,;,yzt8^`U@GPjw;Kђv OrE Ru`ll:{JcJVL 9W2,>}uR/TgԄ$!8 wj[#zmyI,uxF[:Ȇ'ͦC ^_Oo G^[FSDx20I~g4>q-u[ JAI{Qى\&41߳U匪qFMJ`wcQŶ>h9]\3Xjh;,66~GNA;o~SXC9fѷ(+'b>/fAB7_+&ߏBQ%{$|ʵ+uygT3jW9r0%J5@IENDB`weboob-1.1/modules/allrecipes/module.py000066400000000000000000000031661265717027300203020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.recipe import CapRecipe, Recipe from weboob.tools.backend import Module from .browser import AllrecipesBrowser from urllib import quote_plus __all__ = ['AllrecipesModule'] class AllrecipesModule(Module, CapRecipe): NAME = 'allrecipes' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = u'Allrecipes English recipe website' LICENSE = 'AGPLv3+' BROWSER = AllrecipesBrowser def get_recipe(self, id): return self.browser.get_recipe(id) def iter_recipes(self, pattern): return self.browser.iter_recipes(quote_plus(pattern.encode('utf-8'))) def fill_recipe(self, recipe, fields): if 'nb_person' in fields or 'instructions' in fields or 'thumbnail_url' in fields: recipe = self.browser.get_recipe(recipe.id, recipe) return recipe OBJECTS = {Recipe: fill_recipe} weboob-1.1/modules/allrecipes/pages.py000066400000000000000000000067461265717027300201230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.capabilities.recipe import Recipe, Comment from weboob.capabilities.base import NotAvailable from weboob.browser.filters.standard import Regexp, CleanText, Env, Duration from weboob.browser.filters.html import CleanHTML import re class CookingDuration(Duration): _regexp = re.compile(r'PT((?P\d+)H)?((?P\d+)M)?((?P\d+)S)?') class ResultsPage(HTMLPage): @pagination @method class iter_recipes(ListElement): item_xpath = '//article[@class="grid-col--fixed-tiles"]' def next_page(self): return CleanText('//button[@id="btnMoreResults"]/@href')(self) class item(ItemElement): klass = Recipe obj_id = Regexp(CleanText('./a[1]/@href'), '/recipe/(.*)/') obj_title = CleanText('./a/h3') obj_short_description = CleanText('./a/div/div[@class="rec-card__description"]') class RecipePage(HTMLPage): @method class get_recipe(ItemElement): klass = Recipe obj_id = Env('_id') obj_title = CleanText('//h1[@itemprop="name"]') def obj_preparation_time(self): dt = CookingDuration(CleanText('//time[@itemprop="prepTime"]/@datetime'))(self) return int(dt.total_seconds() / 60) def obj_cooking_time(self): dt = CookingDuration(CleanText('//time[@itemprop="cookTime"]/@datetime'))(self) return int(dt.total_seconds() / 60) def obj_nb_person(self): nb_pers = CleanText('//meta[@id="metaRecipeServings"]/@content')(self) return [nb_pers] if nb_pers else NotAvailable def obj_ingredients(self): ingredients = [] for el in self.el.xpath('//ul[has-class("checklist")]/li/label/span[@itemprop="ingredients"]'): ing = CleanText('.')(el) if ing: ingredients.append(ing) return ingredients obj_instructions = CleanHTML('//ol[@itemprop="recipeInstructions"]') obj_thumbnail_url = CleanText('//section[has-class("hero-photo")]/span/a/img/@src') obj_picture_url = CleanText('//section[has-class("hero-photo")]/span/a/img/@src') @method class get_comments(ListElement): item_xpath = '//div[@itemprop="review"]' ignore_duplicate = True class item(ItemElement): klass = Comment obj_author = CleanText('./article/a/div/a/ul/li/h4[@itemprop="author"]') obj_rate = CleanText('./article/div/div[@class="rating-stars"]/@data-ratingstars') obj_text = CleanText('./p[@itemprop="reviewBody"]') obj_id = CleanText('./article/a/@href') weboob-1.1/modules/allrecipes/test.py000066400000000000000000000022271265717027300177710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest import itertools class AllrecipesTest(BackendTest): MODULE = 'allrecipes' def test_recipe(self): recipes = list(itertools.islice(self.backend.iter_recipes('french fries'), 0, 20)) assert len(recipes) full_recipe = self.backend.get_recipe(recipes[0].id) assert full_recipe.instructions assert full_recipe.ingredients assert full_recipe.title weboob-1.1/modules/amazon/000077500000000000000000000000001265717027300155775ustar00rootroot00000000000000weboob-1.1/modules/amazon/__init__.py000066400000000000000000000014401265717027300177070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AmazonModule __all__ = ['AmazonModule'] weboob-1.1/modules/amazon/browser.py000066400000000000000000000111601265717027300176330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from requests.exceptions import Timeout, ConnectionError from weboob.browser import LoginBrowser, URL, need_login from weboob.browser.exceptions import ServerError, HTTPNotFound from weboob.capabilities.bill import Subscription, Bill from weboob.capabilities.shop import OrderNotFound from weboob.exceptions import BrowserIncorrectPassword from .pages import HomePage, LoginPage, AmazonPage, HistoryPage, \ OrderOldPage, OrderNewPage __all__ = ['Amazon'] class Amazon(LoginBrowser): BASEURL = 'https://www.amazon.com' MAX_RETRIES = 10 CURRENCY = u'$' home = URL(r'/$', r'http://www.amazon.com/$', HomePage) login = URL(r'/ap/signin/.*$', LoginPage) history = URL(r'/gp/css/order-history.*$', r'/gp/your-account/order-history.*$', HistoryPage) order_old = URL(r'/gp/css/summary.*$', r'/gp/css/summary/edit.html\?orderID=%\(order_id\)s', r'/gp/digital/your-account/order-summary.html.*$', r'/gp/digital/your-account/orderPe-summary.html\?orderID=%\(order_id\)s', OrderOldPage) order_new = URL(r'/gp/css/summary.*$', r'/gp/your-account/order-details.*$', r'/gp/your-account/order-details\?orderID=%\(order_id\)s', OrderNewPage) unknown = URL(r'/.*$', AmazonPage) def get_currency(self): return self.CURRENCY def get_order(self, id_): order = self.to_order(id_).order() if order: return order else: raise OrderNotFound() def iter_orders(self): histRoot = self.to_history() for histYear in histRoot.iter_years(): for order in histYear.iter_orders(): if order.order(): yield order.order() def iter_payments(self, order): return self.to_order(order.id).payments() def iter_items(self, order): return self.to_order(order.id).items() @need_login def to_history(self): self.history.stay_or_go() assert self.history.is_here() return self.page @need_login def to_order(self, order_id): """ Amazon updates its website in stages: they reroute a random part of their users to new pages, and the rest to old ones. """ for i in xrange(self.MAX_RETRIES): if (self.order_new.is_here() or self.order_old.is_here()) \ and self.page.order_number() == order_id: return self.page try: self.order_new.go(order_id=order_id) except HTTPNotFound: self.order_old.go(order_id=order_id) raise OrderNotFound() def do_login(self): self.session.cookies.clear() self.home.go().to_login().login(self.username, self.password) if not self.page.logged: raise BrowserIncorrectPassword() def location(self, *args, **kwargs): """ Amazon throws 500 HTTP status code for apparently valid requests from time to time. Requests eventually succeed after retrying. """ for i in xrange(self.MAX_RETRIES): try: return super(Amazon, self).location(*args, **kwargs) except (ServerError, Timeout, ConnectionError) as e: pass raise e @need_login def get_subscription_list(self): sub = Subscription() sub.label = u'amazon' sub.id = u'amazon' yield sub @need_login def iter_bills(self, subscription): orders = self.iter_orders() for o in orders: b = Bill() b._url = o._bill['url'] b.id = '%s.%s' % (subscription.id, o.id) b.date = o.date b.price = o.total b.format = o._bill['format'] b.currency = b.get_currency(self.get_currency()) b.vat = o.tax yield b weboob-1.1/modules/amazon/favicon.png000066400000000000000000000042671265717027300177430ustar00rootroot00000000000000PNG  IHDR@@iqgAMA a cHRMz&u0`:pQ<bKGD pHYs!!IDATx{leimm\F7   8AT`&B`B4`"2qh$) LFڭ9z= <>>ILb$ޱ(L}0`oNMMOv GD1 SQ"b=EF0x8G+MVqU _N8(эXk!Gáx-4:qA-a—ƿT};(H;z]&APwpXxDD[p>]s!"mڵDQO9-8D@! u(I]1-&Wq&| ')tPds{Z&WRw&Lgc\)9翄U"(DH*", CW~s E  [s\.rWo%]Q3 'D8Ԡ=^9>.8cIX |U^BACx hCy0L?cN8Ő#UI K@Oy0? =n qx5/Z)Mhh{oO97MiadEѐ-LfpMBÀ؜آL1TMFpTX%{ mh$&\͟2%tEXtdate:create2014-10-26T14:24:29-05:00p%tEXtdate:modify2014-10-26T14:24:29-05:00DutEXtSoftwareAdobe ImageReadyqe<IENDB`weboob-1.1/modules/amazon/fr/000077500000000000000000000000001265717027300162065ustar00rootroot00000000000000weboob-1.1/modules/amazon/fr/__init__.py000066400000000000000000000000001265717027300203050ustar00rootroot00000000000000weboob-1.1/modules/amazon/fr/browser.py000066400000000000000000000034041265717027300202440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import URL from ..browser import Amazon from .pages import HomePage, LoginPage, AmazonPage, HistoryPage, \ OrderOldPage, OrderNewPage __all__ = ['AmazonFR'] class AmazonFR(Amazon): BASEURL = 'https://www.amazon.fr' CURRENCY = u'€' home = URL(r'/$', r'.*/homepage\.html.*', HomePage) login = URL(r'/ap/signin/.*$', LoginPage) history = URL(r'/gp/css/order-history.*$', r'/gp/your-account/order-history.*$', HistoryPage) order_old = URL(r'/gp/css/summary.*$', r'/gp/css/summary/edit.html\?orderID=%\(order_id\)s', r'/gp/digital/your-account/order-summary.html.*$', r'/gp/digital/your-account/orderPe-summary.html\?orderID=%\(order_id\)s', OrderOldPage) order_new = URL(r'/gp/css/summary.*$', r'/gp/your-account/order-details.*$', r'/gp/your-account/order-details\?orderID=%\(order_id\)s', OrderNewPage) unknown = URL(r'/.*$', AmazonPage) weboob-1.1/modules/amazon/fr/pages.py000066400000000000000000000354031265717027300176640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.shop import Order, Payment, Item from weboob.browser.pages import HTMLPage, pagination, NextPage from weboob.capabilities.base import empty from datetime import datetime from decimal import Decimal import re # Ugly array to avoid the use of french locale FRENCH_MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre'] class AmazonPage(HTMLPage): @property def logged(self): return bool(self.doc.xpath(u'//*[contains(text(),"Déconnectez-vous")]')) class HomePage(AmazonPage): def to_login(self): url1 = self.doc.xpath('//a[@id="nav-link-yourAccount"]/@href') url2 = self.doc.xpath('//a[@id="nav-your-account"]/@href') self.browser.location((url1 or url2)[0]) return self.browser.page class LoginPage(AmazonPage): def login(self, email, password): form = self.get_form(name='signIn') form['email'] = email form['password'] = password form.submit() class HistoryPage(AmazonPage): forced_encoding = True ENCODING = 'UTF-8' def iter_years(self): for year in self.opt_years(): yield self.to_year(year) @pagination def iter_orders(self): for id_ in self.doc.xpath(u'//span[contains(text(),"N° de commande")]/../span[2]/text()'): yield self.browser.to_order(id_.strip()) for next_ in self.doc.xpath(u'//ul[@class="a-pagination"]' u'//a[contains(text(),"Suivante")]/@href'): raise NextPage(next_) def to_year(self, year): form = self.get_form('//form[contains(@class,"time-period-chooser")]') form['orderFilter'] = [year] form.submit() return self.browser.page def opt_years(self): return [x for x in self.doc.xpath( '//select[@name="orderFilter"]/option/@value' ) if x.startswith('year-')] class OrderPage(AmazonPage): def shouldSkip(self): # Reports only fully shipped and delivered orders, because they have # finalized payment amounts. # Payment for not yet shipped orders may change, and is not always # available. return bool([x for s in [u'En préparation pour expédition', u'En cours de préparation'] # TODO : Other French status applied ? for x in self.doc.xpath(u'//*[contains(text(),"%s")]' % s)]) def decimal_amount(self, amount): m = re.match(u'.*EUR ([,0-9]+).*', amount) if m: return Decimal(m.group(1).replace(",", ".")) def month_to_int(self, text): for (idx, month) in enumerate(FRENCH_MONTHS): text = text.replace(month, str(idx + 1)) return text class OrderNewPage(OrderPage): is_here = u'//*[contains(text(),"Commandé le")]' def order(self): if not self.shouldSkip(): order = Order(id=self.order_number()) order.date = self.order_date() order.tax = self.tax() order.discount = self.discount() order.shipping = self.shipping() order.total = self.grand_total() order._bill = self.bill() return order def bill(self): pdf = self.doc.xpath(u'//a[contains(text(), "Imprimer une facture")]') htlm = self.doc.xpath(u'//a[contains(text(), "Imprimer un récapitulatif de commande")]') format = u'pdf' if pdf else u'html' url = pdf[0].attrib['href'] if pdf else htlm[0].attrib['href'] return {'url': url, 'format': format} def order_date(self): return datetime.strptime( re.match(u'.*Commandé le ([0-9]+ [0-9]+ [0-9]+) .*', self.month_to_int(self.date_num())).group(1), '%d %m %Y') def order_number(self): m = re.match(u'.*N° de commande : +([^ ]+) .*', self.date_num()) if m: return m.group(1) def payments(self): if self.gift(): pmt = Payment() pmt.date = self.order_date() pmt.method = u'GIFT CARD' pmt.amount = -self.gift() yield pmt transactions = list(self.transactions()) if transactions: for t in transactions: yield t else: for method in self.paymethods(): pmt = Payment() pmt.date = self.order_date() pmt.method = method pmt.amount = self.grand_total() yield pmt break def paymethods(self): for root in self.doc.xpath(u'//h5[contains(text(),"Méthode de paiement")]'): alt = root.xpath('../div/img/@alt')[0] span = root.xpath('../div/span/text()')[0] digits = re.match(r'[^0-9]*([0-9]+)[^0-9]*', span).group(1) yield u'%s %s' % (alt, digits) def grand_total(self): return self.decimal_amount(self.doc.xpath( '//span[contains(text(),"Montant total TTC")]/..' '/following-sibling::div[1]/span/text()')[0].strip()) def date_num(self): return u' '.join( self.doc.xpath( '//span[@class="order-date-invoice-item"]/text()' )).replace('\n', '') def tax(self): return self.amount(u' TVA') def shipping(self): return self.amount(u'Livraison :') def discount(self): # TODO : French translation return self.amount(u'Bon de réduction', u'Subscribe & Save', u'Your Coupon Savings', u'Lightning Deal') def gift(self): # TODO : French translation return self.amount(u'Gift Card Amount') def amount(self, *names): return Decimal(sum(self.decimal_amount(amount.strip()) for n in names for amount in self.doc.xpath( '(//span[contains(text(),"%s")]/../..//span)[2]/text()' % n))) def transactions(self): for row in self.doc.xpath('//span[contains(text(),"Transactions")]' '/../../div/div'): text = row.text_content().strip().replace('\n', ' ') if u'Expédition' not in text: continue date, method, amount = re.match( '.* ' '([0-9]+ [^ ]+ [0-9]+)' '[ -]+' '([A-z][^:]+)' ': +' '(EUR [^ ]+)', text).groups() date = datetime.strptime(self.month_to_int(date), '%d %m %Y') method = method.replace(u'finissant par ', u'').upper() amount = self.decimal_amount(amount) pmt = Payment() pmt.date = date pmt.method = method pmt.amount = amount yield pmt def items(self): for item in self.doc.xpath('//div[contains(@class,"a-box shipment")]' '/div/div/div/div/div/div'): url = (item.xpath(u'*//a[contains(@href,"/gp/product")]/@href') + [u''])[0] label = u''.join(item.xpath( '*//a[contains(@href,"/gp/product")]/text()')).strip() price = u''.join(x.strip() for x in item.xpath( '*//span[contains(text(),"EUR")]/text()') if x.strip().startswith('EUR')) price = self.decimal_amount(price) multi = re.match(u'([0-9]+) de (.*)', label) if multi: amount, label = multi.groups() price *= Decimal(amount) if url: url = unicode(self.browser.BASEURL) + \ re.match(u'(/gp/product/.*)/ref=.*', url).group(1) if label and price: itm = Item() itm.label = label itm.url = url itm.price = price yield itm class OrderOldPage(OrderPage): forced_encoding = True ENCODING = 'ISO-8859-15' is_here = u'//*[contains(text(),"Amazon.fr numéro de commande")]' def order(self): if not self.shouldSkip(): order = Order(id=self.order_number()) order.date = self.order_date() order.tax = Decimal(self.tax()) if not empty(self.tax()) else Decimal(0.00) order.discount = Decimal(self.discount()) if not empty(self.discount()) else Decimal(0.00) order.shipping = Decimal(self.shipping()) if not empty(self.shipping()) else Decimal(0.00) order.total = Decimal(self.grand_total()) if not empty(self.grand_total()) else Decimal(0.00) return order def order_date(self): date_str = self.doc.xpath(u'//b[contains(text(),"Commande numérique")]')[0].text month_str = re.match(u'.*Commande numérique : [0-9]+ ([^ ]+) [0-9]+.*', date_str).group(1) return datetime.strptime( re.match(u'.*Commande numérique : ([0-9]+ [0-9]+ [0-9]+).*', date_str.replace(month_str, str(FRENCH_MONTHS.index(month_str) + 1))).group(1), '%d %m %Y') def order_number(self): num_com = u' '.join(self.doc.xpath( u'//b[contains(text(),"Amazon.fr numéro de commande")]/../text()') ).strip() return num_com def tax(self): return self.sum_amounts(u'TVA:') def discount(self): # TODO : French translation return self.sum_amounts(u'Subscribe & Save:', u'Bon de réduction:', u'Promotion Applied:', u'Your Coupon Savings:') def shipping(self): # TODO : French translation return self.sum_amounts(u'Shipping & Handling:', u'Free shipping:', u'Free Shipping:') def payments(self): for shmt in self.shipments(): gift = self.gift(shmt) if gift: pmt = Payment() pmt.date = self.order_date() pmt.method = u'CARTE CADEAU' pmt.amount = -gift yield pmt transactions = list(self.transactions()) if transactions: for t in transactions: yield t else: for method in self.paymethods(): pmt = Payment() pmt.date = self.order_date() pmt.method = method pmt.amount = self.grand_total() yield pmt break def shipments(self): # TODO : French translation for cue in (u'Shipment #', u'Subscribe and Save Shipment'): for shmt in self.doc.xpath('//b[contains(text(),"%s")]' % cue): yield shmt def items(self): for shmt in self.shipments(): root = shmt.xpath(u'../../../../../../../..' u'//b[text()="Articles commandés"]')[0] for item in root.xpath('../../../tr')[1:]: count = url = label = None for div in item.xpath('*//div'): m = re.match(u'^\s*(\d+)\s*of:(.*)$', div.text, re.MULTILINE + re.DOTALL) if not m: continue count = Decimal(m.group(1).strip()) label = unicode(m.group(2).strip()) if label: url = u'' else: a = div.xpath('*//a[contains(@href,"/gp/product")]')[0] url = unicode(a.attrib['href']) label = unicode(a.text.strip()) price1 = item.xpath('*//div')[-1].text.strip() price = count * self.decimal_amount(price1) itm = Item() itm.label = label itm.url = url itm.price = price yield itm def sum_amounts(self, *names): return sum(self.amount(shmt, x) for shmt in self.shipments() for x in names) def amount(self, shmt, name): for root in shmt.xpath(u'../../../../../../../..' u'//td[text()="Sous-total articles: "]/../..'): for node in root.xpath(u'tr/td[text()="%s"]' % name): return self.decimal_amount( node.xpath('../td')[-1].text.strip()) for node in root.xpath(u'tr/td/b[text()="%s"]' % name): return self.decimal_amount( node.xpath('../../td/b')[-1].text.strip()) return Decimal(0) def gift(self, shmt): # TODO : French translation return self.amount(shmt, u'Gift Card Amount:') def paymethods(self): # TODO : French translation root = self.doc.xpath('//b[text()="Payment Method: "]/..') if len(root) == 0: return root = root[0] text = root.text_content().strip() while text: # TODO : French translation for pattern in [ u'^.*Payment Method:', u'^([^\n]+)\n +\| Last digits: +([0-9]+)\n', u'^Gift Card\n', # Skip gift card. u'^Billing address.*$']: match = re.match(pattern, text, re.DOTALL+re.MULTILINE) if match: text = text[match.end():].strip() if match.groups(): yield u' '.join(match.groups()).upper() break else: break def transactions(self): # TODO : French translation for tr in self.doc.xpath( u'//div[contains(b,"Credit Card transactions")]' u'/following-sibling::table[1]/tr'): label, date = tr.xpath('td[1]/text()')[0].strip().split(u'\xa0') amount = tr.xpath('td[2]/text()')[0].strip() date = datetime.strptime(date, '%B %d, %Y:') method = label.replace(u'ending in ', u'')[:-1].upper() amount = self.decimal_amount(amount) pmt = Payment() pmt.date = date pmt.method = method pmt.amount = amount yield pmt def grand_total(self): return self.decimal_amount(self.doc.xpath( u'//td[contains(b,"Total pour cette commande")]')[0].text) weboob-1.1/modules/amazon/module.py000066400000000000000000000074111265717027300174410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bill import CapBill, Subscription, Bill, SubscriptionNotFound, BillNotFound from weboob.capabilities.shop import CapShop, Order from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.ordereddict import OrderedDict from .browser import Amazon from .fr.browser import AmazonFR __all__ = ['AmazonModule'] class AmazonModule(Module, CapShop, CapBill): NAME = 'amazon' MAINTAINER = u'Oleg Plakhotniuk' EMAIL = 'olegus8@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Amazon' website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ 'www.amazon.com': u'Amazon.com', 'www.amazon.fr': u'Amazon France', }.iteritems())]) BROWSERS = { 'www.amazon.com': Amazon, 'www.amazon.fr': AmazonFR, } CONFIG = BackendConfig( Value('website', label=u'Website', choices=website_choices, default='www.amazon.com'), ValueBackendPassword('email', label='Username', masked=False), ValueBackendPassword('password', label='Password')) def create_default_browser(self): self.BROWSER = self.BROWSERS[self.config['website'].get()] return self.create_browser(self.config['email'].get(), self.config['password'].get()) def get_currency(self): return self.browser.get_currency() def get_order(self, id_): return self.browser.get_order(id_) def iter_orders(self): return self.browser.iter_orders() def iter_payments(self, order): if not isinstance(order, Order): order = self.get_order(order) return self.browser.iter_payments(order) def iter_items(self, order): if not isinstance(order, Order): order = self.get_order(order) return self.browser.iter_items(order) def iter_resources(self, objs, split_path): if Order in objs: self._restrict_level(split_path) return self.iter_orders() if Subscription in objs: self._restrict_level(split_path) return self.iter_subscription() def iter_subscription(self): return self.browser.get_subscription_list() def get_subscription(self, _id): return find_object(self.iter_subscription(), id=_id, error=SubscriptionNotFound) def get_bill(self, _id): subid = _id.split('.')[0] subscription = self.get_subscription(subid) return find_object(self.iter_bills(subscription), id=_id, error=BillNotFound) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_bills(subscription) def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) if bill._url: return self.browser.open(bill._url).content return None weboob-1.1/modules/amazon/pages.py000066400000000000000000000323651265717027300172610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.capabilities.shop import Order, Payment, Item from weboob.browser.pages import HTMLPage, pagination, NextPage from datetime import datetime from decimal import Decimal import re class AmazonPage(HTMLPage): @property def logged(self): return bool(self.doc.xpath(u'//*[contains(text(),"Sign Out")]')) class HomePage(AmazonPage): def to_login(self): url1 = self.doc.xpath('//a[@id="nav-link-yourAccount"]/@href') url2 = self.doc.xpath('//a[@id="nav-your-account"]/@href') self.browser.location((url1 or url2)[0]) return self.browser.page class LoginPage(AmazonPage): def login(self, email, password): form = self.get_form(name='signIn') form['email'] = email form['password'] = password form.submit() class HistoryPage(AmazonPage): def iter_years(self): for year in self.opt_years(): yield self.to_year(year) @pagination def iter_orders(self): for id_ in self.doc.xpath( u'//span[contains(text(),"Order #")]/../span[2]/text()'): yield self.browser.to_order(id_.strip()) for next_ in self.doc.xpath(u'//ul[@class="a-pagination"]' u'//a[contains(text(),"Next")]/@href'): raise NextPage(next_) def to_year(self, year): form = self.get_form('//form[contains(@class,"time-period-chooser")]') form['orderFilter'] = [year] form.submit() return self.browser.page def opt_years(self): return [x for x in self.doc.xpath( '//select[@name="orderFilter"]/option/@value' ) if x.startswith('year-')] class OrderPage(AmazonPage): def shouldSkip(self): # Reports only fully shipped and delivered orders, because they have # finalized payment amounts. # Payment for not yet shipped orders may change, and is not always # available. return bool([x for s in [u'Not Yet Shipped', u'Not yet shipped', u'Preparing for Shipment', u'Shipping now', u'In transit', u'On the way'] for x in self.doc.xpath(u'//*[contains(text(),"%s")]' % s)]) class OrderNewPage(OrderPage): is_here = u'//*[contains(text(),"Ordered on")]' def order(self): if not self.shouldSkip(): order = Order(id=self.order_number()) order.date = self.order_date() order.tax = self.tax() order.discount = self.discount() order.shipping = self.shipping() return order def order_date(self): return datetime.strptime( re.match('.*Ordered on ([^ ]+ [0-9]+, [0-9]+) .*', self.date_num()).group(1), '%B %d, %Y') def order_number(self): m = re.match('.*Order# +([^ ]+) .*', self.date_num()) if m: return m.group(1) def payments(self): if self.gift(): pmt = Payment() pmt.date = self.order_date() pmt.method = u'GIFT CARD' pmt.amount = -self.gift() yield pmt transactions = list(self.transactions()) if transactions: for t in transactions: yield t else: for method in self.paymethods(): pmt = Payment() pmt.date = self.order_date() pmt.method = method pmt.amount = self.grand_total() yield pmt break def paymethods(self): for root in self.doc.xpath(u'//h5[contains(text(),"Payment Method")]'): div = u''.join(root.xpath('../div/text()')).strip() if div: yield div else: alt = root.xpath('../div/img/@alt')[0] span = root.xpath('../div/span/text()')[0] digits = re.match(r'[^0-9]*([0-9]+)[^0-9]*', span).group(1) yield u'%s %s' % (alt, digits) def grand_total(self): return AmTr.decimal_amount(self.doc.xpath( u'//span[contains(text(),"Grand Total:")]/..' u'/following-sibling::div[1]/span/text()')[0].strip()) def date_num(self): return u' '.join(self.doc.xpath( '//span[@class="order-date-invoice-item"]/text()' ) or self.doc.xpath( '//*[contains(text(),"Ordered on")]/text()')).replace('\n', '') def tax(self): return self.amount(u'Estimated tax to be collected') def shipping(self): return self.amount(u'Free shipping', u'Free Shipping', u'Prime Pantry Delivery', u'Shipping & Handling') def discount(self): return self.amount(u'Promotion applied', u'Promotion Applied', u'Subscribe & Save', u'Your Coupon Savings', u'Lightning Deal', u'No-Rush Credit') def gift(self): return self.amount(u'Gift Card Amount') def amount(self, *names): return Decimal(sum(AmTr.decimal_amount(amount.strip()) for n in names for amount in self.doc.xpath( '//span[contains(text(),"%s:")]' '/../following::div[1]/span/text()' % n))) def transactions(self): for row in self.doc.xpath('//span[contains(text(),"Transactions")]' '/../../div/div'): text = row.text_content().strip().replace('\n', ' ') if u'Items shipped:' not in text: continue date, method, amount = re.match( '.* ' '([A-z]+ [0-9]+, [0-9]+)' '[ -]+' '([A-z][^:]+)' ': +' '([^ ]+)', text).groups() date = datetime.strptime(date, '%B %d, %Y') method = method.replace(u'ending in ', u'').upper() amount = AmTr.decimal_amount(amount) pmt = Payment() pmt.date = date pmt.method = method pmt.amount = amount yield pmt def items(self): for item in self.doc.xpath('//div[contains(@class,"a-box shipment")]' '/div/div/div/div/div/div'): url = (item.xpath(u'*//a[contains(@href,"/gp/product")]/@href') + [u''])[0] label = u''.join(item.xpath( '*//a[contains(@href,"/gp/product")]/text()')).strip() price = u''.join(x.strip() for x in item.xpath( '*//span[contains(text(),"$")]/text()') if x.strip().startswith('$')) price = AmTr.decimal_amount(price) multi = re.match(u'([0-9]+) of (.*)', label) if multi: amount, label = multi.groups() price *= Decimal(amount) if url: url = unicode(self.browser.BASEURL) + \ re.match(u'(/gp/product/.*)/ref=.*', url).group(1) if label: itm = Item() itm.label = label itm.url = url itm.price = price yield itm class OrderOldPage(OrderPage): is_here = u'//*[contains(text(),"Amazon.com order number")]' def order(self): if not self.shouldSkip(): order = Order(id=self.order_number()) order.date = self.order_date() order.tax = self.tax() order.discount = self.discount() order.shipping = self.shipping() return order def order_date(self): return datetime.strptime(u' '.join(self.doc.xpath( u'//b[contains(text(),"Order Placed")]/../text()')).strip(), '%B %d, %Y') def order_number(self): return u' '.join(self.doc.xpath( u'//td/b[contains(text(),"Amazon.com order number")]/../text()') ).strip() def tax(self): return self.sum_amounts(u'Sales Tax:') def discount(self): return self.sum_amounts(u'Subscribe & Save:', u'Promotion applied:', u'Promotion Applied:', u'Your Coupon Savings:') def shipping(self): return self.sum_amounts(u'Shipping & Handling:', u'Free shipping:', u'Free Shipping:') def payments(self): for shmt in self.shipments(): gift = self.gift(shmt) if gift: pmt = Payment() pmt.date = self.order_date() pmt.method = u'GIFT CARD' pmt.amount = -gift yield pmt transactions = list(self.transactions()) if transactions: for t in transactions: yield t else: for method in self.paymethods(): pmt = Payment() pmt.date = self.order_date() pmt.method = method pmt.amount = self.grand_total() yield pmt break def shipments(self): for cue in (u'Shipment #', u'Subscribe and Save Shipment'): for shmt in self.doc.xpath('//b[contains(text(),"%s")]' % cue): yield shmt def items(self): for shmt in self.shipments(): root = shmt.xpath(u'../../../../../../../..' u'//b[text()="Items Ordered"]')[0] for item in root.xpath('../../../tr')[1:]: count = url = label = None for div in item.xpath('*//div'): m = re.match(u'^\s*(\d+)\s*of:(.*)$', div.text, re.MULTILINE + re.DOTALL) if not m: continue count = Decimal(m.group(1).strip()) label = unicode(m.group(2).strip()) if label: url = u'' else: a = div.xpath('*//a[contains(@href,"/gp/product")]')[0] url = unicode(a.attrib['href']) label = unicode(a.text.strip()) price1 = item.xpath('*//div')[-1].text.strip() price = count * AmTr.decimal_amount(price1) itm = Item() itm.label = label itm.url = url itm.price = price yield itm def sum_amounts(self, *names): return sum(self.amount(shmt, x) for shmt in self.shipments() for x in names) def amount(self, shmt, name): for root in shmt.xpath(u'../../../../../../../..' u'//td[text()="Item(s) Subtotal: "]/../..'): for node in root.xpath(u'tr/td[text()="%s"]' % name): return AmTr.decimal_amount( node.xpath('../td')[-1].text.strip()) for node in root.xpath(u'tr/td/b[text()="%s"]' % name): return AmTr.decimal_amount( node.xpath('../../td/b')[-1].text.strip()) return Decimal(0) def gift(self, shmt): return self.amount(shmt, u'Gift Card Amount:') def paymethods(self): root = self.doc.xpath('//b[text()="Payment Method: "]/..')[0] text = root.text_content().strip() while text: for pattern in [ u'^.*Payment Method:', u'^([^\n]+)\n +\| Last digits: +([0-9]+)\n', u'^Gift Card\n', # Skip gift card. u'^Billing address.*$']: match = re.match(pattern, text, re.DOTALL+re.MULTILINE) if match: text = text[match.end():].strip() if match.groups(): yield u' '.join(match.groups()).upper() break else: break def transactions(self): for tr in self.doc.xpath( u'//div[contains(b,"Credit Card transactions")]' u'/following-sibling::table[1]/tr'): label, date = tr.xpath('td[1]/text()')[0].strip().split(u'\xa0') amount = tr.xpath('td[2]/text()')[0].strip() date = datetime.strptime(date, '%B %d, %Y:') method = label.replace(u'ending in ', u'')[:-1].upper() amount = AmTr.decimal_amount(amount) pmt = Payment() pmt.date = date pmt.method = method pmt.amount = amount yield pmt def grand_total(self): return AmTr.decimal_amount(self.doc.xpath( '//td[b="Grand Total:"]/following-sibling::td[1]/b')[0].text) weboob-1.1/modules/amazon/test.py000066400000000000000000000021461265717027300171330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class AmazonTest(BackendTest): MODULE = 'amazon' def test_history(self): """ Test that at least one item was ordered in the whole history. """ b = self.backend items = (i for o in b.iter_orders() for i in b.iter_items(o)) item = next(items, None) self.assertNotEqual(item, None) weboob-1.1/modules/amazonstorecard/000077500000000000000000000000001265717027300175065ustar00rootroot00000000000000weboob-1.1/modules/amazonstorecard/__init__.py000066400000000000000000000014671265717027300216270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014-2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AmazonStoreCardModule __all__ = ['AmazonStoreCardModule'] weboob-1.1/modules/amazonstorecard/browser.py000066400000000000000000000053261265717027300215510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014-2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import AccountNotFound from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import SomePage, LoginPage, RecentPage, StatementsPage, \ StatementPage, SummaryPage __all__ = ['AmazonStoreCard'] class AmazonStoreCard(LoginBrowser): BASEURL = 'https://www.onlinecreditcenter6.com' MAX_RETRIES = 10 TIMEOUT = 30.0 login = URL('/consumergen2/login.do\?accountType=plcc&clientId=amazon' '&langId=en&subActionId=1000$', '/consumergen2/consumerlogin.do.*$', LoginPage) stmts = URL('/consumergen2/ebill.do$', StatementsPage) recent = URL('/consumergen2/recentActivity.do$', RecentPage) statement = URL('/consumergen2/ebillViewPDF.do.*$', StatementPage) summary = URL('/consumergen2/accountSummary.do$', SummaryPage) unknown = URL('.*', SomePage) def __init__(self, config, *args, **kwargs): super(AmazonStoreCard, self).__init__(config['userid'].get(), config['password'].get(), *args, **kwargs) self.config = config def do_login(self): self.session.cookies.clear() self.login.go() for i in xrange(self.MAX_RETRIES): if not self.login.is_here(): break self.page.proceed(self.config) if not self.page.logged: raise BrowserIncorrectPassword() @need_login def get_account(self, id_): a = next(self.iter_accounts()) if (a.id != id_): raise AccountNotFound() return a @need_login def iter_accounts(self): yield self.summary.go(data=SummaryPage.DATA).account() @need_login def iter_history(self, account): for t in self.recent.go(data=RecentPage.DATA).iter_transactions(): yield t for s in self.stmts.go(data=StatementsPage.DATA).iter_statements(): for t in s.iter_transactions(): yield t weboob-1.1/modules/amazonstorecard/favicon.png000066400000000000000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ϟitf ۶%ܡD^kM:&Qh5['͒JI9TתץԪUY]Ya8BT*rNOOuHql&&'<Z&zU2,hk:b}AQ2E4"\.yAiyHƽZXX`CdY :!tjp^BЉ⦦jLou=yn݊mxH)q]U)/rr]bFU2 m3>9I²,FFFߧZ8?GҤlㄈ1!s(oH)H9)ܰL6ˎwD\>J*P(PTDAumbqm{vqص{zMR,l`bBnh6)J-t#6m"Ea-];P()H;dT*B'8 ); {Z$F,NE$,!I䯓^w&$Q6*XoM?A8G^&ɉ&xCǪ뺴~Vv=f~=ϓw`S)и7p0 <`P$פּҿ/ G,As8)d뭈M?8pCM3}ӛZi<}!tQu(ݜGT߬dVz]dΐ'#~[7 )$} RVJQ5)Qcԍt\NϷEbÓ {1&ݥB!D:'''i4`6Zw߮a`$UP>ooV?6l]#;%SSS,..4}MMMr9PĂ烀q= h׏H(& qgv`vm|>G*B0 )J^wxO.`\C7u џe1NŸ 5%-Pw*NdlfzAXRYV6y+RX#dCA٤VRYXKKr9Zq&p]5ҙ(ŽRP(Q*hBlRiEFFF( %K/1`s_uH:~f~kx6LTѤ\.ݟUk\vZk\ ZT@T.T b˲=zR##Ph&~bl6D#mVH yRt4НqFFc< D5\.yqBkL)~K3NW6ύ\؝a2E{m۱ċPhL\JR)|>O']/ Źs !)8s %KI'g\m1 W0b XqihxZ+ض} !9 P빺,Q/}D{l$ b^fIxOAkĥKh4HCA@:uI8XPnncbs\fI`hh!$*BLan [nfyB'|j4u24fxDB6!8kFGf R׎ꡡmm6Fh׵|9%tEXtdate:create2014-12-28T13:20:51-06:00(s%tEXtdate:modify2014-12-28T13:20:51-06:00u$IENDB`weboob-1.1/modules/amazonstorecard/module.py000066400000000000000000000034461265717027300213540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014-2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import AmazonStoreCard __all__ = ['AmazonStoreCardModule'] class AmazonStoreCardModule(Module, CapBank): NAME = 'amazonstorecard' MAINTAINER = u'Oleg Plakhotniuk' EMAIL = 'olegus8@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Amazon Store Card' CONFIG = BackendConfig( ValueBackendPassword('userid', label='User ID', masked=False), ValueBackendPassword('password', label='Password'), ValueBackendPassword('challengeanswer1', label='Challenge answer 1', masked=False)) BROWSER = AmazonStoreCard def create_default_browser(self): return self.create_browser(config = self.config) def iter_accounts(self): return self.browser.iter_accounts() def get_account(self, id_): return self.browser.get_account(id_) def iter_history(self, account): return self.browser.iter_history(account) weboob-1.1/modules/amazonstorecard/pages.py000066400000000000000000000200321265717027300211540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014-2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import Account, Transaction from weboob.browser.pages import HTMLPage, RawPage, XMLPage from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.tools.date import closest_date from weboob.tools.pdf import decompress_pdf from weboob.tools.tokenizer import ReTokenizer from datetime import datetime, timedelta class SomePage(HTMLPage): @property def logged(self): return bool(self.doc.xpath('//span[@class="logoutBtn"]')) class LoginPage(SomePage): INPUTS = ['userId', 'password', 'challengeAnswer1'] is_here = '//form[@name="consumerLoginForm"]' def proceed(self, config): form = self.get_form(name='consumerLoginForm') for inp in (i for i in self.INPUTS if i in form): form[inp] = config[inp.lower()].get() form.submit() return self.browser.page class SummaryPage(SomePage): DATA = {'subActionId': '1201', 'clientId': 'amazon', 'accountType': 'plcc', 'langId': 'en'} def account(self): label = u' '.join(u''.join(self.doc.xpath( u'//text()[contains(.,"Account ending in")]')).split()) balance = self.doc.xpath( '//span[@id="currentBalance"]/..')[0].text_content() cardlimit = self.doc.xpath(u'//td[contains(text(),' '"Total Credit Limit")]/../td[2]')[0].text_content() paydate = self.doc.xpath(u'//td[contains(text(),' '"Payment Due Date")]/../td[2]')[0].text_content() paymin = self.doc.xpath( '//span[@id="nextMinPayment"]/..')[0].text_content() a = Account() a.id = label[-4:] a.label = label a.currency = Account.get_currency(balance) a.balance = -AmTr.decimal_amount(balance) a.type = Account.TYPE_CARD a.cardlimit = AmTr.decimal_amount(cardlimit) a.paydate = datetime.strptime(paydate, '%m/%d/%Y') a.paymin = AmTr.decimal_amount(paymin) return a class RecentPage(XMLPage): DATA = {'subActionId': '1300', 'requestType': 'ajaxReq'} def iter_transactions(self): for ntrans in reversed(self.doc.xpath('//TRANSACTION')): desc = u' '.join(ntrans.xpath( 'TRANSDESCRIPTION/text()')[0].split()) tdate = u''.join(ntrans.xpath('TRANSACTIONDATE/text()')) pdate = u''.join(ntrans.xpath('POSTDATE/text()')) # Skip transactions which are not posted, # because they are not accounted for in balance calculation. if not pdate: continue t = Transaction() t.date = datetime.strptime(tdate, '%m/%d/%Y') t.rdate = datetime.strptime(pdate, '%m/%d/%Y') t.type = Transaction.TYPE_UNKNOWN t.raw = desc t.label = desc t.amount = -AmTr.decimal_amount(ntrans.xpath('AMOUNT/text()')[0]) yield t class StatementsPage(SomePage): DATA = {'subActionId': '8168', 'clientId': 'amazon', 'accountType': 'plcc', 'langId': 'en'} def iter_statements(self): for url in self.doc.xpath('//a[contains(@href,"ebillViewPDF")]/@href'): if url.endswith('inline=false'): self.browser.location(url) yield self.browser.page class StatementPage(RawPage): LEX = [ ('charge_amount', r'^\(\$([0-9\.]+)\) Tj$'), ('payment_amount', r'^\(\\\(\$([0-9\.]+)\\\)\) Tj$'), ('date', r'^\((\d+/\d+)\) Tj$'), ('full_date', r'^\((\d+/\d+/\d+)\) Tj$'), ('layout_td', r'^([-0-9]+ [-0-9]+) Td$'), ('ref', r'^\(([A-Z0-9]{17})\) Tj$'), ('text', r'^\((.*)\) Tj$') ] def __init__(self, *args, **kwArgs): RawPage.__init__(self, *args, **kwArgs) assert self.doc[:4] == '%PDF' self._pdf = decompress_pdf(self.doc) self._tok = ReTokenizer(self._pdf, '\n', self.LEX) def iter_transactions(self): return sorted(self.read_transactions(), cmp=lambda t1, t2: cmp(t2.date, t1.date) or cmp(t1.label, t2.label) or cmp(t1.amount, t2.amount)) def read_transactions(self): # Statement typically cover one month. # Do 60 days, just to be on a safe side. date_to = self.read_closing_date() date_from = date_to - timedelta(days=60) pos = 0 while not self._tok.tok(pos).is_eof(): pos, trans = self.read_transaction(pos, date_from, date_to) if trans: yield trans else: pos += 1 def read_transaction(self, pos, date_from, date_to): startPos = pos pos, tdate = self.read_date(pos) pos, pdate_layout = self.read_layout_td(pos) pos, pdate = self.read_date(pos) pos, ref_layout = self.read_layout_td(pos) pos, ref = self.read_ref(pos) pos, desc_layout = self.read_layout_td(pos) pos, desc = self.read_text(pos) pos, amount_layout = self.read_layout_td(pos) pos, amount = self.read_amount(pos) if tdate is None or pdate is None \ or desc is None or amount is None or amount == 0: return startPos, None else: tdate = closest_date(tdate, date_from, date_to) pdate = closest_date(pdate, date_from, date_to) desc = u' '.join(desc.split()) trans = Transaction(ref or u'') trans.date = tdate trans.rdate = pdate trans.type = Transaction.TYPE_UNKNOWN trans.raw = desc trans.label = desc trans.amount = amount return pos, trans def read_amount(self, pos): pos, ampay = self.read_payment_amount(pos) if ampay is not None: return pos, ampay return self.read_charge_amount(pos) def read_charge_amount(self, pos): t = self._tok.tok(pos) return (pos+1, -AmTr.decimal_amount(t.value())) \ if t.is_charge_amount() else (pos, None) def read_payment_amount(self, pos): t = self._tok.tok(pos) return (pos+1, AmTr.decimal_amount(t.value())) \ if t.is_payment_amount() else (pos, None) def read_closing_date(self): pos = 0 while not self._tok.tok(pos).is_eof(): pos, text = self.read_text(pos) if text == u'Statement Closing Date': break pos += 1 while not self._tok.tok(pos).is_eof(): pos, date = self.read_full_date(pos) if date is not None: return date pos += 1 def read_text(self, pos): t = self._tok.tok(pos) return (pos+1, unicode(t.value())) \ if t.is_text() else (pos, None) def read_full_date(self, pos): t = self._tok.tok(pos) return (pos+1, datetime.strptime(t.value(), '%m/%d/%Y')) \ if t.is_full_date() else (pos, None) def read_date(self, pos): t = self._tok.tok(pos) return (pos+1, datetime.strptime(t.value(), '%m/%d')) \ if t.is_date() else (pos, None) def read_ref(self, pos): t = self._tok.tok(pos) return (pos+1, t.value()) if t.is_ref() else (pos, None) def read_layout_td(self, pos): t = self._tok.tok(pos) return (pos+1, t.value()) if t.is_layout_td() else (pos, None) weboob-1.1/modules/amazonstorecard/test.py000066400000000000000000000022211265717027300210340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014-2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from itertools import chain class AmazonStoreCardTest(BackendTest): MODULE = 'amazonstorecard' def test_history(self): """ Test that there's at least one transaction in the whole history. """ b = self.backend ts = chain(*[b.iter_history(a) for a in b.iter_accounts()]) t = next(ts, None) self.assertNotEqual(t, None) weboob-1.1/modules/ameli/000077500000000000000000000000001265717027300154015ustar00rootroot00000000000000weboob-1.1/modules/ameli/__init__.py000066400000000000000000000014451265717027300175160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AmeliModule __all__ = ['AmeliModule'] weboob-1.1/modules/ameli/browser.py000066400000000000000000000102251265717027300174360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, LoginValidationPage, HomePage, AccountPage, LastPaymentsPage, PaymentDetailsPage, BillsPage __all__ = ['AmeliBrowser'] class AmeliBrowser(LoginBrowser): BASEURL = 'https://assure.ameli.fr' loginp = URL('/PortailAS/appmanager/PortailAS/assure\?.*_pageLabel=as_login_page', LoginPage) login_validationp = URL('https://assure.ameli.fr:443/PortailAS/appmanager/PortailAS/assure;jsessionid=[a-zA-Z0-9!;-]+\?_nfpb=true&_windowLabel=connexioncompte_2&connexioncompte_2_actionOverride=%2Fportlets%2Fconnexioncompte%2Fvalidationconnexioncompte&_pageLabel=as_login_page$', LoginValidationPage) homep = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_accueil_page', HomePage) accountp = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_info_perso_page', AccountPage) billsp = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_revele_mensuel_presta_page', BillsPage) paymentdetailsp = URL('/PortailAS/appmanager/PortailAS/assure\?.*_pageLabel=as_dernier_paiement_page&paiements_1_actionOverride=%2Fportlets%2Fpaiements%2Fdetailpaiements.*', PaymentDetailsPage) lastpaymentsp = URL('/PortailAS/appmanager/PortailAS/assure\?_nfpb=true&_pageLabel=as_dernier_paiement_page$', LastPaymentsPage) logged = False def do_login(self): self.logger.debug('call Browser.do_login') if self.logged: return True self.loginp.stay_or_go() if self.homep.is_here(): self.logged = True return True self.page.login(self.username, self.password) error = self.page.is_error() if error: raise BrowserIncorrectPassword(error) self.homep.stay_or_go() # Redirection not interpreted by browser. Mannually redirect on homep if not self.homep.is_here(): raise BrowserIncorrectPassword() self.logged = True @need_login def iter_subscription_list(self): self.logger.debug('call Browser.iter_subscription_list') self.accountp.stay_or_go() return self.page.iter_subscription_list() @need_login def get_subscription(self, id): self.logger.debug('call Browser.get_subscription') assert isinstance(id, basestring) for sub in self.iter_subscription_list(): if id == sub._id: return sub return None @need_login def iter_history(self, sub): self.logger.debug('call Browser.iter_history') self.lastpaymentsp.stay_or_go() urls = self.page.iter_last_payments() for url in urls: self.location(url) assert self.paymentdetailsp.is_here() for payment in self.page.iter_payment_details(sub): yield payment @need_login def iter_bills(self, sub): self.logger.debug('call Browser.iter_bills') if not sub._id.isdigit(): return [] self.billsp.stay_or_go() return self.page.iter_bills(sub) @need_login def get_bill(self, id): self.logger.debug('call Browser.get_bill') assert isinstance(id, basestring) subs = self.iter_subscription_list() for sub in subs: for b in self.iter_bills(sub): if id == b.id: return b return False webo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ZGG:͹ PH_JZps[Lbwtw~tށSi^BV iKRb%Gy!NS~oLz1ȴȱM$[_}^dG JU`IZ!,MOYepf''86~B(pcX,bٳ+ഢ*uJE 17814U|Yqy@`h ֶ{k"BNN`_'Fq flj|+o>of7W5K&T2 Piat?y!L3?YgJ%4BAͣD[OZ_bʛ;_zw@ O@L$d4]ϡ^a/c5>fZ~ i-TS~\Y:_SPd]YWza@z]7k/;&A~ƿ@WD8S^K}-GIj>-/kͩ!= 1yq  ϝWgbb$ WOP]etyE}ݍGP!0ElN-z\,EHkEoB`CkO㙬aW'm~0?עzz(~ Nab1_r E@L^طbtώ ARN}~"jL^cr YEAT/jݠ-Li iaPD6Mq&=@nk#: )C>%(׼_,ӿD3P C X@fƏkGl߱zVd( 315&1s.f^[ V&Иs1I3bfdȾC6]c8_Llnua'. Зg  n ̭0tK(Hֳp$v-ݿX=^V`۲e݅w)mݳ+k̅@o+ 3?+DE\IENDB`weboob-1.1/modules/ameli/module.py000066400000000000000000000057061265717027300172500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bill import CapBill, SubscriptionNotFound, BillNotFound, Subscription, Bill from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import AmeliBrowser __all__ = ['AmeliModule'] class AmeliModule(Module, CapBill): NAME = 'ameli' DESCRIPTION = u'Ameli website: French Health Insurance' MAINTAINER = u'Christophe Lampin' EMAIL = 'weboob@lampin.net' VERSION = '1.1' LICENSE = 'AGPLv3+' BROWSER = AmeliBrowser CONFIG = BackendConfig(ValueBackendPassword('login', label='Numero de SS', masked=False), ValueBackendPassword('password', label='Password', masked=True) ) def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): return self.browser.iter_subscription_list() def get_subscription(self, _id): subscription = self.browser.get_subscription(_id) if not subscription: raise SubscriptionNotFound() else: return subscription def iter_bills_history(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_history(subscription) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_bills(subscription) def get_bill(self, id): bill = self.browser.get_bill(id) if not bill: raise BillNotFound() else: return bill def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) request = self.browser.open(bill._url, stream=True) assert(request.headers['content-type'] == "application/pdf") return request.content weboob-1.1/modules/ameli/pages.py000066400000000000000000000202071265717027300170530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime import re import urllib from decimal import Decimal from weboob.browser.pages import HTMLPage from weboob.capabilities.bill import Subscription, Detail, Bill from weboob.browser.filters.standard import CleanText, RawText, Regexp # Ugly array to avoid the use of french locale FRENCH_MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre'] class AmeliBasePage(HTMLPage): def is_logged(self): if self.doc.xpath('//a[@id="id_lien_deco"]'): logged = True else: logged = False self.logger.debug('logged: %s' % (logged)) return logged def is_error(self): errors = self.doc.xpath(u'//*[@id="r_errors"]') if errors: return errors[0].text_content() return False class LoginPage(AmeliBasePage): def login(self, login, password): form = self.get_form('//form[@name="connexionCompteForm"]') form['connexioncompte_2numSecuriteSociale'] = login.encode('utf8') form['connexioncompte_2codeConfidentiel'] = password.encode('utf8') form.submit() class LoginValidationPage(AmeliBasePage): pass class HomePage(AmeliBasePage): pass class AccountPage(AmeliBasePage): def iter_subscription_list(self): fullname = CleanText('//div[@id="bloc_contenu_masituation"]/h3', replace=[('Titulaire du compte : ', '')])(self.doc) number = re.sub('[^\d]+', '', self.doc.xpath('//div[@id="bloc_contenu_masituation"]/ul/li')[2].text) sub = Subscription(number) sub._id = number sub.label = unicode(fullname) firstname = Regexp(RawText('//div[@id="bloc_contenu_masituation"]/h3'), '\t([^\xa0\t]+)\xa0[^:]')(self.doc) sub.subscriber = unicode(firstname) yield sub nb_childs = 0 childs = self.doc.xpath('//div[@class="bloc_infos"]') for child in childs: fullname = CleanText('.//h3[1]')(child) nb_childs = nb_childs + 1 number = "AFFILIE" + str(nb_childs) sub = Subscription(number) sub._id = number sub.label = unicode(fullname) firstname = Regexp(RawText('./h3'), '\t([^\xa0\t]+)\xa0[^:]')(child) sub.subscriber = unicode(firstname) yield sub class LastPaymentsPage(AmeliBasePage): def iter_last_payments(self): list_table = self.doc.xpath('//table[@id="tabDerniersPaiements"]') if len(list_table) > 0: table = list_table[0].xpath('.//tr') for tr in table: list_a = tr.xpath('.//a') if len(list_a) == 0: continue yield list_a[0].attrib.get('href').replace(':443','') class PaymentDetailsPage(AmeliBasePage): def iter_payment_details(self, sub): if CleanText('//div[@class="infoPrestationsAssure"]/span')(self.doc).startswith('Pour %s' % sub.subscriber): id_str = self.doc.xpath('//div[@class="centrepage"]/h2')[0].text.strip() m = re.match('.*le (.*) pour un montant de.*', id_str) if m: id_str = m.group(1) id_date = datetime.strptime(id_str, '%d/%m/%Y').date() id = sub._id + "." + datetime.strftime(id_date, "%Y%m%d") table = self.doc.xpath('//div[@class="infoPrestationsAssure"]//table')[0].xpath('.//tr') line = 1 last_date = None for tr in table: tds = tr.xpath('.//td') if len(tds) == 0: continue det = Detail() if len(tds) == 5: date_str = tds[0].text det.id = id + "." + str(line) det.label = unicode(tds[1].text.strip()) jours = tds[2].text if jours is None: jours = '0' montant = tds[3].text if montant is None: montant = '0' price = tds[4].text if price is None: price = '0' if date_str is None or date_str == '': det.infos = u'' det.datetime = last_date else: det.infos = date_str + u' (' + unicode(re.sub('[^\d,-]+', '', jours)) + u'j) * ' + unicode(re.sub('[^\d,-]+', '', montant)) + u'€' det.datetime = datetime.strptime(date_str.split(' ')[3], '%d/%m/%Y').date() last_date = det.datetime det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.')) if len(tds) == 6: date_str = tds[0].text det.id = id + "." + str(line) det.label = unicode(tds[1].text.strip()) paye = tds[2].text if paye is None: paye = '0' base = tds[3].text if base is None: base = '0' taux = tds[4].text if taux is None: taux = '0' price = tds[5].text if price is None: price = '0' if date_str is None or date_str == '': det.infos = u'' det.datetime = last_date else: det.infos = u'Payé ' + unicode(re.sub('[^\d,-]+', '', paye)) + u'€ / Base ' + unicode(re.sub('[^\d,-]+', '', base)) + u'€ / Taux ' + unicode(re.sub('[^\d,-]+', '', taux)) + '%' det.datetime = datetime.strptime(date_str, '%d/%m/%Y').date() last_date = det.datetime det.price = Decimal(re.sub('[^\d,-]+', '', price).replace(',', '.')) line = line + 1 yield det class BillsPage(AmeliBasePage): def iter_bills(self, sub): try: table = self.doc.xpath('//table[@id="relevesMensuels"]')[0].xpath('.//tr') # When no operations was done in the last month, there is no table. That is fine. except IndexError: return for tr in table: list_tds = tr.xpath('.//td') if len(list_tds) == 0: continue date_str = list_tds[0].text month_str = date_str.split()[0] date = datetime.strptime(re.sub(month_str, str(FRENCH_MONTHS.index(month_str) + 1), date_str), "%m %Y").date() amount = list_tds[1].text if amount is None: continue amount = re.sub('[^\d,-]+', '', amount) bil = Bill() bil.id = sub._id + "." + date.strftime("%Y%m") bil.date = date bil.price = Decimal('-'+amount.strip().replace(',','.')) bil.format = u'pdf' bil.label = date.strftime("%Y%m%d") bil._url = '/PortailAS/PDFServletReleveMensuel.dopdf?PDF.moisRecherche='+date.strftime("%m%Y") yield bil def get_bill(self, bill): self.location(bill._url, urllib.urlencode(bill._args)) weboob-1.1/modules/ameli/test.py000066400000000000000000000021321265717027300167300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class AmeliTest(BackendTest): MODULE = 'ameli' def test_ameli(self): for subscription in self.backend.iter_subscription(): list(self.backend.iter_bills_history(subscription.id)) for bill in self.backend.iter_bills(subscription.id): self.backend.download_bill(bill.id) weboob-1.1/modules/amelipro/000077500000000000000000000000001265717027300161225ustar00rootroot00000000000000weboob-1.1/modules/amelipro/__init__.py000066400000000000000000000014531265717027300202360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AmeliProModule __all__ = ['AmeliProModule'] weboob-1.1/modules/amelipro/browser.py000066400000000000000000000107401265717027300201610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities.bill import Detail from decimal import Decimal from .pages import LoginPage, HomePage, AccountPage, HistoryPage, BillsPage, SearchPage __all__ = ['AmeliProBrowser'] class AmeliProBrowser(LoginBrowser): BASEURL = 'https://espacepro.ameli.fr:443' loginp = URL('/PortailPS/appmanager/portailps/professionnelsante\?_nfpb=true&_pageLabel=vp_login_page', LoginPage) homep = URL('/PortailPS/appmanager/portailps/professionnelsante\?_nfpb=true&_pageLabel=vp_accueil_page', HomePage) accountp = URL('/PortailPS/appmanager/portailps/professionnelsante\?_nfpb=true&_pageLabel=vp_coordonnees_infos_perso_page', AccountPage) billsp = URL('/PortailPS/appmanager/portailps/professionnelsante\?_nfpb=true&_pageLabel=vp_releves_mensuels_page', BillsPage) searchp = URL('/PortailPS/appmanager/portailps/professionnelsante\?_nfpb=true&_pageLabel=vp_recherche_par_date_paiements_page', SearchPage) historyp = URL('/PortailPS/appmanager/portailps/professionnelsante\?_nfpb=true&_windowLabel=vp_recherche_paiement_tiers_payant_portlet_1&vp_recherche_paiement_tiers_payant_portlet_1_actionOverride=%2Fportlets%2Fpaiements%2Frecherche&_pageLabel=vp_recherche_par_date_paiements_page', HistoryPage) logged = False def do_login(self): self.logger.debug('call Browser.do_login') if self.logged: return True self.loginp.stay_or_go() if self.homep.is_here(): self.logged = True return True self.page.login(self.username, self.password) if not self.homep.is_here(): raise BrowserIncorrectPassword() self.logged = True @need_login def get_subscription_list(self): self.logger.debug('call Browser.get_subscription_list') self.accountp.stay_or_go() return self.page.iter_subscription_list() @need_login def get_subscription(self, id): assert isinstance(id, basestring) return self.get_subscription_list() @need_login def iter_history(self, subscription): self.searchp.stay_or_go() date_deb = self.page.doc.xpath('//input[@name="vp_recherche_paiement_tiers_payant_portlet_1dateDebutRecherche"]')[0].value date_fin = self.page.doc.xpath('//input[@name="vp_recherche_paiement_tiers_payant_portlet_1dateFinRecherche"]')[0].value data = {'vp_recherche_paiement_tiers_payant_portlet_1dateDebutRecherche': date_deb, 'vp_recherche_paiement_tiers_payant_portlet_1dateFinRecherche': date_fin, 'vp_recherche_paiement_tiers_payant_portlet_1codeOrganisme': 'null', 'vp_recherche_paiement_tiers_payant_portlet_1actionEvt': 'rechercheParDate', 'vp_recherche_paiement_tiers_payant_portlet_1codeRegime': '01', } self.session.headers.update({'Content-Type': 'application/x-www-form-urlencoded'}) self.historyp.go(data=urllib.urlencode(data)) if self.historyp.is_here(): return self.page.iter_history() @need_login def get_details(self, sub): det = Detail() det.id = sub.id det.label = sub.label det.infos = '' det.price = Decimal('0.0') return det @need_login def iter_bills(self): self.billsp.stay_or_go() return self.page.iter_bills() @need_login def get_bill(self, id): assert isinstance(id, basestring) for b in self.iter_bills(): if id == b.id: return b return None @need_login def download_bill(self, bill): request = self.open(bill._url, data=bill._data, stream=True) return request.content weboob-1.1/modules/amelipro/favicon.png000066400000000000000000000153301265717027300202570ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYsodtIME"IeIDATxi\W羗{e־I%X,yXؖlcn3`C73ѕ=C0`Gxnj^d㰌mY*kWRm{·U,w{YI1w\+apDHIxrעKo~+Eyλdq)6vb#l3HyyxVD}'<`ďM7X4֛B7.Ҋ>vgQy %> Dwee&a߅(Ҏ$[zO$:O~M{W1ZںzcЈh@Un Ta.yCiŲoCxsnv>0w-/"oU~J| 螇v~(G!;^Q+V-sPM}G^uŲe>j%|eTɝ^#cU X*yϯUJ_~J YZV78˟/;Hvnw9º~ |~9CTyuI5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GKN}I$T-O,!ZgcϢ;RUYZ,1l)c@zMnO qGbBBMfqF0 (*}L522\Tkk?f)VMsy,+}YNBEuFA=l+/ԛneW%}GIœH7Yu1qwʼnSv .زn= qB:W:ꅾE,f1^?~X?\Wnfex,˚4UI64g i(pd-2d@g !qja+~Y|01k7zEaw2m.X̼km%g 'mTC _$zuS/>@.b\!aA26,(u0ES5gM[S^bแœθH_}.WxxTtw_=A#?3L3i+U#8 ~)dpj#b(BZ#E(zg->XQDό8:}|GA CXzvꑭ t8&GMB7e#tǥ{O{0B Jاn W )5&tHe,TB3@HZѯSHmPG~ƐOe 0Ț:ۗ2ݻJ3@/t)3q670mh?VV3K̄U13. from weboob.capabilities.bill import CapBill, SubscriptionNotFound, BillNotFound, Subscription, Bill from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import AmeliProBrowser __all__ = ['AmeliProModule'] class AmeliProModule(Module, CapBill): NAME = 'amelipro' DESCRIPTION = u'Ameli website: French Health Insurance for Professionals' MAINTAINER = u'Christophe Lampin' EMAIL = 'weboob@lampin.net' VERSION = '1.1' LICENSE = 'AGPLv3+' BROWSER = AmeliProBrowser CONFIG = BackendConfig(ValueBackendPassword('login', label='numero de SS', masked=False), ValueBackendPassword('password', label='Password', masked=True) ) def create_default_browser(self): self.logger.settings['save_responses'] = False # Set to True to help debugging return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): return self.browser.get_subscription_list() def get_subscription(self, _id): if not _id.isdigit(): raise SubscriptionNotFound() subscription = self.browser.get_subscription(_id) if not subscription: raise SubscriptionNotFound() else: return subscription def iter_bills_history(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_history(subscription) def get_details(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.get_details(subscription) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_bills() def get_bill(self, id): bill = self.browser.get_bill(id) if not bill: raise BillNotFound() else: return bill def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) return self.browser.download_bill(bill) weboob-1.1/modules/amelipro/pages.py000066400000000000000000000113471265717027300176010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime import re from decimal import Decimal from weboob.browser.pages import HTMLPage from weboob.capabilities.bill import Subscription, Detail, Bill # Ugly array to avoid the use of french locale FRENCH_MONTHS = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre'] class LoginPage(HTMLPage): def login(self, login, password): form = self.get_form('//form[@name="connexionCompteForm"]') form['vp_connexion_portlet_1numPS'] = login.encode('utf8') form['vp_connexion_portlet_1password'] = password.encode('utf8') form.submit() class HomePage(HTMLPage): def on_loaded(self): pass class SearchPage(HTMLPage): def on_loaded(self): pass class AccountPage(HTMLPage): def iter_subscription_list(self): ident = self.doc.xpath('//div[@id="identification"]')[0] prof = self.doc.xpath('//div[@id="profession"]')[0] name = ident.xpath('//p/b')[0].text.replace(' ', ' ').strip() number = ident.xpath('//p')[1].text.replace('Cabinet', '').strip() label = prof.xpath('//div[@class="zoneTexte"]')[0].text.strip() sub = Subscription(number) sub._id = number sub.label = unicode(name) + ' ' + unicode(label) sub.subscriber = unicode(name) return sub class HistoryPage(HTMLPage): def iter_history(self): tables = self.doc.xpath('//table[contains(concat(" ", @class, " "), " cTableauTriable ")]') if len(tables) > 0: lines = tables[0].xpath('.//tr') sno = 0 for tr in lines: list_a = tr.xpath('.//a') if len(list_a) == 0: continue date = tr.xpath('.//td')[0].text.strip() lot = list_a[0].text.replace('(*)', '').strip() if lot == 'SNL': sno = sno + 1 lot = lot + str(sno) factures = tr.xpath('.//div[@class="cAlignGauche"]/a') factures_lbl = '' for a in factures: factures_lbl = factures_lbl + a.text.replace('(**)', '').strip() + ' ' montant = tr.xpath('.//div[@class="cAlignDroite"]')[0].text.strip() det = Detail() det.id = u''+lot det.label = u''+lot det.infos = u''+factures_lbl det.datetime = datetime.strptime(date, "%d/%m/%Y").date() det.price = Decimal(montant.replace(',', '.')) yield det class BillsPage(HTMLPage): def iter_bills(self): table = self.doc.xpath('//table[@id="releveCompteMensuel"]')[0].xpath('.//tr') for tr in table: list_tds = tr.xpath('.//td') if len(list_tds) == 0: continue date_str = tr.xpath('.//td[@class="cAlignGauche"]')[0].text month_str = date_str.split()[0] date = datetime.strptime(re.sub(month_str, str(FRENCH_MONTHS.index(month_str) + 1), date_str), "%m %Y").date() amount = tr.xpath('.//td[@class="cAlignDroite"]')[0].text amount = re.sub('[^\d,-]+', '', amount) for format in ('CSV', 'PDF'): bil = Bill() bil.id = date.strftime("%Y%m") + format bil.date = date clean_amount = amount.strip().replace(',','.') if clean_amount != '': bil.price = Decimal('-'+clean_amount) else: bil.price = 0 bil.label = u''+date.strftime("%Y%m%d") bil.format = u''+format filedate = date.strftime("%m%Y") bil._url = '/PortailPS/fichier.do' bil._data = {'FICHIER.type': format.lower()+'.releveCompteMensuel', 'dateReleve': filedate, 'FICHIER.titre': 'Releve' + filedate } yield bil weboob-1.1/modules/amelipro/test.py000066400000000000000000000021351265717027300174540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class AmeliProTest(BackendTest): MODULE = 'AmeliPro' def test_AmeliPro(self): for subscription in self.backend.iter_subscription(): list(self.backend.iter_history(subscription.id)) for bill in self.backend.iter_bills(subscription.id): self.backend.download_bill(bill.id) weboob-1.1/modules/americanexpress/000077500000000000000000000000001265717027300175035ustar00rootroot00000000000000weboob-1.1/modules/americanexpress/__init__.py000066400000000000000000000014521265717027300216160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AmericanExpressModule __all__ = ['AmericanExpressModule'] weboob-1.1/modules/americanexpress/browser.py000066400000000000000000000074321265717027300215460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from urlparse import urlsplit, parse_qsl from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, AccountsPage, TransactionsPage, NewAccountsPage __all__ = ['AmericanExpressBrowser'] class AmericanExpressBrowser(Browser): DOMAIN = 'global.americanexpress.com' PROTOCOL = 'https' ENCODING = 'ISO-8859-1' PAGES = {'https://global.americanexpress.com/myca/logon/.*': LoginPage, 'https://global.americanexpress.com/myca/intl/acctsumm/.*': AccountsPage, 'https://global.americanexpress.com/myca/intl/isummary/.*': NewAccountsPage, 'https://global.americanexpress.com/myca/intl/estatement/.*': TransactionsPage, } def is_logged(self): return self.page is not None and not self.is_on_page(LoginPage) def home(self): if self.is_logged(): self.location(self.buildurl('/myca/intl/acctsumm/emea/accountSummary.do')) else: self.login() def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(LoginPage): self.location(self.absurl('/myca/logon/emea/action?request_type=LogonHandler&DestPage=https%3A%2F%2Fglobal.americanexpress.com%2Fmyca%2Fintl%2Facctsumm%2Femea%2FaccountSummary.do%3Frequest_type%3D%26Face%3Dfr_FR%26intlink%3Dtopnavvotrecompteneligne-HPmyca&Face=fr_FR&Info=CUExpired'), no_login=True) self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() def go_on_accounts_list(self): self.select_form(name='leftnav') self.form.action = self.absurl('/myca/intl/acctsumm/emea/accountSummary.do') self.submit() def get_accounts_list(self): if not self.is_on_page(AccountsPage) and not self.is_on_page(NewAccountsPage): self.go_on_accounts_list() return self.page.get_list() def get_account(self, id): assert isinstance(id, basestring) l = self.get_accounts_list() for a in l: if a.id == id: return a return None def get_history(self, account): if not self.is_on_page(AccountsPage) and not self.is_on_page(NewAccountsPage): self.go_on_accounts_list() url = account._link if not url: return while url is not None: if self.is_on_page(NewAccountsPage): self.location(url) else: self.select_form(name='leftnav') self.form.action = self.absurl(url) self.submit() assert self.is_on_page(TransactionsPage) for tr in self.page.get_history(account.currency): yield tr if self.page.is_last(): url = None else: v = urlsplit(url) args = dict(parse_qsl(v.query)) args['BPIndex'] = int(args['BPIndex']) + 1 url = self.buildurl(v.path, **args) weboob-1.1/modules/americanexpress/favicon.png000066400000000000000000000072221265717027300216410ustar00rootroot00000000000000PNG  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OWY"#?GjP3"*3F6w ]z"?:^y=vzKm|D2aˣd&ʳ7鲠2_ż- @vtl [KlgrrS D'SD  plxtVkRC6E[ˤ9oe=32~z#f= l殩;qAWAaњeL_?9߳yp]\8/IEcUr4 uD^p!'J[JvE#SGAD6Ս/5Ⅷ7DUN{~+;=^9SU9D )8ʈ,gGv83L(+Hu!-fPr&ZrSQǺI*YؤsUE޽ 2;]ھҘ:v&[>' N=@ ?9WjP hL6`-@z`j[yUo_rRȟ'/4Xpd3+Df)Jn I}5OG!IENDB`weboob-1.1/modules/americanexpress/module.py000066400000000000000000000042141265717027300213430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import AmericanExpressBrowser __all__ = ['AmericanExpressModule'] class AmericanExpressModule(Module, CapBank): NAME = 'americanexpress' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'American Express' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label='Code utilisateur', masked=False), ValueBackendPassword('password', label='Mot de passe')) BROWSER = AmericanExpressBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): with self.browser: for account in self.browser.get_accounts_list(): yield account def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): with self.browser: transactions = list(self.browser.get_history(account)) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return transactions weboob-1.1/modules/americanexpress/pages.py000066400000000000000000000166551265717027300211710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime import re from weboob.deprecated.browser import Page, BrokenPageError from weboob.capabilities.bank import Account from weboob.capabilities import NotAvailable from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction from weboob.tools.date import ChaoticDateGuesser from weboob.browser.filters.standard import CleanDecimal class LoginPage(Page): def login(self, username, password): self.browser.select_form(name='ssoform') self.browser.set_all_readonly(False) self.browser['UserID'] = username.encode(self.browser.ENCODING) self.browser['USERID'] = username.encode(self.browser.ENCODING) self.browser['Password'] = password.encode(self.browser.ENCODING) self.browser['PWD'] = password.encode(self.browser.ENCODING) self.browser.submit(nologin=True) class NewAccountsPage(Page): def get_list(self): for div in self.document.xpath('.//div[@id="card-details"]'): a = Account() a.id = self.parser.tocleanstring(div.xpath('.//span[@class="acc-num"]')[0]) a.label =self.parser.tocleanstring( div.xpath('.//span[@class="card-desc"]')[0]) if "carte" in a.label.lower(): a.type = Account.TYPE_CARD balance = self.parser.tocleanstring(div.xpath('.//span[@class="balance-data"]')[0]) if balance in (u'Indisponible', u'Indisponible Facturation en cours', ''): a.balance = NotAvailable else: a.currency = a.get_currency(balance) a.balance = - abs(CleanDecimal(replace_dots=a.currency == 'EUR').filter(balance)) # Cancel card don't have a link to watch history link = self.document.xpath('.//div[@class="wide-bar"]/h3/a') if len(link) == 1: a._link = link[0].attrib['href'] else: a._link = None yield a class AccountsPage(Page): def get_list(self): for box in self.document.getroot().cssselect('div.roundedBox div.contentBox'): a = Account() a.id = self.parser.tocleanstring(box.xpath('.//tr[@id="summaryImageHeaderRow"]//div[@class="summaryTitles"]')[0]) a.label = self.parser.tocleanstring(box.xpath('.//span[@class="cardTitle"]')[0]) if "carte" in a.label.lower(): a.type = Account.TYPE_CARD balance = self.parser.tocleanstring(self.parser.select(box, 'td#colOSBalance div.summaryValues', 1)) if balance in (u'Indisponible', u'Indisponible Facturation en cours', ''): a.balance = NotAvailable else: a.currency = a.get_currency(balance) a.balance = - abs(CleanDecimal(replace_dots=a.currency == 'EUR').filter(balance)) a._link = self.parser.select(box, 'div.summaryTitles a.summaryLink', 1).attrib['href'] yield a class TransactionsPage(Page): COL_ID = 0 COL_DATE = 1 COL_DEBIT_DATE = 2 COL_LABEL = 3 COL_VALUE = -1 def is_last(self): current = False for option in self.document.xpath('//select[@id="viewPeriod"]/option'): if 'selected' in option.attrib: current = True elif current: return False return True def get_end_debit_date(self): for option in self.document.xpath('//select[@id="viewPeriod"]/option'): if 'selected' in option.attrib: m = re.search('(\d+) ([\w\.]+) (\d{4})$', option.text.strip(), re.UNICODE) if m: return datetime.date(int(m.group(3)), self.MONTHS.index(m.group(2).rstrip('.')) + 1, int(m.group(1))) def get_beginning_debit_date(self): for option in self.document.xpath('//select[@id="viewPeriod"]/option'): if 'selected' in option.attrib: m = re.search('^(\d+) ([\w\.]+) (\d{4})', option.text.strip(), re.UNICODE) if m: return datetime.date(int(m.group(3)), self.MONTHS.index(m.group(2).rstrip('.')) + 1, int(m.group(1))) return datetime.date.today() COL_DATE = 0 COL_TEXT = 1 COL_CREDIT = -2 COL_DEBIT = -1 FR_MONTHS = ['janv', u'févr', u'mars', u'avr', u'mai', u'juin', u'juil', u'août', u'sept', u'oct', u'nov', u'déc'] US_MONTHS = ['Jan', u'Feb', u'Mar', u'Apr', u'May', u'Jun', u'Jul', u'Aug', u'Sep', u'Oct', u'Nov', u'Dec'] def get_history(self, currency): self.MONTHS = self.FR_MONTHS if currency == 'EUR' else self.US_MONTHS #checking if the card is still valid if self.document.xpath('//div[@id="errorbox"]'): return #adding a time delta because amex have hard time to put the date in a good interval beginning_date = self.get_beginning_debit_date() - datetime.timedelta(days=300) end_date = self.get_end_debit_date() guesser = ChaoticDateGuesser(beginning_date, end_date) for tr in reversed(self.document.xpath('//div[@id="txnsSection"]//tr[@class="tableStandardText"]')): cols = tr.findall('td') t = Transaction() day, month = self.parser.tocleanstring(cols[self.COL_DATE]).split(' ', 1) day = int(day) month = self.MONTHS.index(month.rstrip('.')) + 1 date = guesser.guess_date(day, month) rdate = None try: detail = self.parser.select(cols[self.COL_TEXT], 'div.hiddenROC', 1) except BrokenPageError: pass else: m = re.search(r' (\d{2} \D{3,4})', (' '.join([txt.strip() for txt in detail.itertext()])).strip()) if m: rday, rmonth = m.group(1).split(' ') rday = int(rday) rmonth = self.MONTHS.index(rmonth.rstrip('.')) + 1 rdate = guesser.guess_date(rday, rmonth) detail.drop_tree() raw = (' '.join([txt.strip() for txt in cols[self.COL_TEXT].itertext()])).strip() credit = self.parser.tocleanstring(cols[self.COL_CREDIT]) debit = self.parser.tocleanstring(cols[self.COL_DEBIT]) t.date = date t.rdate = rdate or date t.raw = re.sub(r'[ ]+', ' ', raw) t.label = re.sub('(.*?)( \d+)? .*', r'\1', raw).strip() t.amount = CleanDecimal(replace_dots=currency == 'EUR').filter(credit or debit) * (1 if credit else -1) if t.amount > 0: t.type = t.TYPE_ORDER else: t.type = t.TYPE_CARD yield t weboob-1.1/modules/americanexpress/test.py000066400000000000000000000020111265717027300210260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class AmericanExpressTest(BackendTest): MODULE = 'americanexpress' def test_americanexpress(self): l = list(self.backend.iter_accounts()) a = l[0] list(self.backend.iter_history(a)) list(self.backend.iter_coming(a)) weboob-1.1/modules/apec/000077500000000000000000000000001265717027300152225ustar00rootroot00000000000000weboob-1.1/modules/apec/__init__.py000066400000000000000000000014261265717027300173360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ApecModule __all__ = ['ApecModule'] weboob-1.1/modules/apec/browser.py000066400000000000000000000127601265717027300172650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.profiles import Profile from weboob.browser import PagesBrowser, URL from .pages import IdsPage, OffrePage __all__ = ['ApecBrowser'] class JsonProfile(Profile): def setup_session(self, session): session.headers["Content-Type"] = "application/json" class ApecBrowser(PagesBrowser): BASEURL = 'https://cadres.apec.fr' PROFILE = JsonProfile() start = 0 json_count = URL('/cms/webservices/rechercheOffre/count', IdsPage) json_ids = URL('/cms/webservices/rechercheOffre/ids', IdsPage) json_offre = URL('/cms/webservices/offre/public\?numeroOffre=(?P<_id>.*)', OffrePage) def create_parameters(self, pattern='', fonctions='[]', lieux='[]', secteursActivite='[]', typesContrat='[]', typesConvention='[]', niveauxExperience='[]', salaire_min='', salaire_max='', date_publication='', start=0, range=20): if date_publication: date_publication = ',"anciennetePublication":%s' % (date_publication) if salaire_max: salaire_max = ',"salaireMaximum":%s' % (salaire_max) if salaire_min: salaire_min = ',"salaireMinimum":%s' % (salaire_min) return '{"activeFiltre":true,"motsCles":"%s","fonctions":%s,"lieux":%s,"secteursActivite":%s,"typesContrat":%s,"typesConvention":%s,"niveauxExperience":%s%s%s%s,"sorts":[{"type":"SCORE","direction":"DESCENDING"}],"pagination":{"startIndex":%s,"range":%s},"typeClient":"CADRE"}' % (pattern, fonctions, lieux, secteursActivite, typesContrat, typesConvention, niveauxExperience, salaire_min, salaire_max, date_publication, start, range) def search_job(self, pattern=None): data = self.create_parameters(pattern=pattern) return self.get_job_adverts(data, pattern=pattern) def get_job_adverts(self, data, pattern='', lieux='', fonctions='', secteursActivite='', salaire_min='', salaire_max='', typesContrat='', date_publication='', niveauxExperience='', typesConvention=''): count = self.json_count.go(data=data).get_adverts_number() self.start = 0 if count: ids = self.json_ids.go(data=data).iter_job_adverts(pattern=pattern, fonctions='[%s]' % fonctions, lieux='[%s]' % lieux, secteursActivite='[%s]' % secteursActivite, typesContrat='[%s]' % typesContrat, niveauxExperience='[%s]' % niveauxExperience, typesConvention='[%s]' % typesConvention, salaire_min=salaire_min, salaire_max=salaire_max, date_publication=date_publication, start=self.start, count=count, range=20) for _id in ids: yield self.json_offre.go(_id=_id.id).get_job_advert() def get_job_advert(self, _id, advert=None): return self.json_offre.go(_id=_id).get_job_advert(obj=advert) def advanced_search_job(self, region='', fonction='', secteur='', salaire='', contrat='', limit_date='', level=''): salaire_max = '' salaire_min = '' if salaire: s = salaire.split('|') salaire_max = s[1] salaire_min = s[0] data = self.create_parameters(fonctions='[%s]' % fonction, lieux='[%s]' % region, secteursActivite='[%s]' % secteur, typesContrat='[%s]' % contrat, niveauxExperience='[%s]' % level, salaire_min=salaire_min, salaire_max=salaire_max, date_publication=limit_date) return self.get_job_adverts(data, fonctions=fonction, lieux=region, secteursActivite=secteur, typesContrat=contrat, niveauxExperience=level, salaire_min=salaire_min, salaire_max=salaire_max, date_publication=limit_date) weboob-1.1/modules/apec/favicon.png000066400000000000000000000172231265717027300173620ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYsodtIME}r IDATxy|]uLwhkeWNupLz&)*'N^$:J_&PI^2pnC 1J36 ϲ5ǹW &Li>sw^komR"ƍRm*?DZ8rd|J)F\T7ŀuy6H.D۽w48nMl<3o#nnw߭߈q97?A b:KY "ry}(G\ޞ xUx#NOuIYq"Jk~˸hzwF†na7 j  g0$(P\@cG7E:2o }Ê=P$R`#1JuiS (m Ŀ?@; WyD]\;Dttm uz_VDg=9rpM cdEyI,2ƄDJyƤ#)"u@ 1& йHP_;`}\d"&W8=$3fQ8iB!`tN:AB0b:Cʠ ffE&vtɦH-ssu$sЩX_5utFLtW"q4֜ԅU Fգiuf_9:\'8u'xmm h@VDn Ft 0w!(BQT~n5DA.J ck븶?3GÎXN.LybUň(Z)hx%46\Ēl_@u,nC]@ 'f~MD\lk-MpwOe-d5hUSrg))1Ι8µ1B[T(fkTKM\vh3@l}lڣf~ MjU1P^r]! A4Ab!@$߮8 JltIb'jlųW@┭}m غ $ Dhi5U[NCi1(Q¶3VюX~ǎ(jŪEj"U]q0b[h'$&"p ]]\tcDD FK!};w,}S̔'(r [h11+Ĉ1vA[2"`:TFHY8 !ױ/":" +D&XfS+iut[cI_ǩ/湶3q_uѓ "?vz`l!tT(0S m2TāJ(gȯIsV{;f^u*TΠc%πnD$m:+7j{r1w묹%Mә?"4 -&m"9SU`枀tw: GB=ȗ#?܍rpp>qSП<ʚҗA#LݽT~1 O*d6ŊnHΘr_EMgc@y:7Y]PMf JD_bĵHEXC\tan^Z[B+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먻:jE(9FY޹͏B%[ԗNsc j8p x5'40ѕ[iƑf&ZcGx u]EZ: :o){QY myy`fany 7fFi$'ofs=voHNO0xZblÁs{ rq8yVjj< 6˓HJ ʊN [Ѽ /`?Y^Q5'sRVˮV'W<ǎ^L&SCΐ=uo曷WxgB(F(10Y8v -d0\̽Z 7&9XKN,*>~q57Yȩ)&0k:~.,ʧM?ZK}ǶqfTtm(E)b6^Ï3J/O{$;~t秷q̖BccŚ))@Cy9%O >R~y*b] G&;{%H=P_"md;As;i0`kBuKxἯ蓸}(!Y8aOg ǟC{hE \T%3f cNJ9N0]7D%y}|98(IFuǒb_Dizv*TwlIҹ'bF㽷h4J MP8- 7`z]jCVAn&p:]h)|)\a² ڳ@IG2;8—XgEա5@f*ӱySQyG}^At%%TH+(h肘h |-AS"B{;f4J( ̤:B򄵫cPX- HфS \Y:OEssS&ah )Bh7aňSԇNqL0Ƭ ձ` 1GL\[T`0 (S[S=qg`؂ pV/έrmͻ4+~q"[**kbA6y[.`rQ'y7мbq8;1ݨXl~$ڼ-q}Q-$1Ϸ,U@?a뢍?镇X϶NH)*Dߴ2Πicx<fC7iQqxoaƯ=}"e๟x6@{{_]wo9#lTw'xEQ?–.쭞|7O??tPR8_;I\{IENDB`weboob-1.1/modules/apec/module.py000066400000000000000000000367241265717027300170750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.job import BaseJobAdvert from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.job import CapJob from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import Value from .browser import ApecBrowser __all__ = ['ApecModule'] class ApecModule(Module, CapJob): NAME = 'apec' DESCRIPTION = u'apec website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' VERSION = '1.1' BROWSER = ApecBrowser places_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '001|99700': u'UE Hors France', '002|99126': u'..Grèce', '003|99132': u'..Royaume Uni', '004|99134': u'..Espagne', '005|99136': u'..Irlande', '006|99139': u'..Portugal', '007|99254': u'..Chypre', '008|99127': u'..Italie', '009|99131': u'..Belgique', '010|99135': u'..Pays Bas', '011|99137': u'..Luxembourg', '012|99144': u'..Malte', '013|99145': u'..Slovénie', '014|99101': u'..Danemark', '015|99104': u'..Suède', '016|99105': u'..Finlande', '017|99106': u'..Estonie', '018|99107': u'..Lettonie', '019|99108': u'..Lituanie', '020|99109': u'..Allemagne', '021|99110': u'..Autriche', '022|99111': u'..Bulgarie', '023|99112': u'..Hongrie', '024|99114': u'..Roumanie', '025|99116': u'..République Tchèque', '026|99117': u'..Slovaquie', '027|99119': u'..Croatie', '028|99122': u'..Pologne', '029|799': u'France', '030|711': u'..Ile-de-France', '031|75': u'....Paris', '032|77': u'....Seine-et-Marne', '033|78': u'....Yvelines', '034|91': u'....Essonne', '035|92': u'....Hauts-de-Seine', '036|93': u'....Seine-Saint-Denis', '037|94': u'....Val-de-Marne', '038|95': u'....Val-d\'Oise', '039|703': u'..Basse-Normandie', '040|14': u'....Calvados', '041|50': u'....Manche', '042|61': u'....Orne', '043|705': u'..Bretagne', '044|22': u'....Côtes d\'Armor', '045|29': u'....Finistère', '046|35': u'....Ille-et-Vilaine', '047|56': u'....Morbihan', '048|706': u'..Centre', '049|18': u'....Cher', '050|28': u'....Eure-et-Loir', '051|36': u'....Indre', '052|37': u'....Indre-et-Loire', '053|41': u'....Loir-et-Cher', '054|45': u'....Loiret', '055|710': u'..Haute-Normandie', '056|27': u'....Eure', '057|76': u'....Seine-Maritime', '058|717': u'..Pays de La Loire', '059|44': u'....Loire-Atlantique', '060|49': u'....Maine-et-Loire', '061|53': u'....Mayenne', '062|72': u'....Sarthe', '063|85': u'....Vendée', '064|700': u'..Alsace', '065|67': u'....Bas-Rhin', '066|68': u'....Haut-Rhin', '067|704': u'..Bourgogne', '068|21': u'....Côte d\'Or', '069|58': u'....Nièvre', '070|71': u'....Saône-et-Loire', '071|89': u'....Yonne', '072|707': u'..Champagne', '073|8': u'....Ardennes', '074|10': u'....Aube', '075|51': u'....Marne', '076|52': u'....Haute-Marne', '077|709': u'..Franche-Comté', '078|25': u'....Doubs', '079|39': u'....Jura', '080|70': u'....Haute-Saône', '081|90': u'....Territoire de Belfort', '082|714': u'..Lorraine', '083|54': u'....Meurthe-et-Moselle', '084|55': u'....Meuse', '085|57': u'....Moselle', '086|88': u'....Vosges', '087|716': u'..Nord-Pas-de-Calais', '088|59': u'....Nord', '089|62': u'....Pas-de-Calais', '090|718': u'..Picardie', '091|2': u'....Aisne', '092|60': u'....Oise', '093|80': u'....Somme', '094|20': u'..Corse', '095|750': u'....Corse du Sud', '096|751': u'....Haute-Corse', '097|702': u'..Auvergne', '098|3': u'....Allier', '099|15': u'....Cantal', '100|43': u'....Haute-Loire', '101|63': u'....Puy-de-Dôme', '102|720': u'..PACA', '103|4': u'....Alpes-de-Haute-Provence', '104|5': u'....Hautes-Alpes', '105|6': u'....Alpes-Maritimes', '106|13': u'....Bouches-du-Rhône', '107|83': u'....Var', '108|84': u'....Vaucluse', '109|721': u'..Rhône-Alpes', '110|1': u'....Ain', '111|7': u'....Ardèche', '112|26': u'....Drôme', '113|38': u'....Isère', '114|42': u'....Loire', '115|69': u'....Rhône', '116|73': u'....Savoie', '117|74': u'....Haute-Savoie', '118|701': u'..Aquitaine', '119|24': u'....Dordogne', '120|33': u'....Gironde', '121|40': u'....Landes', '122|47': u'....Lot-et-Garonne', '123|64': u'....Pyrénées-Atlantiques', '124|712': u'..Languedoc-Roussillon', '125|11': u'....Aude', '126|30': u'....Gard', '127|34': u'....Hérault', '128|48': u'....Lozère', '129|66': u'....Pyrénées-Orientales', '130|713': u'..Limousin', '131|19': u'....Corrèze', '132|23': u'....Creuse', '133|87': u'....Haute-Vienne', '134|715': u'..Midi-Pyrénées', '135|9': u'....Ariège', '136|12': u'....Aveyron', '137|31': u'....Haute-Garonne', '138|32': u'....Gers', '139|46': u'....Lot', '140|65': u'....Hautes-Pyrénées', '141|81': u'....Tarn', '142|82': u'....Tarn-et-Garonne', '143|719': u'..Poitou-Charentes', '144|16': u'....Charente', '145|17': u'....Charente-Maritime', '146|79': u'....Deux-Sèvres', '147|86': u'....Vienne', '148|99712': u'..France Outre-Mer', '149|99519': u'....Terres Australes et Antarctiques Françaises', '150|97100': u'....Guadeloupe', '151|97200': u'....Martinique', '152|97300': u'....Guyane', '153|97400': u'....La Réunion', '154|97500': u'....Saint-Pierre-et-Miquelon', '155|97600': u'....Mayotte', '156|98300': u'....Polynésie Française', '157|98600': u'....Wallis et Futuna', '158|98800': u'....Nouvelle Calédonie', '159|97800': u'....Saint-Martin', '160|97700': u'....Saint-Barthélémy', '161|102099': u'International', '162|99715': u'..Afrique', '163|99716': u'..Asie', '164|99700': u'..UE Hors France', '165|99701': u'..Europe Hors UE', '166|99702': u'..Amérique du Nord', '167|99711': u'..Océanie', '168|99714': u'..Amérique Latine', }.iteritems())]) fonction_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '00|': u'-- Indifférent --', '01|101828': u'Commercial, Marketing', '02|101782': u'.....Administration des ventes et SAV', '03|101783': u'.....Chargé d\'affaires, technico-commercial', '04|101784': u'.....Commercial', '05|101785': u'.....Commerce international', '06|101786': u'.....Direction commerciale et marketing', '07|101787': u'.....Direction régionale et d\'agence', '08|101788': u'.....Marketing', '09|101789': u'.....Ventes en magasin', '10|101829': u'Communication, Création', '11|101790': u'.....Communication', '12|101791': u'.....Création', '13|101792': u'.....Documentation, rédaction technique', '14|101793': u'.....Journalisme, édition', '15|101830': u'Direction d\'entreprise', '16|101794': u'.....Adjoint, conseil de direction', '17|101795': u'.....Direction générale', '18|101831': u'Etudes, Recherche et Développement', '19|101796': u'.....Conception, recherche', '20|101797': u'.....Direction recherche et développement', '21|101798': u'.....Etudes socio-économiques', '22|101799': u'.....Projets scientifiques et techniques', '23|101800': u'.....Test, essai, validation, expertise', '24|101832': u'Gestion, Finance, Administration', '25|101801': u'.....Administration, gestion, organisation', '26|101802': u'.....Comptabilité', '27|101803': u'.....Contrôle de gestion, audit', '28|101804': u'.....Direction gestion, finance', '29|101805': u'.....Droit, fiscalité', '30|101806': u'.....Finance, trésorerie', '31|101833': u'Informatique', '32|101807': u'.....Direction informatique', '33|101808': u'.....Exploitation, maintenance informatique', '34|101809': u'.....Informatique de gestion', '35|101810': u'.....Informatique industrielle', '36|101811': u'.....Informatique web, sites et portails Internet', '37|101812': u'.....Maîtrise d\'ouvrage et fonctionnel', '38|101813': u'.....Système, réseaux, données', '39|101834': u'Production Industrielle, Travaux, Chantiers', '40|101814': u'.....Cadres de chantier', '41|101815': u'.....Cadres de production industrielle', '42|101816': u'.....Direction d\'unité industrielle', '43|101835': u'Ressources Humaines', '44|101817': u'.....Administration des RH', '45|101818': u'.....Développement des RH', '46|101819': u'.....Direction des ressources humaines', '47|101820': u'.....Formation initiale et continue', '48|101836': u'Sanitaire, Social, Culture', '49|101821': u'.....Activités sanitaires, sociales et culturelles', '50|101837': u'Services Techniques', '51|101822': u'.....Achats', '52|101823': u'.....Direction des services techniques', '53|101824': u'.....Logistique', '54|101825': u'.....Maintenance, sécurité', '55|101826': u'.....Process, méthodes', '56|101827': u'.....Qualité', }.iteritems())]) secteur_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'-- Indifférent --', '101752': u'Activités des organisations associatives et administration publique', '101753': u'Activités informatiques', '101754': u'Activités juridiques et comptables', '101755': u'Agroalimentaire', '101756': u'Automobile, aéronautique et autres matériels de transport', '101757': u'Banque et Assurances', '101758': u'Bois - Papier - Imprimerie', '101759': u'Chimie - Caoutchouc - Plastique', '101760': u'Commerce interentreprises', '101761': u'Communication et médias', '101762': u'Conseil et gestion des entreprises', '101763': u'Construction', '101764': u'Distribution généraliste et spécialisée', '101765': u'Energies - Eau', '101766': u'Equipements électriques et électroniques', '101767': u'Formation initiale et continue', '101768': u'Gestion des déchets', '101769': u'Hôtellerie - Restauration - Loisirs', '101770': u'Immobilier', '101771': u'Industrie pharmaceutique', '101772': u'Ingénierie - R et D', '101773': u'Intermédiaires du recrutement', '101774': u'Mécanique - Métallurgie', '101775': u'Meuble, Textile et autres industries manufacturières', '101776': u'Santé - action sociale', '101777': u'Services divers aux entreprises', '101778': u'Télécommunications', '101779': u'Transports et logistique', }.iteritems())]) type_contrat_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'-- Indifférent --', '101888': u'CDI', '101887': u'CDD', '101889': u'Interim', }.iteritems())]) salary_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'-- Indifférent --', '0|35': u'Moins de 35 K€', '35|50': u'Entre 35 et 49 K€', '50|70': u'Entre 50 et 69 K€', '70|90': u'Entre 70 et 90 K€', '90|1000': u'Plus de 90 K€', }.iteritems())]) date_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'-- Indifférent --', '101850': u'Aujourd\'hui', '101851': u'Les 7 derniers jours', '101852': u'Les 30 derniers jours', '101853': u'Toutes les offres', }.iteritems())]) level_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '101882': u'Tous niveaux d\'expérience', '101881': u'Débutant', '101883': u'Expérimenté', }.iteritems())]) CONFIG = BackendConfig(Value('place', label=u'Lieu', choices=places_choices, default=''), Value('fonction', label=u'Fonction', choices=fonction_choices, default=''), Value('secteur', label=u'Secteur', choices=secteur_choices, default=''), Value('contrat', label=u'Contrat', choices=type_contrat_choices, default=''), Value('salaire', label=u'Salaire', choices=salary_choices, default=''), Value('limit_date', label=u'Date', choices=date_choices, default=''), Value('level', label=u'Expérience', choices=level_choices, default='')) def search_job(self, pattern=None): for job_advert in self.browser.search_job(pattern=pattern): yield self.fill_obj(job_advert) def decode_choice(self, choice): splitted_choice = choice.split('|') if len(splitted_choice) == 2: return splitted_choice[1] else: return '' def advanced_search_job(self): for job_advert in self.browser.advanced_search_job(region=self.decode_choice(self.config['place'].get()), fonction=self.decode_choice(self.config['fonction'].get()), secteur=self.config['secteur'].get(), salaire=self.config['salaire'].get(), contrat=self.config['contrat'].get(), limit_date=self.config['limit_date'].get(), level=self.config['level'].get()): yield self.fill_obj(job_advert) def get_job_advert(self, _id, advert=None): job_advert = self.browser.get_job_advert(_id, advert) return self.fill_obj(job_advert) def fill_obj(self, advert, fields=None): if advert.contract_type in self.type_contrat_choices: advert.contract_type = self.type_contrat_choices[advert.contract_type] if advert.experience in self.level_choices: advert.experience = self.level_choices[advert.experience] return advert OBJECTS = {BaseJobAdvert: fill_obj} weboob-1.1/modules/apec/pages.py000066400000000000000000000070661265717027300167040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import requests from weboob.browser.elements import ItemElement, method, DictElement from weboob.browser.pages import JsonPage, pagination from weboob.browser.filters.standard import DateTime, Format, Regexp from weboob.browser.filters.json import Dict from weboob.browser.filters.html import CleanHTML from weboob.capabilities.job import BaseJobAdvert from weboob.capabilities.base import NotAvailable class IdsPage(JsonPage): def get_adverts_number(self): return self.doc['totalCount'] @pagination @method class iter_job_adverts(DictElement): item_xpath = 'resultats' def next_page(self): self.page.browser.start += self.env['range'] if self.page.browser.start <= self.env['count']: data = self.page.browser.create_parameters(pattern=self.env['pattern'], fonctions=self.env['fonctions'], lieux=self.env['lieux'], secteursActivite=self.env['secteursActivite'], typesContrat=self.env['typesContrat'], typesConvention=self.env['typesConvention'], niveauxExperience=self.env['niveauxExperience'], salaire_min=self.env['salaire_min'], salaire_max=self.env['salaire_max'], date_publication=self.env['date_publication'], start=self.page.browser.start, range=self.env['range']) return requests.Request("POST", self.page.url, data=data) class item(ItemElement): klass = BaseJobAdvert obj_id = Regexp(Dict('@uriOffre'), '.*=(.*)') class OffrePage(JsonPage): @method class get_job_advert(ItemElement): klass = BaseJobAdvert obj_id = Dict('numeroOffre') obj_title = Dict('intitule') obj_description = CleanHTML(Dict('texteHtml')) obj_job_name = Dict('intitule') obj_publication_date = DateTime(Dict('datePublication')) obj_society_name = Dict('nomCommercialEtablissement', default=NotAvailable) obj_contract_type = Dict('idNomTypeContrat') obj_place = Dict('lieuTexte') obj_pay = Dict('salaireTexte') obj_experience = Dict('idNomNiveauExperience') obj_url = Format('https://cadres.apec.fr/home/mes-offres/recherche-des-offres-demploi/liste-des-offres-demploi/detail-de-loffre-demploi.html?numIdOffre=%s', Dict('numeroOffre')) weboob-1.1/modules/apec/test.py000066400000000000000000000026461265717027300165630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest import itertools class ApecTest(BackendTest): MODULE = 'apec' def test_apec_search(self): l = list(itertools.islice(self.backend.search_job(u'informaticien'), 0, 50)) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) def test_apec_advanced_search(self): l = list(itertools.islice(self.backend.advanced_search_job(), 0, 50)) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) weboob-1.1/modules/apivie/000077500000000000000000000000001265717027300155675ustar00rootroot00000000000000weboob-1.1/modules/apivie/__init__.py000066400000000000000000000014361265717027300177040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ApivieModule __all__ = ['ApivieModule'] weboob-1.1/modules/apivie/browser.py000066400000000000000000000045061265717027300176310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, AccountsPage, OperationsPage __all__ = ['ApivieBrowser'] class ApivieBrowser(Browser): PROTOCOL = 'https' DOMAIN = 'www.apivie.fr' ENCODING = None PAGES = { 'https?://www.apivie.fr/': LoginPage, 'https?://www.apivie.fr/accueil': LoginPage, 'https?://www.apivie.fr/perte.*': LoginPage, 'https?://www.apivie.fr/accueil-connect': AccountsPage, 'https?://www.apivie.fr/historique-contrat.*': OperationsPage, } def home(self): self.location('https://www.apivie.fr/accueil-connect') def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(LoginPage): self.location('/accueil', no_login=True) self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() def is_logged(self): return not self.is_on_page(LoginPage) def iter_accounts(self): self.location('/accueil-connect') return self.page.iter_accounts() def get_account(self, _id): try: return next(a for a in self.iter_accounts() if a.id == _id) except StopIteration: return None def iter_history(self, account): self.location(self.buildurl('/historique-contrat', contratId=account.id)) assert self.is_on_page(OperationsPage) return self.page.iter_history() weboob-1.1/modules/apivie/favicon.png000066400000000000000000000025551265717027300177310ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs76vtIME 4-MIDATxLUe?^@!%d9FM+Kә\.N9A 0kFMRR2WFa5rG?te* uejw{˽t|u}y< 0`yEy>r_;=N"+n7_GIP2 :ۀL./>ـ?=E6z~x&* Ҟ<J@{?Q"iҲ{?C) Xw8c//YCh!ocptG }:G u'G 't>ԩ4$T/$ `H%a~&1ɚ 'ҤK;pC>Heq 4y_*e)fs'M_V@~)8 ?K+8x2Z^n2kdHDMm5}RtOYAӂi͝5F)beXmd,A5%_xhXXN|-ce{@Zó12桘b ح͡րHvK ey-m'(0z!YPo\p ^rke4'04Էwzlg[K!. from weboob.capabilities.bank import CapBank from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import ApivieBrowser __all__ = ['ApivieModule'] class ApivieModule(Module, CapBank): NAME = 'apivie' DESCRIPTION = u'Apivie' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' BROWSER = ApivieBrowser CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe')) def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): with self.browser: return self.browser.iter_accounts() def get_account(self, _id): with self.browser: return self.browser.get_account(_id) def iter_history(self, account): with self.browser: return self.browser.iter_history(account) weboob-1.1/modules/apivie/pages.py000066400000000000000000000055061265717027300172460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal from weboob.capabilities.bank import Account from weboob.deprecated.browser import Page from weboob.tools.capabilities.bank.transactions import FrenchTransaction class LoginPage(Page): def login(self, username, password): self.browser.select_form(nr=0) self.browser['_58_login'] = username.encode('utf-8') self.browser['_58_password'] = password.encode('utf-8') self.browser.submit(nologin=True) class AccountsPage(Page): COL_LABEL = 0 COL_OWNER = 1 COL_ID = 2 COL_AMOUNT = 3 def iter_accounts(self): for line in self.document.xpath('//table[@summary="informations contrat"]/tbody/tr'): yield self._get_account(line) def _get_account(self, line): tds = line.findall('td') account = Account() account.id = self.parser.tocleanstring(tds[self.COL_ID]) account.label = self.parser.tocleanstring(tds[self.COL_LABEL]) balance_str = self.parser.tocleanstring(tds[self.COL_AMOUNT]) account.balance = Decimal(FrenchTransaction.clean_amount(balance_str)) account.currency = account.get_currency(balance_str) return account class Transaction(FrenchTransaction): pass class OperationsPage(Page): COL_DATE = 0 COL_LABEL = 1 COL_AMOUNT = 2 def iter_history(self): for line in self.document.xpath('//table[@role="treegrid"]/tbody/tr'): tds = line.findall('td') operation = Transaction(int(line.attrib['data-rk'])) date = self.parser.tocleanstring(tds[self.COL_DATE]) label = self.parser.tocleanstring(tds[self.COL_LABEL]) amount = self.parser.tocleanstring(tds[self.COL_AMOUNT]) if len(amount) == 0: continue color = tds[self.COL_AMOUNT].find('span').attrib['class'] if color == 'black': continue operation.parse(date, label) operation.set_amount(amount) if color == 'red' and operation.amount > 0: operation.amount = - operation.amount yield operation weboob-1.1/modules/apivie/test.py000066400000000000000000000017471265717027300171310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class ApivieTest(BackendTest): MODULE = 'apivie' def test_apivie(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/arretsurimages/000077500000000000000000000000001265717027300173475ustar00rootroot00000000000000weboob-1.1/modules/arretsurimages/__init__.py000066400000000000000000000014471265717027300214660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 franek # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ArretSurImagesModule __all__ = ['ArretSurImagesModule'] weboob-1.1/modules/arretsurimages/browser.py000066400000000000000000000045151265717027300214110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 franek # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.deprecated.browser.decorators import id2url from .pages import VideoPage, IndexPage, LoginPage, LoginRedirectPage from .video import ArretSurImagesVideo __all__ = ['ArretSurImagesBrowser'] class ArretSurImagesBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'www.arretsurimages.net' ENCODING = None PAGES = { '%s://%s/contenu.php\?id=.+' % (PROTOCOL, DOMAIN): VideoPage, '%s://%s/emissions.php' % (PROTOCOL, DOMAIN): IndexPage, '%s://%s/forum/login.php' % (PROTOCOL, DOMAIN): LoginPage, '%s://%s/forum/index.php' % (PROTOCOL, DOMAIN): LoginRedirectPage, } def home(self): self.location('http://www.arretsurimages.net') def search_videos(self, pattern): self.location(self.buildurl('/emissions.php')) assert self.is_on_page(IndexPage) return self.page.iter_videos(pattern) @id2url(ArretSurImagesVideo.id2url) def get_video(self, url, video=None): self.login() self.location(url) return self.page.get_video(video) def is_logged(self): return not self.is_on_page(LoginPage) def login(self): if not self.is_on_page(LoginPage): self.location('http://www.arretsurimages.net/forum/login.php', no_login=True) self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() def latest_videos(self): self.location(self.buildurl('/emissions.php')) assert self.is_on_page(IndexPage) return self.page.iter_videos() weboob-1.1/modules/arretsurimages/favicon.png000066400000000000000000000074631265717027300215140ustar00rootroot00000000000000PNG  IHDR@@iq pHYs  tIME *-fP>tEXtCommentCreated with GIMPWIDATx[Yo$uVKwnfFCR<%6" yCQyϟC',<;g!^kVYKsƲ3dWW=|;ȿ?i BB߀i u'סB(Hyz_B!RPRBgB(,˅4`.@) ZA) _FPJAke܎RP !NӀA)KB`Y.p@4 Z)x.zg=Dl҆qr1x+њ n -P.&R:YR2!e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.1/modules/arretsurimages/module.py000066400000000000000000000064541265717027300212170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 franek # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import ArretSurImagesBrowser from .video import ArretSurImagesVideo __all__ = ['ArretSurImagesModule'] class ArretSurImagesModule(Module, CapVideo, CapCollection): NAME = 'arretsurimages' DESCRIPTION = u'arretsurimages website' MAINTAINER = u'franek' EMAIL = 'franek@chicour.net' VERSION = '1.1' CONFIG = BackendConfig(ValueBackendPassword('login', label='email', masked=False), ValueBackendPassword('password', label='Password')) BROWSER = ArretSurImagesBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get(), get_home=False) def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): with self.browser: return self.browser.search_videos(pattern) # raise UserError('Search does not work on ASI website, use ls latest command') def get_video(self, _id): if _id.startswith('http://') and not _id.startswith('http://www.arretsurimages.net'): return None with self.browser: return self.browser.get_video(_id) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields with self.browser: video = self.browser.get_video(ArretSurImagesVideo.id2url(video.id), video) if 'thumbnail' in fields and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest']) if collection.split_path == [u'latest']: for video in self.browser.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest']: collection.title = u'Latest ArretSurImages videos' return raise CollectionNotFound(collection.split_path) OBJECTS = {ArretSurImagesVideo: fill_video} weboob-1.1/modules/arretsurimages/pages.py000066400000000000000000000100301265717027300210120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 franek # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.capabilities.base import UserError from weboob.capabilities.image import BaseImage from weboob.deprecated.browser import Page, BrokenPageError from weboob.capabilities import NotAvailable from .video import ArretSurImagesVideo class IndexPage(Page): def iter_videos(self, pattern=None): videos = self.document.getroot().cssselect("div[class=bloc-contenu-8]") for div in videos: title = self.parser.select(div, 'h1', 1).text_content().replace(' ', ' ') if pattern: if pattern.upper() not in title.upper(): continue m = re.match(r'/contenu.php\?id=(.*)', div.find('a').attrib['href']) _id = '' if m: _id = m.group(1) video = ArretSurImagesVideo(_id) video.title = unicode(title) video.rating = None video.rating_max = None thumb = self.parser.select(div, 'img', 1) url = u'http://www.arretsurimages.net' + thumb.attrib['src'] video.thumbnail = BaseImage(url) video.thumbnail.url = video.thumbnail.id yield video class ForbiddenVideo(UserError): pass class VideoPage(Page): def is_logged(self): try: self.parser.select(self.document.getroot(), '#user-info', 1) except BrokenPageError: return False else: return True def on_loaded(self): if not self.is_logged(): raise ForbiddenVideo('This video or group may contain content that is inappropriate for some users') def get_video(self, video=None): if not video: video = ArretSurImagesVideo(self.get_id()) video.title = unicode(self.get_title()) video.url = unicode(self.get_url()) video.set_empty_fields(NotAvailable) return video def get_firstUrl(self): obj = self.parser.select(self.document.getroot(), 'a.bouton-telecharger', 1) firstUrl = obj.attrib['href'] return firstUrl def get_title(self): title = self.document.getroot().cssselect('div[id=titrage-contenu] h1')[0].text return title def get_id(self): m = re.match(r'http://videos.arretsurimages.net/telecharger/(.*)', self.get_firstUrl()) if m: return m.group(1) self.logger.warning('Unable to parse ID') return 0 def get_url(self): firstUrl = self.get_firstUrl() doc = self.browser.get_document(self.browser.openurl(firstUrl)) links = doc.xpath('//a') url = None i = 1 for link in links: # we take the second link of the page if i == 2: url = link.attrib['href'] i += 1 return url class LoginPage(Page): def login(self, username, password): response = self.browser.response() response.set_data(response.get_data().replace("
", "
")) # Python mechanize is broken, fixing it. self.browser.set_response(response) self.browser.select_form(nr=0) self.browser.form.set_all_readonly(False) self.browser['redir'] = '/forum/index.php' self.browser['username'] = username self.browser['password'] = password self.browser.submit() class LoginRedirectPage(Page): pass weboob-1.1/modules/arretsurimages/test.py000066400000000000000000000024311265717027300207000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 franek # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import BaseVideo from weboob.tools.test import BackendTest, SkipTest class ArretSurImagesTest(BackendTest): MODULE = 'arretsurimages' def test_latest_arretsurimages(self): l = list(self.backend.iter_resources([BaseVideo], [u'latest'])) assert len(l) if self.backend.browser.username != u'None': v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) else: raise SkipTest("User credentials not defined") weboob-1.1/modules/arretsurimages/video.py000066400000000000000000000016541265717027300210350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import BaseVideo class ArretSurImagesVideo(BaseVideo): @classmethod def id2url(cls, _id): return 'http://www.arretsurimages.net/contenu.php?id=%s' % _id weboob-1.1/modules/arte/000077500000000000000000000000001265717027300152455ustar00rootroot00000000000000weboob-1.1/modules/arte/__init__.py000066400000000000000000000014301265717027300173540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ArteModule __all__ = ['ArteModule'] weboob-1.1/modules/arte/browser.py000066400000000000000000000204721265717027300173070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.capabilities.collection import Collection from weboob.capabilities.base import UserError from weboob.capabilities import NotAvailable from weboob.browser import PagesBrowser, URL from .pages import VideosListPage, ArteJsonPage from .video import VERSION_VIDEO, LANG, QUALITY, FORMATS, SITE __all__ = ['ArteBrowser'] class ArteBrowser(PagesBrowser): BASEURL = 'http://arte.tv/' webservice = URL('papi/tvguide/(?P.*)/(?P.*)/(?P.*).json', 'http://(?P<__site>.*).arte.tv/(?P<_lang>\w{2})/player/(?P<_id>.*)', 'https://api.arte.tv/api/player/v1/config/(?P<__lang>\w{2})/(?P.*)\?vector=(?P<___site>.*)', ArteJsonPage) videos_list = URL('http://(?P.*).arte.tv/(?P\w{2})/?(?P.*?)', 'http://(?P<_site>.*).arte.tv/(?P.+)', VideosListPage) def __init__(self, lang, quality, order, format, version, *args, **kwargs): self.order = order self.lang = (value for key, value in LANG.items if key == lang).next() self.version = (value for key, value in VERSION_VIDEO.items if self.lang.get('label') in value.keys() and version == key).next() self.quality = (value for key, value in QUALITY.items if key == quality).next() self.format = format if self.lang.get('label') not in self.version.keys(): raise UserError('%s is not available for %s' % (self.lang.get('label'), version)) PagesBrowser.__init__(self, *args, **kwargs) def search_videos(self, pattern): class_name = 'videos/plus7' method_name = 'search' parameters = '/'.join([self.lang.get('webservice'), 'L1', pattern, 'ALL', 'ALL', '-1', self.order, '10', '0']) return self.webservice.go(class_name=class_name, method_name=method_name, parameters=parameters).iter_videos() def get_video(self, id, video=None): class_name = 'videos' method_name = 'stream/player' parameters = '/'.join([self.lang.get('webservice'), id, 'ALL', 'ALL']) video = self.webservice.go(class_name=class_name, method_name=method_name, parameters=parameters).get_video(obj=video) video.ext, video.url = self.get_url() return video def get_url(self): url = self.page.get_video_url(self.quality, self.format, self.version.get(self.lang.get('label')), self.lang.get('version')) if format == FORMATS.HLS: ext = u'm3u8' url = self.get_m3u8_link(url) else: ext = u'mp4' url = url return ext, url def get_m3u8_link(self, url): r = self.openurl(url) baseurl = url.rpartition('/')[0] links_by_quality = [] for line in r.readlines(): if not line.startswith('#'): links_by_quality.append(u'%s/%s' % (baseurl, line.replace('\n', ''))) if len(links_by_quality): try: return links_by_quality[self.quality[1]] except: return links_by_quality[0] return NotAvailable def get_video_from_program_id(self, _id): class_name = 'epg' method_name = 'program' parameters = '/'.join([self.lang.get('webservice'), 'L2', _id]) video = self.webservice.go(class_name=class_name, method_name=method_name, parameters=parameters).get_program_video() if video: return self.get_video(video.id, video) def latest_videos(self): class_name = 'videos' method_name = 'plus7' parameters = '/'.join([self.lang.get('webservice'), 'L1', 'ALL', 'ALL', '-1', self.order, '10', '0']) return self.webservice.go(class_name=class_name, method_name=method_name, parameters=parameters).iter_videos() def get_arte_programs(self): class_name = 'epg' method_name = 'clusters' parameters = '/'.join([self.lang.get('webservice'), '0', 'ALL']) return self.webservice.go(class_name=class_name, method_name=method_name, parameters=parameters).iter_programs(title=self.lang.get('title')) def get_arte_program_videos(self, program): class_name = 'epg' method_name = 'cluster' parameters = '/'.join([self.lang.get('webservice'), program[-1]]) available_videos = self.webservice.go(class_name=class_name, method_name=method_name, parameters=parameters).iter_program_videos() for item in available_videos: video = self.get_video_from_program_id(item.id) if video: yield video def get_arte_concert_categories(self): return self.videos_list.go(site=SITE.CONCERT.get('id'), lang=self.lang.get('site'), cat='').iter_arte_concert_categories() def get_arte_concert_videos(self, cat): return self.videos_list.go(site=SITE.CONCERT.get('id'), lang=self.lang.get('site'), cat='').iter_arte_concert_videos(cat=cat[-1]) def get_arte_concert_video(self, id, video=None): json_url = self.videos_list.go(_site=SITE.CONCERT.get('id'), id=id).get_json_url() m = re.search('http://(?P<__site>.*).arte.tv/(?P<_lang>\w{2})/player/(?P<_id>.*)', json_url) if m: video = self.webservice.go(__site=m.group('__site'), _lang=m.group('_lang'), _id=m.group('_id')).get_arte_concert_video(obj=video) video.id = u'%s.%s' % (video._site, id) video.ext, video.url = self.get_url() return video def get_arte_cinema_categories(self, cat=[]): menu = self.videos_list.go(site=SITE.CINEMA.get('id'), lang=self.lang.get('site'), cat='').get_arte_cinema_menu() menuSplit = map(lambda x: x.split("/")[2:], menu) result = {} for record in menuSplit: here = result for item in record[:-1]: if item not in here: here[item] = {} here = here[item] if "end" not in here: here["end"] = [] here["end"].append(record[-1]) cat = cat if not cat else cat[1:] if not cat and "end" in result: del result["end"] for el in cat: result = result.get(el) if "end" in result.keys(): return self.page.iter_arte_cinema_categories(cat='/'.join(cat)) else: categories = [] for item in result.keys(): categories.append(Collection([SITE.CINEMA.get('id'), unicode(item)], unicode(item))) return categories def get_arte_cinema_videos(self, cat): return self.videos_list.go(site=SITE.CINEMA.get('id'), lang=self.lang.get('site'), cat='/%s' % '/'.join(cat[1:])).get_arte_cinema_videos() def get_arte_cinema_video(self, id, video=None): json_url = self.videos_list.go(_site=SITE.CINEMA.get('id'), id=id).get_json_url() m = re.search('https://api.arte.tv/api/player/v1/config/(\w{2})/(.*)\?vector=(.*)\&.*', json_url) if m: video = self.webservice.go(__lang=m.group(1), vid=m.group(2), ___site=m.group(3)).get_arte_cinema_video(obj=video) video.ext, video.url = self.get_url() video.id = id return video weboob-1.1/modules/arte/favicon.png000066400000000000000000000014631265717027300174040ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME5p IDATxOVUϝ?̘\f J!2n>h+E-"ĕ` D0(IA X(Mj9.< afyw=_89y~<}I$D"H$1h]x9]ex Kww?q S+YQ՝.!l^ m3Fz<p:+[}.VΝI|~Pw|MZw̷ x2>J\A@|xPBG,|^lo^spL*ƱLq;vbK8>_yM38տ Üˊ߆N 5!|ٰ]i1s!jVT_e>= sfz֙XQ,0TDuB&Rg{y&dk+Bmk&@]kdyu2߁x;AKZ.B~V|2+,pF8'K!54G_wp E,WN,߸yw;B}L>;br%ɊLplq4y>o]6Eq q)r  ï<{ "~ .@̟&P"H$D"H$^qQcIENDB`weboob-1.1/modules/arte/module.py000066400000000000000000000146451265717027300171160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.tools.ordereddict import OrderedDict from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound, Collection from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value from .browser import ArteBrowser from .video import ArteVideo, ArteSiteVideo, VERSION_VIDEO, FORMATS, LANG, QUALITY, SITE __all__ = ['ArteModule'] class ArteModule(Module, CapVideo, CapCollection): NAME = 'arte' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' VERSION = '1.1' DESCRIPTION = 'Arte French and German TV' LICENSE = 'AGPLv3+' order = {'AIRDATE_DESC': 'Date', 'VIEWS': 'Views', 'ALPHA': 'Alphabetic', 'LAST_CHANCE': 'Last chance' } versions_choice = OrderedDict([(k, u'%s' % (v.get('label'))) for k, v in VERSION_VIDEO.items]) format_choice = OrderedDict([(k, u'%s' % (v)) for k, v in FORMATS.items]) lang_choice = OrderedDict([(k, u'%s' % (v.get('label'))) for k, v in LANG.items]) quality_choice = [u'%s' % (k) for k, v in QUALITY.items] CONFIG = BackendConfig(Value('lang', label='Lang of videos', choices=lang_choice, default='FRENCH'), Value('order', label='Sort order', choices=order, default='AIRDATE_DESC'), Value('quality', label='Quality of videos', choices=quality_choice, default=QUALITY.HD), Value('format', label='Format of videos', choices=format_choice, default=FORMATS.HTTP_MP4), Value('version', label='Version of videos', choices=versions_choice)) BROWSER = ArteBrowser def create_default_browser(self): return self.create_browser(lang=self.config['lang'].get(), quality=self.config['quality'].get(), order=self.config['order'].get(), format=self.config['format'].get(), version=self.config['version'].get()) def parse_id(self, _id): sites = '|'.join(k.get('id') for k in SITE.values) m = re.match('^(%s)\.(.*)' % sites, _id) if m: return m.groups() m = re.match('https?://www.arte.tv/guide/\w+/(?P.+)/(.*)', _id) if m: return SITE.PROGRAM.get('id'), m.group(1) m = re.match('https?://(%s).arte.tv/(\w+)/(.*)' % (sites), _id) if m: return m.group(1), '/%s/%s' % (m.group(2), m.group(3)) if not _id.startswith('http'): return 'videos', _id def get_video(self, _id): site, _id = self.parse_id(_id) if site in [value.get('id') for value in SITE.values]: _site = (value for value in SITE.values if value.get('id') == site).next() return getattr(self.browser, _site.get('video'))(_id) else: return self.browser.get_video(_id) def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): return self.browser.search_videos(pattern) def fill_arte_video(self, video, fields): if fields != ['thumbnail']: video = self.browser.get_video(video.id, video) if 'thumbnail' in fields and video and video.thumbnail: video.thumbnail.data = self.browser.open(video.thumbnail.url).content return video def fill_site_video(self, video, fields): if fields != ['thumbnail']: for site in SITE.values: m = re.match('%s\.(.*)' % site.get('id'), video.id) if m: video = getattr(self.browser, site.get('video'))(m.group(1), video) break if 'thumbnail' in fields and video and video.thumbnail: video.thumbnail.data = self.browser.open(video.thumbnail.url).content return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield Collection([u'arte-latest'], u'Latest Arte videos') for site in SITE.values: yield Collection([site.get('id')], site.get('label')) if collection.path_level == 1: if collection.split_path == [u'arte-latest']: for video in self.browser.latest_videos(): yield video else: for site in SITE.values: if collection.split_path[0] == site.get('id') and collection.path_level in site.keys(): for item in getattr(self.browser, site.get(collection.path_level))(): yield item if collection.path_level >= 2: for site in SITE.values: if collection.split_path[0] == site.get('id') and collection.path_level in site.keys(): for item in getattr(self.browser, site.get(collection.path_level))(collection.split_path): yield item def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and (collection.split_path == [u'arte-latest'] or collection.split_path[0] in [value.get('id') for value in SITE.values]): return if BaseVideo in objs and collection.path_level >= 2 and\ collection.split_path[0] in [value.get('id') for value in SITE.values]: return raise CollectionNotFound(collection.split_path) OBJECTS = {ArteVideo: fill_arte_video, ArteSiteVideo: fill_site_video} weboob-1.1/modules/arte/pages.py000066400000000000000000000222721265717027300167230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import timedelta from weboob.capabilities.image import BaseImage from weboob.capabilities.base import BaseObject, NotAvailable from weboob.capabilities.collection import Collection from weboob.browser.pages import HTMLPage, JsonPage from weboob.browser.elements import DictElement, ItemElement, ListElement, method from weboob.browser.filters.standard import Date, Format, Env, CleanText, Field, Regexp, Join from weboob.browser.filters.json import Dict from weboob.browser.filters.html import XPath from .video import ArteVideo, ArteSiteVideo, SITE class ArteItemElement(ItemElement): def condition(self): return 'VID' in self.el obj_id = Dict('VID') def obj_title(self): vti = Dict('VTI')(self) vtu = Dict('VSU', default=None)(self) if not vtu: return vti return '%s: %s' % (vti, vtu) obj_rating = Dict('VRT', default=NotAvailable) obj_rating_max = 10 obj_description = Dict('VDE', default=NotAvailable) obj_date = Date(Dict('VDA', default=NotAvailable), default=NotAvailable) def obj_duration(self): seconds = Dict('videoDurationSeconds')(self) if isinstance(seconds, basestring): seconds = int(seconds) return timedelta(seconds=seconds) def obj_thumbnail(self): url = Dict('VTU/IUR')(self) thumbnail = BaseImage(url) thumbnail.url = thumbnail.id return thumbnail class VideosListPage(HTMLPage): @method class iter_arte_concert_categories(ListElement): item_xpath = '//ul[@class="filter-liste"]/li' class item(ItemElement): klass = Collection obj_title = CleanText('./a/span') obj_id = CleanText('./@data-target', replace=[('video_box_tab_', '')]) def obj_split_path(self): _id = CleanText('./@data-target', replace=[('video_box_tab_', '')])(self) return [SITE.CONCERT.get('id'), u'%s' % _id] @method class iter_arte_concert_videos(ListElement): def find_elements(self): self.item_xpath = '//div[@id="video_box_tab_%s"]/article' % Env('cat')(self) for el in self.el.xpath(self.item_xpath): yield el class item(ItemElement): klass = ArteSiteVideo obj__site = SITE.CONCERT.get('id') obj_id = Format('%s.%s', Field('_site'), CleanText('./@about')) obj_title = CleanText('div/div[@class="info-article "]/div/h3/a') def obj_thumbnail(self): url = CleanText('div/div/a/figure/span/span/@data-src')(self) thumbnail = BaseImage(url) thumbnail.url = thumbnail.id return thumbnail @method class iter_arte_cinema_categories(ListElement): item_xpath = '//li[has-class("leaf")]' class item(ItemElement): klass = Collection def condition(self): return Regexp(CleanText('./a/@href'), '^(/\w{2}/%s/.*)' % self.env['cat'], default=None)(self) obj_title = CleanText('./a') obj_id = CleanText('./a/@href') def obj_split_path(self): _id = Regexp(CleanText('./a/@href'), '/\w{2}/(.*)')(self) return [SITE.CINEMA.get('id')] + _id.split('/') def get_arte_cinema_menu(self): return self.doc.xpath('//li[has-class("leaf")]/a[starts-with(@href,"/")]/@href') @method class get_arte_cinema_videos(ListElement): item_xpath = '//article' class item(ItemElement): klass = ArteSiteVideo def condition(self): return len(XPath('.//div[@class="article-secondary "]')(self)) == 1 and\ len(XPath('.//article')(self)) == 0 obj__site = SITE.CINEMA.get('id') obj_id = Format('%s.%s', Field('_site'), Regexp(CleanText('./div/a/@href'), '(http://.*\.arte\.tv)?/(.*)', '\\2')) obj_title = Join(u' - ', './/div[@class="article-secondary "]/div/div') def obj_thumbnail(self): url = CleanText('.//div[@class="article-primary "]/div[has-class("field-thumbnail")]/span/noscript/img/@src')(self) thumbnail = BaseImage(url) thumbnail.url = thumbnail.id return thumbnail def get_json_url(self): return self.doc.xpath('//div[@class="video-container"]')[0].attrib['arte_vp_url'] class ArteJsonPage(JsonPage): def get_video_url(self, quality, format, version, language_version): _urls = Dict('videoJsonPlayer/VSR')(self.doc) if _urls: urls = _urls.keys() key = '_'.join([format, quality, version]) found = self.find_url(key, urls, version, quality) if not found: # We use the default language version key = '_'.join([format, quality, language_version]) found = self.find_url(key, urls, version, quality) if not found: # We only keep the quality key = '_'.join([quality, language_version]) found = self.find_url(key, urls, version, quality) if not found: found = urls[0] streamer = Dict('videoJsonPlayer/VSR/%s/streamer' % (found), default=None)(self.doc) url = Dict('videoJsonPlayer/VSR/%s/url' % (found))(self.doc) if streamer: return '%s%s' % (streamer, url) return url def find_url(self, key, urls, version, quality): self.logger.debug('available urls: %s' % urls) self.logger.debug('search url matching : %s' % key) # Best Case: key is mathing matching = [s for s in urls if key in s] self.logger.debug('best case matching: %s' % matching) if matching: return matching[0] # Second Case: is the version available matching = [s for s in urls if version in s] self.logger.debug('is version available: %s' % matching) if matching: # Do the quality + version match matching_quality = [s for s in matching if quality in s] self.logger.debug('does quality + version match: %s' % matching_quality) if matching_quality: return matching[0] # Only format + version mathes return matching[0] @method class iter_videos(DictElement): item_xpath = 'videoList' class item(ArteItemElement): klass = ArteVideo @method class iter_programs(DictElement): item_xpath = 'configClusterList' class item(ItemElement): klass = Collection obj_title = Dict(CleanText(Env('title'))) obj_id = Dict('clusterId') def obj_split_path(self): return [SITE.PROGRAM.get('id'), Dict('clusterId')(self)] @method class get_video(ArteItemElement): def __init__(self, *args, **kwargs): super(ArteItemElement, self).__init__(*args, **kwargs) self.el = self.el.get('videoJsonPlayer') klass = ArteVideo @method class get_arte_concert_video(ArteItemElement): def __init__(self, *args, **kwargs): super(ArteItemElement, self).__init__(*args, **kwargs) self.el = self.el.get('videoJsonPlayer') klass = ArteSiteVideo obj__site = SITE.CONCERT.get('id') @method class get_arte_cinema_video(ArteItemElement): def __init__(self, *args, **kwargs): super(ArteItemElement, self).__init__(*args, **kwargs) self.el = self.el.get('videoJsonPlayer') klass = ArteSiteVideo obj__site = SITE.CINEMA.get('id') obj_date = Date(Dict('VRA')) @method class get_program_video(ArteItemElement): def __init__(self, *args, **kwargs): super(ArteItemElement, self).__init__(*args, **kwargs) if 'VDO' in self.el['abstractProgram'].keys(): self.el = self.el['abstractProgram']['VDO'] klass = ArteVideo @method class iter_program_videos(DictElement): item_xpath = 'clusterWrapper/broadcasts' ignore_duplicate = True class item(ItemElement): klass = BaseObject def condition(self): return 'VDS' in self.el.keys() and len(self.el['VDS']) > 0 obj_id = Dict('programId') weboob-1.1/modules/arte/test.py000066400000000000000000000047421265717027300166050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo from .video import SITE class ArteTest(BackendTest): MODULE = 'arte' def test_search(self): l = list(self.backend.search_videos('a')) assert len(l) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) def test_sites(self): for site in SITE.values: if site.get('id') == SITE.PROGRAM.get('id'): continue l1 = list(self.backend.iter_resources([BaseVideo], [site.get('id')])) assert len(l1) l1 = l1[0] while not isinstance(l1, BaseVideo): l1 = list(self.backend.iter_resources([BaseVideo], l1.split_path)) assert len(l1) l1 = l1[0] self.backend.fillobj(l1, ('url',)) self.assertTrue(l1.url, 'URL for video "%s" not found' % (l1.id)) def test_latest(self): l = list(self.backend.iter_resources([BaseVideo], [u'arte-latest'])) assert len(l) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) def test_program(self): l1 = list(self.backend.iter_resources([BaseVideo], [u'program'])) assert len(l1) # some categories may contain no available videos (during summer period for example) for l in l1: l2 = list(self.backend.iter_resources([BaseVideo], l.split_path)) if len(l2) == 0: continue break assert len(l2) v = l2[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) weboob-1.1/modules/arte/video.py000066400000000000000000000051021265717027300167230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.base import enum from weboob.capabilities.video import BaseVideo FORMATS = enum(HTTP_MP4=u'HBBTV', HLS=u'M3U8', RTMP=u'RTMP', HLS_MOBILE=u'MOBILE') LANG = enum(FRENCH={u'label': u'French', u'webservice': u'F', u'site': u'fr', u'version': u'1', u'title': u'titleFR'}, GERMAN={u'label': u'German', u'webservice': u'D', u'site': u'de', u'version': u'1', u'title': u'titleDE'}) SITE = enum(PROGRAM={u'id': u'program', u'label': u'Arte Programs', 1: 'get_arte_programs', 2: 'get_arte_program_videos', u'video': 'get_video_from_program_id'}, CONCERT={u'id': u'concert', u'label': u'Arte Concert videos', 1: 'get_arte_concert_categories', 2: 'get_arte_concert_videos', 'video': 'get_arte_concert_video'}, CINEMA={u'id': u'cinema', u'label': u'Arte Cinema', 1: 'get_arte_cinema_categories', 2: 'get_arte_cinema_categories', 3: 'get_arte_cinema_videos', 'video': 'get_arte_cinema_video'}) QUALITY = enum(HD=u'SQ', MD=u'EQ', SD=u'MQ', LD=u'LQ') VERSION_VIDEO = enum(VOSTA={u'label': u'Original version subtitled (German)', LANG.GERMAN.get('label'): u'3'}, VOSTF={u'label': u'Original version subtitled (French)', LANG.FRENCH.get('label'): u'3'}, VASTA={u'label': u'Translated version (German)', LANG.GERMAN.get('label'): u'1', LANG.FRENCH.get('label'): u'2'}, VFSTF={u'label': u'Translated version (French)', LANG.FRENCH.get('label'): u'1', LANG.GERMAN.get('label'): u'2'}, VASTMA={u'label': u'Deaf version (German)', LANG.GERMAN.get('label'): u'8'}, VFSTMF={u'label': u'Deaf version (French)', LANG.FRENCH.get('label'): u'8'}) class ArteVideo(BaseVideo): pass class ArteSiteVideo(BaseVideo): pass weboob-1.1/modules/attilasub/000077500000000000000000000000001265717027300163025ustar00rootroot00000000000000weboob-1.1/modules/attilasub/__init__.py000066400000000000000000000014371265717027300204200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AttilasubModule __all__ = ['AttilasubModule'] weboob-1.1/modules/attilasub/browser.py000066400000000000000000000035031265717027300203400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import SubtitlesPage, SearchPage __all__ = ['AttilasubBrowser'] class AttilasubBrowser(Browser): DOMAIN = 'davidbillemont3.free.fr' PROTOCOL = 'http' ENCODING = 'windows-1252' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://search.freefind.com/find.html.*': SearchPage, 'http://davidbillemont3.free.fr/.*.htm': SubtitlesPage, } def iter_subtitles(self, language, pattern): self.location('http://search.freefind.com/find.html?id=81131980&_charset_=&bcd=%%F7&scs=1&pageid=r&query=%s&mode=Find%%20pages%%20matching%%20ALL%%20words' % pattern.encode('utf-8')) assert self.is_on_page(SearchPage) return self.page.iter_subtitles(language, pattern) def get_subtitle(self, id): url_end = id.split('|')[0] try: self.location('http://davidbillemont3.free.fr/%s' % url_end) except BrowserHTTPNotFound: return if self.is_on_page(SubtitlesPage): return self.page.get_subtitle(id) weboob-1.1/modules/attilasub/favicon.png000066400000000000000000000064061265717027300204430ustar00rootroot00000000000000PNG  IHDR@@% sRGBbKGD pHYs  tIME0;! IDAThZrGr='zRV]c×'?+ioa$x\2{0$f(hEu0j39_,5~gfGf}_ \"()23r{+#3j+; $ed޼-t!(I$Yk"UON&;$%f4tOf/\)#͝?}ζo"HE铇v}ݴ9Hl6^!"_dffnHwtW%!%o߽í;FN_~}xp85O鍣PKRׯGDkd2֖Ax= `Ӭ}5jԵ՗dfFJ"rFXjqz#??S^%unfyR4fVJ麎$7nefq J+¨SZKZ οA$嵩$")]5BJku_YFɾ-̦WGJL<:(]~'1"M;iqp3/<}ZOqv:puE:ͦl5E"Rw~ݷv$2NzYEKr>g<9LtFJ-3K biōM&wssoDf0 h% $Z0/gNϯ\}gok{+ 9dqDٽffPKز̌kׯ}?#3}o@ C Upgf^3PPD!E|:ݹ(k8a s}2^B 7toxms '  V5LL&ޭsV(D@U L&;7w]#r^&+ЬK(D0G)0_zQ$* " "jWЖ6Ft@4M{D@ffdzf22W2 3 -6! A B`r%JC3h|P[Da^)`b)PdH!F:49Z&2 XeD1:\``Ae4F]na+ 'VA9)&L$BՔeS ySHi6|>S-I M Ht?/xe!(`%G %aRHkMX7D$.$R.P̈́FCk6&G7@B$jV/)+d$#$dORJ@BA`4QFJ2XEEhM"h]̎j I PQܼ#טP$B)hI@r=̭i+P [)Ns!pPK;"Lܔb ??v&aL$HgL?y>. UiƈL:;=?;=^ͅ㳓㳫,-YP|l'훙ϚRG|{{ݮ$J8w5Y#N'{cgg:͔h Tkg =K< ~ޝk׶:Io}oڋLx;@E& #Uo?>>,V2*P0h"l_Rovn^ +/ k޽ν" KBJ41|Z[[7wֵ\&va0@M)A>y6(ϲjIkpÁ@H!82~L0Hd)LDvF#E/\IaV܊y l_a%/ӗ5{M`$5 bN)J4  Xty"R.[C+T fC&"9֯m )) ^I kG:\0>Z1s@֪>UjE(#rF2+h=ND"org4=HPd3߰d$lC\;ZZ֏mf]Wʤ0D&3 /ffE Jq%Hր!4t]fC)FBW#`oUB:NNk_342Nj@7gziseK"idbOVFe9؜ ּT/v +=hlB??;=k7kR&6y4fs&gO=^,''?=J`-4K+8b"F}Kz퓧Z$_Bhϩ|cs{i;]=\TJ5@{|z!֞!/ "f`}hB7IQ뀶x9[ջ8,0IEFFYݼ[k) @2^mݍ$eT*UQVYdž"5"k%{oݾsqht%ǠYPVϕ V6AD+d^2ԑDDJ"zY ʬ}jn?;cq>8 0\ߖ+ZCx`̨,Ç\Mձ*RA֊U J*/*&V_BiiW}EE;YC# ֍`9:Ų? ',F.ρ熂Ϥ6 bIENDB`weboob-1.1/modules/attilasub/module.py000066400000000000000000000033521265717027300201440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.subtitle import CapSubtitle, LanguageNotSupported from weboob.tools.backend import Module from .browser import AttilasubBrowser from urllib import quote_plus __all__ = ['AttilasubModule'] class AttilasubModule(Module, CapSubtitle): NAME = 'attilasub' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = '"Attila\'s Website 2.0" French subtitles' LICENSE = 'AGPLv3+' LANGUAGE_LIST = ['fr'] BROWSER = AttilasubBrowser def get_subtitle(self, id): return self.browser.get_subtitle(id) def get_subtitle_file(self, id): subtitle = self.browser.get_subtitle(id) if not subtitle: return None return self.browser.openurl(subtitle.url.encode('utf-8')).read() def iter_subtitles(self, language, pattern): if language not in self.LANGUAGE_LIST: raise LanguageNotSupported() return self.browser.iter_subtitles(language, quote_plus(pattern.encode('utf-8'))) weboob-1.1/modules/attilasub/pages.py000066400000000000000000000120141265717027300177510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.subtitle import Subtitle from weboob.capabilities.base import NotAvailable from weboob.deprecated.browser import Page class SearchPage(Page): def iter_subtitles(self, language, pattern): fontresult = self.parser.select(self.document.getroot(), 'div.search-results font.search-results') # for each result in freefind, explore the subtitle list page to iter subtitles for res in fontresult: a = self.parser.select(res, 'a', 1) url = a.attrib.get('href', '') self.browser.location(url) assert self.browser.is_on_page(SubtitlesPage) # subtitles page does the job for subtitle in self.browser.page.iter_subtitles(language, pattern): yield subtitle class SubtitlesPage(Page): def get_subtitle(self, id): href = id.split('|')[1] # we have to find the 'tr' which contains the link to this address a = self.parser.select(self.document.getroot(), 'a[href="%s"]' % href, 1) line = a.getparent().getparent().getparent().getparent().getparent() cols = self.parser.select(line, 'td') traduced_title = self.parser.select(cols[0], 'font', 1).text.lower() original_title = self.parser.select(cols[1], 'font', 1).text.lower() nb_cd = self.parser.select(cols[2], 'font', 1).text.strip() nb_cd = int(nb_cd.split()[0]) traduced_title_words = traduced_title.split() original_title_words = original_title.split() # this is to trash special spacing chars traduced_title = " ".join(traduced_title_words) original_title = " ".join(original_title_words) name = unicode('%s (%s)' % (original_title, traduced_title)) url = unicode('http://davidbillemont3.free.fr/%s' % href) subtitle = Subtitle(id, name) subtitle.url = url subtitle.ext = url.split('.')[-1] subtitle.language = unicode('fr') subtitle.nb_cd = nb_cd subtitle.description = NotAvailable return subtitle def iter_subtitles(self, language, pattern): pattern = pattern.strip().replace('+', ' ').lower() pattern_words = pattern.split() tab = self.parser.select(self.document.getroot(), 'table[bordercolor="#B8C0B2"]') if len(tab) == 0: tab = self.parser.select(self.document.getroot(), 'table[bordercolordark="#B8C0B2"]') if len(tab) == 0: return # some results of freefind point on useless pages if tab[0].attrib.get('width', '') != '100%': return for line in tab[0].getiterator('tr'): cols = self.parser.select(line, 'td') traduced_title = self.parser.select(cols[0], 'font', 1).text.lower() original_title = self.parser.select(cols[1], 'font', 1).text.lower() traduced_title_words = traduced_title.split() original_title_words = original_title.split() # if the pattern is one word and in the title OR if the # intersection between pattern and the title is at least 2 words if (len(pattern_words) == 1 and pattern in traduced_title_words) or\ (len(pattern_words) == 1 and pattern in original_title_words) or\ (len(list(set(pattern_words) & set(traduced_title_words))) > 1) or\ (len(list(set(pattern_words) & set(original_title_words))) > 1): # this is to trash special spacing chars traduced_title = " ".join(traduced_title_words) original_title = " ".join(original_title_words) nb_cd = self.parser.select(cols[2], 'font', 1).text.strip() nb_cd = int(nb_cd.strip(' CD')) name = unicode('%s (%s)' % (original_title, traduced_title)) href = self.parser.select(cols[3], 'a', 1).attrib.get('href', '') url = unicode('http://davidbillemont3.free.fr/%s' % href) id = unicode('%s|%s' % (self.browser.geturl().split('/')[-1], href)) subtitle = Subtitle(id, name) subtitle.url = url subtitle.ext = url.split('.')[-1] subtitle.language = unicode('fr') subtitle.nb_cd = nb_cd subtitle.description = NotAvailable yield subtitle weboob-1.1/modules/attilasub/test.py000066400000000000000000000024361265717027300176400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest import urllib from random import choice class AttilasubTest(BackendTest): MODULE = 'attilasub' def test_subtitle(self): subtitles = list(self.backend.iter_subtitles('fr', 'spiderman')) assert (len(subtitles) > 0) for subtitle in subtitles: path, qs = urllib.splitquery(subtitle.url) assert path.endswith('.rar') # get the file of a random sub if len(subtitles): subtitle = choice(subtitles) self.backend.get_subtitle_file(subtitle.id) weboob-1.1/modules/audioaddict/000077500000000000000000000000001265717027300165645ustar00rootroot00000000000000weboob-1.1/modules/audioaddict/__init__.py000066400000000000000000000014451265717027300207010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AudioAddictModule __all__ = ['AudioAddictModule'] weboob-1.1/modules/audioaddict/favicon.png000066400000000000000000000026761265717027300207320ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME6|tEXtCommentCreated with GIMPW&IDATxoG?bP"\*PAADbɭ[B"[phPBBhCby=$&؞7%;JIv}go~rK3^       ‹C݁`L?9[V=d&! h+< (L6@ڠ-j$`_# >Xז2=h T˙ U(4yӯ`Ww.߻ln_w1咮p.3[6oyDidSqM lM xpn꾃~u૯M&{PM_MzP5Ǽ/umMN0iq-l}Sf{6Y$\MΆ -qwUeﴝI\m(3*~876}s|ERGewD{ ԄjK% 2c~ xaiBRW"G6=  RPPPPp]-âIENDB`weboob-1.1/modules/audioaddict/module.py000066400000000000000000000277371265717027300204430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.audiostream import BaseAudioStream from weboob.tools.capabilities.streaminfo import StreamInfo from weboob.capabilities.collection import CapCollection, Collection from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value from weboob.deprecated.browser import StandardBrowser import time __all__ = ['AudioAddictModule'] # # WARNING # # AudioAddict playlists do not seem to be appreciated by mplayer # VLC plays them successfully, therefore I advice to set the media_player # option to another player in the ~/.config/weboob/radioob config file: # [ROOT] # media_player = your_non_mplayer_player class AudioAddictModule(Module, CapRadio, CapCollection): NAME = 'audioaddict' MAINTAINER = u'Pierre Mazière' EMAIL = 'pierre.maziere@gmx.com' VERSION = '1.1' DESCRIPTION = u'Internet radios powered by audioaddict.com services' LICENSE = 'AGPLv3+' BROWSER = StandardBrowser # Data extracted from http://tobiass.eu/api-doc.html NETWORKS = { 'DI': { 'desc': 'Digitally Imported addictive electronic music', 'domain': 'di.fm', 'streams': {'android_low': {'rate': 40, 'fmt': 'aac'}, 'android': {'rate': 64, 'fmt': 'aac'}, 'android_high': {'rate': 96, 'fmt': 'aac'}, 'android_premium_low': {'rate': 40, 'fmt': 'aac'}, 'android_premium_medium': {'rate': 64, 'fmt': 'aac'}, 'android_premium': {'rate': 128, 'fmt': 'aac'}, 'android_premium_high': {'rate': 256, 'fmt': 'aac'}, 'public1': {'rate': 64, 'fmt': 'aac'}, 'public2': {'rate': 40, 'fmt': 'aac'}, 'public3': {'rate': 96, 'fmt': 'mp3'}, 'premium_low': {'rate': 40, 'fmt': 'aac'}, 'premium_medium': {'rate': 64, 'fmt': 'aac'}, 'premium': {'rate': 128, 'fmt': 'aac'}, 'premium_high': {'rate': 256, 'fmt': 'mp3'} } }, 'RadioTunes': { 'desc': 'Radio Tunes', 'domain': 'radiotunes.com', 'streams': {'appleapp_low': {'rate': 40, 'fmt': 'aac'}, 'appleapp': {'rate': 64, 'fmt': 'aac'}, 'appleapp_high': {'rate': 96, 'fmt': 'mp3'}, 'appleapp_premium_medium': {'rate': 64, 'fmt': 'aac'}, 'appleapp_premium': {'rate': 128, 'fmt': 'aac'}, 'appleapp_premium_high': {'rate': 256, 'fmt': 'mp3'}, 'public1': {'rate': 40, 'fmt': 'aac'}, 'public5': {'rate': 40, 'fmt': 'wma'}, 'public3': {'rate': 96, 'fmt': 'mp3'}, 'premium_low': {'rate': 40, 'fmt': 'aac'}, 'premium_medium': {'rate': 64, 'fmt': 'aac'}, 'premium': {'rate': 128, 'fmt': 'aac'}, 'premium_high': {'rate': 256, 'fmt': 'mp3'} } }, 'JazzRadio': { 'desc': 'Jazz Radio', 'domain': 'jazzradio.com', 'streams': {'appleapp_low': {'rate': 40, 'fmt': 'aac'}, 'appleapp': {'rate': 64, 'fmt': 'aac'}, 'appleapp_premium_medium': {'rate': 64, 'fmt': 'aac'}, 'appleapp_premium': {'rate': 128, 'fmt': 'aac'}, 'appleapp_premium_high': {'rate': 256, 'fmt': 'mp3'}, 'public1': {'rate': 40, 'fmt': 'aac'}, 'public3': {'rate': 64, 'fmt': 'mp3'}, 'premium_low': {'rate': 40, 'fmt': 'aac'}, 'premium_medium': {'rate': 64, 'fmt': 'aac'}, 'premium': {'rate': 128, 'fmt': 'aac'}, 'premium_high': {'rate': 256, 'fmt': 'mp3'} } }, 'RockRadio': { 'desc': 'Rock Radio', 'domain': 'rockradio.com', 'streams': {'android_low': {'rate': 40, 'fmt': 'aac'}, 'android': {'rate': 64, 'fmt': 'aac'}, 'android_premium_medium': {'rate': 64, 'fmt': 'aac'}, 'android_premium': {'rate': 128, 'fmt': 'aac'}, 'android_premium_high': {'rate': 256, 'fmt': 'mp3'}, 'public3': {'rate': 96, 'fmt': 'mp3'} } }, 'FrescaRadio': { 'desc': 'Fresca Radio', 'domain': 'frescaradio.com', 'streams': { 'public3': {'rate': 96, 'fmt': 'mp3'} } } } CONFIG = BackendConfig(Value('networks', label='Selected Networks [%s](space separated)' % ' '.join(NETWORKS.keys()), default=''), Value('quality', label='Radio streaming quality', choices={'h': 'high', 'l': 'low'}, default='h') ) def __init__(self, *a, **kw): super(AudioAddictModule, self).__init__(*a, **kw) self.RADIOS = {} self.HISTORY = {} def _get_tracks_history(self, network): self._fetch_radio_list(network) domain = self.NETWORKS[network]['domain'] url = 'http://api.audioaddict.com/v1/%s/track_history' %\ (domain[:domain.rfind('.')]) self.HISTORY[network] = self.browser.location(url) return self.HISTORY def create_default_browser(self): return self.create_browser(parser='json') def _get_stream_name(self, network, quality): streamName = 'public3' for name in self.NETWORKS[network]['streams'].keys(): if name.startswith('public') and \ self.NETWORKS[network]['streams'][name]['rate'] >= 64: if quality == 'h': streamName = name break else: if quality == 'l': streamName = name break return streamName def _fetch_radio_list(self, network=None): quality = self.config['quality'].get() for selectedNetwork in self.config['networks'].get().split(): if network is None or network == selectedNetwork: streamName = self._get_stream_name(selectedNetwork, quality) if not self.RADIOS: self.RADIOS = {} if selectedNetwork not in self.RADIOS: document = self.browser.location('http://listen.%s/%s' % (self.NETWORKS[selectedNetwork]['domain'], streamName)) self.RADIOS[selectedNetwork] = {} for info in document: radio = info['key'] self.RADIOS[selectedNetwork][radio] = {} self.RADIOS[selectedNetwork][radio]['id'] = info['id'] self.RADIOS[selectedNetwork][radio]['name'] = info['name'] self.RADIOS[selectedNetwork][radio]['playlist'] = info['playlist'] return self.RADIOS def iter_radios_search(self, pattern): self._fetch_radio_list() pattern = pattern.lower() for network in self.config['networks'].get().split(): for radio in self.RADIOS[network]: radio_dict = self.RADIOS[network][radio] if pattern in radio_dict['name'].lower() : yield self.get_radio(radio+"."+network) def iter_resources(self, objs, split_path): self._fetch_radio_list() if Radio in objs: for network in self.config['networks'].get().split(): if split_path == [network]: for radio in self.RADIOS[network]: yield self.get_radio(radio+"."+network) return for network in self.config['networks'].get().split(): yield Collection([network], self.NETWORKS[network]['desc']) def get_current(self, network, radio): channel = {} if network not in self.HISTORY: self._get_tracks_history(network) channel = self.HISTORY[network].get(str(self.RADIOS[network][radio]['id'])) else: now=time.time() channel = self.HISTORY[network].get(str(self.RADIOS[network][radio]['id'])) if channel is None: return 'Unknown', 'Unknown' if (channel.get('started')+channel.get('duration')) < now: self._get_tracks_history(network) channel=self.HISTORY[network].get(str(self.RADIOS[network][radio]['id'])) artist = u'' + (channel.get('artist', '') or 'Unknown') title = u''+(channel.get('title', '') or 'Unknown') if artist == 'Unknown': track = u'' + (channel.get('track', '') or 'Unknown') if track != 'Unknown': artist = track[:track.find(' - ')] return artist, title def get_radio(self, radio): if not isinstance(radio, Radio): radio = Radio(radio) radioName, network = radio.id.split('.', 1) self._fetch_radio_list(network) if radioName not in self.RADIOS[network]: return None radio_dict = self.RADIOS[network][radioName] radio.title = radio_dict['name'] radio.description = radio_dict['name'] artist, title = self.get_current(network, radioName) current = StreamInfo(0) current.who = artist current.what = title radio.current = current radio.streams = [] defaultname = self._get_stream_name(network, self.config['quality'].get()) stream = BaseAudioStream(0) stream.bitrate = self.NETWORKS[network]['streams'][defaultname]['rate'] stream.format = self.NETWORKS[network]['streams'][defaultname]['fmt'] stream.title = u'%s %skbps' % (stream.format, stream.bitrate) stream.url = 'http://listen.%s/%s/%s.pls' %\ (self.NETWORKS[network]['domain'], defaultname, radioName) radio.streams.append(stream) i = 1 for name in self.NETWORKS[network]['streams'].keys(): if name == defaultname: continue stream = BaseAudioStream(i) stream.bitrate = self.NETWORKS[network]['streams'][name]['rate'] stream.format = self.NETWORKS[network]['streams'][name]['fmt'] stream.title = u'%s %skbps' % (stream.format, stream.bitrate) stream.url = 'http://listen.%s/%s/%s.pls'%\ (self.NETWORKS[network]['domain'], name, radioName) radio.streams.append(stream) i = i + 1 return radio def fill_radio(self, radio, fields): if 'current' in fields: radioName, network = radio.id.split('.', 1) radio.current = StreamInfo(0) radio.current.who, radio.current.what = self.get_current(network, radioName) return radio OBJECTS = {Radio: fill_radio} weboob-1.1/modules/audioaddict/test.py000066400000000000000000000026521265717027300201220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.radio import Radio class AudioAddictTest(BackendTest): MODULE = 'audioaddict' def test_audioaddict(self): ls = list(self.backend.iter_resources((Radio, ), [])) self.assertTrue(len(ls) > 0) search = list(self.backend.iter_radios_search('classic')) self.assertTrue(len(search) > 0) radio = self.backend.get_radio('classicrock.RockRadio') self.assertTrue(radio.title) self.assertTrue(radio.description) self.assertTrue(radio.current.who) self.assertTrue(radio.current.what) self.assertTrue(radio.streams[0].url) self.assertTrue(radio.streams[0].title) weboob-1.1/modules/aum/000077500000000000000000000000001265717027300150745ustar00rootroot00000000000000weboob-1.1/modules/aum/API.txt000066400000000000000000001354441265717027300162610ustar00rootroot00000000000000 Adopte un Mec API ------------------ Constants: APIKEY = fb0123456789abcd URL = http://api.adopteunmec.com/api.php ME Commands =========== me.login --------- Parameters: - login - pass Errors: - 1.1.1 : invalid login Return value: {u'errors': [], u'result': {u'baskets': u'384', u'events': {u'lastBasket': {u'alert': u'1', u'birthday': u'1989-02-04', u'city': u'Paris', u'country': u'fr', u'cover': u'1', u'id': u'14471939', u'isBan': False, u'isOnline': False, u'last_cnx': u'2011-09-20 13:56:36', u'list5': u'0', u'login': u'kloo', u'mod_level': u'0', u'path': u'9/3/9/1/7/4/4/', u'pseudo': u'Kloolloo', u'region': u'11', u'sex': 1, u'shard': 9, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/14471939/Kloolloo', u'zip': u'75001'}, u'lastChat': {u'alert': u'1', u'birthday': u'1987-10-10', u'city': u'Paris 18e Arrondissement', u'country': u'fr', u'cover': u'0', u'id': u'13280274', u'isBan': False, u'isOnline': False, u'last_cnx': u'2010-11-20 03:37:00', u'list5': u'0', u'login': u'#c1a63bda81cc03ccdf080ca6e003919e', u'mod_level': u'0', u'path': u'4/7/2/0/8/2/3/', u'pseudo': u'Katie Lee', u'region': u'11', u'sex': 1, u'shard': 4, u'style': u'0', u'table': u'adopteun.girls_coma', u'url': u'/api.php?member/view/13280274/KatieLee', u'zip': u'75018'}, u'lastFlash': {u'alert': u'1', u'birthday': u'1983-12-20', u'city': u'Longjumeau', u'country': u'fr', u'cover': u'1', u'id': u'13883475', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-09-20 18:52:13', u'list5': u'0', u'login': u'@', u'mod_level': u'0', u'path': u'5/7/4/3/8/8/3/', u'pseudo': u'Pas Tjs Sage', u'region': u'11', u'sex': 1, u'shard': 5, u'style': u'2', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/13883475/PasTjsSage', u'zip': u'91160'}, u'lastMail': {u'alert': u'1', u'birthday': u'1989-04-28', u'city': u'Paris 8e Arrondissement', u'country': u'fr', u'cover': u'5', u'id': u'13268738', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-09-20 19:24:14', u'list5': u'0', u'login': u'@13268738', u'mod_level': u'0', u'path': u'8/3/7/8/6/2/3/', u'pseudo': u'Th\xe9na', u'region': u'11', u'sex': 1, u'shard': 8, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/13268738/Thna', u'zip': u'75008'}, u'lastVisit': {u'alert': u'1', u'birthday': u'1988-02-27', u'city': u'Paris', u'country': u'fr', u'cover': u'1', u'id': u'14477637', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-09-20 18:31:00', u'list5': u'0', u'login': u'@', u'mod_level': u'0', u'path': u'7/3/6/7/7/4/4/', u'pseudo': u'Lolly', u'region': u'11', u'sex': 1, u'shard': 7, u'style': u'4', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/14477637/Lolly', u'zip': u'75005'}}, u'flashs': 10, u'mails': u'731', u'me': {u'about1': u"Je n'ai pas de temps à perdre, je n'ai ni MSN ni Facebook, je considère qu'on apprécie davantage la discussion face à face autour d'un verre que dans les yeux de son écran.\r
\r
Bon et ne venez que si vous avez quelque chose à me dire, je n'envoie jamais de charmes.", u'about2': u'', u'admin': u'0', u'alert': u'0', u'alert_add': u'6', u'birthday': u'1986-08-13', u'books': u"Orwell (1984, La ferme des animaux)
Barjavel (La nuit des temps, Le voyageur imprudent, Ravage, \x85)
Boris Vian (J'irai cracher sur vos tombes, L'écume des jours\x85)
Bukowski, Desproges, San Antonio
Sartre, Le Canard", u'cat': u'1', u'checks1': u'0', u'checks2': u'16686', u'checks3': u'0', u'checks4': u'0', u'checks5': u'0', u'checks6': u'2', u'checks7': u'0', u'cinema': u'Le Grand Détournement \x97 La Classe Américaine
V pour Vendetta, Pulp Fiction, The Truman Show
Eternal Sunshine of the Spotless Mind, Match Point
Idiocracy, The Big Lebowski, La cité de la peur
Sin City, Orange Mecanique, Buffet Froid, L', u'city': u'Paris', u'country': u'fr', u'cover': u'5', u'drink': u'2', u'email': u'tesiruna@parano.me', u'eyes': u'3', u'f': u'', u'first_cnx': u'2010-05-16 09:13:53', u'first_ip': u'81.57.125.104', u'food': u'1', u'godfather': u'0', u'hair_color': u'5', u'hair_size': u'3', u'hobbies': u'', u'id': u'22450639', u'img_count': u'5', u'isBan': False, u'isOnline': True, u'job': u'Dieu', u'last_chat': u'-0001-11-29 23:09:21', u'last_cnx': u'2011-09-20 19:24:25', u'last_ip': u'88.161.27.232', u'lat': u'48.861961', u'latR': u'0.852802098431', u'list1': u'2', u'list2': u'2', u'list3': u'2', u'list4': u'3', u'list5': u'0', u'list6': u'0', u'lng': u'2.33594', u'lngR': u'0.040769844129', u'login': u'@22450639', u'mod_level': u'1', u'music': u"Pink Floyd, Scorpions, Emperor
Metallica, Iron Maiden, Accept
Slash's Snakepit, Queen, Deep Purple
Led Zeppelin, Rolling Stones
Brassens, Souchon, Brel, Vian", u'origins': u'1', u'pass': u'8f3fa83cec9a243ae53c1337d2b5e1cf', u'path': u'9/3/6/0/5/4/2/', u'phone': u'-', u'pictures': [{u'file': u'5', u'height': u'427', u'id': u'7315391', u'md5': u'859fcd2e425617c33c16d6a1bc510ad3', u'member': u'22450639', u'rank': u'1', u'valid': u'1578737', u'width': u'500'}], u'pseudo': u'Nazification', u'region': u'11', u'sex': 0, u'shape': u'1', u'shard': 9, u'size': u'175', u'smoke': u'2', u'style': u'0', u'subregion': u'76', u'table': u'adopteun.boys', u'texts1': u'', u'texts2': u'', u'texts3': u'', u'texts4': u'', u'texts5': u'', u'texts6': u'', u'title': u'', u'tvs': u'Je ne possède pas la TV



', u'url': u'/api.php?member/view/22450639/Nazification', u'validated': True, u'visites': u'0', u'w': u'', u'warn': u'0', u'weight': u'55', u'zip': u'75000'}, u'news': {u'newBaskets': 3, u'newMails': 1, u'newVisits': 113}, u'popu': u'71540', u'subMobile': False, u'subWebsite': False, u'token': u'ea7bac8837f6e5bb1e2a3267d6a08b32e388d593', u'visites': u'958'}} me.[default] ------------ Return value: {u'errors': [], u'result': {u'events': {u'lastBasket': {u'alert': u'1', u'birthday': u'1989-02-04', u'city': u'Paris', u'country': u'fr', u'cover': u'1', u'id': u'14471939', u'isBan': False, u'isOnline': False, u'last_cnx': u'2011-09-20 13:56:36', u'list5': u'0', u'login': u'kloo', u'mod_level': u'0', u'path': u'9/3/9/1/7/4/4/', u'pseudo': u'Kloolloo', u'region': u'11', u'sex': 1, u'shard': 9, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/14471939/Kloolloo', u'zip': u'75001'}, u'lastChat': {u'alert': u'1', u'birthday': u'1987-10-10', u'city': u'Paris 18e Arrondissement', u'country': u'fr', u'cover': u'0', u'id': u'13280274', u'isBan': False, u'isOnline': False, u'last_cnx': u'2010-11-20 03:37:00', u'list5': u'0', u'login': u'#c1a63bda81cc03ccdf080ca6e003919e', u'mod_level': u'0', u'path': u'4/7/2/0/8/2/3/', u'pseudo': u'Katie Lee', u'region': u'11', u'sex': 1, u'shard': 4, u'style': u'0', u'table': u'adopteun.girls_coma', u'url': u'/api.php?member/view/13280274/KatieLee', u'zip': u'75018'}, u'lastFlash': {u'alert': u'1', u'birthday': u'1983-12-20', u'city': u'Longjumeau', u'country': u'fr', u'cover': u'1', u'id': u'13883475', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-09-20 18:52:13', u'list5': u'0', u'login': u'@', u'mod_level': u'0', u'path': u'5/7/4/3/8/8/3/', u'pseudo': u'Pas Tjs Sage', u'region': u'11', u'sex': 1, u'shard': 5, u'style': u'2', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/13883475/PasTjsSage', u'zip': u'91160'}, u'lastMail': {u'alert': u'1', u'birthday': u'1989-04-28', u'city': u'Paris 8e Arrondissement', u'country': u'fr', u'cover': u'5', u'id': u'13268738', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-09-20 19:47:28', u'list5': u'0', u'login': u'@13268738', u'mod_level': u'0', u'path': u'8/3/7/8/6/2/3/', u'pseudo': u'Th\xe9na', u'region': u'11', u'sex': 1, u'shard': 8, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/13268738/Thna', u'zip': u'75008'}, u'lastVisit': {u'alert': u'1', u'birthday': u'1988-02-27', u'city': u'Paris', u'country': u'fr', u'cover': u'1', u'id': u'14477637', u'isBan': False, u'isOnline': False, u'last_cnx': u'2011-09-20 19:09:00', u'list5': u'0', u'login': u'@', u'mod_level': u'0', u'path': u'7/3/6/7/7/4/4/', u'pseudo': u'Lolly', u'region': u'11', u'sex': 1, u'shard': 7, u'style': u'4', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/14477637/Lolly', u'zip': u'75005'}}, u'news': {u'newBaskets': 0, u'newMails': 1, u'newVisits': 113}, u'token': u'9a97a03774c9f440e676c78f48794a7221a67285'}} me.basket ---------- Return value: {u'errors': [], u'popu': 71840, u'result': {u'basket': [{u'alert': u'1', u'birthday': u'1989-02-04', u'city': u'Paris', u'country': u'fr', u'cover': u'1', u'date': u'2011-09-19 01:52:29', u'id': u'14471939', u'isBan': False, u'isOnline': False, u'last_cnx': u'2011-09-20 13:56:36', u'list5': u'0', u'login': u'kloo', u'mod_level': u'0', u'path': u'9/3/9/1/7/4/4/', u'pseudo': u'Kloolloo', u'region': u'11', u'sex': 1, u'shard': 9, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/14471939/Kloolloo', u'zip': u'75001'}], u'inBasket': 57, u'token': u'ea7bac8837f6e5bb1e2a3267d6a08b32e388d593'}} me.flashs --------- Return value: {u'errors': [], u'result': {u'all': [{u'date': u'2011-10-19 10:50:43', u'fid': u'41311269', u'id': u'12656592', u'member': {u'alert': u'1', u'birthday': u'1986-08-08', u'city': u'Armes', u'country': u'fr', u'cover': u'3', u'id': u'12656592', u'isBan': False, u'isOnline': False, u'last_cnx': u'2011-10-19 17:28:00', u'list5': u'0', u'login': u'@12656592', u'mod_level': u'0', u'path': u'2/9/5/6/5/6/2/', u'pseudo': u'Yayanne', u'region': u'5', u'sex': 1, u'shard': 2, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/12656592/Yayanne', u'zip': u'58500'}, u'seen': u'2011-10-19 10:54:09'}], u'count': 1467, u'news': [], u'olds': [], u'popu': u'110350', u'token': u'3af90dd563431fe6b4c65930d18337c997fac34e'}} me.visits --------- Return value: {u'errors': [], u'result': {u'count': u'607', u'news': [], u'offset': 0, u'olds': [{u'alert': u'0', u'birthday': u'1985-01-29', u'city': u'Albi', u'country': u'fr', u'cover': u'11', u'date': u'2011-10-19 17:40:43', u'id': u'13461054', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-10-19 17:47:25', u'list5': u'0', u'login': u'@13461054', u'mod_level': u'0', u'path': u'4/5/0/1/6/4/3/', u'pseudo': u'Bruume', u'region': u'15', u'seen': u'2011-10-19 17:42:55', u'sex': 1, u'shard': 4, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/13461054/Bruume', u'vid': u'199226074', u'zip': u'81000'}], u'popu': u'110350', u'token': u'd7380871794008c94971acec82b7b679dd800307'}} MESSAGE Commands ================ message.[default] ----------------- Arguments: - P=, Return value: {u'errors': [], u'result': {u'count': 1, u'threads': [{u'cat': u'0', u'date': u'2011-09-20 19:22:11', u'id': u'11132125', u'id_from': u'13268738', u'id_to': u'22450639', u'member': {u'alert': u'1', u'birthday': u'1989-04-28', u'city': u'Paris 8e Arrondissement', u'country': u'fr', u'cover': u'5', u'id': u'13268738', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-09-20 19:54:15', u'list5': u'0', u'login': u'@13268738', u'mod_level': u'0', u'path': u'8/3/7/8/6/2/3/', u'pseudo': u'Th\xe9na', u'region': u'11', u'sex': 1, u'shard': 8, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/13268738/Thna', u'zip': u'75008'}, u'message': u'0', u'status': u'0', u'title': u"J'aime bien les \xe9l\xe9phants. Toi ?"}], u'token': u'0f70c31bc6d05d45bee64e6f2eab9b537640f2f8'}} message.thread -------------- Parameters: - memberId - count Return value: {u'result': {u'popu': u'15910', u'thread': {u'isNew': False, u'member': {u'alert': u'3', u'birthday': u'1987-04-22', u'city': u'Maisons-Alfort', u'country': u'fr', u'cover': u'6', u'id': u'14022243', u'isBan': False, u'isOnline': False, u'last_cnx': u'2011-09-20 18:18:00', u'list5': u'0', u'login': u'@', u'mod_level': u'0', u'path': u'3/4/2/2/2/0/4/', u'pseudo': u'Sophkipeut', u'region': u'11', u'sex': 1, u'shard': 3, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/14022243/Sophkipeut', u'zip': u'94700'}, u'messages': [{u'date': u'2011-09-19 17:52:03', u'id': u'46583458', u'id_from': u'14022243', u'id_to': u'23185402', u'message': u"Lol, moi j'ai fait attention, mais bon ça n'empêche pas son bidou, ceci dit c'est planqué par ses loooooooooooong poils ^^", u'src': u'', u'title': u"Lol, moi j'ai fait attention, mais bon \xe7a n'emp\xea..."}, {u'date': u'2011-09-19 17:49:39', u'id': u'47467748', u'id_from': u'23185402', u'id_to': u'14022243', u'message': u"Ah oui, justement le vétérinaire m'avait dit après la castration de Futex qu'il fallait faire attention à son poids, du coup ça m'a tellement vexé que j'ai fais attention au point qu'il est sans doute même trop maigre.", u'src': u'', u'title': u"Ah oui, justement le v\xe9t\xe9rinaire m'avait dit apr\xe8..."}], u'remoteStatus': u'2', u'status': u'1', u'warning': 0}, u'token': u'dbeccf96256d4f11991626707881fdba28f54d73'}} message.new ----------- Parameters: - memberId - message Return value: {u'errors': [], u'result': {u'thread': {u'isNew': False, u'member': {u'alert': u'1', u'birthday': u'1986-12-08', u'city': u'Rosny-sous-Bois', u'country': u'fr', u'cover': u'6', u'id': u'11099536', u'isBan': False, u'isOnline': False, u'last_cnx': u'2011-09-20 16:26:32', u'list5': u'0', u'login': u'@11099536', u'mod_level': u'0', u'path': u'6/3/5/9/9/0/1/', u'pseudo': u'Debo', u'region': u'11', u'sex': 1, u'shard': 6, u'style': u'0', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/11099536/Debo', u'zip': u'93110'}, u'messages': [{u'date': u'2011-09-20 20:09:07', u'id': u'46588573', u'id_from': u'23185402', u'id_to': u'11099536', u'message': u'Coucou', u'src': u'iphone', u'title': u'Coucou'}, {u'date': u'2011-09-20 16:27:34', u'id': u'46638469', u'id_from': u'11099536', u'id_to': u'23185402', u'message': u"Coucou pour tout t'avouer je ne m'y etais pas connecté depuis septembre ! un peu moins de boulot alors j'y traine !!\r\n\r\nEt toi ça va? tu devais pas partir au canada? tu es deja revenu.?", u'src': u'', u'title': u"Coucou pour tout t'avouer je ne m'y etais pas co..."}], u'remoteStatus': u'0', u'status': u'2', u'warning': 0}, u'token': u'2491f8ccb6741ceee2a461dc523939796904a0fa'}} message.delete -------------- Parameters: - id_user Return Value: Unknown MEMBER Commands =============== member.view ----------- Parameters: - id Return value: {u'errors': [], u'result': {u'member': {u'about1': u"comment te dire.. j'ai autant envie te laisser boire dans ma bouteille que mettre ma langue dans ta bouche !", u'about2': u"LES BISOUS C'EST BIEN LES BIJOUX C'EST MIEUX!\r
\r
Et l'humour encore plus, mouhaha\r
\r
PS: Si vous êtes le sosie de Pharell Williams, adoptez moi ;)", u'admin': u'0', u'alert': u'1', u'alert_add': u'0', u'birthday': u'1991-05-31', u'books': u"L'Analphabète - Rendell
Etat limite - Assouline
Marie-Antoinette - Zweig

", u'cat': u'2', u'checks1': u'2', u'checks2': u'1588', u'checks3': u'0', u'checks4': u'0', u'checks5': u'64', u'checks6': u'192', u'checks7': u'0', u'cinema': u"My Blueberry Night
Shinning - L'exorciste - Ester - Gothika
How High ! - Requiem for a dream
Remember Me - trainspotting
He gots game - Buffet froid", u'city': u'Paris', u'country': u'fr', u'cover': u'1', u'drink': u'2', u'eyes': u'5', u'f': u'', u'first_cnx': u'2011-09-17 00:18:59', u'first_ip': u'82.120.134.233', u'food': u'3', u'godfather': u'0', u'hair_color': u'4', u'hair_size': u'3', u'hobbies': u'Le théâtre définitivement ! et le sport !', u'id': u'14465370', u'img_count': u'6', u'isBan': False, u'isOnline': False, u'job': u'etudiante', u'last_chat': u'0000-00-00 00:00:00', u'last_cnx': u'2011-09-24 00:09:29', u'last_ip': u'92.151.177.164', u'lat': u'48.8814', u'latR': u'0.853141372984', u'list1': u'0', u'list2': u'42', u'list3': u'0', u'list4': u'0', u'list5': u'0', u'list6': u'0', u'lng': u'2.3365', u'lngR': u'0.0407796179728', u'login': u'@', u'mailable': True, u'mod_level': u'0', u'music': u'Daft Punk - Bloody Beetrots - Kid Cudi - Jamiroquai
Red Hot - Ray Charles - BEP - Gorillaz - Birdy nam nam
Citizen Cope - Angus & Julia Stone - Portishead
50cent - Sia - Ben Harper - Busta Rhymes
Musiques de gansta ! ET Debussy', u'origins': u'1', u'path': u'0/7/3/5/6/4/4/', u'phone': u'-', u'popu': {u'bonus': u'6', u'contacts': u'1', u'flashs': u'246', u'id': u'14465370', u'invits': u'0', u'mails': u'39', u'popu': u'11345', u'visites': u'645'}, u'pseudo': u'Ruslana', u'region': u'11', u'sex': 1, u'shape': u'1', u'shard': 0, u'size': u'170', u'smoke': u'2', u'style': u'4', u'subregion': u'76', u'table': u'adopteun.girls', u'texts1': u'', u'texts2': u'', u'texts3': u'', u'texts4': u'', u'texts5': u'', u'texts6': u'MON SOURIRE HAHAHA', u'title': u'', u'tvs': u'Dexter
OC
True blood
Envoyé spécial ;) - Arte !
', u'url': u'/api.php?member/view/14465370/Ruslana', u'visites': u'0', u'w': u'', u'warn': u'0', u'weight': u'50', u'zip': u'75008'}, u'token': u'e0247704012e01bc32756b357b010e5206ac9c76'}} member.pictures --------------- Parameters: - id Return value: {u'errors': [], u'result': {u'pictures': [{u'id': u'12363004', u'rating': 4.4473684210500002, u'url': u'http://s0.adopteunmec.com/0/6/0/1/6/image7.jpg'}], u'token': u'e131f1b194f2a19337882398b10b79457a638252'}} member.addBasket ---------------- Parameters: - id Errors: - 5.1.1 : member does not exist - 5.1.5 : already sent charm to this one - 5.1.6 : no enough charms available Return value: {u'errors': u'0', u'flashs': 4, u'result': {u'token': u'55039d0557393bb7c5e4381792143d003f0e60c0'}} SEARH Commands ============== search.[default] ---------------- Return value: {u'errors': [], u'result': {u'qsearch': {u'ageMax': u'25', u'ageMin': u'18', u'dist': u'0', u'new': u'0', u'query': u'{"sex":1,"ageMin":"18","ageMax":"25","region":"fr","new":"0","dist":"0"}', u'region': u'fr', u'sex': 1}, u'search': {u'ageMax': u'27', u'ageMin': u'20', u'checks1': u'0', u'checks2': u'0', u'country': u'fr', u'dist': u'50', u'drink': u'0', u'eyes': u'0', u'food': u'0', u'hair_color': u'0', u'hair_size': u'0', u'origins': u'0', u'pseudo': u'', u'query': u'{"ageMin":"20","ageMax":"27","country":"fr","region":"11","subregion":"0","dist":"50","pseudo":"","sex":"1","sizeMin":"0","sizeMax":"0","weightMin":"0","weightMax":"75","shape":"0","hair_size":"0","hair_color":"0","eyes":"0","origins":"0","style":"0","checks1":"0","checks2":"0","smoke":"0","drink":"0","food":"0","search":"true"}', u'region': u'11', u'search': u'true', u'sex': u'1', u'shape': u'0', u'sizeMax': u'0', u'sizeMin': u'0', u'smoke': u'0', u'style': u'0', u'subregion': u'0', u'weightMax': u'75', u'weightMin': u'0'}, u'token': u'3196a3365d927f2ee8738ec8dfc4a5abd75e3ee3'}} search.quick ------------ Parameters: - sex (int[0,1]) - ageMin (int) - ageMax (int) - region (str) - new (int) - dist (int) Return Value: {u'errors': [], u'result': {u'regions': {u'be': None, u'be_24': u' - wallonie', u'be_25': u' - bruxelles capitale', u'be_26': u' - flandre', u'ca': None, u'ca_34': u' - canada', u'ca_35': u' - quebec', u'ch': None, u'ch_27': u' - r\xe9gion l\xe9manique', u'ch_28': u' - espace Mittelland', u'ch_29': u' - suisse du nord-ouest', u'ch_30': u' - zurich', u'ch_31': u' - suisse orientale', u'ch_32': u' - suisse centrale', u'ch_33': u' - tessin', u'fr': None, u'fr_1': u' - alsace', u'fr_10': u' - haute-normandie', u'fr_11': u' - ile-de-france', u'fr_12': u' - languedoc-roussillon', u'fr_13': u' - limousin', u'fr_14': u' - lorraine', u'fr_15': u' - midi-pyr\xe9n\xe9es', u'fr_16': u' - nord-pas-de-calais', u'fr_17': u' - paca', u'fr_18': u' - pays de la loire', u'fr_19': u' - picardie', u'fr_2': u' - aquitaine', u'fr_20': u' - poitou-charentes', u'fr_21': u' - rh\xf4ne-alpes', u'fr_22': u' - corse', u'fr_23': u' - dom+tom', u'fr_3': u' - auvergne', u'fr_4': u' - basse-normandie', u'fr_5': u' - bourgogne', u'fr_6': u' - bretagne', u'fr_7': u' - centre', u'fr_8': u' - champagne-ardenne', u'fr_9': u' - franche-comt\xe9'}, u'search': [{u'alert': u'2', u'birthday': u'1985-11-21', u'city': u'Boulogne-Billancourt', u'country': u'fr', u'cover': u'12', u'id': u'14252744', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-09-24 15:19:48', u'list5': u'0', u'login': u'@', u'mod_level': u'0', u'path': u'4/4/7/2/5/2/4/', u'pseudo': u'Birdy', u'region': u'11', u'sex': 1, u'shard': 4, u'style': u'5', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/14252744/Birdy', u'zip': u'92100'}], u'token': u'ef78ac6d812ab15f2f8efd578f4da4ef2e23aa71'}} search.advanced --------------- Parameters: - ageMin (int) - ageMax (int) - country (str) - region (int) - subregion (int) - dist (int) - pseudo (str) - sex (int[0,1]) - sizeMin (int) - sizeMax (int) - weightMin (int) - weightMax (int) - shape (int) - hair_size (int) - hair_color (int) - eyes (int) - origins (int) - style (int) - checks1 (int) - checks2 (int) - smoke (int) - drink (int) - food (int) - search (bool) Return Value: {u'errors': [], u'regions': {u'be': None, u'be_24': u' - wallonie', u'be_25': u' - bruxelles capitale', u'be_26': u' - flandre', u'ca': None, u'ca_34': u' - canada', u'ca_35': u' - quebec', u'ch': None, u'ch_27': u' - r\xe9gion l\xe9manique', u'ch_28': u' - espace Mittelland', u'ch_29': u' - suisse du nord-ouest', u'ch_30': u' - zurich', u'ch_31': u' - suisse orientale', u'ch_32': u' - suisse centrale', u'ch_33': u' - tessin', u'fr': None, u'fr_1': u' - alsace', u'fr_10': u' - haute-normandie', u'fr_11': u' - ile-de-france', u'fr_12': u' - languedoc-roussillon', u'fr_13': u' - limousin', u'fr_14': u' - lorraine', u'fr_15': u' - midi-pyr\xe9n\xe9es', u'fr_16': u' - nord-pas-de-calais', u'fr_17': u' - paca', u'fr_18': u' - pays de la loire', u'fr_19': u' - picardie', u'fr_2': u' - aquitaine', u'fr_20': u' - poitou-charentes', u'fr_21': u' - rh\xf4ne-alpes', u'fr_22': u' - corse', u'fr_23': u' - dom+tom', u'fr_3': u' - auvergne', u'fr_4': u' - basse-normandie', u'fr_5': u' - bourgogne', u'fr_6': u' - bretagne', u'fr_7': u' - centre', u'fr_8': u' - champagne-ardenne', u'fr_9': u' - franche-comt\xe9'}, u'result': {u'search': [{u'alert': u'1', u'birthday': u'1988-04-07', u'city': u'Dammartin', u'country': u'fr', u'cover': u'25', u'id': u'13579115', u'isBan': False, u'isOnline': True, u'last_cnx': u'2011-09-24 15:17:22', u'list5': u'0', u'login': u'@', u'mod_level': u'0', u'path': u'5/1/1/9/7/5/3/', u'pseudo': u"S\xe9 's\xe9", u'region': u'11', u'sex': 1, u'shard': 5, u'style': u'1', u'table': u'adopteun.girls', u'url': u'/api.php?member/view/13579115/Ss', u'zip': u'77230'}], u'token': u'f92aede46118dcdba6d484146b4627777fbe7188'}} weboob-1.1/modules/aum/__init__.py000066400000000000000000000015051265717027300172060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .browser import AuMBrowser from .module import AuMModule __all__ = ['AuMBrowser', 'AuMModule'] weboob-1.1/modules/aum/antispam.py000066400000000000000000000116611265717027300172670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re class AntiSpam(object): def check_thread(self, thread): resume = thread['title'] # Check if there is an email address in the offer. if re.match('^[\w\d\.\-_]+@[\w\d\.]+ vous offre la pos', resume): return False if thread['who']['pseudo'] == 'Ekaterina': return False return True def check_profile(self, profile): # The name of profile is in form #123456789 if profile['pseudo'] == '': return False if profile['announce'].startswith('salut! je te donne mon msn'): return False if profile['shopping_list'].startswith('cam to cam'): return False if profile['shopping_list'].startswith('je suis une femme tres tres belle et je recherche un homme qui aime le sexe'): return False if profile['shopping_list'].endswith('mmmmmmmmmmmmmmmm'): return False return True # ipaddr is not available anymore. for ipaddr in (profile['last_ip'], profile['first_ip']): if ipaddr.startswith('41.202.'): return False if ipaddr.startswith('41.250.'): return False if ipaddr.startswith('41.251.'): return False if ipaddr.startswith('41.141.'): return False if ipaddr.startswith('194.177.'): return False if ipaddr.startswith('41.85.'): return False if ipaddr.startswith('41.86.'): return False if ipaddr.startswith('196.47.'): return False if re.match('105\.13\d.*', ipaddr): return False if ipaddr in ('62.157.186.18', '198.36.222.8', '212.234.67.61', '203.193.158.210', '41.189.34.180', '41.66.12.36', '196.47.137.21', '213.136.125.122', '41.191.87.188'): return False return True def check_contact(self, contact): if contact.id == 1: return True if not self.check_profile(contact._aum_profile): return False return True # ipaddr is not available anymore. first_ip = contact.profile['info']['IPaddr'].value.split(' ')[0] last_ip = contact.profile['info']['IPaddr'].value.rstrip(')') for ipaddr in (first_ip, last_ip): if ipaddr.endswith('.afnet.net'): return False if ipaddr.endswith('.iam.net.ma'): return False if ipaddr.endswith('.amsterdam.ananoos.net'): return False if ipaddr.endswith('.tedata.net'): return False if ipaddr.endswith('kupo.fr'): return False if ipaddr.endswith('.static.virginmedia.com'): return False if ipaddr.endswith('frozenway.com'): return False if ipaddr.endswith('.rev.bgtn.net'): return False if ipaddr.endswith('real-vpn.com'): return False if ipaddr.endswith('.nl.ipodah.net'): return False if ipaddr.endswith('.wanamaroc.com'): return False if ipaddr.endswith('.ukservers.com'): return False if ipaddr.endswith('.startdedicated.com'): return False if ipaddr.endswith('.clients.your-server.de'): return False if ipaddr.endswith('.cba.embratel.net.br'): return False if ipaddr.endswith('.idstelcom.com'): return False if ipaddr.endswith('proxy.chg-support.com'): return False if ipaddr.endswith('.sprintsvc.net'): return False if ipaddr.endswith('.relakks.com'): return False return True def check_mail(self, mail): # Spambot with a long first-message. if mail['message'] is None: return True if mail['message'].find('Je veux que vous m\'ayez ecrit directement sur le mon e-mail') >= 0: return False if mail['message'].find('ilusa12010@live.fr') >= 0: return False return True weboob-1.1/modules/aum/browser.py000066400000000000000000000333241265717027300171360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2008-2011 Romain Bignon, Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from base64 import b64encode from hashlib import sha256 from datetime import datetime import math import re import urllib import urllib2 from weboob.exceptions import BrowserIncorrectPassword, BrowserHTTPNotFound, BrowserUnavailable from weboob.deprecated.browser import Browser from weboob.browser.browsers import LoginBrowser from weboob.browser.pages import HTMLPage from weboob.browser.filters.standard import CleanText from weboob.tools.json import json from weboob.tools.date import local2utc from weboob.tools.misc import to_unicode from weboob.capabilities.base import UserError from weboob.capabilities.messages import CantSendMessage __all__ = ['AuMBrowser'] class AuMException(UserError): ERRORS = {"0.0.0": "Bad signature", "0.0.1": "Malformed request", "0.0.2": "Not logged", "1.1.1": "No member has this login", "1.1.2": "Password don't match", "1.1.3": "User has been banned", "1.12.1": "Invalid country", "1.12.1": "Invalid region", "4.0.1": "Member not found", "4.1.1": "Thread doesn't exist", "4.1.2": "Cannot write to this member", "5.1.1": "Member tergeted doesn't exist", "5.1.2": "Sex member targeted is not the opposite of the member logged", "5.1.3": "Not possible to send a charm", "5.1.4": "Not possible to send a charm because the 5 charms has been already used", "5.1.5": "Not possible because the guy has already send a charm to this girl", "5.1.6": "No more money", "5.1.7": "Not possible to add to basket", "5.2.1": "Member doesn't exist", "5.3.1": "Member doesn't exist", } def __init__(self, code): Exception.__init__(self, self.ERRORS.get(code, code)) self.code = code class WebsiteBrowser(LoginBrowser): BASEURL = 'https://www.adopteunmec.com' VERIFY = False TIMEOUT = 3.0 def login(self): data = {'username': self.username, 'password': self.password, 'remember': 'on', } self.open('/auth/login', data=data) #self.readurl('https://www.adopteunmec.com/auth/login', urllib.urlencode(data)) def get_profile(self, id): profile = {} if datetime.now().hour >= 18 or datetime.now().hour < 1: return profile r = None try: r = self.open('https://www.adopteunmec.com/profile/%s' % id) except BrowserUnavailable: pass if r is None or not re.match('https://www.adopteunmec.com/profile/\d+', r.url): self.login() try: r = self.open('https://www.adopteunmec.com/profile/%s' % id) except BrowserUnavailable: r = None if r is None: return {} page = HTMLPage(self, r) doc = page.doc profile['popu'] = {} for tr in doc.xpath('//div[@id="popularity"]//tr'): cols = tr.findall('td') if not cols[0].text: continue key = CleanText('./th')(tr).strip().lower() value = int(re.sub(u'[^0-9]+', u'', cols[0].text).strip()) profile['popu'][key] = value for script in doc.xpath('//script'): text = script.text if text is None: continue m = re.search("'memberLat'\s*:\s*([\-\d\.]+),", text, re.IGNORECASE) if m: profile['lat'] = float(m.group(1)) m = re.search("'memberLng'\s*:\s*([\-\d\.]+),", text, re.IGNORECASE) if m: profile['lng'] = float(m.group(1)) return profile class AuMBrowser(Browser): DOMAIN = 'www.adopteunmec.com' APIKEY = 'fb0123456789abcd' APITOKEN = 'DCh7Se53v8ejS8466dQe63' APIVERSION = '2.2.5' USER_AGENT = 'Mozilla/5.0 (Linux; U; Android4.1.1; fr_FR; GT-N7100; Build/JRO03C) com.adopteunmec.androidfr/17' GIRL_PROXY = None consts = None my_sex = 0 my_id = 0 my_name = u'' my_coords = (0,0) def __init__(self, username, password, search_query, *args, **kwargs): kwargs['get_home'] = False Browser.__init__(self, username, password, *args, **kwargs) # now we do authentication ourselves #self.add_password('https://www.adopteunmec.com/api/', self.username, self.password) self.login() kwargs.pop('get_home') self.website = WebsiteBrowser(self.username, self.password, *args, **kwargs) self.website.login() self.home() self.search_query = search_query def id2url(self, id): return u'https://www.adopteunmec.com/profile/%s' % id def url2id(func): def inner(self, id, *args, **kwargs): m = re.match('^https?://.*adopteunmec.com.*/(\d+)$', str(id)) if m: id = int(m.group(1)) else: m = re.match('^https?://.*adopteunmec.com/(index.php/)?profile/(\d+).*', str(id)) if m: id = int(m.group(2)) return func(self, id, *args, **kwargs) return inner def api0_request(self, command, action, parameter='', data=None, nologin=False): if data is None: # Always do POST requests. data = '' elif isinstance(data, (list,tuple,dict)): data = urllib.urlencode(data) elif isinstance(data, unicode): data = data.encode('utf-8') url = self.buildurl('http://api.adopteunmec.com/api.php', S=self.APIKEY, C=command, A=action, P=parameter, O='json') buf = self.openurl(url, data).read() try: r = json.loads(buf[buf.find('{'):]) except ValueError: raise ValueError(buf) if 'errors' in r and r['errors'] != '0' and len(r['errors']) > 0: code = r['errors'][0] if code in (u'0.0.2', u'1.1.1', u'1.1.2'): if not nologin: self.login() return self.api0_request(command, action, parameter, data, nologin=True) else: raise BrowserIncorrectPassword(AuMException.ERRORS[code]) else: raise AuMException(code) return r def login(self): self.api_request('applications/android') # XXX old API is disabled #r = self.api0_request('me', 'login', data={'login': self.username, # 'pass': self.password, # }, nologin=True) #self.my_coords = (float(r['result']['me']['lat']), float(r['result']['me']['lng'])) #if not self.search_query: # self.search_query = 'region=%s' % r['result']['me']['region'] def api_request(self, command, **kwargs): if 'data' in kwargs: data = to_unicode(kwargs.pop('data')).encode('utf-8', 'replace') else: data = None headers = {} if not command.startswith('applications'): today = local2utc(datetime.now()).strftime('%Y-%m-%d') token = sha256(self.username + self.APITOKEN + today).hexdigest() headers['Authorization'] = 'Basic %s' % (b64encode('%s:%s' % (self.username, self.password))) headers['X-Platform'] = 'android' headers['X-Client-Version'] = self.APIVERSION headers['X-AUM-Token'] = token url = self.buildurl(self.absurl('/api/%s' % command), **kwargs) if isinstance(url, unicode): url = url.encode('utf-8') req = self.request_class(url, data, headers) buf = self.openurl(req).read() try: r = json.loads(buf) except ValueError: raise ValueError(buf) return r def get_exception(self, e): if isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode'): if e.getcode() in (410,): return BrowserHTTPNotFound return Browser.get_exception(self, e) def home(self): r = self.api_request('home/') self.my_sex = r['user']['sex'] self.my_id = int(r['user']['id']) self.my_name = r['user']['pseudo'] if self.my_coords == (0,0): profile = self.get_full_profile(self.my_id) if 'lat' in profile and 'lng' in profile: self.my_coords = [profile['lat'], profile['lng']] return r def get_consts(self): if self.consts is not None: return self.consts self.consts = [{}, {}] for key, sexes in self.api_request('values').iteritems(): for sex, values in sexes.iteritems(): if sex in ('boy', 'both'): self.consts[0][key] = values if sex in ('girl', 'both'): self.consts[1][key] = values return self.consts def score(self): r = self.home() return int(r['user']['points']) def get_my_name(self): return self.my_name def get_my_id(self): return self.my_id def nb_new_mails(self): r = self.home() return r['counters']['new_mails'] def nb_new_baskets(self): r = self.home() return r['counters']['new_baskets'] def nb_new_visites(self): r = self.home() return r['counters']['new_visits'] def nb_available_charms(self): r = self.home() return r['subscription']['flashes_stock'] def get_baskets(self): r = self.api_request('basket', count=30, offset=0) return r['results'] def get_flashs(self): r = self.api_request('charms/', count=30, offset=0) return r['results'] def get_visits(self): r = self.api_request('visits', count=30, offset=0) return r['results'] def get_threads_list(self, count=30): r = self.api_request('threads', count=count, offset=0) return r['results'] @url2id def get_thread_mails(self, id, count=30): r = self.api_request('threads/%s' % id, count=count, offset=0) return r @url2id def post_mail(self, id, content): content = content.replace('\n', '\r\n') try: self.api_request('threads/%s' % id, data=content) except BrowserHTTPNotFound: raise CantSendMessage('Unable to send message.') @url2id def delete_thread(self, id): r = self.api_request('message', 'delete', data={'id_user': id}) self.logger.debug('Thread deleted: %r' % r) @url2id def send_charm(self, id): try: self.api_request('users/%s/charms' % id, data='') except BrowserHTTPNotFound: return False else: return True @url2id def add_basket(self, id): try: self.api_request('basket/%s' % id, data='') except BrowserHTTPNotFound: return False else: return True def search_profiles(self, **kwargs): if not self.search_query: # retrieve query self.login() r = self.api_request('users?count=100&offset=0&%s' % (self.search_query % {'lat': self.my_coords[0], 'lng': self.my_coords[1]})) ids = [s['id'] for s in r['results']] return set(ids) @url2id def get_full_profile(self, id): if self.GIRL_PROXY is not None: res = self.openurl(self.GIRL_PROXY % id) profile = json.load(res) if 'lat' in profile and 'lng' in profile: profile['dist'] = self.get_dist(profile['lat'], profile['lng']) else: profile = self.get_profile(id) return profile def get_dist(self, lat, lng): coords = (float(lat), float(lng)) R = 6371 lat1 = math.radians(self.my_coords[0]) lat2 = math.radians(coords[0]) lon1 = math.radians(self.my_coords[1]) lon2 = math.radians(coords[1]) dLat = lat2 - lat1 dLong = lon2 - lon1 a= pow(math.sin(dLat/2), 2) + math.cos(lat1) * math.cos(lat2) * pow(math.sin(dLong/2), 2) c= 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)) return R * c @url2id def get_profile(self, id): # XXX OLD API IS DISABLED (fucking faggots) #r = self.api0_request('member', 'view', data={'id': id}) #if not 'result' in r: # print r #profile = r['result']['member'] profile = {} profile.update(self.api_request('users/%s' % id)) profile.update(self.website.get_profile(id)) # Calculate distance in km. profile['dist'] = 0.0 if 'lat' in profile and 'lng' in profile: profile['dist'] = self.get_dist(profile['lat'], profile['lng']) return profile weboob-1.1/modules/aum/contact.py000066400000000000000000000266461265717027300171170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2008-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from html2text import unescape import socket from datetime import datetime from dateutil.parser import parse as parse_dt from weboob.tools.ordereddict import OrderedDict from weboob.capabilities.contact import Contact as _Contact, ProfileNode from weboob.tools.html import html2text class FieldBase(object): def __init__(self, key, key2=None): self.key = key self.key2 = key2 def get_value(self, value, consts): raise NotImplementedError() class FieldStr(FieldBase): def get_value(self, profile, consts): return html2text(unicode(profile[self.key])).strip() class FieldBool(FieldBase): def get_value(self, profile, consts): return bool(int(profile[self.key])) class FieldDist(FieldBase): def get_value(self, profile, consts): return '%.2f km' % float(profile[self.key]) class FieldIP(FieldBase): def get_hostname(self, s): try: return socket.gethostbyaddr(s)[0] except (socket.gaierror, socket.herror): return s def get_value(self, profile, consts): s = self.get_hostname(profile[self.key]) if profile[self.key] != profile[self.key2]: s += ' (first %s)' % self.get_hostname(profile[self.key2]) return s class FieldProfileURL(FieldBase): def get_value(self, profile, consts): id = int(profile[self.key]) if id > 0: return 'http://www.adopteunmec.com/index.php/profile/%d' % id else: return '' class FieldPopu(FieldBase): def get_value(self, profile, consts): return unicode(profile['popu'][self.key]) class FieldPopuRatio(FieldBase): def get_value(self, profile, consts): v1 = float(profile['popu'][self.key]) v2 = float(profile['popu'][self.key2]) if v2 == 0.0: return 'NaN' else: return '%.2f' % (v1 / v2) class FieldOld(FieldBase): def get_value(self, profile, consts): birthday = parse_dt(profile[self.key]) return int((datetime.now() - birthday).days / 365.25) class FieldList(FieldBase): def get_value(self, profile, consts): return profile[self.key] class FieldBMI(FieldBase): def __init__(self, key, key2, fat=False): FieldBase.__init__(self, key, key2) self.fat = fat def get_value(self, profile, consts): height = int(profile[self.key]) weight = int(profile[self.key2]) if height == 0 or weight == 0: return '' bmi = (weight / float(pow(height / 100.0, 2))) if not self.fat: return bmi elif bmi < 15.5: return 'severely underweight' elif bmi < 18.4: return 'underweight' elif bmi < 24.9: return 'normal' elif bmi < 30: return 'overweight' else: return 'obese' class FieldConst(FieldBase): def get_value(self, profile, consts): v = profile[self.key] if isinstance(v, (basestring,int)): try: return consts[self.key][str(v)] except KeyError: return '' elif isinstance(v, (tuple,list)): labels = [] for i in v: labels.append(consts[self.key][i]) return labels class Contact(_Contact): TABLE = OrderedDict(( ('_info', OrderedDict(( ('title', FieldStr('title')), # ipaddr is not available anymore. #('IPaddr', FieldIP('last_ip', 'first_ip')), ('admin', FieldBool('admin')), ('ban', FieldBool('isBan')), ('first', FieldStr('first_cnx')), ('godfather', FieldProfileURL('godfather')), ))), ('_stats', OrderedDict(( ('mails', FieldPopu('mails')), ('charms', FieldPopu('charmes')), ('visites', FieldPopu('visites')), ('baskets', FieldPopu('panier')), ('invits', FieldPopu('invits')), ('bonus', FieldPopu('bonus')), ('score', FieldStr('points')), ('ratio', FieldPopuRatio('mails', 'charmes')), ('mailable', FieldBool('can_mail')), ))), ('details', OrderedDict(( #('old', FieldStr('age')), ('old', FieldOld('birthdate')), ('birthday', FieldStr('birthdate')), ('zipcode', FieldStr('zip')), ('location', FieldStr('city')), ('distance', FieldDist('dist')), ('country', FieldStr('country')), ('phone', FieldStr('phone')), ('eyes', FieldConst('eyes_color')), ('hair_color', FieldConst('hair_color')), ('hair_size', FieldConst('hair_size')), ('height', FieldConst('size')), ('weight', FieldConst('weight')), ('BMI', FieldBMI('size', 'weight')), ('fat', FieldBMI('size', 'weight', fat=True)), ('shape', FieldConst('shape')), ('origins', FieldConst('origins')), ('signs', FieldConst('features')), ('job', FieldStr('job')), ('style', FieldConst('styles')), ('food', FieldConst('diet')), ('favorite_food', FieldConst('favourite_food')), ('drink', FieldConst('alcohol')), ('smoke', FieldConst('tobacco')), ))), ('tastes', OrderedDict(( ('hobbies', FieldStr('hobbies')), ('music', FieldList('music')), ('cinema', FieldList('cinema')), ('books', FieldList('books')), ('tv', FieldList('tvs')), ))), ('+sex', OrderedDict(( ('underwear', FieldConst('underwear')), ('practices', FieldConst('sexgames')), ('favorite', FieldConst('arousing')), ('toys', FieldConst('sextoys')), ))), ('+personality', OrderedDict(( ('snap', FieldStr('fall_for')), ('exciting', FieldStr('turned_on_by')), ('hate', FieldStr('cant_stand')), ('vices', FieldStr('vices')), ('assets', FieldStr('assets')), ('fantasies', FieldStr('fantasies')), ('is', FieldConst('character')), ))), ('-personality', OrderedDict(( ('accessories', FieldConst('accessories')), ('skills', FieldConst('skills')), ('socios', FieldConst('socios')), ('family', FieldConst('family')), ('pets', FieldConst('pets')), ))) )) def parse_profile(self, profile, consts): if profile['online']: self.status = Contact.STATUS_ONLINE self.status_msg = u'online' self.status_msg = u'since %s' % profile['last_cnx'] else: self.status = Contact.STATUS_OFFLINE self.status_msg = u'last connection %s' % profile['last_cnx'] self.summary = unicode(unescape(profile.get('announce', '').strip())) if len(profile.get('shopping_list', '')) > 0: self.summary += u'\n\nLooking for:\n%s' % unescape(profile['shopping_list'].strip()) for photo in profile['pics']: self.set_photo(photo.split('/')[-1], url=photo + '/full', thumbnail_url=photo + '/small', hidden=False) self.profile = OrderedDict() if 'sex' in profile: for section, d in self.TABLE.iteritems(): flags = ProfileNode.SECTION if section.startswith('_'): flags |= ProfileNode.HEAD if (section.startswith('+') and int(profile['sex']) != 1) or \ (section.startswith('-') and int(profile['sex']) != 0): continue section = section.lstrip('_+-') s = ProfileNode(section, section.capitalize(), OrderedDict(), flags=flags) for key, builder in d.iteritems(): try: value = builder.get_value(profile, consts[int(profile['sex'])]) except KeyError: pass else: s.value[key] = ProfileNode(key, key.capitalize().replace('_', ' '), value) self.profile[section] = s self._aum_profile = profile weboob-1.1/modules/aum/favicon.png000066400000000000000000000042171265717027300172330ustar00rootroot00000000000000PNG  IHDR@@% sRGB pHYs  tIME 2!IDAThip]=!ᒅbFAE.P):J]AjVjGFvZ3.R U[VK$D,I{O?2%عoy{s"("(Te|D.[)EtV4I?2 +׊eL'vI?R)FP\0BB.l0AiSN~E0:5KC+O8x>[y}!jpNqx2έ>Y98=eO&n) oްoFĸ!Aq$~=~BOM_gdZnKa1Eb?{GC!QSeS|7ϩq>*3lL0Ɖx-|O^Ԓ6E[dzV>*=z/zTbxj.ng:4@߫kS:)D]&dؕ!K3IJB/h><B$`+;\M f!(-G72A= ǹ^䒶F.rOGUԣc\9]|v'ʹ"| iJuc>UR }?- (7Ҧ3eWPx!yI ![= n$H UCKe:w%HO?D>(KJ!s7,$~f}7uOC͔.чmp)%`|ZUAdqIO|W($o::hoH%mx9/{^dcʷ'Ħ^ZƓER% 80

z `w|w|2|؊6D4<[?,g;,^.zϙn;V@GwOiL@d _2}%׼ x#D_f$LêA]\]/s'蚁T*FM,PF]xB}9?f&`D6!u:ЫI$R5[KǫH*th ڷXO\utljlJF/uvIsth"d0wR FE#yJdQڟFw%sr$Njtݍag("("(_y*lIENDB`weboob-1.1/modules/aum/module.py000066400000000000000000000461241265717027300167420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import time import datetime from html2text import unescape from dateutil import tz from dateutil.parser import parse as _parse_dt from weboob.capabilities.base import NotLoaded from weboob.capabilities.chat import CapChat from weboob.capabilities.messages import CapMessages, CapMessagesPost, Message, Thread from weboob.capabilities.dating import CapDating, OptimizationNotFound, Event from weboob.capabilities.contact import CapContact, ContactPhoto, Query, QueryError from weboob.capabilities.account import CapAccount, StatusField from weboob.tools.backend import Module, BackendConfig from weboob.deprecated.browser import BrowserUnavailable, BrowserHTTPNotFound from weboob.tools.value import Value, ValueBool, ValueBackendPassword from weboob.tools.date import local2utc from weboob.tools.misc import to_unicode from .contact import Contact from .antispam import AntiSpam from .browser import AuMBrowser from .optim.profiles_walker import ProfilesWalker from .optim.visibility import Visibility from .optim.queries_queue import QueriesQueue __all__ = ['AuMModule'] def parse_dt(s): d = _parse_dt(s) return local2utc(d) class AuMModule(Module, CapMessages, CapMessagesPost, CapDating, CapChat, CapContact, CapAccount): NAME = 'aum' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'"Adopte un Mec" French dating website' CONFIG = BackendConfig(Value('username', label='Username'), ValueBackendPassword('password', label='Password'), ValueBool('antispam', label='Enable anti-spam', default=False), ValueBool('baskets', label='Get baskets with new messages', default=True), Value('search_query', label='Search query', default='')) STORAGE = {'profiles_walker': {'viewed': []}, 'queries_queue': {'queue': []}, 'sluts': {}, 'notes': {}, } BROWSER = AuMBrowser MAGIC_ID_BASKET = 1 def __init__(self, *args, **kwargs): Module.__init__(self, *args, **kwargs) if self.config['antispam'].get(): self.antispam = AntiSpam() else: self.antispam = None def create_default_browser(self): return self.create_browser(self.config['username'].get(), self.config['password'].get(), self.config['search_query'].get()) def report_spam(self, id): with self.browser: pass #self.browser.delete_thread(id) # Do not report fakes to website, to let them to other guys :) #self.browser.report_fake(id) # ---- CapDating methods --------------------- def init_optimizations(self): self.add_optimization('PROFILE_WALKER', ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)) self.add_optimization('VISIBILITY', Visibility(self.weboob.scheduler, self.browser)) self.add_optimization('QUERIES_QUEUE', QueriesQueue(self.weboob.scheduler, self.storage, self.browser)) def iter_events(self): all_events = {} with self.browser: all_events[u'baskets'] = (self.browser.get_baskets, 'You were put into %s\'s basket') all_events[u'flashs'] = (self.browser.get_flashs, 'You sent a charm to %s') all_events[u'visits'] = (self.browser.get_visits, 'Visited by %s') for type, (events, message) in all_events.iteritems(): for event in events(): e = Event(event['who']['id']) e.date = parse_dt(event['date']) e.type = type if 'who' in event: e.contact = self._get_partial_contact(event['who']) else: e.contact = self._get_partial_contact(event) if not e.contact: continue e.message = message % e.contact.name yield e def iter_new_contacts(self): with self.browser: for _id in self.browser.search_profiles():#.difference(self.OPTIM_PROFILE_WALKER.visited_profiles): contact = Contact(_id, '', 0) yield contact # ---- CapMessages methods --------------------- def fill_thread(self, thread, fields): return self.get_thread(thread) def iter_threads(self): with self.browser: threads = self.browser.get_threads_list() for thread in threads: #if thread['member'].get('isBan', thread['member'].get('dead', False)): # with self.browser: # self.browser.delete_thread(thread['member']['id']) # continue if self.antispam and not self.antispam.check_thread(thread): self.logger.info('Skipped a spam-thread from %s' % thread['pseudo']) self.report_spam(thread['who']['id']) continue t = Thread(int(thread['who']['id'])) t.flags = Thread.IS_DISCUSSION t.title = u'Discussion with %s' % to_unicode(thread['who']['pseudo']) yield t def get_thread(self, id, contacts=None, get_profiles=False): """ Get a thread and its messages. The 'contacts' parameters is only used for internal calls. """ thread = None if isinstance(id, Thread): thread = id id = thread.id if not thread: thread = Thread(int(id)) thread.flags = Thread.IS_DISCUSSION full = False else: full = True with self.browser: mails = self.browser.get_thread_mails(id, 100) my_name = self.browser.get_my_name() child = None msg = None slut = self._get_slut(id) if contacts is None: contacts = {} if not thread.title: thread.title = u'Discussion with %s' % mails['who']['pseudo'] self.storage.set('sluts', int(thread.id), 'status', mails['status']) self.storage.save() for mail in mails['results']: flags = 0 if self.antispam and not self.antispam.check_mail(mail): self.logger.info('Skipped a spam-mail from %s' % mails['who']['pseudo']) self.report_spam(thread.id) break if parse_dt(mail['date']) > slut['lastmsg']: flags |= Message.IS_UNREAD if get_profiles: if mail['from'] not in contacts: try: with self.browser: contacts[mail['from']] = self.get_contact(mail['from']) except BrowserHTTPNotFound: pass if self.antispam and mail['from'] in contacts and not self.antispam.check_contact(contacts[mail['from']]): self.logger.info('Skipped a spam-mail-profile from %s' % mails['who']['pseudo']) self.report_spam(thread.id) break if int(mail['from']) == self.browser.my_id: if mails['remote_status'] == 'new' and msg is None: flags |= Message.IS_NOT_RECEIVED else: flags |= Message.IS_RECEIVED signature = u'' #if mail.get('src', None): # signature += u'Sent from my %s\n\n' % mail['src'] if mail['from'] in contacts: signature += contacts[mail['from']].get_text() msg = Message(thread=thread, id=int(time.strftime('%Y%m%d%H%M%S', parse_dt(mail['date']).timetuple())), title=thread.title, sender=to_unicode(my_name if int(mail['from']) == self.browser.my_id else mails['who']['pseudo']), receivers=[to_unicode(my_name if int(mail['from']) != self.browser.my_id else mails['who']['pseudo'])], date=parse_dt(mail['date']), content=to_unicode(unescape(mail['message'] or '').strip()), signature=signature, children=[], flags=flags) if child: msg.children.append(child) child.parent = msg child = msg if full and msg: # If we have get all the messages, replace NotLoaded with None as # parent. msg.parent = None if not full and not msg: # Perhaps there are hidden messages msg = NotLoaded thread.root = msg return thread def iter_unread_messages(self): try: contacts = {} with self.browser: threads = self.browser.get_threads_list() for thread in threads: #if thread['member'].get('isBan', thread['member'].get('dead', False)): # with self.browser: # self.browser.delete_thread(int(thread['member']['id'])) # continue if self.antispam and not self.antispam.check_thread(thread): self.logger.info('Skipped a spam-unread-thread from %s' % thread['who']['pseudo']) self.report_spam(thread['member']['id']) continue slut = self._get_slut(thread['who']['id']) if parse_dt(thread['date']) > slut['lastmsg'] or thread['status'] != slut['status']: try: t = self.get_thread(thread['who']['id'], contacts, get_profiles=True) except BrowserUnavailable: continue for m in t.iter_all_messages(): if m.flags & m.IS_UNREAD: yield m if not self.config['baskets'].get(): return # Send mail when someone added me in her basket. # XXX possibly race condition if a slut adds me in her basket # between the aum.nb_new_baskets() and aum.get_baskets(). with self.browser: slut = self._get_slut(-self.MAGIC_ID_BASKET) new_baskets = self.browser.nb_new_baskets() if new_baskets > 0: baskets = self.browser.get_baskets() my_name = self.browser.get_my_name() for basket in baskets: if parse_dt(basket['date']) <= slut['lastmsg']: continue contact = self.get_contact(basket['who']['id']) if self.antispam and not self.antispam.check_contact(contact): self.logger.info('Skipped a spam-basket from %s' % contact.name) self.report_spam(basket['who']['id']) continue thread = Thread(int(basket['who']['id'])) thread.title = 'Basket of %s' % contact.name thread.root = Message(thread=thread, id=self.MAGIC_ID_BASKET, title=thread.title, sender=contact.name, receivers=[my_name], date=parse_dt(basket['date']), content='You are taken in her basket!', signature=contact.get_text(), children=[], flags=Message.IS_UNREAD) yield thread.root except BrowserUnavailable as e: self.logger.debug('No messages, browser is unavailable: %s' % e) pass # don't care about waiting def set_message_read(self, message): if int(message.id) == self.MAGIC_ID_BASKET: # Save the last baskets checks. slut = self._get_slut(-self.MAGIC_ID_BASKET) if slut['lastmsg'] < message.date: slut['lastmsg'] = message.date self.storage.set('sluts', -self.MAGIC_ID_BASKET, slut) self.storage.save() return slut = self._get_slut(message.thread.id) if slut['lastmsg'] < message.date: slut['lastmsg'] = message.date self.storage.set('sluts', int(message.thread.id), slut) self.storage.save() def _get_slut(self, id): id = int(id) sluts = self.storage.get('sluts') if not sluts or id not in sluts: slut = {'lastmsg': datetime.datetime(1970,1,1), 'status': None} else: slut = self.storage.get('sluts', id) slut['lastmsg'] = slut.get('lastmsg', datetime.datetime(1970,1,1)).replace(tzinfo=tz.tzutc()) slut['status'] = slut.get('status', None) return slut # ---- CapMessagesPost methods --------------------- def post_message(self, message): with self.browser: self.browser.post_mail(message.thread.id, message.content) # ---- CapContact methods --------------------- def fill_contact(self, contact, fields): if 'profile' in fields: contact = self.get_contact(contact) if contact and 'photos' in fields: for name, photo in contact.photos.iteritems(): with self.browser: if photo.url and not photo.data: data = self.browser.openurl(photo.url).read() contact.set_photo(name, data=data) if photo.thumbnail_url and not photo.thumbnail_data: data = self.browser.openurl(photo.thumbnail_url).read() contact.set_photo(name, thumbnail_data=data) def fill_photo(self, photo, fields): with self.browser: if 'data' in fields and photo.url and not photo.data: photo.data = self.browser.readurl(photo.url) if 'thumbnail_data' in fields and photo.thumbnail_url and not photo.thumbnail_data: photo.thumbnail_data = self.browser.readurl(photo.thumbnail_url) return photo def get_contact(self, contact): with self.browser: if isinstance(contact, Contact): _id = contact.id elif isinstance(contact, (int,long,basestring)): _id = contact else: raise TypeError("The parameter 'contact' isn't a contact nor a int/long/str/unicode: %s" % contact) profile = self.browser.get_full_profile(_id) if not profile: return None _id = profile['id'] if isinstance(contact, Contact): contact.id = _id contact.name = profile['pseudo'] else: contact = Contact(_id, profile['pseudo'], Contact.STATUS_ONLINE) contact.url = self.browser.id2url(_id) contact.parse_profile(profile, self.browser.get_consts()) return contact def _get_partial_contact(self, contact): s = 0 if contact.get('online', False): s = Contact.STATUS_ONLINE else: s = Contact.STATUS_OFFLINE c = Contact(contact['id'], to_unicode(contact['pseudo']), s) c.url = self.browser.id2url(contact['id']) if 'age' in contact: c.status_msg = u'%s old, %s' % (contact['age'], contact['city']) if contact['cover'] is not None: url = contact['cover'] + '/%(type)s' else: url = u'http://s.adopteunmec.com/www/img/thumb0.jpg' c.set_photo(u'image%s' % contact['cover'], url=url % {'type': 'full'}, thumbnail_url=url % {'type': 'small'}) return c def iter_contacts(self, status=Contact.STATUS_ALL, ids=None): with self.browser: threads = self.browser.get_threads_list(count=100) for thread in threads: c = self._get_partial_contact(thread['who']) if c and (c.status & status) and (not ids or c.id in ids): yield c def send_query(self, id): if isinstance(id, Contact): id = id.id queries_queue = None try: queries_queue = self.get_optimization('QUERIES_QUEUE') except OptimizationNotFound: pass if queries_queue and queries_queue.is_running(): if queries_queue.enqueue_query(id): return Query(id, 'A charm has been sent') else: return Query(id, 'Unable to send charm: it has been enqueued') else: with self.browser: if not self.browser.send_charm(id): raise QueryError('No enough charms available') return Query(id, 'A charm has been sent') def get_notes(self, id): if isinstance(id, Contact): id = id.id return self.storage.get('notes', id) def save_notes(self, id, notes): if isinstance(id, Contact): id = id.id self.storage.set('notes', id, notes) self.storage.save() # ---- CapChat methods --------------------- def iter_chat_messages(self, _id=None): with self.browser: return self.browser.iter_chat_messages(_id) def send_chat_message(self, _id, message): with self.browser: return self.browser.send_chat_message(_id, message) #def start_chat_polling(self): #self._profile_walker = ProfilesWalker(self.weboob.scheduler, self.storage, self.browser) def get_account_status(self): with self.browser: return ( StatusField(u'myname', u'My name', unicode(self.browser.get_my_name())), StatusField(u'score', u'Score', unicode(self.browser.score())), StatusField(u'avcharms', u'Available charms', unicode(self.browser.nb_available_charms())), StatusField(u'newvisits', u'New visits', unicode(self.browser.nb_new_visites())), ) OBJECTS = {Thread: fill_thread, Contact: fill_contact, ContactPhoto: fill_photo } weboob-1.1/modules/aum/optim/000077500000000000000000000000001265717027300162245ustar00rootroot00000000000000weboob-1.1/modules/aum/optim/__init__.py000066400000000000000000000000001265717027300203230ustar00rootroot00000000000000weboob-1.1/modules/aum/optim/profiles_walker.py000066400000000000000000000072271265717027300217760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from random import randint from weboob.deprecated.browser import BrowserUnavailable from weboob.capabilities.dating import Optimization from weboob.tools.log import getLogger class ProfilesWalker(Optimization): def __init__(self, sched, storage, browser): super(ProfilesWalker, self).__init__() self._sched = sched self._storage = storage self._browser = browser self._logger = getLogger('walker', browser.logger) self._walk_cron = None self._view_cron = None self._visited_profiles = set(storage.get('profiles_walker', 'viewed')) self._logger.info(u'Loaded %d already visited profiles from storage.' % len(self._visited_profiles)) self._profiles_queue = set() def save(self): self._storage.set('profiles_walker', 'viewed', list(self._visited_profiles)) self._storage.save() def start(self): self._walk_cron = self._sched.repeat(60, self.enqueue_profiles) self._view_cron = self._sched.schedule(randint(5, 10), self.view_profile) return True def stop(self): self._sched.cancel(self._walk_cron) self._sched.cancel(self._view_cron) self._walk_cron = None self._view_cron = None return True def is_running(self): return self._walk_cron is not None def enqueue_profiles(self): try: with self._browser: profiles_to_visit = self._browser.search_profiles().difference(self._visited_profiles) self._logger.info(u'Enqueuing profiles to visit: %s' % profiles_to_visit) self._profiles_queue = set(profiles_to_visit) self.save() except BrowserUnavailable: return def view_profile(self): try: try: id = self._profiles_queue.pop() except KeyError: return # empty queue try: with self._browser: profile = self._browser.get_profile(id) self._logger.info(u'Visited profile %s (%s)' % (profile['pseudo'], id)) # Get score from the aum_score module #d = self.nucentral_core.callService(context.Context.fromComponent(self), 'aum_score', 'score', profile) # d.addCallback(self.score_cb, profile.getID()) # deferredlist.append(d) # do not forget that we visited this profile, to avoid re-visiting it. self._visited_profiles.add(id) self.save() except BrowserUnavailable: # We consider this profil hasn't been [correctly] analysed self._profiles_queue.add(id) return except Exception as e: self._logger.exception(e) finally: if self._view_cron is not None: self._view_cron = self._sched.schedule(randint(5, 10), self.view_profile) weboob-1.1/modules/aum/optim/queries_queue.py000066400000000000000000000065601265717027300214660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import BrowserUnavailable from weboob.capabilities.dating import Optimization from weboob.capabilities.contact import QueryError from weboob.tools.log import getLogger class QueriesQueue(Optimization): def __init__(self, sched, storage, browser): super(QueriesQueue, self).__init__() self._sched = sched self._storage = storage self._browser = browser self._logger = getLogger('queriesqueue', browser.logger) self._queue = storage.get('queries_queue', 'queue', default=[]) self._check_cron = None def save(self): self._storage.set('queries_queue', 'queue', self._queue) self._storage.save() def start(self): self._check_cron = self._sched.repeat(3600, self.flush_queue) return True def stop(self): self._sched.cancel(self._check_cron) self._check_cron = None return True def is_running(self): return self._check_cron is not None def enqueue_query(self, id, priority=999): id_queue = [_id[1] for _id in self._queue] if int(id) in id_queue: raise QueryError('This id is already queued') self._queue.append((int(priority), int(id))) self.save() # Try to flush queue to send it now. self.flush_queue() # Check if the enqueued query has been sent for _, i in self._queue: if i == int(id): return False return True def flush_queue(self): self._queue.sort() priority = 0 id = None try: try: while len(self._queue) > 0: priority, id = self._queue.pop() if not id: continue with self._browser: if self._browser.send_charm(id): self._logger.info('Charm sent to %s', id) else: self._queue.append((priority, id)) self._logger.info("Charm can't be send to %s", id) break # As the charm has been correctly sent (no exception raised), # we don't store anymore ID, because if nbAvailableCharms() # fails, we don't want to re-queue this ID. id = None priority = 0 except BrowserUnavailable: # We consider this profil hasn't been [correctly] analysed if id is not None: self._queue.append((priority, id)) finally: self.save() weboob-1.1/modules/aum/optim/visibility.py000066400000000000000000000027141265717027300207710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import BrowserUnavailable from weboob.capabilities.dating import Optimization class Visibility(Optimization): def __init__(self, sched, browser): super(Visibility, self).__init__() self._sched = sched self._browser = browser self._cron = None def start(self): self._cron = self._sched.repeat(60*5, self.reconnect) return True def stop(self): self._sched.cancel(self._cron) self._cron = None return True def is_running(self): return self._cron is not None def reconnect(self): try: with self._browser: self._browser.login() except BrowserUnavailable: pass weboob-1.1/modules/aum/test.py000066400000000000000000000027341265717027300164330ustar00rootroot00000000000000# -*- CODing: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.deprecated.browser import BrowserUnavailable class AuMTest(BackendTest): MODULE = 'aum' def test_new_messages(self): try: for message in self.backend.iter_unread_messages(): pass except BrowserUnavailable: # enough frequent to do not care about. pass def test_contacts(self): try: contacts = list(self.backend.iter_contacts()) if len(contacts) == 0: # so bad, we can't test that... return self.backend.fillobj(contacts[0], ['photos', 'profile']) except BrowserUnavailable: # enough frequent to do not care about. pass weboob-1.1/modules/axabanque/000077500000000000000000000000001265717027300162575ustar00rootroot00000000000000weboob-1.1/modules/axabanque/__init__.py000066400000000000000000000014361265717027300203740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import AXABanqueModule __all__ = ['AXABanqueModule'] weboob-1.1/modules/axabanque/browser.py000066400000000000000000000103061265717027300203140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.deprecated.browser.parsers.jsonparser import JsonParser from .pages import LoginPage, PostLoginPage, AccountsPage, TransactionsPage, CBTransactionsPage, UnavailablePage, PredisconnectedPage __all__ = ['AXABanque'] class AXABanque(Browser): PROTOCOL = 'https' DOMAIN = 'www.axabanque.fr' PAGES = {'https?://www.axa.fr/.sendvirtualkeyboard.json': (LoginPage, JsonParser()), 'https?://www.axa.fr/.loginAxa.json': (PostLoginPage, JsonParser()), 'https?://www.axabanque.fr/login_errors/indisponibilite.*': UnavailablePage, 'https?://www.axabanque.fr/.*page-indisponible.html.*': UnavailablePage, 'https?://www.axabanque.fr/.*erreur/erreurBanque.faces': UnavailablePage, 'https?://www.axa.fr/axa-predisconnect.html': PredisconnectedPage, 'https?://www.axabanque.fr/transactionnel/client/liste-comptes.html': AccountsPage, 'https?://www.axabanque.fr/webapp/axabanque/jsp/panorama.faces': TransactionsPage, 'https?://www.axabanque.fr/webapp/axabanque/jsp/detailCarteBleu.*.faces': CBTransactionsPage, 'https?://www.axabanque.fr/webapp/axabanque/jsp/detail(?!CarteBleu).*.faces': TransactionsPage, } def is_logged(self): return self.page is not None and not self.is_on_page(LoginPage) def home(self): if self.is_logged(): self.location('/transactionnel/client/liste-comptes.html') else: self.login() def login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if self.is_logged(): return if not self.is_on_page(LoginPage): self.location('https://www.axa.fr/.sendvirtualkeyboard.json', data=urllib.urlencode({'login': self.username}), no_login=True) self.page.login(self.username, self.password) if not self.is_on_page(PostLoginPage): raise BrowserIncorrectPassword() if not self.page.redirect(): raise BrowserIncorrectPassword() def get_accounts_list(self): if not self.is_on_page(AccountsPage): self.location('/transactionnel/client/liste-comptes.html') if self.page.is_password_expired(): raise BrowserIncorrectPassword() return self.page.get_list() def get_account(self, id): assert isinstance(id, basestring) l = self.get_accounts_list() for a in l: if a.id == id: return a return None def get_history(self, account): if not self.is_on_page(AccountsPage): account = self.get_account(account.id) if self.page.is_password_expired(): raise BrowserIncorrectPassword() args = account._args args['javax.faces.ViewState'] = self.page.get_view_state() self.location('/webapp/axabanque/jsp/panorama.faces', urllib.urlencode(args)) assert self.is_on_page(TransactionsPage) self.page.more_history() assert self.is_on_page(TransactionsPage) return self.page.get_history() weboob-1.1/modules/axabanque/favicon.png000066400000000000000000000043451265717027300204200ustar00rootroot00000000000000PNG  IHDR@@iqbKGDC pHYs B(xtIME :.drIDATxyTɢ,hT(Ĉ=jc@p?u͉ъӜxĈZڪK$5J"&F1U4* 2 >cUYqdnּ SY5κ|1Ɉ ^,Nͬs*1ewu9?[uV՜erGGMƠgc/JCI:C/۔} Sy?BaL'WU,#=@œ}}ohws6 'wʮ|k#:)%hKٔNO!)ۊ&{#`~z 3bi5w)+*d\O[ .C@H_6ZB-lNGkU"D5S= F#IYe v\u 5oVhK KM"a,OeA~l̚<lDa ܌Xz)hYN\$`qZ4s3bQ'.yG8m|Ӣ {o'sٺuP뼦y\ŷ}FE;󩾷C0?=F륮Vk0&3ζN$uIB9[o}v%@cSK6ZhSF+DU^V˰  ܵLI{N֤|{KdnkI=# ydݠ.6D,<{ Ɨ6`+.!w}$o ǯ6",p%N%6W|qg2 G; ŧS\\Cwwcga{L>е߱o&5;`kY9T\yj z7T*Nj' #\]O'_( Ur8|EoX`oHX V.K>>΢F}M;tB.cĠ>F2<%mZhZoCZ&>}]Je7df?o~)bjA V|~R#J >C֥S|MF2Rߦ֡E J-Wy:>wٺr23_|L 9Hs W?ti Kd畘3=aIJe \MwI$e؋K// ~Z\-ly'glx7 ce> A룈KfG'`bUy\LD-neUETUoclzi{7CEQ9w Mˌ)hױxSr~Y"آϣ˰Шj'0ifm`m c?̙I{!hLQn㗱yIV߸";/1gK^{q>Q(Puhcnv {C==q$d/0~+kS#+}I\BqWu&&{ÑQjMٜ:V$l{;_oKNl~S!/0#.`s-b95Pԏ _qc9cTM`k&`A_M(}2qd⪨ ?gp++9)|jֿBmjeFctHw^U ~6Wq57KJLaΜX Wn=IxzHWbz&$mj<<*s$>}y%C$-y;@!sj`ũE&A}=65RZ|b_O>{s3H"7A#v40y~:WRJ{K3!(*-7 ~Zš_meizC| 3%I,:\xe3AZ͚پ&7T/7)DM8/qQR_S63 uQ ⓌݵxF3n3oMOxIENDB`weboob-1.1/modules/axabanque/module.py000066400000000000000000000037221265717027300201220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import AXABanque __all__ = ['AXABanqueModule'] class AXABanqueModule(Module, CapBank): NAME = 'axabanque' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'AXA Banque' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label=u'N° de client', regexp='\d+', masked=False), ValueBackendPassword('password', label='Code', regexp='\d+')) BROWSER = AXABanque def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): with self.browser: return self.browser.get_accounts_list() def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): with self.browser: return self.browser.get_history(account) weboob-1.1/modules/axabanque/pages.py000066400000000000000000000337561265717027300177460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from decimal import Decimal, InvalidOperation import re import lxml.html from weboob.deprecated.browser import Page as _BasePage, BrowserUnavailable, BrokenPageError, BrowserBanned from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard class BasePage(_BasePage): def get_view_state(self): return self.document.xpath('//input[@name="javax.faces.ViewState"]')[0].attrib['value'] def is_password_expired(self): return len(self.document.xpath('//div[@id="popup_client_modifier_code_confidentiel"]')) def parse_number(self, number): # For some client they randomly displayed 4,115.00 and 4 115,00. # Browser is waiting for for 4 115,00 so we format the number to match this. if '.' in number and len(number.split('.')[-1]) == 2: return number.replace(',', ' ').replace('.', ',') return number class UnavailablePage(BasePage): def on_loaded(self): raise BrowserUnavailable() class PredisconnectedPage(BasePage): def on_loaded(self): raise BrowserBanned() class VirtKeyboard(MappedVirtKeyboard): margin = 2, 2, 2, 2 symbols={'0':'e2df31c137e6c6cb214f92f7d6cd590a', '1':'6057c05937af4574ff453956fbbd2e0e', '2':'5ea5a38efacd3977f17bbc7af83a1943', '3':'560a86b430d2c77e1bd9688efa1b08f9', '4':'e6b6b156ea34a8ae9304526e091b2960', '5':'914483946ee0e55bcc732fce09a0b7c0', '6':'c2382b8f56a0d902e9b399037a9052b5', '7':'c5294f8154a1407560222ac894539d30', '8':'fa1f25a1d5a674dd7bc0d201413d7cfe', '9':'7658424ff8ab127d27e08b7b9b14d331' } color=(0xFF, 0xFF, 0xFF, 0x0) def check_color(self, pixel): step = 10 return abs(pixel[0] - self.color[0]) < step and abs(pixel[1] - self.color[1]) < step and abs(pixel[2] - self.color[2]) < step def __init__(self, page): key = page.document.getroot().xpath('//input')[0].value page.browser.login_key = key img = page.document.getroot().xpath('//img')[0] img_url = 'https://www.axa.fr/.sendvirtualkeyboard.png?key=' + key img_file = page.browser.openurl(img_url) MappedVirtKeyboard.__init__(self, img_file, page.document, img, self.color) self.check_symbols(self.symbols, page.browser.responses_dirname) def get_symbol_code(self,md5sum): code = MappedVirtKeyboard.get_symbol_code(self,md5sum) return code[-3:-2] def get_string_code(self,string): code = '' for c in string: code += self.get_symbol_code(self.symbols[c]) return code class LoginPage(BasePage): def login(self, login, password): document = lxml.html.fromstring(self.document['html']) self.document = document.getroottree() vk = VirtKeyboard(self) args = {'login': login, 'password': vk.get_string_code(password), 'remeberMe': 'false', 'key': self.browser.login_key, } self.browser.location('https://www.axa.fr/.loginAxa.json', urllib.urlencode(args), no_login=True) class PostLoginPage(BasePage): def redirect(self): if 'tokenBanque' not in self.document: return False url = 'https://www.axabanque.fr/webapp/axabanque/client/sso/connexion?token=%s' % self.document['tokenBanque'] self.browser.location(url) self.browser.location('http://www.axabanque.fr/webapp/axabanque/jsp/panorama.faces') return True class AccountsPage(BasePage): ACCOUNT_TYPES = {'courant-titre': Account.TYPE_CHECKING, } def js2args(self, s): args = {} # For example: # noDoubleClic(this);;return oamSubmitForm('idPanorama','idPanorama:tableaux-comptes-courant-titre:0:tableaux-comptes-courant-titre-cartes:0:_idJsp321',null,[['paramCodeProduit','9'],['paramNumContrat','12234'],['paramNumCompte','12345678901'],['paramNumComptePassage','1234567890123456']]); for sub in re.findall("\['([^']+)','([^']+)'\]", s): args[sub[0]] = sub[1] args['idPanorama:_idcl'] = re.search("'(idPanorama:[^']+)'", s).group(1) args['idPanorama_SUBMIT'] = 1 return args def get_list(self): for table in self.document.getroot().cssselect('div#table-panorama table.table-produit'): tds = table.xpath('./tbody/tr')[0].findall('td') if len(tds) < 3: continue boxes = table.xpath('./tbody//tr') foot = table.xpath('./tfoot//tr') for box in boxes: account = Account() if len(box.xpath('.//a')) != 0 and 'onclick' in box.xpath('.//a')[0].attrib: args = self.js2args(box.xpath('.//a')[0].attrib['onclick']) account.label = u'{0} {1}'.format(unicode(table.xpath('./caption')[0].text.strip()), unicode(box.xpath('.//a')[0].text.strip())) elif len(foot[0].xpath('.//a')) != 0 and 'onclick' in foot[0].xpath('.//a')[0].attrib: args = self.js2args(foot[0].xpath('.//a')[0].attrib['onclick']) account.label = unicode(table.xpath('./caption')[0].text.strip()) else: continue self.logger.debug('Args: %r' % args) if 'paramNumCompte' not in args: try: label = unicode(table.xpath('./caption')[0].text.strip()) except Exception: label = 'Unable to determine' self.logger.warning('Unable to get account ID for %r' % label) continue try: account.id = args['paramNumCompte'] + args['paramNumContrat'] if 'Visa' in account.label: card_id = re.search('(\d+)', box.xpath('./td[2]')[0].text.strip()) if card_id: account.id += card_id.group(1) if 'Valorisation' in account.label or u'Liquidités' in account.label: account.id += args['idPanorama:_idcl'].split('Jsp')[-1] except KeyError: account.id = args['paramNumCompte'] account_type_str = table.attrib['class'].split(' ')[-1][len('tableaux-comptes-'):] account.type = self.ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN) currency_title = table.xpath('./thead//th[@class="montant"]')[0].text.strip() m = re.match('Montant \((\w+)\)', currency_title) if not m: self.logger.warning('Unable to parse currency %r' % currency_title) else: account.currency = account.get_currency(m.group(1)) try: account.balance = Decimal(FrenchTransaction.clean_amount(self.parse_number(u''.join([txt.strip() for txt in box.cssselect("td.montant")[0].itertext()])))) except InvalidOperation: #The account doesn't have a amount pass account._args = args yield account class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^RET(RAIT) DAB (?P

\d{2})/(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(CARTE|CB ETRANGER) (?P
\d{2})/(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile('^(?PVIR(EMEN)?T? (SEPA)?(RECU|FAVEUR)?)( /FRM)?(?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^PRLV (?P.*)( \d+)?$'), FrenchTransaction.TYPE_ORDER), (re.compile('^(CHQ|CHEQUE) .*$'), FrenchTransaction.TYPE_CHECK), (re.compile('^(AGIOS /|FRAIS) (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(CONVENTION \d+ |F )?COTIS(ATION)? (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^REMISE (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^(?P.*)( \d+)? QUITTANCE .*'), FrenchTransaction.TYPE_ORDER), (re.compile('^.* LE (?P
\d{2})/(?P\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_UNKNOWN), ] class TransactionsPage(BasePage): COL_DATE = 0 COL_TEXT = 1 COL_DEBIT = 2 COL_CREDIT = 3 def more_history(self): link = None for a in self.document.xpath('.//a'): if a.text is not None and a.text.strip() == 'Sur les 6 derniers mois': link = a break if link is None: # this is a check account args = {'categorieMouvementSelectionnePagination': 'afficherTout', 'nbLigneParPageSelectionneHautPagination': -1, 'nbLigneParPageSelectionneBasPagination': -1, 'periodeMouvementSelectionneComponent': '', 'categorieMouvementSelectionneComponent': '', 'nbLigneParPageSelectionneComponent': -1, 'idDetail:btnRechercherParNbLigneParPage': '', 'idDetail_SUBMIT': 1, 'paramNumComptePassage': '', 'codeEtablissement': '', 'paramNumCodeSousProduit': '', 'idDetail:_idcl': '', 'idDetail:scroll_banqueHaut': '', 'paramNumContrat': '', 'paramCodeProduit': '', 'paramNumCompte': '', 'codeAgence': '', 'idDetail:_link_hidden_': '', 'paramCodeFamille': '', 'javax.faces.ViewState': self.get_view_state(), } else: # something like a PEA or so value = link.attrib['id'] id = value.split(':')[0] args = {'%s:_idcl' % id: value, '%s:_link_hidden_' % id: '', '%s_SUBMIT' % id: 1, 'javax.faces.ViewState': self.get_view_state(), 'paramNumCompte': '', } form = self.document.xpath('//form')[-1] self.browser.location(form.attrib['action'], urllib.urlencode(args)) def get_history(self): #DAT account can't have transaction if self.document.xpath('//table[@id="table-dat"]'): return #These accounts have investments, no transactions if self.document.xpath('//table[@id="InfosPortefeuille"]'): return tables = self.document.xpath('//table[@id="table-detail-operation"]') if len(tables) == 0: tables = self.document.xpath('//table[@id="table-detail"]') if len(tables) == 0: tables = self.document.getroot().cssselect('table.table-detail') if len(tables) == 0: try: self.parser.select(self.document.getroot(), 'td.no-result', 1) except BrokenPageError: raise BrokenPageError('Unable to find table?') else: return for tr in tables[0].xpath('.//tr'): tds = tr.findall('td') if len(tds) < 4: continue t = Transaction() date = u''.join([txt.strip() for txt in tds[self.COL_DATE].itertext()]) raw = u''.join([txt.strip() for txt in tds[self.COL_TEXT].itertext()]) debit = self.parse_number(u''.join([txt.strip() for txt in tds[self.COL_DEBIT].itertext()])) credit = self.parse_number(u''.join([txt.strip() for txt in tds[self.COL_CREDIT].itertext()])) t.parse(date, re.sub(r'[ ]+', ' ', raw)) t.set_amount(credit, debit) yield t class CBTransactionsPage(TransactionsPage): COL_CB_CREDIT = 2 def get_history(self): tables = self.document.xpath('//table[@id="idDetail:dataCumulAchat"]') transactions =list() if len(tables) == 0: return transactions for tr in tables[0].xpath('.//tr'): tds = tr.findall('td') if len(tds) < 3: continue t = Transaction() date = u''.join([txt.strip() for txt in tds[self.COL_DATE].itertext()]) raw = self.parse_number(u''.join([txt.strip() for txt in tds[self.COL_TEXT].itertext()])) credit = self.parse_number(u''.join([txt.strip() for txt in tds[self.COL_CB_CREDIT].itertext()])) debit = "" t.parse(date, re.sub(r'[ ]+', ' ', raw)) t.set_amount(credit, debit) transactions.append(t) for histo in super(CBTransactionsPage, self).get_history(): transactions.append(histo) transactions.sort(key=lambda transaction: transaction.date, reverse=True) return iter(transactions) weboob-1.1/modules/axabanque/test.py000066400000000000000000000017531265717027300176160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class AXABanqueTest(BackendTest): MODULE = 'axabanque' def test_axabanque(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/banqueaccord/000077500000000000000000000000001265717027300167415ustar00rootroot00000000000000weboob-1.1/modules/banqueaccord/__init__.py000066400000000000000000000014521265717027300210540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BanqueAccordModule __all__ = ['BanqueAccordModule'] weboob-1.1/modules/banqueaccord/browser.py000066400000000000000000000051451265717027300210030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, need_login, URL from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, IndexPage, AccountsPage, OperationsPage __all__ = ['BanqueAccordBrowser'] class BanqueAccordBrowser(LoginBrowser): BASEURL = 'https://www.banque-accord.fr/site/s/' TIMEOUT = 30.0 login = URL('login/login.html', LoginPage) index = URL('detailcompte/detailcompte.html', IndexPage) accounts = URL('detailcompte/ongletdetailcompte.html', AccountsPage) operations = URL('detailcompte/ongletdernieresoperations.html', OperationsPage) def do_login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.login.go() self.page.login(self.username, self.password) if not self.index.is_here(): raise BrowserIncorrectPassword() @need_login def get_accounts_list(self): self.index.stay_or_go() for a in self.page.get_list(): post = {'numeroCompte': a.id,} self.index.go(data=post) a.balance = self.page.get_loan_balance() if a.balance is not None: a.type = a.TYPE_LOAN else: self.accounts.go() a.balance = self.page.get_balance() a.type = a.TYPE_CARD if a.balance is None: continue yield a @need_login def iter_history(self, account): post = {'numeroCompte': account.id} self.index.go(data=post) if account.type == account.TYPE_LOAN: return self.page.iter_loan_transactions() self.operations.go() return sorted(self.page.iter_transactions(), key=lambda tr: tr.rdate, reverse=True) weboob-1.1/modules/banqueaccord/favicon.png000066400000000000000000000076521265717027300211060ustar00rootroot00000000000000PNG  IHDR@@iqbKGDks pHYs  tIME 903tEXtCommentCreated with GIMPWIDATxy՝?U^^C/,M52h)HhhTq$5s\A3ꈢQ#'@ŰtM76?zM749uߍ硜+pO! E)Q/Xw"?ԕEtz#*eV3 M݅-,jb#`}"y ƣ*}QlMJ˲-Є%6`$cٟsK@!~KQ(AH>D.µ!Ų'iJ˥'UG\Qє(J(_ph v5o~ L°V[:8qT%*Wc)G.@[ig{ = Y!LİHb٫g;$!p>ry_Á@%Jۓ%X" \H.XU͊ѯ BHUߞ|#U92vlXd,ۑig%}kwe@rUq.EjG% eDSO_ :ȣQH[gh#y'iJ!]BrPX;G'%I4e [`xsp˧#(Y-#vDљCzQbt@ͬ=7\Ц@6)nqMK7% ]q6[By)= c H!C½ |֭KRP"sȖ%tr{QǹҾK O= ''J.okwGճ{-4yۀ@H;ip?OBH e99)*BSRx;Ad; s?n\)m!O,C3žeD &<_΂w;K۴i"nF=wYB"O i1?̮FFi1ԥg ݍ˷9G;k7JߟLXzom}0 dJF LAye|oİLSč@>yQucPaw>5bH_%J_7!a Z~R4V(O̤@^jXOe~)o)ڥձ}op>`nbz3# sEs1ſnZ[ [:O(C&7P w@w ƾ<}L9W6fol"V7!iHeas{(v)`ILJY})k^vr ؟2G]ïNMQ9-ҝF]KG]'?/k0`w1%sdٵ7A-Om|\ a59kgw~4HE0L*[(]{/vtckA]&CsS.-0%_O_n,"tA0|oWQms Uu`5 6~qi̖UrFl"nG 1CfV~s4`ZHG-yӟ3t^޴O*3.s{!fJ63koɯ9/]$n[겪mޜ u5_,-JEN6X)= v$yC8 y=!O~1HPP)M(^ku+޼G\BCʱXfEc z=slw E”acw HM4&@4`kr?3t)y?#9өN~b ٞp[.|`iBAnr,o++`kߜ>9fuO$,ey/|% 4'aETTkYټp M4ΰr&/{XӴ33\*1al7v8x|怑`֦&LFv mR[,(sטbUö 5fbu4F\t6 d7^1SrQIIp H]Xyi٪th >'޻OM4uF2S᠓\biAs9u*R~-IOe Jr1ZSiceMӑp;l^\sl'y|4-ɝ4DGZ/)[NEMӁr[mВe_UkGR/!>;dPym%ߜ1:d7S颙Д NY9;<7IMCkj guUY%VoGQ-2:qҜx S<;D^]9W"9MS2^Snsl^r -?v̭ 0=fɿA:ILmvw ihN4,=V?#ƦZ&WE()/I[ku5)#+u'Ʒ?6=\ h@`  TA + wg} #'q]Ko)1}KXմGKF(*0*׆2 ڴw_:!-^<񲾎{)HPDJ;H+RA{&/9[[Al%^IK9ܼxCPRO~GKjץ)e=fYfYC<"'W鷵8>yuT jNۙdh۲i|9u$eK/%~rF\ؿMd:;v'T}>ߣ_䦛&)s bZ/M5n 7@S \I@M@ AlG#un567_'$]'MȣOhvO`(4ڹ6 t+iנ0>#]-'k~3UE!P< ;a 8%geWIENDB`weboob-1.1/modules/banqueaccord/module.py000066400000000000000000000036361265717027300206100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.base import find_object from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import BanqueAccordBrowser __all__ = ['BanqueAccordModule'] class BanqueAccordModule(Module, CapBank): NAME = 'banqueaccord' DESCRIPTION = u'Banque Accord' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', regexp='\d+', masked=False), ValueBackendPassword('password', label=u"Code d'accès", regexp='\d+')) BROWSER = BanqueAccordBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): return self.browser.iter_history(account) weboob-1.1/modules/banqueaccord/pages.py000066400000000000000000000173541265717027300204240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from dateutil.relativedelta import relativedelta from decimal import Decimal, InvalidOperation import re from cStringIO import StringIO from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, Regexp, CleanDecimal, Env from weboob.browser.filters.html import Attr from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard, VirtKeyboardError from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.exceptions import ParseError class Transaction(FrenchTransaction): PATTERNS = [(re.compile(ur'^(?P.*?) - traité le \d+/\d+$'), FrenchTransaction.TYPE_CARD)] class VirtKeyboard(MappedVirtKeyboard): symbols={'0':('8664b9cdfa66b4c3a1ec99c35a2bf64b','9eb80c6e99410eaac32905b2c77e65e5','37717277dc2471c8a7bf37e2068a8f01'), '1':('1f36986f9d27dde54ce5b08e8e285476','9d0aa7a0a2bbab4f2c01ef1e820cb3f1'), '2':('b560b0cce2ca74d3d499d73775152ab7',), '3':('d16e426e71fc29b1b55d0fbded99a473',), '4':('19c68066e414e08d17c86fc5c4acc949','c43354a7f7739508f76c538d5b3bce26'), '5':('4b9abf98e30a1475997ec770cbe5e702','2059b4aa95c7b3156b171255fa10bbdd'), '6':('804be4171d61f9cc10e9978c43b1d2a0','a41b091d4a11a318406a5a8bd3ed3837'), '7':('8adf951f4eea5f446f714214e101d555',), '8':('568135f3844213c30f2c7880be867d3d',), '9':('a3750995c511ea1492ac244421109e77','eeb3a8ba804f19380dfe94a91a37595b'), } color=(0,0,0) def __init__(self, page): img = page.doc.find("//img[@usemap='#cv']") res = page.browser.open(img.attrib['src']) MappedVirtKeyboard.__init__(self, StringIO(res.content), page.doc, img, self.color, 'href', convert='RGB') self.check_symbols(self.symbols, page.browser.responses_dirname) def check_color(self, pixel): for p in pixel: if p >= 0xd5: return False return True def get_symbol_coords(self, coords): # strip borders x1, y1, x2, y2 = coords return MappedVirtKeyboard.get_symbol_coords(self, (x1+10, y1+10, x2-10, y2-10)) def get_symbol_code(self, md5sum_list): for md5sum in md5sum_list: try: code = MappedVirtKeyboard.get_symbol_code(self,md5sum) except VirtKeyboardError: continue else: return ''.join(re.findall(r"'(\d+)'", code)[-2:]) raise VirtKeyboardError('Symbol not found') def get_string_code(self, string): code = '' for c in string: code += self.get_symbol_code(self.symbols[c]) return code class LoginPage(HTMLPage): def login(self, login, password): vk = VirtKeyboard(self) form = self.get_form('//form[@id="formulaire-login"]') code = vk.get_string_code(password) assert len(code)==10, ParseError("Wrong number of character.") form['accordirect.identifiant'] = login form['accordirect.code'] = code form.submit() class IndexPage(LoggedPage, HTMLPage): @method class get_list(ListElement): item_xpath = '//li[@id="menu-n2-mesproduits"]//li//a' class item(ItemElement): klass = Account obj_id = Regexp(Attr('.', 'onclick'), r"^[^']+'([^']+)'.*", r"\1") obj_label = CleanText('.') def condition(self): return self.el.get('onclick') is not None loan_init_date = Transaction.Date(CleanText('//table//td[contains(text(), "Date de sous")]/../td[2]')) loan_next_date = Transaction.Date(CleanText('//table//td[contains(text(), "Prochaine")]/../td[2]')) loan_nb = CleanText('//table//td[contains(text(), "Nombre de mensu") and contains(text(), "rembours")]/../td[2]') loan_total_amount = CleanDecimal('//table//td/strong[contains(text(), "Montant emprunt")]/../../td[2]', replace_dots=False) loan_amount = CleanDecimal('//table//td/strong[contains(text(), "Montant de la")]/../../td[2]', replace_dots=False) def get_loan_balance(self): try: total_amount = - self.loan_total_amount(self.doc) except InvalidOperation: return None nb = int(self.loan_nb(self.doc)) amount = self.loan_amount(self.doc) return total_amount + (nb*amount) def iter_loan_transactions(self): init_date = self.loan_init_date(self.doc) next_date = self.loan_next_date(self.doc) nb = int(self.loan_nb(self.doc)) total_amount = - self.loan_total_amount(self.doc) amount = self.loan_amount(self.doc) if init_date is NotAvailable and total_amount == Decimal('0.0'): return for _ in xrange(nb): next_date = next_date - relativedelta(months=1) tr = Transaction() tr.raw = tr.label = u'Mensualité' tr.date = tr.rdate = tr.vdate = next_date tr.amount = amount yield tr tr = Transaction() tr.raw = tr.label = u'Emprunt initial' tr.date = tr.rdate = init_date tr.amount = total_amount yield tr def get_card_name(self): return CleanText('//h1[1]')(self.doc) class AccountsPage(LoggedPage, HTMLPage): def get_balance(self): balance = Decimal('0.0') lines = self.doc.xpath('//div[@class="detail"]/table//tr') if len(lines) == 0: return None for line in lines: try: left = line.xpath('./td[@class="gauche"]')[0] right = line.xpath('./td[@class="droite"]')[0] except IndexError: #useless line continue if len(left.xpath('./span[@class="precision"]')) == 0 or \ (left.text is None or 'total' not in left.text.lower()): continue balance -= CleanDecimal('.', replace_dots=False)(right) return balance class OperationsPage(LoggedPage, HTMLPage): @method class iter_transactions(ListElement): item_xpath = '//div[contains(@class, "mod-listeoperations")]//table/tbody/tr' class credit(ItemElement): klass = Transaction obj_type = Transaction.TYPE_CARD obj_date = Transaction.Date('./td[1]') obj_raw = Transaction.Raw('./td[2]') obj_amount = Env('amount') def condition(self): self.env['amount'] = Transaction.Amount('./td[4]')(self.el) return self.env['amount'] > 0 class debit(ItemElement): klass = Transaction obj_type = Transaction.TYPE_CARD obj_date = Transaction.Date('./td[1]') obj_raw = Transaction.Raw('./td[2]') obj_amount = Env('amount') def condition(self): self.env['amount'] = - Transaction.Amount('./td[3]')(self.el) return self.env['amount'] != 0 weboob-1.1/modules/banqueaccord/test.py000066400000000000000000000016231265717027300202740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class BanqueAccordTest(BackendTest): MODULE = 'banqueaccord' def test_banqueaccord(self): raise NotImplementedError() weboob-1.1/modules/banquepopulaire/000077500000000000000000000000001265717027300175065ustar00rootroot00000000000000weboob-1.1/modules/banquepopulaire/__init__.py000066400000000000000000000014521265717027300216210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BanquePopulaireModule __all__ = ['BanquePopulaireModule'] weboob-1.1/modules/banquepopulaire/browser.py000066400000000000000000000272031265717027300215470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from weboob.deprecated.browser import Browser, BrowserIncorrectPassword, BrokenPageError from weboob.deprecated.browser.parsers.iparser import RawParser from .pages import LoginPage, IndexPage, AccountsPage, AccountsFullPage, CardsPage, TransactionsPage, \ UnavailablePage, RedirectPage, HomePage, Login2Page, ErrorPage, \ LineboursePage, NatixisPage, InvestmentNatixisPage, InvestmentLineboursePage, MessagePage, \ DocumentsPage, PostDocument, ExtractPdf __all__ = ['BanquePopulaire'] class BanquePopulaire(Browser): PROTOCOL = 'https' ENCODING = 'iso-8859-15' PAGES = {'https://[^/]+/auth/UI/Login.*': LoginPage, 'https://[^/]+/cyber/internet/Login.do': IndexPage, 'https://[^/]+/cyber/internet/StartTask.do\?taskInfoOID=mesComptes.*': AccountsPage, 'https://[^/]+/cyber/internet/StartTask.do\?taskInfoOID=maSyntheseGratuite.*': AccountsPage, 'https://[^/]+/cyber/internet/StartTask.do\?taskInfoOID=accueilSynthese.*': AccountsPage, 'https://[^/]+/cyber/internet/StartTask.do\?taskInfoOID=equipementComplet.*': AccountsPage, 'https://[^/]+/cyber/internet/StartTask.do\?taskInfoOID=documentsDemat.*': DocumentsPage, 'https://[^/]+/cyber/internet/ContinueTask.do\?.*dialogActionPerformed=EQUIPEMENT_COMPLET.*': AccountsFullPage, 'https://[^/]+/cyber/internet/ContinueTask.do\?.*dialogActionPerformed=VUE_COMPLETE.*': AccountsPage, 'https://[^/]+/cyber/internet/ContinueTask.do\?.*dialogActionPerformed=ENCOURS_COMPTE.*': CardsPage, 'https://[^/]+/cyber/internet/ContinueTask.do\?.*dialogActionPerformed=SELECTION_ENCOURS_CARTE.*': TransactionsPage, 'https://[^/]+/cyber/internet/ContinueTask.do\?.*dialogActionPerformed=SOLDE.*': TransactionsPage, 'https://[^/]+/cyber/internet/ContinueTask.do\?.*dialogActionPerformed=CONTRAT.*': TransactionsPage, 'https://[^/]+/cyber/internet/ContinueTask.do\?.*dialogActionPerformed=TELECHARGER.*': PostDocument, 'https://[^/]+/cyber/internet/Page.do\?.*': TransactionsPage, 'https://[^/]+/cyber/internet/Sort.do\?.*': TransactionsPage, 'https://[^/]+/cyber/internet/ContinueTask.do': ErrorPage, 'https://[^/]+/cyber/internet/DownloadDocument.do\?documentId=.*': (ExtractPdf, RawParser()), 'https://[^/]+/s3f-web/.*': UnavailablePage, 'https://[^/]+/static/errors/nondispo.html': UnavailablePage, 'https://[^/]+/portailinternet/_layouts/Ibp.Cyi.Layouts/RedirectSegment.aspx.*': RedirectPage, 'https://[^/]+/portailinternet/Catalogue/Segments/.*.aspx(\?vary=(?P.*))?': HomePage, 'https://[^/]+/portailinternet/Pages/.*.aspx\?vary=(?P.*)': HomePage, 'https://[^/]+/portailinternet/Pages/default.aspx': HomePage, 'https://[^/]+/portailinternet/Transactionnel/Pages/CyberIntegrationPage.aspx': HomePage, 'https://[^/]+/WebSSO_BP/_(?P\d+)/index.html\?transactionID=(?P.*)': Login2Page, 'https://www.linebourse.fr/ReroutageSJR': LineboursePage, 'https://www.linebourse.fr/DetailMessage.*': MessagePage, 'https://www.linebourse.fr/Portefeuille': InvestmentLineboursePage, 'https://www.assurances.natixis.fr/espaceinternet-bp/views/common.*': NatixisPage, 'https://www.assurances.natixis.fr/espaceinternet-bp/views/contrat.*': InvestmentNatixisPage, } def __init__(self, website, *args, **kwargs): self.DOMAIN = website self.token = None Browser.__init__(self, *args, **kwargs) # XXX FUCKING HACK BECAUSE BANQUE POPULAIRE ARE FAGGOTS AND INCLUDE NULL # BYTES IN DOCUMENTS. def get_document(self, result, parser=None, encoding=None): from io import BytesIO buf = BytesIO(result.read().replace('\0', '')) return Browser.get_document(self, buf, parser, encoding) def is_logged(self): return not self.is_on_page(LoginPage) def home(self): self.login() def login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(LoginPage): self.location('%s://%s' % (self.PROTOCOL, self.DOMAIN), no_login=True) self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() ACCOUNT_URLS = ['mesComptes', 'mesComptesPRO', 'maSyntheseGratuite', 'accueilSynthese', 'equipementComplet'] def go_on_accounts_list(self): for taskInfoOID in self.ACCOUNT_URLS: self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID=taskInfoOID, token=self.token)) if not self.page.is_error(): if self.page.pop_up(): self.logger.debug('Popup displayed, retry') self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID=taskInfoOID, token=self.token)) self.ACCOUNT_URLS = [taskInfoOID] break else: raise BrokenPageError('Unable to go on the accounts list page') if self.page.is_short_list(): self.select_form(nr=0) self.set_all_readonly(False) self['dialogActionPerformed'] = 'EQUIPEMENT_COMPLET' self['token'] = self.page.build_token(self['token']) self.submit() def get_accounts_list(self, get_iban=True): # We have to parse account list in 2 different way depending if we want the iban number or not # thanks to stateful website self.go_on_accounts_list() next_pages = [] accounts = [] for a in self.page.iter_accounts(next_pages): if get_iban: accounts.append(a) else: yield a while len(next_pages) > 0: next_page = next_pages.pop() if not self.is_on_page(AccountsFullPage): self.go_on_accounts_list() # If there is an action needed to go to the "next page", do it. if 'prevAction' in next_page: params = self.page.get_params() params['dialogActionPerformed'] = next_page.pop('prevAction') params['token'] = self.page.build_token(self.token) self.location('/cyber/internet/ContinueTask.do', urllib.urlencode(params)) next_page['token'] = self.page.build_token(self.token) self.location('/cyber/internet/ContinueTask.do', urllib.urlencode(next_page)) for a in self.page.iter_accounts(next_pages): if get_iban: accounts.append(a) else: yield a if get_iban: for a in accounts: iban = self.get_iban_number(a) if iban: a.iban = iban yield a def get_iban_number(self, account): self.location('/cyber/internet/StartTask.do?taskInfoOID=documentsDemat&token=%s' % self.page.build_token(self.token)) token = self.page.build_token(self.token) #We need to get an extract document because we can find iban number on it if self.is_on_page(DocumentsPage): doc_id = self.page.get_account_extract(account.id) if doc_id: id = self.page.get_doc_id() if id: self.location('/cyber/internet/DownloadDocument.do?documentId=%s' % id) if self.is_on_page(ExtractPdf): iban = self.page.get_iban() self.location('/cyber/internet/StartTask.do?taskInfoOID=documentsDemat&token=%s' % token) return iban return None def get_account(self, id): assert isinstance(id, basestring) for a in self.get_accounts_list(False): if a.id == id: return a return None def get_history(self, account, coming=False): account = self.get_account(account.id) if coming: params = account._coming_params else: params = account._params if params is None: return params['token'] = self.page.build_token(params['token']) self.location('/cyber/internet/ContinueTask.do', urllib.urlencode(params)) if not self.page or self.page.no_operations(): return # Sort by values dates (see comment in TransactionsPage.get_history) if len(self.page.document.xpath('//a[@id="tcl4_srt"]')) > 0: self.select_form(predicate=lambda form: form.attrs.get('id', '') == 'myForm') self.form.action = self.absurl('/cyber/internet/Sort.do?property=tbl1&sortBlocId=blc2&columnName=dateValeur') params['token'] = self.page.build_token(params['token']) self.submit() while True: assert self.is_on_page(TransactionsPage) for tr in self.page.get_history(account, coming): yield tr next_params = self.page.get_next_params() if next_params is None: return self.location(self.buildurl('/cyber/internet/Page.do', **next_params)) def get_investment(self, account): if not account._invest_params: raise NotImplementedError() account = self.get_account(account.id) params = account._invest_params params['token'] = self.page.build_token(params['token']) self.location('/cyber/internet/ContinueTask.do', urllib.urlencode(params)) if self.is_on_page(ErrorPage): raise NotImplementedError() url, params = self.page.get_investment_page_params() if params: self.location(url, urllib.urlencode(params)) if self.is_on_page(LineboursePage): self.location('https://www.linebourse.fr/Portefeuille') while self.is_on_page(MessagePage): self.page.skip() self.location('https://www.linebourse.fr/Portefeuille') elif self.is_on_page(NatixisPage): self.page.submit_form() return self.page.get_investments() return iter([]) weboob-1.1/modules/banquepopulaire/favicon.png000066400000000000000000000024201265717027300216370ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME .X1IDATx[}Hg~ƚCdkn-+hYJYt+6 v[Z(:6Ơ0velS em~Ykj/wleֻ&w{̓w!q =PLyė)OWB׶i)x|kmjW]|WvlPA5lP9ۈ"՝|m;Xy٠`݃c8oa$زA ~ m44~iBEs>Fṇ-m3snII*}, :hu]@pDžkЫBmo|2V.n&sdl0*+3AQC!46M4ՒMfٕ,4|%xQhK> ZO>DbcpL-&rlݜNú=BPxM-+W]vo&d=?hRB,qX- ʺsӢ\t3^7k%Y$`o:eO0\^NRTT"nUV}SoTV&Q/*AQΒpxcHK zu6rU/>v2*W %PLFYd*_ gF0~.*y9[k형&jJVâk߻]8s~Qkp-]D`2PD h X6ǔ^%(6  5%HMѣ0߈"3^s?1w]-@zP F}M!'3ǹ<T{dn=%|c W\o+y՝(;|@L7Л=r*Tgw>Gb `o /PO+ o}oNc_/:-@NG8lO!}R?% $ syFl0"/m]+x4N_K DeY|xȇ#RIq$[%p-p`Xܾ1Kn\r9#rXq *> Hs;IENDB`weboob-1.1/modules/banquepopulaire/module.py000066400000000000000000000100631265717027300213450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import ValueBackendPassword, Value from .browser import BanquePopulaire __all__ = ['BanquePopulaireModule'] class BanquePopulaireModule(Module, CapBank): NAME = 'banquepopulaire' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Banque Populaire' LICENSE = 'AGPLv3+' website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ 'www.ibps.alpes.banquepopulaire.fr': u'Alpes', 'www.ibps.alsace.banquepopulaire.fr': u'Alsace', 'www.ibps.bpaca.banquepopulaire.fr': u'Aquitaine Centre atlantique', 'www.ibps.atlantique.banquepopulaire.fr': u'Atlantique', 'www.ibps.bpbfc.banquepopulaire.fr': u'Bourgogne-Franche Comté', 'www.ibps.bretagnenormandie.cmm.groupe.banquepopulaire.fr': u'Crédit Maritime Bretagne Normandie', 'www.ibps.atlantique.creditmaritime.groupe.banquepopulaire.fr': u'Crédit Maritime Atlantique', 'www.ibps.sudouest.creditmaritime.groupe.banquepopulaire.fr': u'Crédit Maritime du Littoral du Sud-Ouest', 'www.ibps.cotedazur.banquepopulaire.fr': u'Côte d\'azur', 'www.ibps.loirelyonnais.banquepopulaire.fr': u'Loire et Lyonnais', 'www.ibps.lorrainechampagne.banquepopulaire.fr': u'Lorraine Champagne', 'www.ibps.massifcentral.banquepopulaire.fr': u'Massif central', 'www.ibps.nord.banquepopulaire.fr': u'Nord', 'www.ibps.occitane.banquepopulaire.fr': u'Occitane', 'www.ibps.ouest.banquepopulaire.fr': u'Ouest', 'www.ibps.provencecorse.banquepopulaire.fr': u'Provence et Corse', 'www.ibps.rivesparis.banquepopulaire.fr': u'Rives de Paris', 'www.ibps.sud.banquepopulaire.fr': u'Sud', 'www.ibps.valdefrance.banquepopulaire.fr': u'Val de France', }.iteritems(), key=lambda k_v: (k_v[1], k_v[0]))]) CONFIG = BackendConfig(Value('website', label=u'Région', choices=website_choices), ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passee')) BROWSER = BanquePopulaire def create_default_browser(self): repls = ('alsace', 'bpalc'), ('lorrainechampagne', 'bpalc') website = reduce(lambda a, kv: a.replace(*kv), repls, self.config['website'].get()) return self.create_browser(website, self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): with self.browser: return self.browser.get_accounts_list() def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): with self.browser: return self.browser.get_history(account) def iter_coming(self, account): with self.browser: return self.browser.get_history(account, coming=True) def iter_investment(self, account): with self.browser: return self.browser.get_investment(account) weboob-1.1/modules/banquepopulaire/pages.py000066400000000000000000001012701265717027300211600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from urlparse import urlsplit, parse_qsl from decimal import Decimal import re import urllib from mechanize import Cookie, FormNotFoundError from weboob.browser.filters.standard import CleanText from weboob.exceptions import BrowserUnavailable, BrowserIncorrectPassword from weboob.deprecated.browser import Page as _BasePage, BrokenPageError from weboob.capabilities.bank import Account, Investment from weboob.capabilities import NotAvailable, UserError from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.json import json from weboob.tools.pdf import decompress_pdf class WikipediaARC4(object): def __init__(self, key=None): self.state = range(256) self.x = self.y = 0 if key is not None: self.init(key) def init(self, key): for i in range(256): self.x = (ord(key[i % len(key)]) + self.state[i] + self.x) & 0xFF self.state[i], self.state[self.x] = self.state[self.x], self.state[i] self.x = 0 def crypt(self, input): output = [None]*len(input) for i in xrange(len(input)): self.x = (self.x + 1) & 0xFF self.y = (self.state[self.x] + self.y) & 0xFF self.state[self.x], self.state[self.y] = self.state[self.y], self.state[self.x] output[i] = chr((ord(input[i]) ^ self.state[(self.state[self.x] + self.state[self.y]) & 0xFF])) return ''.join(output) class BasePage(_BasePage): def get_token(self): try: token = self.parser.select(self.document.getroot(), '//form//input[@name="token"]', 1, 'xpath').attrib['value'] except BrokenPageError: token = self.parser.select(self.document.getroot(), '//body', 1, 'xpath').attrib['onload'] token = re.search(r"saveToken\('(.*?)'", token).group(1) return token def on_loaded(self): if not self.is_error(): self.browser.token = self.get_token() self.logger.debug('Update token to %s', self.browser.token) def is_error(self): return False def build_token(self, token): """ These fucking faggots have introduced a new protection on the token. Each time there is a call to SAB (selectActionButton), the token available in the form is modified with a key available in JS: ipsff(function(){TW().ipthk([12, 25, 17, 5, 23, 26, 15, 30, 6]);}); Each value of the array is an index for the current token to append the char at this position at the end of the token. """ table = None for script in self.document.xpath('//script'): if script.text is None: continue m = re.search(r'ipthk\(([^\)]+)\)', script.text, flags=re.MULTILINE) if m: table = json.loads(m.group(1)) if table is None: return token for i in table: token += token[i] return token def get_params(self): params = {} for field in self.document.xpath('//input'): params[field.attrib['name']] = field.attrib.get('value', '') return params def get_button_actions(self): actions = {} for script in self.document.xpath('//script'): if script.text is None: continue for id, action, strategy in re.findall(r'''attEvt\(window,"(?P[^"]+)","click","sab\('(?P[^']+)','(?P[^']+)'\);"''', script.text, re.MULTILINE): actions[id] = {'dialogActionPerformed': action, 'validationStrategy': strategy, } return actions class RedirectPage(BasePage): """ var i = 'lyhrnu551jo42yfzx0jm0sqk'; setCookie('i', i); var welcomeMessage = decodeURI('M MACHIN'); var lastConnectionDate = decodeURI('17 Mai 2013'); var lastConnectionTime = decodeURI('14h27'); var userId = '12345678'; var userCat = '1'; setCookie('uwm', $.rc4EncryptStr(welcomeMessage, i)); setCookie('ulcd', $.rc4EncryptStr(lastConnectionDate, i)); setCookie('ulct', $.rc4EncryptStr(lastConnectionTime, i)); setCookie('uid', $.rc4EncryptStr(userId, i)); setCookie('uc', $.rc4EncryptStr(userCat, i)); var agentCivility = 'Mlle'; var agentFirstName = decodeURI('Jeanne'); var agentLastName = decodeURI('Machin'); var agentMail = decodeURI('gary@example.org'); setCookie('ac', $.rc4EncryptStr(agentCivility, i)); setCookie('afn', $.rc4EncryptStr(agentFirstName, i)); setCookie('aln', $.rc4EncryptStr(agentLastName, i)); setCookie('am', $.rc4EncryptStr(agentMail, i)); var agencyLabel = decodeURI('DTC'); var agencyPhoneNumber = decodeURI('0123456789'); setCookie('al', $.rc4EncryptStr(agencyLabel, i)); setCookie('apn', $.rc4EncryptStr(agencyPhoneNumber, i)); Note: that cookies are useless to login on website """ def add_cookie(self, name, value): c = Cookie(0, name, value, None, False, '.' + self.browser.DOMAIN, True, True, '/', False, False, None, False, None, None, {}) cookiejar = self.browser._ua_handlers["_cookies"].cookiejar cookiejar.set_cookie(c) def on_loaded(self): redirect_url = None args = {} RC4 = None for script in self.document.xpath('//script'): if script.text is None: continue m = re.search('window.location=\'([^\']+)\'', script.text, flags=re.MULTILINE) if m: redirect_url = m.group(1) for line in script.text.split('\r\n'): m = re.match("^var (\w+) = [^']*'([^']*)'.*", line) if m: args[m.group(1)] = m.group(2) m = re.match("^setCookie\('([^']+)', (\w+)\);", line) if m: self.add_cookie(m.group(1), args[m.group(2)]) m = re.match("^setCookie\('([^']+)', .*rc4EncryptStr\((\w+), \w+\)", line) if m: self.add_cookie(m.group(1), RC4.crypt(args[m.group(2)]).encode('hex')) if RC4 is None and 'i' in args: RC4 = WikipediaARC4(args['i']) if redirect_url is not None: self.browser.location(self.browser.request_class(self.browser.absurl(redirect_url), None, {'Referer': self.url})) try: self.browser.select_form(name="CyberIngtegrationPostForm") except FormNotFoundError: pass else: self.browser.submit(nologin=True) class ErrorPage(BasePage): def get_token(self): try: buf = self.document.xpath('//body/@onload')[0] except IndexError: return else: m = re.search("saveToken\('([^']+)'\)", buf) if m: return m.group(1) class UnavailablePage(BasePage): def on_loaded(self): try: a = self.document.xpath('//a[@class="btn"]')[0] except IndexError: raise BrowserUnavailable() else: self.browser.location(a.attrib['href'], nologin=True) class LoginPage(BasePage): def on_loaded(self): try: h1 = self.parser.select(self.document.getroot(), 'h1', 1) except BrokenPageError: pass if h1.text is not None and h1.text.startswith('Le service est moment'): try: raise BrowserUnavailable(self.document.xpath('//h4')[0].text) except KeyError: raise BrowserUnavailable(h1.text) def login(self, login, passwd): self.browser.select_form(name='Login') self.browser['IDToken1'] = login.encode(self.browser.ENCODING) self.browser['IDToken2'] = passwd.encode(self.browser.ENCODING) self.browser.submit(nologin=True) class Login2Page(LoginPage): @property def request_url(self): transactionID = self.group_dict['transactionID'] return 'https://www.icgauth.banquepopulaire.fr/dacswebssoissuer/api/v1u0/transaction/%s' % transactionID def on_loaded(self): r = self.browser.openurl(self.request_url) doc = json.load(r) self.form_id = doc['step']['validationUnits'][0]['PASSWORD_LOOKUP'][0]['id'] def login(self, login, password): payload = {'validate': {'PASSWORD_LOOKUP': [{'id': self.form_id, 'login': login.encode(self.browser.ENCODING).upper(), 'password': password.encode(self.browser.ENCODING), 'type': 'PASSWORD_LOOKUP' }] } } req = self.browser.request_class(self.request_url + '/step') req.add_header('Content-Type', 'application/json') r = self.browser.openurl(req, json.dumps(payload)) doc = json.load(r) self.logger.debug(doc) if 'phase' in doc and doc['phase']['state'] == 'TERMS_OF_USE': # Got: # {u'phase': {u'state': u'TERMS_OF_USE'}, u'validationUnits': [{u'LIST_OF_TERMS': [{u'type': u'TERMS', u'id': u'b7f28f91-7aa0-48aa-8028-deec13ae341b', u'reference': u'CGU_CYBERPLUS'}]}]} if 'reference' in doc['validationUnits'][0]: del doc['validationUnits'][0]['reference'] payload = {'validate': doc['validationUnits'][0]} req = self.browser.request_class(self.request_url + '/step') req.add_header('Content-Type', 'application/json') r = self.browser.openurl(req, json.dumps(payload)) doc = json.load(r) self.logger.debug(doc) if ('phase' in doc and doc['phase']['previousResult'] == 'FAILED_AUTHENTICATION') or \ doc['response']['status'] != 'AUTHENTICATION_SUCCESS': raise BrowserIncorrectPassword() self.browser.location(doc['response']['saml2_post']['action'], urllib.urlencode({'SAMLResponse': doc['response']['saml2_post']['samlResponse']})) class IndexPage(BasePage): def get_token(self): url = self.document.getroot().xpath('//frame[@name="portalHeader"]')[0].attrib['src'] v = urlsplit(url) args = dict(parse_qsl(v.query)) return args['token'] class HomePage(BasePage): def get_token(self): vary = None if self.group_dict.get('vary', None) is not None: vary = self.group_dict['vary'] else: for script in self.document.xpath('//script'): if script.text is None: continue m = re.search("'vary', '([\d-]+)'\)", script.text) if m: vary = m.group(1) break r = self.browser.openurl(self.browser.request_class(self.browser.buildurl(self.browser.absurl('/portailinternet/Transactionnel/Pages/CyberIntegrationPage.aspx'), vary=vary), 'taskId=aUniversMesComptes', {'Referer': self.url})) if not int(r.info().get('Content-Length', '')): r = self.browser.openurl(self.browser.request_class(self.browser.buildurl(self.browser.absurl('/portailinternet/Transactionnel/Pages/CyberIntegrationPage.aspx')), 'taskId=aUniversMesComptes', {'Referer': self.url})) doc = self.browser.get_document(r) date = None for script in doc.xpath('//script'): if script.text is None: continue m = re.search('lastConnectionDate":"([^"]*)"', script.text) if m: date = m.group(1) r = self.browser.openurl(self.browser.request_class(self.browser.absurl('/cyber/ibp/ate/portal/integratedInternet.jsp'), 'session%%3Aate.lastConnectionDate=%s&taskId=aUniversMesComptes' % date, {'Referer': r.geturl()})) v = urlsplit(r.geturl()) args = dict(parse_qsl(v.query)) return args['token'] class AccountsPage(BasePage): ACCOUNT_TYPES = {u'Mes comptes d\'épargne': Account.TYPE_SAVINGS, u'Mon épargne': Account.TYPE_SAVINGS, u'Placements': Account.TYPE_SAVINGS, u'Liste complète de mon épargne': Account.TYPE_SAVINGS, u'Mes comptes': Account.TYPE_CHECKING, u'Comptes en euros': Account.TYPE_CHECKING, u'Liste complète de mes comptes': Account.TYPE_CHECKING, u'Mes emprunts': Account.TYPE_LOAN, u'Liste complète de mes emprunts':Account.TYPE_LOAN, u'Financements': Account.TYPE_LOAN, u'Mes services': None, # ignore this kind of accounts (no bank ones) u'Équipements': None, # ignore this kind of accounts (no bank ones) u'Synthèse': None, # ignore this title } def is_error(self): for script in self.document.xpath('//script'): if script.text is not None and \ (u"Le service est momentanément indisponible" in script.text or u"Votre abonnement ne vous permet pas d'accéder à ces services" in script.text): return True return False def pop_up(self): if self.document.xpath('//span[contains(text(), "du navigateur Internet.")]'): return True return False def is_short_list(self): return len(self.document.xpath('//script[contains(text(), "EQUIPEMENT_COMPLET")]')) > 0 COL_NUMBER = 0 COL_TYPE = 1 COL_LABEL = 2 COL_BALANCE = 3 COL_COMING = 4 def iter_accounts(self, next_pages): account_type = Account.TYPE_UNKNOWN params = self.get_params() actions = self.get_button_actions() for div in self.document.getroot().cssselect('div.btit'): if div.text in (None, u'Synthèse'): continue account_type = self.ACCOUNT_TYPES.get(div.text.strip(), Account.TYPE_UNKNOWN) if account_type is None: # ignore services accounts self.logger.debug('Ignore account type %s', div.text.strip()) continue # Go to the full list of this kind of account, if any. btn = div.getparent().xpath('.//button/span[text()="Suite"]') if len(btn) > 0: btn = btn[0].getparent() _params = params.copy() _params.update(actions[btn.attrib['id']]) next_pages.append(_params) continue currency = None for th in div.getnext().xpath('.//thead//th'): m = re.match('.*\((\w+)\)$', th.text) if m and currency is None: currency = Account.get_currency(m.group(1)) for tr in div.getnext().xpath('.//tbody/tr'): if 'id' not in tr.attrib: continue args = dict(parse_qsl(tr.attrib['id'])) tds = tr.findall('td') if len(tds) < 4 or 'identifiant' not in args: self.logger.warning('Unable to parse an account') continue account = Account() account.id = args['identifiant'].replace(' ', '') account.label = u' '.join([u''.join([txt.strip() for txt in tds[1].itertext()]), u''.join([txt.strip() for txt in tds[2].itertext()])]).strip() account.type = account_type balance = FrenchTransaction.clean_amount(u''.join([txt.strip() for txt in tds[3].itertext()])) account.balance = Decimal(balance or '0.0') account.currency = currency if account.type == account.TYPE_LOAN: account.balance = - abs(account.balance) account._prev_debit = None account._next_debit = None account._params = None account._coming_params = None account._invest_params = None if balance != u'' and len(tds[3].xpath('.//a')) > 0: account._params = params.copy() account._params['dialogActionPerformed'] = 'SOLDE' account._params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1] if len(tds) >= 5 and len(tds[self.COL_COMING].xpath('.//a')) > 0: _params = account._params.copy() _params['dialogActionPerformed'] = 'ENCOURS_COMPTE' # If there is an action needed before going to the cards page, save it. m = re.search('dialogActionPerformed=([\w_]+)', self.url) if m and m.group(1) != 'EQUIPEMENT_COMPLET': _params['prevAction'] = m.group(1) next_pages.append(_params) if not account._params: account._invest_params = params.copy() account._invest_params['dialogActionPerformed'] = 'CONTRAT' account._invest_params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1] yield account # Needed to preserve navigation. btn = self.document.xpath('.//button/span[text()="Retour"]') if len(btn) > 0: btn = btn[0].getparent() _params = params.copy() _params.update(actions[btn.attrib['id']]) self.browser.openurl('/cyber/internet/ContinueTask.do', urllib.urlencode(_params)) class AccountsFullPage(AccountsPage): pass class CardsPage(BasePage): COL_ID = 0 COL_TYPE = 1 COL_LABEL = 2 COL_DATE = 3 COL_AMOUNT = 4 def iter_accounts(self, next_pages): params = self.get_params() account = None for tr in self.document.xpath('//table[@id="TabCtes"]/tbody/tr'): cols = tr.xpath('./td') id = self.parser.tocleanstring(cols[self.COL_ID]) if len(id) > 0: if account is not None: yield account account = Account() account.id = id.replace(' ', '') account.type = Account.TYPE_CARD account.balance = account.coming = Decimal('0') account._next_debit = datetime.date.today() account._prev_debit = datetime.date(2000,1,1) account.label = u' '.join([self.parser.tocleanstring(cols[self.COL_TYPE]), self.parser.tocleanstring(cols[self.COL_LABEL])]) account._params = None account._invest_params = None account._coming_params = params.copy() account._coming_params['dialogActionPerformed'] = 'SELECTION_ENCOURS_CARTE' account._coming_params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1] elif account is None: raise BrokenPageError('Unable to find accounts on cards page') else: account._params = params.copy() account._params['dialogActionPerformed'] = 'SELECTION_ENCOURS_CARTE' account._params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1] date_col = self.parser.tocleanstring(cols[self.COL_DATE]) m = re.search('(\d+)/(\d+)/(\d+)', date_col) if not m: self.logger.warning('Unable to parse date %r' % date_col) continue date = datetime.date(*reversed(map(int, m.groups()))) if date.year < 100: date = date.replace(year=date.year+2000) amount = Decimal(FrenchTransaction.clean_amount(self.parser.tocleanstring(cols[self.COL_AMOUNT]))) if not date_col.endswith('(1)'): # debited account.coming += - abs(amount) account._next_debit = date elif date > account._prev_debit: account._prev_balance = - abs(amount) account._prev_debit = date if account is not None: yield account # Needed to preserve navigation. btn = self.document.xpath('.//button/span[text()="Retour"]') if len(btn) > 0: btn = btn[0].getparent() actions = self.get_button_actions() _params = params.copy() _params.update(actions[btn.attrib['id']]) self.browser.openurl('/cyber/internet/ContinueTask.do', urllib.urlencode(_params)) class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^RET DAB (?P.*?) RETRAIT (DU|LE) (?P
\d{2})(?P\d{2})(?P\d+).*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^RET DAB (?P.*?) CARTE ?:.*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?P.*) RETRAIT DU (?P
\d{2})(?P\d{2})(?P\d{2}) .*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(RETRAIT CARTE )?RET(RAIT)? DAB (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('((\w+) )?(?P
\d{2})(?P\d{2})(?P\d{2}) CB[:\*][^ ]+ (?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile('^VIR(EMENT)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(PRLV|PRELEVEMENT) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?PCHEQUE .*)'), FrenchTransaction.TYPE_CHECK), (re.compile('^(AGIOS /|FRAIS) (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_BANK), (re.compile('^(CONVENTION \d+ )?COTIS(ATION)? (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_BANK), (re.compile('^REMISE (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^(?PECHEANCE PRET .*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile('^(?P.*)( \d+)? QUITTANCE .*'), FrenchTransaction.TYPE_ORDER), (re.compile('^.* LE (?P
\d{2})/(?P\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_UNKNOWN), ] class TransactionsPage(BasePage): def get_next_params(self): nxt = self.document.xpath('//li[contains(@id, "_nxt")]') if len(nxt) == 0 or nxt[0].attrib.get('class', '') == 'nxt-dis': return None params = {} for field in self.document.xpath('//input'): params[field.attrib['name']] = field.attrib.get('value', '') params['validationStrategy'] = 'NV' params['pagingDirection'] = 'NEXT' params['pagerName'] = nxt[0].attrib['id'].split('_', 1)[0] return params def get_history(self, account, coming): if len(self.document.xpath('//table[@id="tbl1"]')) > 0: return self.get_account_history() if len(self.document.xpath('//table[@id="TabFact"]')) > 0: return self.get_card_history(account, coming) raise NotImplementedError('Unable to find what kind of history it is.') COL_COMPTA_DATE = 0 COL_LABEL = 1 COL_REF = 2 # optional COL_OP_DATE = -4 COL_VALUE_DATE = -3 COL_DEBIT = -2 COL_CREDIT = -1 def get_account_history(self): for tr in self.document.xpath('//table[@id="tbl1"]/tbody/tr'): tds = tr.findall('td') if len(tds) < 5: continue t = Transaction() # XXX We currently take the *value* date, but it will probably # necessary to use the *operation* one. # Default sort on website is by compta date, so in browser.py we # change the sort on value date. date = self.parser.tocleanstring(tds[self.COL_OP_DATE]) vdate = self.parser.tocleanstring(tds[self.COL_VALUE_DATE]) raw = self.parser.tocleanstring(tds[self.COL_LABEL]) debit = self.parser.tocleanstring(tds[self.COL_DEBIT]) credit = self.parser.tocleanstring(tds[self.COL_CREDIT]) t.parse(date, re.sub(r'[ ]+', ' ', raw), vdate) t.set_amount(credit, debit) # Strip the balance displayed in transaction labels t.label = re.sub('solde en valeur : .*', '', t.label) # XXX Fucking hack to include the check number not displayed in the full label. if re.match("^CHEQUE ", t.label): t.label = 'CHEQUE No: %s' % self.parser.tocleanstring(tds[self.COL_REF]) yield t COL_CARD_DATE = 0 COL_CARD_LABEL = 1 COL_CARD_AMOUNT = 2 def get_card_history(self, account, coming): if coming: debit_date = account._next_debit elif not hasattr(account, '_prev_balance'): return else: debit_date = account._prev_debit if 'ContinueTask.do' in self.url: t = Transaction() t.parse(debit_date, 'RELEVE CARTE') t.amount = -account._prev_balance yield t for i, tr in enumerate(self.document.xpath('//table[@id="TabFact"]/tbody/tr')): tds = tr.findall('td') if len(tds) < 3: continue t = Transaction() date = self.parser.tocleanstring(tds[self.COL_CARD_DATE]) label = self.parser.tocleanstring(tds[self.COL_CARD_LABEL]) amount = '-' + self.parser.tocleanstring(tds[self.COL_CARD_AMOUNT]) t.parse(debit_date, re.sub(r'[ ]+', ' ', label)) t.set_amount(amount) t.rdate = t.parse_date(date) yield t def no_operations(self): if len(self.document.xpath('//table[@id="tbl1" or @id="TabFact"]//td[@colspan]')) > 0: return True if len(self.document.xpath(u'//div[contains(text(), "Accès à LineBourse")]')) > 0: return True return False def get_investment_page_params(self): script = self.document.xpath('//body')[0].attrib['onload'] url = None m = re.search(r"','(.+?)',\[", script, re.MULTILINE) if m: url = m.group(1) params = {} for key, value in re.findall(r"key:'(?PSJRToken)'\,value:'(?P.*?)'}", script, re.MULTILINE): params[key] = value return url, params if url and params else None class LineboursePage(_BasePage): pass class InvestmentLineboursePage(_BasePage): COL_LABEL = 0 COL_QUANTITY = 1 COL_UNITVALUE = 2 COL_VALUATION = 3 COL_UNITPRICE = 4 COL_PERF_PERCENT = 5 COL_PERF = 6 def get_investments(self): for line in self.document.xpath('//table[contains(@summary, "Contenu")]/tbody/tr[@class="color4"]'): cols1 = line.findall('td') cols2 = line.xpath('./following-sibling::tr')[0].findall('td') inv = Investment() inv.label = self.parser.tocleanstring(cols1[self.COL_LABEL].xpath('.//span')[0]) inv.code = self.parser.tocleanstring(cols1[self.COL_LABEL].xpath('./a')[0]).split(' ')[-1] inv.quantity = self.parse_decimal(cols2[self.COL_QUANTITY]) inv.unitprice = self.parse_decimal(cols2[self.COL_UNITPRICE]) inv.unitvalue = self.parse_decimal(cols2[self.COL_UNITVALUE]) inv.valuation = self.parse_decimal(cols2[self.COL_VALUATION]) inv.diff = self.parse_decimal(cols2[self.COL_PERF]) yield inv def parse_decimal(self, string): value = self.parser.tocleanstring(string) if value == '': return NotAvailable return Decimal(Transaction.clean_amount(value)) class NatixisPage(_BasePage): def submit_form(self): self.browser.select_form(name="formRoutage") self.browser.submit(nologin=True) class InvestmentNatixisPage(_BasePage): COL_LABEL = 0 COL_QUANTITY = 2 COL_UNITVALUE = 3 COL_VALUATION = 4 def get_investments(self): for line in self.document.xpath('//div[@class="row-fluid table-contrat-supports"]/table/tbody[(@class)]/tr'): cols = line.findall('td') inv = Investment() inv.label = self.parser.tocleanstring(cols[self.COL_LABEL]).replace('Cas sans risque ', '') inv.quantity = self.parse_decimal(cols[self.COL_QUANTITY]) inv.unitvalue = self.parse_decimal(cols[self.COL_UNITVALUE]) inv.valuation = self.parse_decimal(cols[self.COL_VALUATION]) yield inv def parse_decimal(self, string): value = self.parser.tocleanstring(string).replace('Si famille fonds generaux, on affiche un tiret', '').replace('Cas sans risque', '').replace(' ', '') if value == '-': return NotAvailable return Decimal(Transaction.clean_amount(value)) class MessagePage(_BasePage): def skip(self): try: self.browser.select_form(name="leForm") except FormNotFoundError: pass else: self.browser.submit(nologin=True) class DocumentsPage(BasePage): def get_account_extract(self, acc_id): for td in self.document.xpath('//tbody[@class="ts tms"]/tr'): if CleanText().filter(td.xpath('./td[1]')[0]) in acc_id and CleanText().filter(td.xpath('./td[4]')[0]) == "Extrait de compte": self.browser.select_form(predicate=lambda form: form.attrs.get('id', '') == 'myForm') self.browser.set_all_readonly(False) doc_id = self.browser['taskOID'] self.browser['token'] = self.build_token(self.browser['token']) self.browser['attribute($SEL_ACTIVE$tbl2)'] = td.xpath('./@id')[0].split('_', 1)[1] self.browser['dialogActionPerformed'] = "TELECHARGER" self.browser['attribute($SEL_$lst1_hidden)'] = 'lst1$listeTypeDoc$listeTypeDocSelectionne$' self.browser['attribute($SEL_$lst2_hidden)'] = 'lst2$listeCompteRecherche$listeCompteSelect$' self.browser['dateDebut'] = '23/09/2014' self.browser['dateFin'] = '23/09/2015' self.browser['attribute($SEL_$tbl2_hidden)'] = 'tbl2$listeDocumentSelectionne$' self.browser['attribute($SEL_ACTIVE$tbl2_hidden)'] = 'tbl2$documentSelectionne$' self.browser.submit() return doc_id return False class PostDocument(BasePage): def get_doc_id(self): for script in self.document.xpath('//script'): if script.text is None: continue m = re.search("DocumentUtils\.download\('(.*)'\)", script.text) if m: return m.group(1) return None class ExtractPdf(_BasePage): iban_regexp= r'\(IBAN \) Tj(?:.*[\n\r]){5}\((\w{4})\)(?:.*[\n\r]){10}\((\d{4})\)(?:.*[\n\r]){10}\((\d{4})\)(?:.*[\n\r]){10}\((\d{4})\)(?:.*[\n\r]){10}\((\d{4})\)(?:.*[\n\r]){10}\((\d{4})\)(?:.*[\n\r]){10}\((\d{3})\)' def __init__(self, *args, **kwargs): _BasePage.__init__(self, *args, **kwargs) try: self._pdf = decompress_pdf(self.document) except OSError as e: raise UserError(u'Make sure mupdf-tools is installed (%s)' % e) def get_iban(self): res = re.findall(self.iban_regexp, self._pdf) if res and len(res) == 1: return u''.join(res[0]) return None weboob-1.1/modules/banquepopulaire/test.py000066400000000000000000000017671265717027300210520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class BanquePopulaireTest(BackendTest): MODULE = 'banquepopulaire' def test_banquepop(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/barclays/000077500000000000000000000000001265717027300161125ustar00rootroot00000000000000weboob-1.1/modules/barclays/__init__.py000066400000000000000000000014341265717027300202250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BarclaysModule __all__ = ['BarclaysModule'] weboob-1.1/modules/barclays/browser.py000066400000000000000000000121511265717027300201470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, Login2Page, IndexPage, AccountsPage, TransactionsPage, \ CardPage, ValuationPage, LoanPage, MarketPage, AssurancePage, LogoutPage __all__ = ['Barclays'] class Barclays(Browser): PROTOCOL = 'https' DOMAIN = 'www.barclays.fr' PAGES = {'https?://.*.barclays.fr/\d-index.html': IndexPage, 'https://.*.barclays.fr/barclaysnetV2/logininstit.do.*': LoginPage, 'https://.*.barclays.fr/barclaysnetV2/loginSecurite.do.*': Login2Page, 'https://.*.barclays.fr/bayexterne/barclaysnet/deconnexion/index.html': LogoutPage, 'https://.*.barclays.fr/barclaysnetV2/tbord.do.*': AccountsPage, 'https://.*.barclays.fr/barclaysnetV2/releve.do.*': TransactionsPage, 'https://.*.barclays.fr/barclaysnetV2/cartes.do.*': CardPage, 'https://.*.barclays.fr/barclaysnetV2/valuationViewBank.do.*': ValuationPage, 'https://.*.barclays.fr/barclaysnetV2/pret.do.*': LoanPage, 'https://.*.barclays.fr/barclaysnetV2/titre.do.*': MarketPage, 'https://.*.barclays.fr/barclaysnetV2/assurance.do.*': AssurancePage, } SESSION_PARAM = None def __init__(self, secret, *args, **kwargs): self.secret = secret Browser.__init__(self, *args, **kwargs) def is_logged(self): return self.page is not None and not self.is_on_page((LoginPage, IndexPage, Login2Page)) def home(self): if self.is_logged(): link = self.page.document.xpath('.//a[contains(@id, "tbordalllink")]')[0].attrib['href'] m = re.match('(.*?fr)', self.page.url) if m: absurl = m.group(1) self.location('%s%s' % (absurl, link)) else: self.login() def set_session_param(self): if self.is_logged(): link = self.page.document.xpath('.//a[contains(@id, "tbordalllink")]')[0].attrib['href'] m = re.search('&(.*)', link) if m: self.SESSION_PARAM = m.group(1) def login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if self.is_logged(): return if not self.is_on_page(LoginPage): self.location('https://b-net.barclays.fr/barclaysnetV2/logininstit.do?lang=fr&nodoctype=0', no_login=True) self.page.login(self.username, self.password) if not self.page.has_redirect(): raise BrowserIncorrectPassword() self.location('loginSecurite.do', no_login=True) if self.is_on_page(LogoutPage): raise BrowserIncorrectPassword() self.page.login(self.secret) if not self.is_logged(): raise BrowserIncorrectPassword() self.set_session_param() def get_accounts_list(self): if not self.is_on_page(AccountsPage): self.home() return self.page.get_list() def get_account(self, id): assert isinstance(id, basestring) l = self.get_accounts_list() for a in l: if a.id == id: return a return None def get_history(self, account): if not self.is_on_page(AccountsPage): self.home() self.location(account._link) assert self.is_on_page((TransactionsPage, ValuationPage, LoanPage, MarketPage, AssurancePage)) transactions = list() for tr in self.page.get_history(): transactions.append(tr) for tr in self.get_card_operations(account): transactions.append(tr) for tr in sorted(transactions, key=lambda t: t.rdate, reverse=True) : yield tr def get_card_operations(self, account): for card in account._card_links: if not self.is_on_page(AccountsPage): self.home() self.location(card) assert self.is_on_page(CardPage) for tr in self.page.get_history(): yield tr weboob-1.1/modules/barclays/favicon.png000066400000000000000000000076631265717027300202610ustar00rootroot00000000000000PNG  IHDR@@iq pHYs76vtIME !7lRIDATx[{p]ys_eYecl@08p: mi-Mix40L &%30C4N MM=llYeJǷ{%oI~pTlRn_h=`%(iJ*}.=+0Ʀ5ɞǮrD&'-tւ u 8M ?Xɪx!v2!w;kY\/ߞVl_z msr!x\^} \|'L\ӫΩG7Y(W{mCEDF5M43,,p/mu=Y# g~?+| ,u\.t!D ^~:k19[O\K;Y_gJ3RsbK{ s}qΪk=cRe~.88 0Q5 9XXW5q_ǟOki&c\ʶggɠcOR&…c` Ѱ:# g Vπ?&ثe?22:UjVŰ*2:\2obW_5qMw˭ۧ,.}0!@&ˤ&2Igo: ' 8|i$ Gp.5kA& UKi={/ۤGkSJ,L;x&oe*yj pUkodոpO_0"`Cau2jG a6AGU1v١VʷV^Yƽ^aʝ~i3Ixrs[1!!< XY$M~xՋ OdIg;Iw=sDTet8yK.0}AӴdTsԿU:A2I0.Hx~#3΋)Iĵ.e/{kY/|3Oq4|FIcP)hU|I}d2(s`lq @80v;+Ƹ< O?ϸTG.hQpV΁ ĥ#u-X قspn#Y噋/{:l+Μ<QZ~.5s?Wh re4Apս>2 gS`\-[r='~̺V[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ŝ& #xgskWw8rDg-sg=8*GrT&]TIENDB`weboob-1.1/modules/barclays/module.py000066400000000000000000000045231265717027300177550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Barclays __all__ = ['BarclaysModule'] class BarclaysModule(Module, CapBank): NAME = 'barclays' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Barclays' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label=u"N° d'abonné", masked=False), ValueBackendPassword('password', label='Code confidentiel'), ValueBackendPassword('secret', label='Mot secret')) BROWSER = Barclays def create_default_browser(self): return self.create_browser(self.config['secret'].get(), self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): with self.browser: return self.browser.get_accounts_list() def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): with self.browser: for tr in self.browser.get_history(account): if not tr._coming: yield tr def iter_coming(self, account): with self.browser: for tr in self.browser.get_card_operations(account): if tr._coming: yield tr weboob-1.1/modules/barclays/pages.py000066400000000000000000000265671265717027300176030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from decimal import Decimal import re from weboob.deprecated.browser import Page from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction class LoginPage(Page): def login(self, login, passwd): self.browser.select_form(name='frmLogin') self.browser['username'] = login.encode(self.browser.ENCODING) self.browser['password'] = passwd.encode(self.browser.ENCODING) self.browser.submit(nologin=True) def has_redirect(self): if len(self.document.getroot().xpath('//form')) > 0: return False else: return True class Login2Page(Page): def login(self, secret): label = self.document.xpath('//span[@class="PF_LABEL"]')[0].text.strip() letters = '' for n in re.findall('(\d+)', label): letters += secret[int(n) - 1] self.browser.select_form(name='frmControl') self.browser['word'] = letters.encode(self.browser.ENCODING) self.browser.submit(name='valider', nologin=True) class IndexPage(Page): pass class AccountsPage(Page): ACCOUNT_TYPES = {u'Epargne': Account.TYPE_SAVINGS, u'Liquidités': Account.TYPE_CHECKING, u'Titres': Account.TYPE_MARKET, u'Prêts': Account.TYPE_LOAN, } def get_list(self): accounts = [] for block in self.document.xpath('//div[@class="pave"]/div'): head_type = block.xpath('./div/span[@class="accGroupLabel"]')[0].text.strip() account_type = self.ACCOUNT_TYPES.get(head_type, Account.TYPE_UNKNOWN) for tr in block.cssselect('ul li.tbord_account'): id = tr.attrib.get('id', '') if id.find('contratId') != 0: self.logger.warning('Unable to parse contract ID: %r' % id) continue id = id[id.find('contratId')+len('contratId'):] link = tr.cssselect('span.accountLabel a')[0] balance = Decimal(FrenchTransaction.clean_amount(tr.cssselect('span.accountTotal')[0].text)) if id.endswith('CRT'): account = accounts[-1] account._card_links.append(link.attrib['href']) if not account.coming: account.coming = Decimal('0.0') account.coming += balance continue account = Account() account.id = id account.label = unicode(link.text.strip()) account.type = account_type account.balance = balance account.currency = account.get_currency(tr.cssselect('span.accountDev')[0].text) account._link = link.attrib['href'] account._card_links = [] accounts.append(account) if len(accounts) == 0: # Sometimes, accounts are only in javascript... for script in self.document.xpath('//script'): text = script.text if text is None: continue if 'remotePerso' not in text: continue account = None card_account = None attribs = {} account_type = Account.TYPE_UNKNOWN for line in text.split('\n'): line = line.strip() m = re.match("data.libelle = '(.*)';", line) if m: account_type = self.ACCOUNT_TYPES.get(m.group(1), Account.TYPE_UNKNOWN) elif line == 'var remotePerso = new Object;': account = Account() elif account is not None: m = re.match("remotePerso.(\w+) = '?(.*?)'?;", line) if m: attribs[m.group(1)] = m.group(2) elif line.startswith('listProduitsGroup'): account.id = attribs['refContrat'] account.label = attribs['libelle'] account.type = account_type account.balance = Decimal(FrenchTransaction.clean_amount(attribs['soldeDateOpeValeurFormatted'])) account.currency = account.get_currency(attribs['codeDevise']) account._link = 'tbord.do?id=%s&%s' % (attribs['id'], self.browser.SESSION_PARAM) account._card_links = [] if account.id.endswith('CRT'): if not len(accounts): card_account = account else: a = accounts[-1] a._card_links.append(account._link) if not a.coming: a.coming = Decimal('0.0') a.coming += account.balance else: if 'COURANT' in account.label: account.type = account.TYPE_CHECKING elif account.id.endswith('TTR'): account.type = account.TYPE_MARKET elif re.match('^\d+C$', account.id): account.type = account.TYPE_LIFE_INSURANCE elif re.match('^\d+PRT$', account.id): account.type = account.TYPE_LOAN elif not account.type: account.type = account.TYPE_SAVINGS if card_account: account._card_links.append(card_account._link) if not account.coming: account.coming = Decimal('0.0') account.coming += card_account.balance card_account = None accounts.append(account) account = None return accounts class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^RET DAB (?P.*?) RETRAIT DU (?P
\d{2})(?P\d{2})(?P\d{2}).*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^RET DAB (?P.*?) CARTE ?:.*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^RET DAB (?P
\d{2})/(?P\d{2})/(?P\d{2}) (?P.*?) CARTE .*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?P.*) RETRAIT DU (?P
\d{2})(?P\d{2})(?P\d{2}) .*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('(\w+) (?P
\d{2})(?P\d{2})(?P\d{2}) CB[:\*][^ ]+ (?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile('^(?PVIR(EMEN)?T? (SEPA)?(RECU|FAVEUR)?)( /FRM)?(?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^PRLV (?P.*) (REF \w+)?$'),FrenchTransaction.TYPE_ORDER), (re.compile('^CHEQUE.*? (REF \w+)?$'), FrenchTransaction.TYPE_CHECK), (re.compile('^(AGIOS /|FRAIS) (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(CONVENTION \d+ )?COTIS(ATION)? (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^REMISE (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^(?P.*)( \d+)? QUITTANCE .*'), FrenchTransaction.TYPE_ORDER), (re.compile('^.* LE (?P
\d{2})/(?P\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_UNKNOWN), ] class HistoryBasePage(Page): def get_history(self): self.logger.warning('Do not support account of type %s' % type(self).__name__) return iter([]) class TransactionsPage(HistoryBasePage): def get_history(self): for tr in self.document.xpath('//table[@id="operation"]/tbody/tr'): tds = tr.findall('td') if len(tds) < 5: continue t = Transaction() date = u''.join([txt.strip() for txt in tds[0].itertext()]) raw = u' '.join([txt.strip() for txt in tds[1].itertext()]) debit = u''.join([txt.strip() for txt in tds[-3].itertext()]) credit = u''.join([txt.strip() for txt in tds[-2].itertext()]) t.parse(date, re.sub(r'[ ]+', ' ', raw)) t.set_amount(credit, debit) t._coming = False if t.raw.startswith('ACHAT CARTE -DEBIT DIFFERE'): continue yield t class CardPage(HistoryBasePage): def get_history(self): debit_date = None coming = True for tr in self.document.xpath('//table[@class="report"]/tbody/tr'): tds = tr.findall('td') if len(tds) == 2: # headers m = re.match('.* (\d+)/(\d+)/(\d+)', tds[0].text.strip()) debit_date = datetime.date(int(m.group(3)), int(m.group(2)), int(m.group(1))) if debit_date < datetime.date.today(): coming = False if len(tds) != 3: continue t = Transaction() date = u''.join([txt.strip() for txt in tds[0].itertext()]) raw = u' '.join([txt.strip() for txt in tds[1].itertext()]) amount = u''.join([txt.strip() for txt in tds[-1].itertext()]) t.parse(date, re.sub(r'[ ]+', ' ', raw)) if debit_date is not None: t.date = debit_date t.label = unicode(tds[1].find('span').text.strip()) t.type = t.TYPE_CARD t._coming = coming t.set_amount(amount) yield t class ValuationPage(HistoryBasePage): pass class LoanPage(HistoryBasePage): pass class MarketPage(HistoryBasePage): pass class AssurancePage(HistoryBasePage): pass class LogoutPage(Page): pass weboob-1.1/modules/barclays/test.py000066400000000000000000000017511265717027300174470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class BarclaysTest(BackendTest): MODULE = 'barclays' def test_banquepop(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/batoto/000077500000000000000000000000001265717027300156025ustar00rootroot00000000000000weboob-1.1/modules/batoto/__init__.py000066400000000000000000000014311265717027300177120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BatotoModule __all__ = ['BatotoModule'] weboob-1.1/modules/batoto/favicon.png000066400000000000000000000221311265717027300177340ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDC pHYs  tIME 8tEXtComment̖#IDATx{yYUo_s*kZnnE6m@GBtuB 1A  gFPfޫ*+3+{/eYM837{q}=w9|Aw=0t&gΦټgYMBC)oou|`" *Dחn?-g[vl!儔6I"!&0H33ZkqY^S[_8 p| %iX4-KnF"8 $UPo̽V&#BRrv4JդX\LKpin5Nͬ7 Y%IqMw|\pucd~dJeV*u-˱DY*I0~\NoΞ̌LWb6+xxhXi3AK$Y]_lnX w;/?RG?W-9J*TFTWrDy׮=5=( li-""AV"&!P il PD"ӳ,9北sgg`` !,lm67oF:Fc-3TZ  FɔtkcH ~P*VKgޕHaz O%*쳏^4GA^inZ~:)Gzt>R |[)-!;ãZCQ 7Ֆ.O v4(˫M,^92#C 4JQ䣐n !&3X[4[[f _P wV:-LϜж5ׯ__Zr< Ҙ;Ԙ:mgutՕ ]")뗏̜\s]7: Y:óe%riu{֔VP4 rC0bLaZ)[gL š abq<2Ml˶a8+jup0``wkkWn a;BYb]_.LY`0mK/1]. W=' ( 3?svsԲlymG)fx=/ @031rmvH@ I-y&Zm !0g.mm( 񱣍b~4;ǎT>,D;F`0qёmL"]hzReKRY`vٙvqb3*49rLD=0{\f/]B2efm'mH@Xtnge;&3Dd+k!eÓ:'.3;ZkY;4SۥnU+HH&KD-T^sjuLx^ZjS 1.Gss7@@ppM/ & 0LUXS3Znl.IOf&u" vQm.МR\`07CD63[>všR*qvvV BJA`2] MP, BeKD[X/PYIɓ CXO@Dk%qN({ f2QSGY2h)۶BJrmIl"8H/-?3T픚:˖f/ 5̶'ljNo7'`Ha IRʛ$(o!mf&*}?U[_x{td8 B.ȑd]}|-f9{Mq"Y XCj "f=;bPW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("ߟ`7^PalGs_> KR ;Nll;^ @iP?DCP,V^-&M7]gu5N\7#"6!u3 X1өE_N{K?+7: ?g3kٜ59v4xL0I)Y #@3똙BϽ?05IENDB`weboob-1.1/modules/batoto/module.py000066400000000000000000000025141265717027300174430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderModule, DisplayPage __all__ = ['BatotoModule'] class BatotoModule(GenericComicReaderModule): NAME = 'batoto' DESCRIPTION = 'Batoto manga reading website' DOMAIN = 'www.batoto.com' BROWSER_PARAMS = dict( img_src_xpath="//img[@id='comic_page']/@src", page_list_xpath="(//select[@id='page_select'])[1]/option/@value") ID_REGEXP = r'[^/]+/[^/]+' URL_REGEXP = r'.+batoto.(?:com|net)/read/_/(%s).+' % ID_REGEXP ID_TO_URL = 'http://www.batoto.net/read/_/%s' PAGES = {URL_REGEXP: DisplayPage} weboob-1.1/modules/batoto/test.py000066400000000000000000000017451265717027300171420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.capabilities.gallery.genericcomicreadertest import GenericComicReaderTest class BatotoTest(GenericComicReaderTest): MODULE = 'batoto' def test_download(self): return self._test_download('26287/yurumates_ch4_by_primitive-scans') weboob-1.1/modules/bforbank/000077500000000000000000000000001265717027300160765ustar00rootroot00000000000000weboob-1.1/modules/bforbank/__init__.py000066400000000000000000000014441265717027300202120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Baptiste Delpey # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BforbankModule __all__ = ['BforbankModule'] weboob-1.1/modules/bforbank/browser.py000066400000000000000000000044311265717027300201350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Baptiste Delpey # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.exceptions import BrowserIncorrectPassword from weboob.browser import LoginBrowser, URL, need_login from weboob.capabilities.bank import Account from .pages import LoginPage, ErrorPage, AccountsPage, HistoryPage, LoanHistoryPage class BforbankBrowser(LoginBrowser): BASEURL = 'https://www.bforbank.com' login = URL('/connexion-client/service/login\?urlBack=%2Fespace-client', LoginPage) error = URL('/connexion-client/service/auth', ErrorPage) home = URL('/espace-client/$', AccountsPage) loan_history = URL('/espace-client/livret/consultation.*', LoanHistoryPage) history = URL('/espace-client/consultation/operations/.*', HistoryPage) def __init__(self, birthdate, *args, **kwargs): super(BforbankBrowser, self).__init__(*args, **kwargs) self.birthdate = birthdate def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.password.isdigit() self.login.stay_or_go() assert self.login.is_here() self.page.login(self.birthdate, self.username, self.password) if self.error.is_here(): raise BrowserIncorrectPassword() @need_login def iter_accounts(self): self.home.stay_or_go() return self.page.iter_accounts() @need_login def get_history(self, account): if account.type == Account.TYPE_MARKET: raise NotImplementedError() self.location(account._link.replace('tableauDeBord', 'operations')) return self.page.get_operations() weboob-1.1/modules/bforbank/module.py000066400000000000000000000043241265717027300177400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Baptiste Delpey # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.base import find_object from weboob.tools.value import ValueBackendPassword, Value from .browser import BforbankBrowser __all__ = ['BforbankModule'] class BforbankModule(Module, CapBank): NAME = 'bforbank' DESCRIPTION = u'BforBank' MAINTAINER = u'Baptiste Delpey' EMAIL = 'b.delpey@hotmail.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Code personnel'), Value('birthdate', label='Date de naissance', regexp='^(\d{2}[/-]?\d{2}[/-]?\d{4}|)$') ) BROWSER = BforbankBrowser def create_default_browser(self): return self.create_browser(self.config['birthdate'].get(), self.config['login'].get(), self.config['password'].get()) def get_account(self, _id): return find_object(self.browser.iter_accounts(), id=_id, error=AccountNotFound) def iter_accounts(self): return self.browser.iter_accounts() def iter_coming(self, account): raise NotImplementedError() def iter_history(self, account): return self.browser.get_history(account) def iter_investment(self, account): raise NotImplementedError() weboob-1.1/modules/bforbank/pages.py000066400000000000000000000152661265717027300175610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Baptiste Delpey # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from StringIO import StringIO from PIL import Image from weboob.browser.pages import LoggedPage, HTMLPage from weboob.browser.elements import method, ListElement, ItemElement from weboob.capabilities.bank import Account from weboob.browser.filters.standard import CleanText, Regexp, Field, Map, CleanDecimal from weboob.tools.capabilities.bank.transactions import FrenchTransaction class BfBKeyboard(object): symbols = {'0': '00111111001111111111111111111111000000111000000001111111111111111111110011111100', '1': '00000000000011000000011100000001100000001111111111111111111100000000000000000000', '2': '00100000111110000111111000011111000011111000011101111111100111111100010111000001', '3': '00100001001110000111111000011111001000011101100001111111011111111111110000011110', '4': '00000011000000111100000111010001111001001111111111111111111111111111110000000100', '5': '00000001001111100111111110011110010000011001000001100110011110011111110000111110', '6': '00011111000111111110111111111111001100011000100001110011001111001111110100011110', '7': '10000000001000000000100000111110011111111011111100111110000011100000001100000000', '8': '00000011001111111111111111111110001000011000100001111111111111111111110010011110', '9': '00111000001111110011111111001110000100011000010011111111111111111111110011111100', } def __init__(self, basepage): self.basepage = basepage self.fingerprints = [] for htmlimg in self.basepage.doc.xpath('.//div[@class="m-btn-pin"]//img'): url = htmlimg.attrib.get("src") imgfile = StringIO(basepage.browser.open(url).content) img = Image.open(imgfile) matrix = img.load() s = "" # The digit is only displayed in the center of image for x in range(19, 27): for y in range(17, 27): (r, g, b, o) = matrix[x, y] # If the pixel is "red" enough if g + b < 450: s += "1" else: s += "0" self.fingerprints.append(s) def get_symbol_code(self, digit): fingerprint = self.symbols[digit] for i, string in enumerate(self.fingerprints): if string == fingerprint: return i def get_string_code(self, string): code = '' for c in string: codesymbol = self.get_symbol_code(c) code += str(codesymbol) return code class LoginPage(HTMLPage): def login(self, birthdate, username, password): vk = BfBKeyboard(self) code = vk.get_string_code(password) form = self.get_form() form['j_username'] = username form['birthDate'] = birthdate form['indexes'] = code form.submit() class ErrorPage(HTMLPage): pass class MyDecimal(CleanDecimal): # BforBank uses commas for thousands seps et and decimal seps def filter(self, text): text = super(CleanDecimal, self).filter(text) text = re.sub(r'[^\d\-\,]', '', text) text = re.sub(r',(?!(\d+$))', '', text) return super(MyDecimal, self).filter(text) class AccountsPage(LoggedPage, HTMLPage): @method class iter_accounts(ListElement): item_xpath = '//table/tbody/tr' class item(ItemElement): klass = Account TYPE = {'Livret': Account.TYPE_SAVINGS, 'Compte': Account.TYPE_CHECKING, 'PEA': Account.TYPE_MARKET, 'Compte-titres': Account.TYPE_MARKET, 'PEA-PME': Account.TYPE_MARKET, 'Assurance-vie': Account.TYPE_MARKET, } obj_id = CleanText('./td//div[contains(@class, "-synthese-title") or contains(@class, "-synthese-text")]') & Regexp(pattern=r'(\d+)') obj_label = CleanText('./td//div[contains(@class, "-synthese-title")]') obj_balance = MyDecimal('./td//div[contains(@class, "-synthese-num")]', replace_dots=True) obj_currency = FrenchTransaction.Currency('./td//div[contains(@class, "-synthese-num")]') obj_type = Map(Regexp(Field('label'), r'^([^ ]*)'), TYPE, default=Account.TYPE_UNKNOWN) obj__link = CleanText('./@data-href') def condition(self): return not len(self.el.xpath('./td[@class="chart"]')) class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^(?PVIREMENT)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?PINTERETS)'), FrenchTransaction.TYPE_BANK), ] class LoanHistoryPage(LoggedPage, HTMLPage): @method class get_operations(ListElement): item_xpath = '//table[contains(@class, "table")]/tbody/div/tr[contains(@class, "submit")]' class item(ItemElement): klass = Transaction obj_amount = MyDecimal('./td[4]', replace_dots=True) obj_date = Transaction.Date('./td[2]') obj_vdate = Transaction.Date('./td[3]') obj_raw = Transaction.Raw('./td[1]') class HistoryPage(LoggedPage, HTMLPage): @method class get_operations(ListElement): item_xpath = '//table[has-class("style-operations")]/tbody//tr' class item(ItemElement): klass = Transaction def condition(self): if 'tr-section' in self.el.attrib['class']: self.parent.env['date'] = Transaction.Date(Regexp(CleanText('.//th'), '(\d+/\d+/\d+)'))(self.el) return False if 'tr-trigger' in self.el.attrib['class']: return True return False def obj_date(self): return self.parent.env['date'] obj_raw = Transaction.Raw('./td[1]') obj_amount = MyDecimal('./td[2]', replace_dots=True) weboob-1.1/modules/bforbank/test.py000066400000000000000000000016111265717027300174260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Baptiste Delpey # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class BforbankTest(BackendTest): MODULE = 'bforbank' def test_bforbank(self): raise NotImplementedError() weboob-1.1/modules/biplan/000077500000000000000000000000001265717027300155575ustar00rootroot00000000000000weboob-1.1/modules/biplan/__init__.py000066400000000000000000000014321265717027300176700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BiplanModule __all__ = ['BiplanModule'] weboob-1.1/modules/biplan/browser.py000066400000000000000000000042431265717027300176170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import ProgramPage, EventPage __all__ = ['BiplanBrowser'] class BiplanBrowser(PagesBrowser): BASEURL = 'http://www.lebiplan.org' program_page = URL('/fr/biplan-prog-(?P<_category>.*).php', ProgramPage) event_page = URL('/(?P<_id>.*).html', EventPage) def list_events_concert(self, date_from, date_to=None, city=None, categories=None): return self.program_page.go(_category='concert').list_events(date_from=date_from, date_to=date_to, city=city, categories=categories, is_concert=True) def list_events_theatre(self, date_from, date_to=None, city=None, categories=None): return self.program_page.go(_category='theatre').list_events(date_from=date_from, date_to=date_to, city=city, categories=categories, is_concert=False) def get_event(self, _id, event=None): return self.event_page.go(_id=_id).get_event(obj=event) weboob-1.1/modules/biplan/calendar.py000066400000000000000000000027071265717027300177100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS, CATEGORIES class BiplanCalendarEvent(BaseCalendarEvent): def __init__(self): BaseCalendarEvent.__init__(self) self.city = u'LILLE' self.location = u'19, rue Colbert' self.sequence = 1 self.transp = TRANSP.TRANSPARENT self.status = STATUS.CONFIRMED self.timezone = u'Europe/Paris' class BiplanCalendarEventConcert(BiplanCalendarEvent): def __init__(self): BiplanCalendarEvent.__init__(self) self.category = CATEGORIES.CONCERT class BiplanCalendarEventTheatre(BiplanCalendarEvent): def __init__(self): BiplanCalendarEvent.__init__(self) self.category = CATEGORIES.THEATRE weboob-1.1/modules/biplan/favicon.png000066400000000000000000000403121265717027300177120ustar00rootroot00000000000000PNG  IHDR@@iq pHYs   cHRMz%u0`:o_F@PIDATx@@  GGG  $$$""" '''*** $$$"""  ###333000   !!! $$$          ))) """  >>> GGG%%%+++ %%%  )))###   """   ,,,"""  '''$$$ 444 999777%%%...(((######  $$$  <<<  )))***---&&& ###UUUMMM(((222  ???###<<<777...GGG??? CCCEEE!!!333  !!! 000'''!!!777%%%999BBB555111333$$$ """BBB999???FFF CCC]]]vvv  ### DDD 555===!!!CCCHHH  ###PPP++++++--- !!!\\\    PPPSSSEEE 777---HHH~~~\\\DDD    :::kkkIII###(((QQQ+++***999>>>222```ggg """### ###555---"""999...iii*** iii444 [[[<<<999)))999666 &&&mmm222--- 777TTT((([[[;;;ZZZnnneeewww%%%555888llljjj@@@777 666777000___PPP$$$$$$pppNNN===<<>>'''UUUyyyOOO{{{iiiNNNaaa]]]HHH000""" +++ZZZzzzAAAOOOxxxaaa aaa iiiyyy???666!!!### 222$$$%%%000 ###EEE ^^^ ???%%%{{{===MMM(((???AAA RRRVVV))))))$$$'''...DDDrrriii{{{888SSS{{{nnn))) QQQ [[[''']]])))<<<,,,www AAA"""000@@@qqq!!!```kkk)))iii'''qqqKKKttt111UUUmmmqqq"""''' UUUGGG ~~~ '''}}}BBBXXX}}}&&&\\\000}}}BBB}}}'''XXX'''lll}}}222 oooXXX'''BBBlll'''lllBBBBBBRRR UUU???!!!:::000:::VVVhhhWWWNNNeeeJJJ @@@XXX'''BBBXXXXXXBBB}}}rrr FFF%%% ...UUU???{{{ JJJ ZZZVVVfffllloooRRR DDDQQQ555  000 ttt ### /// BBBnnnooo\\\999... EEEMMM  ...  QQQ"""fff---333,,,888000FFF;;;BBB|||%%%+++333KKK___OOO[[[444|||nnn ######  QQQ...###    BBBGGG777 >>>222VVVxxx>>>  """:::===''''''(((   ---EEE777LLL999))) $$$  %%%!!!  ''' lll ccc*** ###ggg"""      LLL   ###    (((///            444 _aU pIENDB`weboob-1.1/modules/biplan/module.py000066400000000000000000000054611265717027300174240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES import itertools from .browser import BiplanBrowser from.calendar import BiplanCalendarEvent __all__ = ['BiplanModule'] class BiplanModule(Module, CapCalendarEvent): NAME = 'biplan' DESCRIPTION = u'lebiplan.org website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' ASSOCIATED_CATEGORIES = [CATEGORIES.CONCERT, CATEGORIES.THEATRE] BROWSER = BiplanBrowser def search_events(self, query): if self.has_matching_categories(query): theatre_events = [] concert_events = [] if CATEGORIES.CONCERT in query.categories: concert_events = self.browser.list_events_concert(query.start_date, query.end_date, query.city, query.categories) if CATEGORIES.THEATRE in query.categories: theatre_events = self.browser.list_events_theatre(query.start_date, query.end_date, query.city, query.categories) items = list(itertools.chain(concert_events, theatre_events)) items.sort(key=lambda o: o.start_date) return items def list_events(self, date_from, date_to=None): items = list(itertools.chain(self.browser.list_events_concert(date_from, date_to), self.browser.list_events_theatre(date_from, date_to))) items.sort(key=lambda o: o.start_date) return items def get_event(self, _id): return self.browser.get_event(_id) def fill_obj(self, event, fields): return self.browser.get_event(event.id, event) OBJECTS = {BiplanCalendarEvent: fill_obj} weboob-1.1/modules/biplan/pages.py000066400000000000000000000127631265717027300172410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from datetime import datetime, time import weboob.tools.date as date_util from .calendar import BiplanCalendarEventConcert, BiplanCalendarEventTheatre from weboob.browser.elements import ItemElement, SkipItem, ListElement, method from weboob.browser.pages import HTMLPage from weboob.browser.filters.standard import Filter, CleanText, Env, Regexp, CombineDate from weboob.browser.filters.html import Link, CleanHTML class BiplanPrice(Filter): def filter(self, el): index = 1 if len(el) > 1 else 0 content = CleanText.clean(CleanText('.', ['HORAIRES'])(el[index])) a_price = content.split(' - ')[-1] parsed_price = re.findall(r"\d*\,\d+|\d+", " ".join(a_price)) if parsed_price and len(parsed_price) > 0: return float(parsed_price[0].replace(',', '.')) return float(0) class BiplanDate(Filter): def filter(self, el): content = CleanText.clean(CleanText(CleanHTML('.'), ['*'])(el[0])) a_date = content[0:content.index(' - ')] for fr, en in date_util.DATE_TRANSLATE_FR: a_date = fr.sub(en, a_date) try: _month = datetime.strptime(a_date, "%A %d %B").month if (datetime.now().month > _month): a_date += u' %i' % (datetime.now().year + 1) else: a_date += u' %i' % (datetime.now().year) except ValueError: pass return datetime.strptime(a_date, "%A %d %B %Y") class StartTime(Filter): def filter(self, el): index = 1 if len(el) > 1 else 0 content = CleanText.clean(CleanText('.', ['HORAIRES'])(el[index])) _content = content.split(' - ') a_time = _content[2] if len(_content) > 2 else _content[0] regexp = re.compile(ur'(?P\d+)h?(?P\d+)') m = regexp.search(a_time) if m: return time(int(m.groupdict()['hh'] or 0), int(m.groupdict()['mm'] or 0)) return time(0, 0) class EndTime(Filter): def filter(self, el): return time.max class ProgramPage(HTMLPage): @method class list_events(ListElement): item_xpath = '//div[@class="ligne"]' class item(ItemElement): def klass(self): return BiplanCalendarEventConcert() if self.env['is_concert'] else BiplanCalendarEventTheatre() def condition(self): return (self.el.xpath('./div') and CleanText('./div/a/img/@src')(self)[-1] != '/') def validate(self, obj): return (self.is_valid_event(obj, self.env['city'], self.env['categories']) and self.is_event_in_valid_period(obj.start_date, self.env['date_from'], self.env['date_to'])) def is_valid_event(self, event, city, categories): if city and city != '' and city.upper() != event.city.upper(): return False if categories and len(categories) > 0 and event.category not in categories: return False return True def is_event_in_valid_period(self, event_date, date_from, date_to): if event_date >= date_from: if not date_to: return True else: if event_date <= date_to: return True return False obj_id = Regexp(Link('./div/a'), '/(.*?).html') obj_start_date = CombineDate(BiplanDate('div/div/b'), StartTime('div/div/b')) obj_end_date = CombineDate(BiplanDate('div/div/b'), EndTime('.')) obj_price = BiplanPrice('div/div/b') obj_summary = CleanText("div/div/div/a/strong") class EventPage(HTMLPage): encoding = u'utf-8' @method class get_event(ItemElement): klass = BiplanCalendarEventConcert if Env('is_concert') else BiplanCalendarEventTheatre def parse(self, el): _div = "//div/div/div[@id='popup']" div = el.xpath("%s" % _div)[0] if self.obj.id: event = self.obj event.url = self.page.url event.description = CleanHTML("%s/div/div[@class='presentation-popup']" % _div)(self) raise SkipItem() self.env['is_concert'] = (div.attrib['class'] != 'theatre-popup') self.env['url'] = self.page.url obj_id = Env('_id') base = "//div[@id='popup']" obj_price = BiplanPrice("%s/div/b" % base) obj_start_date = CombineDate(BiplanDate("%s/div/b" % base), StartTime("%s/div/b" % base)) obj_end_date = CombineDate(BiplanDate("%s/div/b" % base), EndTime(".")) obj_url = Env('url') obj_summary = CleanText('%s/div/div/span' % base) obj_description = CleanHTML('%s/div/div[@class="presentation-popup"]' % base) weboob-1.1/modules/biplan/test.py000066400000000000000000000024231265717027300171110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime from weboob.tools.test import BackendTest, SkipTest class BiplanTest(BackendTest): MODULE = 'biplan' def test_biplan_list(self): if datetime.now() > datetime(datetime.now().year, 7, 14) and datetime.now() < datetime(datetime.now().year, 9, 15): raise SkipTest("Fermeture estivale") l = list(self.backend.list_events(datetime.now())) assert len(l) event = self.backend.get_event(l[0].id) self.assertTrue(event.url, 'URL for event "%s" not found: %s' % (event.id, event.url)) weboob-1.1/modules/blablacar/000077500000000000000000000000001265717027300162155ustar00rootroot00000000000000weboob-1.1/modules/blablacar/__init__.py000066400000000000000000000014401265717027300203250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BlablacarModule __all__ = ['BlablacarModule'] weboob-1.1/modules/blablacar/browser.py000066400000000000000000000030461265717027300202550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import DeparturesPage from datetime import datetime import urllib class BlablacarBrowser(PagesBrowser): BASEURL = 'https://www.blablacar.fr' departures = URL('/search_xhr\?(?P.*)', DeparturesPage) def get_roadmap(self, departure, arrival, filters): pass def get_station_departures(self, station_id, arrival_id, date): query = {'fn': station_id} if arrival_id: query['tn'] = arrival_id if date: _date = datetime.strftime(date, "%d/%m/%Y") query['db'] = _date _heure = datetime.strftime(date, "%H") query['hb'] = _heure query['he'] = '24' return self.departures.open(qry=urllib.urlencode(query)).get_station_departures() weboob-1.1/modules/blablacar/module.py000066400000000000000000000026101265717027300200530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.travel import CapTravel from .browser import BlablacarBrowser __all__ = ['BlablacarModule'] class BlablacarModule(Module, CapTravel): NAME = 'blablacar' DESCRIPTION = u'blablacar website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = BlablacarBrowser def iter_roadmap(self, departure, arrival, filters): return self.browser.get_roadmap(departure, arrival, filters) def iter_station_departures(self, station_id, arrival_id, date): return self.browser.get_station_departures(station_id, arrival_id, date) weboob-1.1/modules/blablacar/pages.py000066400000000000000000000061701265717027300176720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.travel import Departure from weboob.browser.filters.standard import CleanText, Format, Regexp, CleanDecimal from weboob.browser.filters.html import Link from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.pages import JsonPage from weboob.capabilities.base import Currency from io import StringIO import lxml.html as html from datetime import datetime class DeparturesPage(JsonPage): ENCODING = None def __init__(self, browser, response, *args, **kwargs): super(DeparturesPage, self).__init__(browser, response, *args, **kwargs) self.encoding = self.ENCODING or response.encoding parser = html.HTMLParser(encoding=self.encoding) if 'results' in self.doc['html']: self.doc = html.parse(StringIO(self.doc['html']['results']), parser) else: self.doc = html.Element('brinbrin') @method class get_station_departures(ListElement): item_xpath = '//ul[@class="trip-search-results"]/li/a' class item(ItemElement): klass = Departure obj_id = Regexp(Link('.'), '/(.*)') def obj_time(self): _date = CleanText('./article/div/h3[@itemprop="startDate"]/@content')(self).split('-') _time = Regexp(CleanText('./article/div/h3[@itemprop="startDate"]'), u'.* à (\d+)h')(self) return datetime(int(_date[0]), int(_date[1]), int(_date[2]), int(_time), 0) obj_type = Format('%s (%s)', CleanText('./article/div/dl[@class="car-type"]/dt/strong'), CleanText('./article/div/dl[@class="car-type"]/dd/span/@title')) obj_departure_station = CleanText('./article/div/dl[@class="geo-from"]/dd', replace=[(": voir avec le conducteur", "")]) obj_arrival_station = CleanText('./article/div/dl[@class="geo-to"]/dd', replace=[(": voir avec le conducteur", "")]) obj_price = CleanDecimal(CleanText('./article/div/div[@itemprop="location"]/strong/span[last()]')) def obj_currency(self): txt = CleanText('./article/div/div[@itemprop="location"]')(self) return Currency.get_currency(txt) obj_information = CleanText('./article/div/div[@class="availability"]') weboob-1.1/modules/blablacar/test.py000066400000000000000000000020161265717027300175450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from datetime import datetime class BlablacarTest(BackendTest): MODULE = 'blablacar' def test_blablacar(self): departures = list(self.backend.iter_station_departures('lille', 'lens', datetime.now())) self.assertTrue(len(departures) > 0) weboob-1.1/modules/bnporc/000077500000000000000000000000001265717027300155755ustar00rootroot00000000000000weboob-1.1/modules/bnporc/__init__.py000066400000000000000000000014351265717027300177110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BNPorcModule __all__ = ['BNPorcModule'] weboob-1.1/modules/bnporc/company/000077500000000000000000000000001265717027300172435ustar00rootroot00000000000000weboob-1.1/modules/bnporc/company/__init__.py000066400000000000000000000000001265717027300213420ustar00rootroot00000000000000weboob-1.1/modules/bnporc/company/browser.py000066400000000000000000000065621265717027300213110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Baptiste Delpey # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import date, timedelta from weboob.browser import LoginBrowser, URL, need_login from weboob.capabilities.base import find_object from weboob.capabilities.bank import AccountNotFound from .pages import LoginPage, AccountsPage, HistoryPage __all__ = ['BNPCompany'] class BNPCompany(LoginBrowser): BASEURL = 'https://secure1.entreprises.bnpparibas.net' login = URL('/sommaire/jsp/identification.jsp', LoginPage) accounts = URL('/NCCPresentationWeb/e10_soldes/liste_soldes.do', AccountsPage) history = URL('/NCCPresentationWeb/e11_releve_op/listeOperations.do', HistoryPage) def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.password.isdigit() self.login.go() self.login.go() assert self.login.is_here() self.page.login(self.username, self.password) @need_login def get_accounts_list(self): self.accounts.go() return self.page.iter_accounts() @need_login def get_account(self, _id): return find_object(self.get_accounts_list(), id=_id, error=AccountNotFound) def get_transactions(self, id_account, typeReleve, dateMin, dateMax='null'): self.open('https://secure1.entreprises.bnpparibas.net/NCCPresentationWeb/e11_releve_op/init.do?e10=true') params = {} params['identifiant'] = id_account params['typeSole'] = 'C' params['typeReleve'] = typeReleve params['typeDate'] = 'O' params['ajax'] = 'true' params['dateMin'] = dateMin params['dateMax'] = dateMax self.history.go(params=params) return self.page.iter_history() @need_login def iter_history(self, account): return self.get_transactions(account.id, 'Comptable', (date.today() - timedelta(days=90)).strftime('%Y%m%d'), date.today().strftime('%Y%m%d')) @need_login def iter_coming_operations(self, account): return self.get_transactions(account.id, 'Previsionnel', (date.today().strftime('%Y%m%d'))) @need_login def iter_investment(self, account): raise NotImplementedError() @need_login def get_transfer_accounts(self): raise NotImplementedError() @need_login def transfer(self, account, to, amount, reason): raise NotImplementedError() @need_login def iter_threads(self): raise NotImplementedError() @need_login def get_thread(self, thread): raise NotImplementedError() weboob-1.1/modules/bnporc/company/pages.py000066400000000000000000000155271265717027300207260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Baptiste Delpey # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from StringIO import StringIO import hashlib from decimal import Decimal from datetime import datetime from weboob.capabilities.bank import Account from weboob.exceptions import BrowserIncorrectPassword from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard, VirtKeyboardError class BNPVirtKeyboard(MappedVirtKeyboard): symbols = {'0': 'ff069462836e30a39c911034048f5bb3', '1': '7969f04e4e82eaefa2ce7a9a23c26178', '2': '1e6020f97ca1c3ce3da4f39ded15d67d', '3': 'f84284b40aea93c24814e23e14e76cc8', '4': '88bab262d4b344c0ef8f06ddd01adbcf', '5': '0a270764fc5d8334bcb55053432b26cb', '6': 'e6a4444a6c752cd3e655f2883e530080', '7': '933d4ca5df6b2b3df2dea00a21a3fed6', '8': ['f28b918777d21a5fde2bffb9899e2138', 'a97e6e27159084d50f8ef00548b70252'], '9': 'be751b77af0d998ab4c2cfd38455b2a6', } color=(0,0,0) def __init__(self, basepage): img = basepage.doc.xpath('//img[@id="gridpass_img"]')[0] imgdata = basepage.browser.open(img.attrib['src']).content MappedVirtKeyboard.__init__(self, StringIO(imgdata), basepage.doc, img, self.color, convert='RGB') self.check_symbols(self.symbols, basepage.browser.responses_dirname) def get_symbol_code(self, md5sum): code = MappedVirtKeyboard.get_symbol_code(self, md5sum) code = code.split("'")[3] assert code.isdigit() return code def check_color(self, pixel): for p in pixel: if p >= 200: return False return True def checksum(self, coords): """Copy of parent checksum(), but cropping (removes empty lines)""" x1, y1, x2, y2 = coords s = '' for y in range(y1, min(y2 + 1, self.height)): for x in range(x1, min(x2 + 1, self.width)): if self.check_color(self.pixar[x, y]): s += " " else: s += "O" s += "\n" s = '\n'.join([l for l in s.splitlines() if l.strip()]) return hashlib.md5(s).hexdigest() class LoginPage(HTMLPage): def login(self, login, password): try: vk = BNPVirtKeyboard(self) except VirtKeyboardError as err: self.logger.error("Error: %s" % err) return False form = self.get_form(name='loginPwdForm') form['txtAuthentMode'] = 'PASSWORD' form['txtPwdUserId'] = login form['gridpass_hidden_input'] = vk.get_string_code(password) form.submit() def on_load(self): if self.doc.xpath('//p[contains(text(), "Your identification is wrong.")]'): raise BrowserIncorrectPassword("Your identification is wrong.") class AccountsPage(LoggedPage, JsonPage): FAMILY_TO_TYPE = { u"Compte chèque": Account.TYPE_CHECKING, } def iter_accounts(self): for f in self.path('tableauSoldes.listeGroupes'): for g in f: for a in g.get('listeComptes'): yield Account.from_dict({ 'id': a.get('numeroCompte'), 'iban': a.get('numeroCompte'), 'type': self.FAMILY_TO_TYPE.get(a.get('libelleType')) or Account.TYPE_UNKNOWN, 'label': '%s %s' % (a.get('libelleType'), a.get('libelleTitulaire')), 'currency': a.get('deviseTenue'), 'balance': Decimal(a.get('soldeComptable')) / 100, 'coming': Decimal(a.get('soldePrevisionnel')) / 100, }) class HistoryPage(LoggedPage, JsonPage): CODE_TO_TYPE = { "AUTOP": FrenchTransaction.TYPE_UNKNOWN, # Autres opérations, "BOURS": FrenchTransaction.TYPE_BANK, # Bourse / Titres, "CARTE": FrenchTransaction.TYPE_CARD, # Cartes, "CHEQU": FrenchTransaction.TYPE_CHECK, # Chèques, "CREDD": FrenchTransaction.TYPE_UNKNOWN, # Crédits documentaires, "CREDI": FrenchTransaction.TYPE_UNKNOWN, # Crédits, "EFFET": FrenchTransaction.TYPE_UNKNOWN, # Effets, "ESPEC": FrenchTransaction.TYPE_UNKNOWN, # Espèces, "FACCB": FrenchTransaction.TYPE_UNKNOWN, # Factures / Retraits cartes, "ICHEQ": FrenchTransaction.TYPE_UNKNOWN, # Impayés chèques, "IEFFE": FrenchTransaction.TYPE_UNKNOWN, # Impayés et incidents effets, "IMPAY": FrenchTransaction.TYPE_UNKNOWN, # Impayés et rejets, "IPRLV": FrenchTransaction.TYPE_UNKNOWN, # Impayés prélèvements, TIP et télérèglements, "PRLVT": FrenchTransaction.TYPE_UNKNOWN, # Prélèvements, TIP et télérèglements, "REMCB": FrenchTransaction.TYPE_UNKNOWN, # Remises cartes, "RJVIR": FrenchTransaction.TYPE_ORDER, # Rejets de virements, "VIREM": FrenchTransaction.TYPE_ORDER, # Virements, "VIRIT": FrenchTransaction.TYPE_ORDER, # Virements internationaux, "VIRSP": FrenchTransaction.TYPE_ORDER, # Virements européens, "VIRTR": FrenchTransaction.TYPE_ORDER, # Virements de trésorerie, "VIRXX": FrenchTransaction.TYPE_ORDER, # Autres virements } def one(self, path, context=None): try: return list(self.path(path, context))[0] except IndexError: return None def iter_history(self): for op in self.get('mouvementsBDDF'): codeFamille = self.one('nature.codefamille', op) tr = FrenchTransaction.from_dict({ 'id': op.get('id'), 'type': self.CODE_TO_TYPE.get(codeFamille) or FrenchTransaction.TYPE_UNKNOWN, 'category': self.one('nature.libelle', op), 'raw': ' '.join(op.get('libelle').split()) or op.get('nature')['libelle'], 'date': datetime.fromtimestamp(op.get('dateOperation') / 1000), 'vdate': datetime.fromtimestamp(op.get('dateValeur') / 1000), 'amount': Decimal(self.one('montant.montant', op)) / 100, }) yield tr weboob-1.1/modules/bnporc/deprecated/000077500000000000000000000000001265717027300176755ustar00rootroot00000000000000weboob-1.1/modules/bnporc/deprecated/__init__.py000066400000000000000000000000001265717027300217740ustar00rootroot00000000000000weboob-1.1/modules/bnporc/deprecated/browser.py000066400000000000000000000332151265717027300217360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from datetime import datetime from logging import warning from random import randint from weboob.deprecated.browser import Browser, BrowserIncorrectPassword, BrowserPasswordExpired from weboob.capabilities.bank import TransferError, Transfer, Account from .perso.accounts_list import AccountsList, AccountPrelevement from .perso.transactions import AccountHistory, AccountComing from .perso.investment import AccountMarketInvestment, AccountLifeInsuranceInvestment from .perso.transfer import TransferPage, TransferConfirmPage, TransferCompletePage from .perso.login import LoginPage, ConfirmPage, ChangePasswordPage, InfoMessagePage from .perso.messages import MessagePage, MessagesPage from .pro import ProAccountsList, ProAccountHistory __all__ = ['BNPorc'] class BNPorc(Browser): DOMAIN = 'www.secure.bnpparibas.net' PROTOCOL = 'https' CERTHASH = ['5511f0ff19c982b6351c17b901bfa7419f075edb13f2df41e446248beb7866bb', 'fa8cb72ef2e46054469af916f7ec222b1904901fecde8511a0f769ba0385410d', '86cd4ba8cfbc53937dfc402e8c2d0a2d5ffb630a73bbeafd09c39f8b54a6a6c3', 'dfab57aecb7dd8460ba0e802c798e7aff3288b10451992a372e3e8bdc5f1f0c7'] ENCODING = None # refer to the HTML encoding PAGES = {'.*pageId=unedescomptes.*': AccountsList, '.*pageId=releveoperations.*': AccountHistory, '.*FicheA': AccountHistory, '.*SAF_DPF.*': AccountMarketInvestment, '.*identifiant=Assurance_Vie_Consultation.*': AccountLifeInsuranceInvestment, '.*Action=SAF_CHM.*': ChangePasswordPage, '.*pageId=mouvementsavenir.*': AccountComing, '.*NS_AVEDP.*': AccountPrelevement, '.*NS_VIRDF.*': TransferPage, '.*NS_VIRDC.*': TransferConfirmPage, '.*/NS_VIRDA\?stp=(?P\d+).*': TransferCompletePage, '.*type=homeconnex.*': LoginPage, '.*layout=HomeConnexion.*': ConfirmPage, '.*SAF_CHM_VALID.*': ConfirmPage, '.*Action=DSP_MSG.*': InfoMessagePage, '.*MessagesRecus.*': MessagesPage, '.*BmmFicheLireMessage.*': MessagePage, # Pro 'https?://www.secure.bnpparibas.net/banque/portail/entrepros/Fiche\?.*identifiant=PRO_Une_Comptes.*': ProAccountsList, 'https?://www.secure.bnpparibas.net/SAF_ROP.*': ProAccountHistory, 'https?://www.secure.bnpparibas.net/NS_AVEDT.*': ProAccountHistory, } def __init__(self, *args, **kwargs): self.rotating_password = kwargs.pop('rotating_password', None) self.password_changed_cb = kwargs.pop('password_changed_cb', None) Browser.__init__(self, *args, **kwargs) def home(self): self.location('https://www.secure.bnpparibas.net/banque/portail/particulier/HomeConnexion?type=homeconnex') def is_logged(self): return not self.is_on_page(LoginPage) def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.password.isdigit() if not self.is_on_page(LoginPage): self.home() self.page.login(self.username, self.password) self.location('/NSFR?Action=DSP_VGLOBALE', no_login=True) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() #self.readurl('/SAF_SOA?Action=6') def change_password(self, new_password): assert new_password.isdigit() and len(new_password) == 6 buf = self.readurl('https://www.secure.bnpparibas.net/NSFR?Action=SAF_CHM', if_fail='raise') buf = buf[buf.find('/SAF_CHM?Action=SAF_CHM'):] buf = buf[:buf.find('"')] self.location(buf) assert self.is_on_page(ChangePasswordPage) #self.readurl('/banque/portail/particulier/bandeau') #self.readurl('/common/vide.htm') self.page.change_password(self.password, new_password) if not self.is_on_page(ConfirmPage) or self.page.get_error() is not None: self.logger.error('Oops, unable to change password (%s)' % (self.page.get_error() if self.is_on_page(ConfirmPage) else 'unknown')) return self.password, self.rotating_password = (new_password, self.password) if self.password_changed_cb: self.password_changed_cb(self.rotating_password, self.password) def check_expired_password(func): def inner(self, *args, **kwargs): try: return func(self, *args, **kwargs) except BrowserPasswordExpired: if self.rotating_password is not None: warning('[%s] Your password has expired. Switching...' % self.username) self.change_password(self.rotating_password) return func(self, *args, **kwargs) else: raise return inner @check_expired_password def get_accounts_list(self): if not self.is_on_page(AccountsList): self.location('/NSFR?Action=DSP_VGLOBALE') return self.page.get_list() def get_account(self, id): assert isinstance(id, basestring) if not self.is_on_page(AccountsList): self.location('/NSFR?Action=DSP_VGLOBALE') l = self.page.get_list() for a in l: if a.id == id: return a return None def iter_history(self, account): if account.type == Account.TYPE_LIFE_INSURANCE: raise NotImplementedError() if account._link_id is None: return iter([]) if account._stp is not None: # Pro self.location(self.buildurl('/SAF_ROP', Origine='DSP_HISTOCPT', ch4=account._link_id, stp=account._stp)) else: # Perso if not self.is_on_page(AccountsList): self.location('/NSFR?Action=DSP_VGLOBALE') execution = self.page.document.xpath('//form[@name="goToApplication"]/input[@name="execution"]')[0].attrib['value'] data = {'gt': 'homepage:basic-theme', 'externalIAId': 'IAStatements', 'cboFlowName': 'flow/iastatement', 'contractId': account._link_id, 'groupId': '-2', 'pastOrPendingOperations': 1, 'groupSelected':'-2', 'step': 'STAMENTS', 'pageId': 'releveoperations', #'operationsPerPage': 100, #'_eventId': 'changeOperationsPerPage', 'sendEUD': 'true', 'execution': execution, } self.location('https://www.secure.bnpparibas.net/banque/portail/particulier/FicheA', urllib.urlencode(data)) e = self.page.document.xpath('//form[@name="displayStatementForm"]/input[@name="_flowExecutionKey"]') if len(e) != 1: return iter([]) execution = e[0].attrib['value'] data = {'_eventId': 'changeOperationsPerPage', 'newCategoryId': '', 'categorisationInProgress': '', 'contractId': account._link_id, '_flowExecutionKey': execution, 'groupId': '-2', 'operations.objectsPerPage': 100, 'operations.pageNumber': 1, 'pageId': 'releveoperations', } # it's not a joke, BNP guys are really crappy. for i in xrange(30): data['_operations.list[%d].checkedOff' % i] = 'on' data['_operations.list[%d].selectedForCategorization' % i] = 'on' self.location('https://www.secure.bnpparibas.net/banque/portail/particulier/FicheA', urllib.urlencode(data)) return self.page.iter_operations() def iter_coming_operations(self, account): if account._link_id is None: return iter([]) if account._stp is not None: # Pro self.location(self.buildurl('/NS_AVEDT', Origine='DSP_DT', ch4=account._link_id, stp=account._stp)) else: # Perso if not self.is_on_page(AccountsList): self.location('/NSFR?Action=DSP_VGLOBALE') execution = self.page.document.xpath('//form[@name="goToApplication"]/input[@name="execution"]')[0].attrib['value'] data = {'gt': 'homepage:basic-theme', 'externalIAId': 'IAStatements', 'cboFlowName': 'flow/iastatement', 'contractId': account._link_id, 'groupId': '-2', 'pastOrPendingOperations': 2, 'groupSelected':'-2', 'step': 'STAMENTS', 'pageId': 'mouvementsavenir', #'operationsPerPage': 100, #'_eventId': 'changeOperationsPerPage', 'sendEUD': 'true', 'execution': execution, } self.location('https://www.secure.bnpparibas.net/banque/portail/particulier/FicheA', urllib.urlencode(data)) return self.page.iter_coming_operations() def iter_investment(self, account): if account.type == Account.TYPE_MARKET: if not account.iban or u'espèce' in account.label.lower(): return iter([]) stp = datetime.strftime(datetime.now(), '%Y%m%d%H%M%S') self.location('https://www.secure.bnpparibas.net/SAF_DPF?Origine=DSP_DPF&ch4=' + account.iban + 'stp=' + stp) data = {'ch4': account.iban, 'Origine': 'DSP_DPF', 'chD': 'oui', 'chT': 'sans', 'chU': 'alpha', 'x': randint(0, 99), 'y': randint(0, 18) } self.location('https://www.secure.bnpparibas.net/SAF_DPF', urllib.urlencode(data)) elif account.type == Account.TYPE_LIFE_INSURANCE: if not account._link_id: return iter([]) self.location('https://www.secure.bnpparibas.net/banque/portail/particulier/Fiche?type=folder&identifiant=Assurance_Vie_Consultation_20071002051044&contrat=' + account._link_id) else: raise NotImplementedError() return self.page.iter_investment() @check_expired_password def get_transfer_accounts(self): if not self.is_on_page(TransferPage): self.location('/NS_VIRDF') assert self.is_on_page(TransferPage) return self.page.get_accounts() @check_expired_password def transfer(self, from_id, to_id, amount, reason=None): if not self.is_on_page(TransferPage): self.location('/NS_VIRDF') accounts = self.page.get_accounts() self.page.transfer(from_id, to_id, amount, reason) if not self.is_on_page(TransferCompletePage): raise TransferError('An error occured during transfer') transfer = Transfer(self.page.get_id()) transfer.amount = amount transfer.origin = accounts[from_id].label transfer.recipient = accounts[to_id].label transfer.date = datetime.now() return transfer def messages_page(self): if not self.is_on_page(MessagesPage): if not self.is_on_page(AccountsList): self.location('/NSFR?Action=DSP_VGLOBALE') self.location(self.page.get_messages_link()) assert self.is_on_page(MessagesPage) def iter_threads(self): self.messages_page() for thread in self.page.iter_threads(): yield thread def get_thread(self, thread): self.messages_page() if not hasattr(thread, '_link_id') or not thread._link_id: for t in self.iter_threads(): if t.id == thread.id: thread = t break # mimic validerFormulaire() javascript # yes, it makes no sense page_id, unread = thread._link_id self.select_form('listerMessages') self.form.set_all_readonly(False) self['identifiant'] = page_id if len(thread.id): self['idMessage'] = thread.id # the JS does this, but it makes us unable to read unread messages #if unread: # self['newMsg'] = thread.id self.submit() assert self.is_on_page(MessagePage) thread.root.content = self.page.get_content() return thread weboob-1.1/modules/bnporc/deprecated/perso/000077500000000000000000000000001265717027300210255ustar00rootroot00000000000000weboob-1.1/modules/bnporc/deprecated/perso/__init__.py000066400000000000000000000000001265717027300231240ustar00rootroot00000000000000weboob-1.1/modules/bnporc/deprecated/perso/accounts_list.py000066400000000000000000000117641265717027300242620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from decimal import Decimal from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.capabilities.bank import Account from weboob.capabilities.base import NotAvailable from weboob.deprecated.browser import Page, BrokenPageError, BrowserPasswordExpired class AccountsList(Page): ACCOUNT_TYPES = { u'Liquidités': Account.TYPE_CHECKING, u'Epargne disponible': Account.TYPE_SAVINGS, u'Titres': Account.TYPE_MARKET, u'Assurance vie': Account.TYPE_LIFE_INSURANCE, u'Capitalisation': Account.TYPE_LIFE_INSURANCE, u'Crédit immobilier': Account.TYPE_LOAN, } def on_loaded(self): pass def _parse_iban(self, account, url): m = re.search('ch4=(\w+)', url) if m: account.iban = unicode(m.group(1)) def _parse_account_group(self, table): typename = unicode(table.attrib.get('summary', '').replace('Liste des contrats/comptes ', '')) typeid = self.ACCOUNT_TYPES.get(typename, Account.TYPE_UNKNOWN) account = None for tr in table.xpath('.//tr'): if tr.find('td') is not None and tr.find('td').attrib.get('class', '') == 'typeTitulaire': account = self._parse_account(tr) account.type = typeid yield account elif tr.get('class', '') == 'listeActionBig' and account is not None: try: url = tr.xpath('.//a')[-1].get('href', '') except IndexError: pass else: self._parse_iban(account, url) account = None def _parse_account(self, tr): account = Account() # for pro usage account._stp = None account.id = tr.xpath('.//td[@class="libelleCompte"]/input')[0].attrib['id'][len('libelleCompte'):] if len(str(account.id)) == 23: account.id = str(account.id)[5:21] a = tr.xpath('.//td[@class="libelleCompte"]/a')[0] m = re.match(r'javascript:goToStatements\(\'(\d+)\'', a.get('onclick', '')) if m: account._link_id = m.group(1) else: # Find _link_id of life insurances m = re.match(r'javascript:overviewRedirectionOperation.*contrat=(\d+)', a.get('onclick', '')) if m: account._link_id = m.group(1) else: # Can't get history for this account. account._link_id = None # To prevent multiple-IDs for CIF (for example), add an arbitrary char in ID. account.id += 'C' account.label = u''+a.text.strip() tds = tr.findall('td') account.currency = account.get_currency(tds[3].find('a').text) account.balance = self._parse_amount(tds[3].find('a')) if tds[4].find('a') is not None: account.coming = self._parse_amount(tds[4].find('a')) else: account.coming = NotAvailable return account def _parse_amount(self, elem): return Decimal(FrenchTransaction.clean_amount(elem.text)) def get_list(self): accounts = [] for table in self.document.xpath('//table[@class="tableCompte"]'): for account in self._parse_account_group(table): accounts.append(account) if len(accounts) == 0: # oops, no accounts? check if we have not exhausted the allowed use # of this password for img in self.document.getroot().cssselect('img[align="middle"]'): if img.attrib.get('alt', '') == 'Changez votre code secret': raise BrowserPasswordExpired('Your password has expired') return accounts def get_execution_id(self): return self.document.xpath('//input[@name="_flowExecutionKey"]')[0].attrib['value'] def get_messages_link(self): """ Get the link to the messages page, which seems to have an identifier in it. """ for link in self.parser.select(self.document.getroot(), 'div#pantalon div.interieur a'): if 'MessagesRecus' in link.attrib.get('href', ''): return link.attrib['href'] raise BrokenPageError('Unable to find the link to the messages page') class AccountPrelevement(AccountsList): pass weboob-1.1/modules/bnporc/deprecated/perso/investment.py000066400000000000000000000057531265717027300236050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from decimal import Decimal from xml.etree import ElementTree from weboob.deprecated.browser import Page from weboob.capabilities.bank import Investment from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.capabilities.base import NotAvailable def clean_text(el): text = ElementTree.tostring(el, 'utf-8', 'text').decode('utf-8') return re.sub(ur'[\s\xa0]+', u' ', text).strip() def clean_cells(cells): return list(map(clean_text, cells)) def clean_amount(amount): return Decimal(FrenchTransaction.clean_amount(amount)) if amount and amount != ' NS' else NotAvailable def clean_amounts(amounts): return list(map(clean_amount, amounts)) class AccountMarketInvestment(Page): def iter_investment(self): table = self.document.xpath('//table[@align="center"]')[4] rows = table.xpath('.//tr[@class="hdoc1"]') for tr in rows: cells = clean_cells(tr.findall('td')) cells[2:] = clean_amounts(cells[2:]) inv = Investment() inv.label, _, inv.quantity, inv.unitvalue, inv.valuation = cells tr2 = tr.xpath('./following-sibling::tr')[0] tr2td = tr2.findall('td')[1] inv.id = inv.code = clean_text(tr2.xpath('.//a')[0]) inv.unitprice = clean_amount(tr2td.xpath('.//td[@class="hdotc1nb"]')[0].text) inv.description = u'' if inv.unitprice: inv.diff = inv.quantity * inv.unitprice - inv.valuation yield inv class AccountLifeInsuranceInvestment(Page): def iter_investment(self): rows = self.document.xpath('//table[@id="mefav_repartition_supports_BPF"]//tr') or \ self.document.xpath('//tbody[@id="mefav_repartition_supports"]//tr') for tr in rows: cells = clean_cells(tr.findall('td')) cells[3:] = clean_amounts(cells[3:]) inv = Investment() inv.label, _, inv.code, inv.quantity, inv.unitvalue, inv.valuation, _ = cells if inv.code: inv.id = inv.code if not inv.unitvalue: # XXX Fonds eu Euros inv.code = u'XX' + re.sub(ur'[^A-Za-z0-9]', u'', inv.label).upper() inv.description = u'' yield inv weboob-1.1/modules/bnporc/deprecated/perso/login.py000066400000000000000000000125011265717027300225060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2011 Romain Bignon, Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import time import re import urllib from weboob.deprecated.browser import Page, BrowserUnavailable from weboob.tools.captcha.virtkeyboard import VirtKeyboard, VirtKeyboardError class BNPVirtKeyboard(VirtKeyboard): symbols={'0': '9cc4789a2cb223e8f2d5e676e90264b5', '1': 'e10b58fc085f9683052d5a63c96fc912', '2': '04ec647e7b3414bcc069f0c54eb55a4c', '3': 'fde84fd9bac725db8463554448f1e469', '4': '2359eea8671bf112b58264bec0294f71', '5': '82b55b63480114f04fad8c5c4fa5673a', '6': 'e074864faeaeabb3be3d118192cd8879', '7': 'af5740e4ca71fadc6f4ae1412d864a1c', '8': 'cab759c574038ad89a0e35cc76ab7214', '9': '828cf0faf86ac78e7f43208907620527' } url="/NSImgGrille?timestamp=%d" color=27 def __init__(self, page): coords = {} size = 136 x, y, width, height = (0, 0, size/5, size/5) for a in page.document.xpath('//div[@id="secret-nbr-keyboard"]/a'): code = a.attrib['ondblclick'] coords[code] = (x+1, y+1, x+height-2, y+height-2) if (x + width + 1) >= size: y += height x = 0 else: x += width VirtKeyboard.__init__(self, page.browser.openurl(self.url % time.time()), coords, self.color) self.check_symbols(self.symbols, page.browser.responses_dirname) def get_symbol_code(self, md5sum): code = VirtKeyboard.get_symbol_code(self, md5sum) return re.sub(u'[^\d]', '', code) def get_string_code(self, string): code = '' for c in string: code += self.get_symbol_code(self.symbols[c]) return code class LoginPage(Page): def on_loaded(self): for td in self.document.getroot().cssselect('td.LibelleErreur'): if td.text is None: continue msg = td.text.strip() if 'indisponible' in msg: raise BrowserUnavailable(msg) def login(self, login, password): try: vk=BNPVirtKeyboard(self) except VirtKeyboardError as err: self.logger.error("Error: %s"%err) return False # Mechanize does not recognize the form.. form = self.document.xpath('//form[@name="logincanalnet"]')[0] url = form.attrib['action'] params = {} for ctrl in form.findall('input'): params[ctrl.attrib['name']] = ctrl.attrib['value'] params['ch1'] = login.encode('iso-8859-1') params['ch5'] = vk.get_string_code(password) self.browser.location(url, urllib.urlencode(params)) class ConfirmPage(Page): def get_error(self): for td in self.document.xpath('//td[@class="hdvon1"]'): if td.text: return td.text.strip() return None def get_relocate_url(self): script = self.document.xpath('//script')[0] m = re.match('document.location.replace\("(.*)"\)', script.text[script.text.find('document.location.replace'):]) if m: return m.group(1) class InfoMessagePage(Page): def on_loaded(self): pass class ChangePasswordPage(Page): def change_password(self, current, new): try: vk=BNPVirtKeyboard(self) except VirtKeyboardError as err: self.logger.error("Error: %s"%err) return False from mechanize import Cookie c = Cookie(0, 'wbo_segment_369721', 'AA%7CAB%7C%7C%7C', None, False, '.secure.bnpparibas.net', True, True, '/', False, False, None, False, None, None, {}) cookiejar = self.browser._ua_handlers["_cookies"].cookiejar cookiejar.set_cookie(c) code_current=vk.get_string_code(current) code_new=vk.get_string_code(new) data = (('ch1', code_current), ('ch2', code_new), ('radiobutton3', 'radiobutton'), ('ch3', code_new), ('x', 23), ('y', 13), ) headers = {'Referer': self.url} #headers = {'Referer': "https://www.secure.bnpparibas.net/SAF_CHM?Action=SAF_CHM&Origine=SAF_CHM&stp=%s" % (int(datetime.now().strftime('%Y%m%d%H%M%S')))} #import time #time.sleep(10) request = self.browser.request_class('https://www.secure.bnpparibas.net/SAF_CHM_VALID', urllib.urlencode(data), headers) self.browser.location(request) weboob-1.1/modules/bnporc/deprecated/perso/messages.py000066400000000000000000000063471265717027300232200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Page, BrokenPageError from weboob.capabilities.messages import Message, Thread from weboob.capabilities.base import NotLoaded from weboob.tools.capabilities.messages.genericArticle import try_drop_tree import re from datetime import datetime from lxml.html import make_links_absolute class MessagesPage(Page): def iter_threads(self): table = self.parser.select(self.document.getroot(), 'table#listeMessages', 1) for tr in table.xpath('./tr'): if tr.attrib.get('class', '') not in ('msgLu', 'msgNonLu'): continue author = unicode(self.parser.select(tr, 'td.colEmetteur', 1).text) link = self.parser.select(tr, 'td.colObjet a', 1) date_raw = self.parser.select(tr, 'td.colDate1', 1).attrib['data'] jsparams = re.search('\((.+)\)', link.attrib['onclick']).groups()[0] jsparams = [i.strip('\'" ') for i in jsparams.split(',')] page_id, _id, unread = jsparams # this means unread on the website unread = False if unread == "false" else True # 2012/02/29:01h30min45sec dt_match = re.match('(\d+)/(\d+)/(\d+):(\d+)h(\d+)min(\d+)sec', date_raw).groups() dt_match = [int(d) for d in dt_match] thread = Thread(_id) thread._link_id = (page_id, unread) thread.date = datetime(*dt_match) thread.title = unicode(link.text) message = Message(thread, 0) message.set_empty_fields(None) message.flags = message.IS_HTML message.title = thread.title message.date = thread.date message.sender = author message.content = NotLoaded # This is the only thing we are missing thread.root = message yield thread class MessagePage(Page): def get_content(self): """ Get the message content. This page has a date, but it is less precise than the main list page, so we only use it for the message content. """ try: content = self.parser.select(self.document.getroot(), 'div.txtMessage div.contenu', 1) except BrokenPageError: # This happens with some old messages (2007) content = self.parser.select(self.document.getroot(), 'div.txtMessage', 1) content = make_links_absolute(content, self.url) try_drop_tree(self.parser, content, 'script') return self.parser.tostring(content) weboob-1.1/modules/bnporc/deprecated/perso/transactions.py000066400000000000000000000110001265717027300240770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.deprecated.browser import Page from weboob.tools.capabilities.bank.transactions import FrenchTransaction class Transaction(FrenchTransaction): PATTERNS = [(re.compile(u'^(?PCHEQUE)(?P.*)'), FrenchTransaction.TYPE_CHECK), (re.compile('^(?PFACTURE CARTE) DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*?)( CA?R?T?E? ?\d*X*\d*)?$'), FrenchTransaction.TYPE_CARD), (re.compile('^(?P(PRELEVEMENT|TELEREGLEMENT|TIP)) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?PPRLV( EUROPEEN)? SEPA) (?P.*?)( MDT/.*?)?( ECH/\d+)?( ID .*)?$'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?PECHEANCEPRET)(?P.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile('^(?PRETRAIT DAB) (?P
\d{2})/(?P\d{2})/(?P\d{2})( (?P\d+)H(?P\d+))?( \d+)? (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?PVIR(EMEN)?T? (RECU |FAVEUR )?(TIERS )?)\w+ \d+/\d+ \d+H\d+ \w+ (?P.*)$'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?PVIR(EMEN)?T? (EUROPEEN )?(SEPA )?(RECU |FAVEUR |EMIS )?(TIERS )?)(/FRM |/DE |/MOTIF |/BEN )?(?P.*?)(/.+)?$'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?PREMBOURST) CB DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?PREMBOURST)(?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?PCOMMISSIONS)(?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P(?PREMUNERATION).*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?PREMISE CHEQUES)(?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] class AccountHistory(Page): def iter_operations(self): for tr in self.document.xpath('//table[@id="tableCompte"]//tr'): if len(tr.xpath('td[@class="debit"]')) == 0: continue id = tr.find('td').find('input').attrib['id'].lstrip('_') op = Transaction(id) op.parse(date=tr.findall('td')[1].text, raw=tr.findall('td')[2].text.replace(u'\xa0', u'')) debit = tr.xpath('.//td[@class="debit"]')[0].text credit = tr.xpath('.//td[@class="credit"]')[0].text op.set_amount(credit, debit) yield op def iter_coming_operations(self): i = 0 for tr in self.document.xpath('//table[@id="tableauOperations"]//tr'): if 'typeop' in tr.attrib: tds = tr.findall('td') if len(tds) != 3: continue text = tds[1].text or u'' text = text.replace(u'\xa0', u'') for child in tds[1].getchildren(): if child.text: text += child.text if child.tail: text += child.tail i += 1 operation = Transaction(i) operation.parse(date=tr.attrib['dateop'], raw=text) operation.set_amount(tds[2].text) yield operation class AccountComing(AccountHistory): pass weboob-1.1/modules/bnporc/deprecated/perso/transfer.py000066400000000000000000000075621265717027300232350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.deprecated.browser import Page, BrowserPasswordExpired from weboob.tools.ordereddict import OrderedDict from weboob.capabilities.bank import TransferError class Account(object): def __init__(self, id, label, send_checkbox, receive_checkbox): self.id = id self.label = label self.send_checkbox = send_checkbox self.receive_checkbox = receive_checkbox class TransferPage(Page): def on_loaded(self): for td in self.document.xpath('//td[@class="hdvon1"]'): if td.text and 'Vous avez atteint le seuil de' in td.text: raise BrowserPasswordExpired(td.text.strip()) def get_accounts(self): accounts = OrderedDict() for table in self.document.getiterator('table'): if table.attrib.get('cellspacing') == '2': for tr in table.cssselect('tr.hdoc1, tr.hdotc1'): tds = tr.findall('td') id = tds[1].text.replace(u'\xa0', u'') label = tds[0].text if label is None and tds[0].find('nobr') is not None: label = tds[0].find('nobr').text send_checkbox = tds[4].find('input').attrib['value'] if tds[4].find('input') is not None else None receive_checkbox = tds[5].find('input').attrib['value'] if tds[5].find('input') is not None else None account = Account(id, label, send_checkbox, receive_checkbox) accounts[id] = account return accounts def transfer(self, from_id, to_id, amount, reason): accounts = self.get_accounts() # Transform RIBs to short IDs if len(str(from_id)) == 23: from_id = str(from_id)[5:21] if len(str(to_id)) == 23: to_id = str(to_id)[5:21] try: sender = accounts[from_id] except KeyError: raise TransferError('Account %s not found' % from_id) try: recipient = accounts[to_id] except KeyError: raise TransferError('Recipient %s not found' % to_id) if sender.send_checkbox is None: raise TransferError('Unable to make a transfer from %s' % sender.label) if recipient.receive_checkbox is None: raise TransferError('Unable to make a transfer to %s' % recipient.label) self.browser.select_form(nr=0) self.browser['C1'] = [sender.send_checkbox] self.browser['C2'] = [recipient.receive_checkbox] self.browser['T6'] = str(amount).replace('.', ',') if reason: self.browser['T5'] = reason.encode('utf-8') self.browser.submit() class TransferConfirmPage(Page): def on_loaded(self): for td in self.document.getroot().cssselect('td#size2'): raise TransferError(td.text.strip()) for a in self.document.getiterator('a'): m = re.match('/NSFR\?Action=VIRDA&stp=(\d+)', a.attrib['href']) if m: self.browser.location('/NS_VIRDA?stp=%s' % m.group(1)) return class TransferCompletePage(Page): def get_id(self): return self.group_dict['id'] weboob-1.1/modules/bnporc/deprecated/pro.py000066400000000000000000000126761265717027300210630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from urlparse import urlparse, parse_qsl from decimal import Decimal, InvalidOperation from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account from weboob.deprecated.browser import Page from .perso.transactions import Transaction class ProAccountsList(Page): COL_LABEL = 1 COL_ID = 2 COL_BALANCE = 3 COL_COMING = 5 def on_loaded(self): for msg in self.document.xpath('//div[@id="idMessageInfoUdC"]'): raise BrowserIncorrectPassword(self.parser.tocleanstring(msg)) def get_list(self, pro=True): accounts = [] for tr in self.document.xpath('//tr[@class="comptes"]'): cols = tr.findall('td') if len(cols) < 5: continue account = Account() account.id = self.parser.tocleanstring(cols[self.COL_ID]).replace(" ", "") account.label = self.parser.tocleanstring(cols[self.COL_LABEL]) account.balance = Decimal(self.parser.tocleanstring(cols[self.COL_BALANCE])) try: account.coming = Decimal(self.parser.tocleanstring(cols[self.COL_COMING])) except InvalidOperation: if self.parser.tocleanstring(cols[self.COL_COMING]) != '-': self.logger.warning('Unable to parse coming value', exc_info=True) account.coming = NotAvailable account._link_id = None account._stp = None a = cols[self.COL_LABEL].find('a') if a is not None: url = urlparse(a.attrib['href']) p = dict(parse_qsl(url.query)) account._link_id = p.get('ch4', None) account._stp = p.get('stp', None) for input_tag in tr.xpath('.//input[starts-with(@id, "urlRib")]'): m = re.search('ch4=(\w+)', input_tag.get('value', '')) if m: account.iban = unicode(m.group(1)) break else: select = tr.xpath('.//select//@onchange')[0] m = re.search("\(this,'(\w+)", select) if m: iban = unicode(m.group(1)) if iban.startswith('FR') and len(iban) == 27: account.iban = unicode(m.group(1)) accounts.append(account) # If there are also personnal accounts linked, display the page and iter on them. if pro and len(self.document.xpath('//div[@class="onglets"]//a[contains(@href, "afficherComptesPrives")]')) > 0: self.browser.select_form(name='myForm') self.browser.set_all_readonly(False) self.browser['udcAction'] = '/afficherComptesPrives' self.browser.submit() for a in self.browser.page.get_list(False): accounts.append(a) return accounts class ProAccountHistory(Page): COL_DATE = 0 COL_LABEL = 1 COL_DEBIT = -2 COL_CREDIT = -1 def on_loaded(self): # If transactions are ordered by type, force order by date. try: checkbox = self.document.xpath('//input[@name="szTriDate"]')[0] except IndexError: return if 'checked' not in checkbox.attrib: self.browser.select_form(name='formtri') self.browser['szTriDate'] = ['date'] self.browser['szTriRub'] = [] self.browser.submit() def iter_operations(self): for i, tr in enumerate(self.document.xpath('//tr[@class="hdoc1" or @class="hdotc1"]')): cols = tr.findall('td') if len(cols) < 4: continue op = Transaction(i) date = self.parser.tocleanstring(cols[self.COL_DATE]) raw = self.parser.tocleanstring(cols[self.COL_LABEL]) raw = re.sub(r'[ \xa0]+', ' ', raw).strip() op.parse(date=date, raw=raw) debit = self.parser.tocleanstring(cols[self.COL_DEBIT]) credit = self.parser.tocleanstring(cols[self.COL_CREDIT]) op.set_amount(credit, debit) yield op def iter_coming_operations(self): for i, tr in enumerate(self.document.xpath('//tr[@class="hdoc1" or @class="hdotc1"]')): cols = tr.findall('td') if len(cols) < 4: continue op = Transaction(i) date = self.parser.tocleanstring(cols[self.COL_DATE]) raw = self.parser.tocleanstring(cols[self.COL_LABEL]) raw = re.sub(r'[ \xa0]+', ' ', raw).strip() op.parse(date=date, raw=raw) credit = self.parser.tocleanstring(cols[self.COL_CREDIT]) op.set_amount(credit) yield op weboob-1.1/modules/bnporc/enterprise/000077500000000000000000000000001265717027300177555ustar00rootroot00000000000000weboob-1.1/modules/bnporc/enterprise/__init__.py000066400000000000000000000000001265717027300220540ustar00rootroot00000000000000weboob-1.1/modules/bnporc/enterprise/browser.py000066400000000000000000000075541265717027300220250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, AccountsPage, HistoryPage, UnknownPage __all__ = ['BNPEnterprise'] class BNPEnterprise(Browser): DOMAIN = 'entreprises.bnpparibas.net' PROTOCOL = 'https' CERTHASH = 'e0569d214f9f95a574baa8b9f189da42922bfded21d614fed43cdb21adb44999' PAGES = {'%s://%s/NSAccess.*' % (PROTOCOL, DOMAIN): LoginPage, '%s://%s/UNE\?.*' % (PROTOCOL, DOMAIN): AccountsPage, '%s://%s/ROP\?Action=F_RELCO.+' % (PROTOCOL, DOMAIN): HistoryPage, '%s://%s/RLOPI\?.+' % (PROTOCOL, DOMAIN): HistoryPage, '%s://%s/NSFR' % (PROTOCOL, DOMAIN): UnknownPage} def home(self): self.location('%s://%s/NSAccess' % (self.PROTOCOL, self.DOMAIN)) def is_logged(self): if self.page: if self.page.get_error() is not None: return False return not self.is_on_page(LoginPage) def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.password.isdigit() if not self.is_on_page(LoginPage): self.home() self.page.login(self.username, self.password) self.location('/UNE?ch6=0&ch8=2000&chA=1&chh=O', no_login=True) if not self.is_logged(): raise BrowserIncorrectPassword() def get_accounts_list(self): # options shows accounts in their original currency # it's the "en capitaux" mode, not sure if it's the best # the "en valeur" mode is ch8=1000 if not self.is_on_page(AccountsPage): self.location('/UNE?ch6=0&ch8=2000&chA=1&chh=O') for account in self.page.get_list(): yield account def get_account(self, _id): for a in self.get_accounts_list(): if a.id == _id: yield a def _get_history(self, url): numPage = 1 while numPage is not None: self.location(url + '&chP=%s' % numPage) for tr in self.page.iter_history(): yield tr nextNumPage = self.page.get_next_numpage() if nextNumPage is not None and nextNumPage <= numPage: self.logger.error("Currently on page %d, next page cannot be %d!" % (numPage, nextNumPage)) return numPage = nextNumPage def iter_history(self, account): if account._link_id is None: return iter([]) self.location('/ROP?Action=F_RELCO&ch4=%s&ch8=2000' % account._link_id) d1, d2 = self.page.get_date_range() return self._get_history('/ROP?Action=F_RELCO&ch4=%s&ch5=%s&ch9=%s&ch8=2000' % (account._link_id, d1, d2)) def iter_coming_operations(self, account): if account._link_id is None: return self.location('/RLOPI?chC=%s&ch8=0000' % account.id) d1, d2 = self.page.get_date_range() for tr in self._get_history('/RLOPI?chC=%s&ch8=0000&chB=1&ch7=%s&ch9=%s' % (account.id, d1, d2)): if tr._coming: yield tr def iter_investment(self, account): raise NotImplementedError() weboob-1.1/modules/bnporc/enterprise/pages.py000066400000000000000000000272441265717027300214370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal import hashlib from urlparse import parse_qs from datetime import datetime import re from weboob.capabilities.bank import Account from weboob.deprecated.browser import Page, BrokenPageError from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard, VirtKeyboardError from weboob.tools.misc import to_unicode class Transaction(FrenchTransaction): PATTERNS = [(re.compile(u'^(?PCHEQUE)(?P.*)'), FrenchTransaction.TYPE_CHECK), (re.compile('^(?PFACTURE CARTE) DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*?)( CA?R?T?E? ?\d*X*\d*)?$'), FrenchTransaction.TYPE_CARD), (re.compile('^(?P(PRELEVEMENT|TELEREGLEMENT|TIP)) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?PECHEANCEPRET)(?P.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile('^(?PRETRAIT DAB) (?P
\d{2})/(?P\d{2})/(?P\d{2})( (?P\d+)H(?P\d+))? (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?PVIR(EMEN)?T? ((RECU|FAVEUR) TIERS|SEPA RECU)?)( /FRM)?(?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?PREMBOURST) CB DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?PREMBOURST)(?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?PCOMMISSIONS)(?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P(?PREMUNERATION).*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?PREMISE CHEQUES)(?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] class BEPage(Page): def get_error(self): for title in self.document.xpath('/html/head/title'): if 'erreur' in title.text or 'error' in title.text: return self.parser.select(self.document.getroot(), '//input[@name="titre_page"]', 1, 'xpath').value class BNPVirtKeyboard(MappedVirtKeyboard): symbols = {'0': '97a2b5816f2db74851fe05afd17dc9fe', '1': '0a24fe3a35efeb0a89aa5e7b098e6842', '2': '65ff550debf85eacf8efaadd6cd80aa5', '3': '2bd67143fcd4207ac14d0ea8afdf4ebb', '4': 'a46bfd21636805a31a579b253c3b23d5', '5': '3f644894037255bc0feaba9abb1facfa', '6': '40d91064a749563fa4dd31fb52e880f0', '7': 'cd3af65da74d57df1e6a91ca946c09b7', '8': '85b718e032a02e887c757a7745a1f0bd', '9': 'c2cdc08c8c68855d83c0899d7e8c6719', '-1': 'd41d8cd98f00b204e9800998ecf8427e', } color = 45 def __init__(self, basepage): img = basepage.document.find("//img[@usemap='#MapGril']") imgdata = basepage.browser.openurl(img.attrib['src']) MappedVirtKeyboard.__init__(self, imgdata, basepage.document, img, self.color) self.check_symbols(self.symbols, basepage.browser.responses_dirname) def get_symbol_coords(self, coords): # strip borders x1, y1, x2, y2 = coords return MappedVirtKeyboard.get_symbol_coords(self, (x1+6, y1+1, x2-6, y2-4)) def get_symbol_code(self, md5sum): code = MappedVirtKeyboard.get_symbol_code(self, md5sum) code = code.split("'")[1] assert code.isdigit() return code def get_string_code(self, string): code = '' for c in string: code += self.get_symbol_code(self.symbols[c]) return code def checksum(self, coords): """Copy of parent checksum(), but cropping (removes empty lines)""" x1, y1, x2, y2 = coords s = '' for y in range(y1, min(y2 + 1, self.height)): for x in range(x1, min(x2 + 1, self.width)): if self.check_color(self.pixar[x, y]): s += " " else: s += "O" s += "\n" s = '\n'.join([l for l in s.splitlines() if l.strip()]) return hashlib.md5(s).hexdigest() class LoginPage(BEPage): def login(self, login, password): try: vk = BNPVirtKeyboard(self) except VirtKeyboardError as err: self.logger.error("Error: %s" % err) return False self.browser.select_form(name='ident') self.browser.set_all_readonly(False) self.browser['ch1'] = login.encode('iso-8859-1') self.browser['chgrille'] = vk.get_string_code(password) self.browser.submit() class AccountsPage(BEPage): TYPES = {u'Compte de chèques': Account.TYPE_CHECKING, } def find_table(self): for table in self.parser.select(self.document.getroot(), 'table', 'many'): for td in self.parser.select(table, 'tr td'): if td.text and td.text.strip().startswith('COMPTES '): return table def calculate_key(self, rib): table = dict((ord(a), b) for a, b in zip( u'abcdefghijklmnopqrstuvwxyz', u'12345678912345678923456789')) rib = rib.lower().translate(table) return 97 - (100 * int(rib)) % 97 def get_list(self): table = self.find_table() for tr in self.parser.select(table, 'tr', 'many'): tds = self.parser.select(tr, 'td') if len(tds) != 6: continue tdlabel, tdid, tdcur, tdupdated, tdbal, tdbalcur = tds account = Account() account.label = to_unicode(tdlabel.text_content().strip()) # this is important - and is also the last part of the id (considering spaces) # we can't use only the link as it does not goes where we want try: link = self.parser.select(tdlabel, 'a', 1) except BrokenPageError: # probably an account we can't display the history account._link_id = None else: account._link_id = parse_qs(link.attrib['href'])['ch4'][0] account.id = to_unicode(tdid.text.strip().replace(' ', '')) account.iban = 'FR76' + account.id if len(account.iban) == 25: # We miss the key at the end of iban account.iban = 'FR76' + account.id + str(self.calculate_key(account.id)) # just in case we are showing the converted balances account._main_currency = Account.get_currency(tdcur.text) # we have to ignore those accounts, because using NotAvailable # makes boobank and probably many others crash if tdbal.text_content().strip() == 'indisponible': continue account.balance = Decimal(Transaction.clean_amount(tdbal.text_content())) account.currency = Account.get_currency(tdbalcur.text) account.type = self.TYPES.get(account.label, Account.TYPE_UNKNOWN) account._updated = datetime.strptime(tdupdated.text, '%d/%m/%Y') yield account class HistoryPage(BEPage): def is_empty(self): for td in self.parser.select(self.document.getroot(), 'td.V11vertGras'): if u'Aucune opération enregistrée' in to_unicode(td.text_content()): return True return False def find_table(self): for table in self.parser.select(self.document.getroot(), 'table', 'many'): for td in self.parser.select(table, 'tr td'): if re.search('^OP.RATION', td.text_content().strip()): return table def get_date_range(self): try: radio = self.parser.select(self.document, '//input[@name="br_tout_date"]', 1, 'xpath') except BrokenPageError: input = self.document.xpath('//input[@name="chB"]')[0] d1, d2 = re.findall('(\d+/\d+/\d+)', input.tail) else: d1 = radio.attrib['value'][0:10] d2 = radio.attrib['value'][10:20] return (d1, d2) TXT2CONST = {u'DATE VALEUR': 'vdate', u'DATE D\'OPE': 'date', u'OP.RATION': 'label', u'D.BIT': 'debit', u'CR.DIT': 'credit', } def iter_history(self): if self.is_empty(): return columns = {'date': 0, 'vdate': 1, 'label': 2, 'debit': 3, 'credit': 4} table = self.find_table() for i, tr in enumerate(self.parser.select(table, 'tr', 'many')): tds = self.parser.select(tr, 'td') if len(tds) != 5: continue if self.parser.select(tr, 'td.thtitrefondbleu'): for i, td in enumerate(tds): txt = self.parser.tocleanstring(td) for part, const in self.TXT2CONST.iteritems(): if re.search(part, txt): columns[const] = i break continue tddate = self.parser.tocleanstring(tds[columns['date']]) tdval = self.parser.tocleanstring(tds[columns['vdate']]) tdlabel = self.parser.tocleanstring(tds[columns['label']]) tddebit = self.parser.tocleanstring(tds[columns['debit']]) tdcredit = self.parser.tocleanstring(tds[columns['credit']]) if all((tddate, tdlabel, any((tddebit, tdcredit)))): if tddebit: tdamount = '- %s' % tddebit else: tdamount = tdcredit t = Transaction() t.set_amount(tdamount) t.parse(tddate, tdlabel, tdval) t._coming = (tds[0].find('span') is not None) yield t def get_next_numpage(self): current = 1 m = re.search('chP=(\d+)', self.url) if m: current = int(m.group(1)) try: pages = self.parser.tocleanstring(self.document.xpath('.//td[contains(text(), "Page")]')[0]) except IndexError: # No pagination return None # We get list of all page numbers... pages = sorted(map(int, re.findall('(\d+)', pages))) try: # ...find position of the current page... curidx = pages.index(current) except ValueError: self.logger.warning('Unable to find the current page (%d)' % current) return None try: # ... and return number of the next page return pages[curidx+1] except IndexError: # Last page return None class UnknownPage(BEPage): pass weboob-1.1/modules/bnporc/favicon.png000066400000000000000000000121101265717027300177230ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME  xtEXtCommentCreated with GIMPWIDATxy]uu?wιӛbˠ4&A DK2XXPBWY]UZ&H*Q  Ȥ( {;oe}{gs~OqTK ?Tʻ6 $}?=yЊKA e% *jdV@_ jP ̏6(UbC%jDHAs N Z-Zd&j\yEU#%jE{dDTvd6(c_|Cr\8]h̗KBYԵδU,b|gO*> f2cS8>K\^_{ᝁC%^d&CFj5hv 2QIPCP~!!,/evk߹q]\u& _kmVPp[\ ZCRV-*/".Vq ]Pbu wp DjEQʫjn|X1S""B )ܭ9#ܮ.5JS5TSܻw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-~xɀX XĻ)љre4Ͽ\nx{q4w'AeҶ]^^`$e-3>v\RA仍oQ@Rf^Ŷ`kV0 l_?.vrtUK:Qz%㯺Lobp,:~ssIqyD;6!'39|eQs_Gx,h.@:'xcelh i6fţI,)psm;hQ!!X4 @4^3OS.|w5ZzvEӥt^0IN01DH":[UmG)(ڥH4炳p$Q\ w,2 uSMN3'Wx ɭ"B$3Z38Y\x;s_Q'N4ސ5J̉@- t8QQcSCT"Sp.?] ɜB\Mٔ!B\E!2ʰ ˰ 3"#ԥN(ԩ_?E_RȪ* Fg}OBJ%yҠp`&(_{>}Ve).4вv/ǰu6~5hQ&UYֻuPq*xx8 po^-r;$lq~`fsvAEH;EY[݋.[D|@~9u;~{O/0 *7MTPB[1doyGS G&>1 yCpl+nә:,nj2~#h!a|nܷX'RI%i_'/ urd\P9_̀ a {g9noE l~ZN18NVsLN5;H0VEFAb>>}6zV{L/v@皹\UTQM Kv$MKډSvZ| Sm܅-/Ҧqۛ4n{oqpl@ m$b~4VԔz[emKpڢqZq脵ly)-kT`b^&d_@bP\dFVmNeF I*ҷh17^^@AӍN/kˍf0 c31x%ljG.k DD ,յ}0~= qZa#W'*:iLjiW]I,Q#`gҿ*Β"d}KlhlQ1ުmIENDB`weboob-1.1/modules/bnporc/module.py000066400000000000000000000140761265717027300174440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal from datetime import datetime, timedelta from weboob.capabilities.bank import CapBank, AccountNotFound, Account, Recipient from weboob.capabilities.messages import CapMessages, Thread from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .deprecated.browser import BNPorc from .enterprise.browser import BNPEnterprise from .company.browser import BNPCompany from .pp.browser import BNPPartPro, HelloBank __all__ = ['BNPorcModule'] class BNPorcModule(Module, CapBank, CapMessages): NAME = 'bnporc' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'BNP Paribas' CONFIG = BackendConfig( ValueBackendPassword('login', label=u'Numéro client', masked=False), ValueBackendPassword('password', label=u'Code secret', regexp='^(\d{6}|)$'), #ValueBackendPassword('rotating_password', default='', # label='Password to set when the allowed uses are exhausted (6 digits)', # regexp='^(\d{6}|)$'), Value('website', label='Type de compte', default='pp', choices={'pp': 'Particuliers/Professionnels', 'hbank': 'HelloBank', 'ent': 'Entreprises', 'ppold': 'Particuliers/Professionnels (ancien site)', 'ent2': 'Entreprises et PME (nouveau site)'})) STORAGE = {'seen': []} # Store the messages *list* for this duration CACHE_THREADS = timedelta(seconds=3 * 60 * 60) def __init__(self, *args, **kwargs): Module.__init__(self, *args, **kwargs) self._threads = None self._threads_age = datetime.utcnow() def create_default_browser(self): b = {'ppold': BNPorc, 'ent': BNPEnterprise, 'ent2': BNPCompany, 'pp': BNPPartPro, 'hbank': HelloBank} self.BROWSER = b[self.config['website'].get()] return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): for account in self.browser.get_accounts_list(): yield account def get_account(self, _id): account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): return self.browser.iter_history(account) def iter_coming(self, account): return self.browser.iter_coming_operations(account) def iter_investment(self, account): return self.browser.iter_investment(account) def iter_transfer_recipients(self, ignored): if self.config['website'].get() != 'ppold': raise NotImplementedError() for account in self.browser.get_transfer_accounts().itervalues(): recipient = Recipient() recipient.id = account.id recipient.label = account.label yield recipient def transfer(self, account, to, amount, reason=None): if self.config['website'].get() != 'ppold': raise NotImplementedError() if isinstance(account, Account): account = account.id try: assert account.isdigit() assert to.isdigit() amount = Decimal(amount) except (AssertionError, ValueError): raise AccountNotFound() with self.browser: return self.browser.transfer(account, to, amount, reason) def iter_threads(self, cache=False): """ If cache is False, always fetch the threads from the website. """ old = self._threads_age < datetime.utcnow() - self.CACHE_THREADS threads = self._threads if not cache or threads is None or old: with self.browser: threads = list(self.browser.iter_threads()) # the website is stupid and does not have the messages in the proper order threads = sorted(threads, key=lambda t: t.date, reverse=True) self._threads = threads seen = self.storage.get('seen', default=[]) for thread in threads: if thread.id not in seen: thread.root.flags |= thread.root.IS_UNREAD else: thread.root.flags &= ~thread.root.IS_UNREAD yield thread def fill_thread(self, thread, fields=None): if fields is None or 'root' in fields: return self.get_thread(thread) def get_thread(self, _id): if self.config['website'].get() != 'ppold': raise NotImplementedError() if isinstance(_id, Thread): thread = _id _id = thread.id else: thread = Thread(_id) with self.browser: thread = self.browser.get_thread(thread) return thread def iter_unread_messages(self): if self.config['website'].get() != 'ppold': raise NotImplementedError() threads = list(self.iter_threads(cache=True)) for thread in threads: if thread.root.flags & thread.root.IS_UNREAD: thread = self.fillobj(thread) or thread yield thread.root def set_message_read(self, message): self.storage.get('seen', default=[]).append(message.thread.id) self.storage.save() OBJECTS = {Thread: fill_thread} weboob-1.1/modules/bnporc/pp/000077500000000000000000000000001265717027300162145ustar00rootroot00000000000000weboob-1.1/modules/bnporc/pp/__init__.py000066400000000000000000000000001265717027300203130ustar00rootroot00000000000000weboob-1.1/modules/bnporc/pp/browser.py000066400000000000000000000201631265717027300202530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2015 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import time from weboob.browser import LoginBrowser, URL, need_login from weboob.capabilities.base import find_object from weboob.capabilities.bank import AccountNotFound from weboob.tools.json import json from weboob.browser.exceptions import ServerError from .pages import LoginPage, AccountsPage, AccountsIBANPage, HistoryPage, TransferInitPage, \ ConnectionThresholdPage, LifeInsurancesPage, LifeInsurancesHistoryPage, \ LifeInsurancesDetailPage, MarketListPage, MarketPage, MarketHistoryPage, \ MarketSynPage __all__ = ['BNPPartPro', 'HelloBank'] class CompatMixin(object): def __enter__(self): return self def __exit__(self, type, value, tb): pass def JSON(data): return ('json', data) def isJSON(obj): return type(obj) is tuple and obj and obj[0] == 'json' class JsonBrowserMixin(object): def open(self, *args, **kwargs): if isJSON(kwargs.get('data')): kwargs['data'] = json.dumps(kwargs['data'][1]) if 'headers' not in kwargs: kwargs['headers'] = {} kwargs['headers']['Content-Type'] = 'application/json' return super(JsonBrowserMixin, self).open(*args, **kwargs) class BNPParibasBrowser(CompatMixin, JsonBrowserMixin, LoginBrowser): TIMEOUT = 30.0 login = URL(r'identification-wspl-pres/identification\?acceptRedirection=true×tamp=(?P\d+)', 'SEEA-pa01/devServer/seeaserver', 'https://mabanqueprivee.bnpparibas.net/fr/espace-prive/comptes-et-contrats\?u=%2FSEEA-pa01%2FdevServer%2Fseeaserver', LoginPage) con_threshold = URL('/fr/connexion/100-connexions', '/fr/connexion/mot-de-passe-expire', '/fr/espace-prive/100-connexions.*', '/fr/espace-pro/100-connexions-pro.*', '/fr/espace-client/100-connexions', '/fr/systeme/page-indisponible', ConnectionThresholdPage) accounts = URL('udc-wspl/rest/getlstcpt', AccountsPage) ibans = URL('rib-wspl/rpc/comptes', AccountsIBANPage) history = URL('rop-wspl/rest/releveOp', HistoryPage) transfer_init = URL('virement-wspl/rest/initialisationVirement', TransferInitPage) lifeinsurances = URL('mefav-wspl/rest/infosContrat', LifeInsurancesPage) lifeinsurances_history = URL('mefav-wspl/rest/listMouvements', LifeInsurancesHistoryPage) lifeinsurances_detail = URL('mefav-wspl/rest/detailMouvement', LifeInsurancesDetailPage) market_list = URL('pe-war/rpc/SAVaccountDetails/get', MarketListPage) market_syn = URL('pe-war/rpc/synthesis/get', MarketSynPage) market = URL('pe-war/rpc/portfolioDetails/get', MarketPage) market_history = URL('/pe-war/rpc/turnOverHistory/get', MarketHistoryPage) def do_login(self): timestamp = lambda: int(time.time() * 1e3) self.login.go(timestamp=timestamp()) if self.login.is_here(): self.page.login(self.username, self.password) @need_login def get_accounts_list(self): ibans = self.ibans.go().get_ibans_dict() ibans.update(self.transfer_init.go(data=JSON({'restitutionVF': 1, 'type': 'TOUS'})).get_ibans_dict()) accounts = self.accounts.go().iter_accounts(ibans) self.market_syn.go(data=JSON({})) for account in accounts: for market_acc in self.page.get_list(): if account.label == market_acc['securityAccountName']: account.valuation_diff = market_acc['profitLoss'] break yield account @need_login def get_account(self, _id): return find_object(self.get_accounts_list(), id=_id, error=AccountNotFound) @need_login def iter_history(self, account, coming=False): if account.type == account.TYPE_LIFE_INSURANCE: return self.iter_lifeinsurance_history(account, coming) elif account.type == account.TYPE_MARKET and not coming: try: self.page = self.market_list.go(data=JSON({})) except ServerError: self.logger.warning("An Internal Server Error occured") return iter([]) for market_acc in self.page.get_list(): if account.label == market_acc['securityAccountName']: self.page = self.market_history.go(data=JSON({ "securityAccountNumber": market_acc['securityAccountNumber'], })) return self.page.iter_history() return iter([]) else: self.page = self.history.go(data=JSON({ "ibanCrypte": account.id, "pastOrPending": 1, "triAV": 0, "startDate": None, "endDate": None })) return self.page.iter_coming() if coming else self.page.iter_history() @need_login def iter_lifeinsurance_history(self, account, coming=False): self.page = self.lifeinsurances_history.go(data=JSON({ "ibanCrypte": account.id, })) for tr in self.page.iter_history(coming): page = self.lifeinsurances_detail.go(data=JSON({ "ibanCrypte": account.id, "idMouvement": tr._op.get('idMouvement'), "ordreMouvement": tr._op.get('ordreMouvement'), "codeTypeMouvement": tr._op.get('codeTypeMouvement'), })) tr.investments = list(page.iter_investments()) yield tr @need_login def iter_coming_operations(self, account): return self.iter_history(account, coming=True) @need_login def iter_investment(self, account): if account.type == account.TYPE_LIFE_INSURANCE: self.page = self.lifeinsurances.go(data=JSON({ "ibanCrypte": account.id, })) return self.page.iter_investments() elif account.type == account.TYPE_MARKET: try: self.page = self.market_list.go(data=JSON({})) except ServerError: self.logger.warning("An Internal Server Error occured") return iter([]) for market_acc in self.page.get_list(): if account.label == market_acc['securityAccountName']: # Sometimes generate an Internal Server Error ... try: self.page = self.market.go(data=JSON({ "securityAccountNumber": market_acc['securityAccountNumber'], })) except ServerError: self.logger.warning("An Internal Server Error occured") break return self.page.iter_investments() return iter([]) @need_login def get_transfer_accounts(self): raise NotImplementedError() @need_login def transfer(self, account, to, amount, reason): raise NotImplementedError() @need_login def iter_threads(self): raise NotImplementedError() @need_login def get_thread(self, thread): raise NotImplementedError() class BNPPartPro(BNPParibasBrowser): BASEURL_TEMPLATE = r'https://%s.bnpparibas/' BASEURL = BASEURL_TEMPLATE % 'mabanque' def switch(self, subdomain): self.BASEURL = self.BASEURL_TEMPLATE % subdomain class HelloBank(BNPParibasBrowser): BASEURL = 'https://www.hellobank.fr/' weboob-1.1/modules/bnporc/pp/pages.py000066400000000000000000000363601265717027300176750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2015 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from cStringIO import StringIO from random import randint from decimal import Decimal from datetime import datetime from weboob.browser.pages import JsonPage, LoggedPage, HTMLPage from weboob.tools.captcha.virtkeyboard import GridVirtKeyboard from weboob.capabilities.bank import Account, Investment from weboob.capabilities import NotAvailable from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable from weboob.tools.json import json from weboob.tools.date import parse_french_date as Date class ConnectionThresholdPage(HTMLPage): def change_pass(self, oldpass, newpass): res = self.browser.open('/identification-wspl-pres/grille?accessible=false') url = '/identification-wspl-pres/grille/%s' % res.json()['data']['idGrille'] keyboard = self.browser.open(url) vk = BNPKeyboard(self, keyboard) data = {} data['codeAppli'] = 'PORTAIL' data['idGrille'] = res.json()['data']['idGrille'] data['typeGrille'] = res.json()['data']['typeGrille'] data['confirmNouveauPassword'] = vk.get_string_code(newpass) data['nouveauPassword'] = vk.get_string_code(newpass) data['passwordActuel'] = vk.get_string_code(oldpass) self.browser.location('/mcs-wspl/rpc/modifiercodesecret', data=data) def on_load(self): new_pass = ''.join([str((int(l) + 1) % 10) for l in self.browser.password]) self.logger.warning('Password expired. Renewing it...') self.change_pass(self.browser.password, new_pass) self.change_pass(new_pass, self.browser.password) def cast(x, typ, default=None): try: return typ(x or default) except ValueError: return default class BNPKeyboard(GridVirtKeyboard): color = (0x1f, 0x27, 0x28) margin = 3, 3 symbols = {'0': '43b2227b92e0546d742a1f087015e487', '1': '2914e8cc694de26756096d0d0d4c6e0f', '2': 'aac54304a7bb850805d29f54557be366', '3': '0376d9f8419efee42e253d195a152547', '4': '3719595f15b1ac1c5a73d84aa290b5f6', '5': '617597f07a6530479927536671485439', '6': '4f5dce7bd0d9213fdae54b79bb8dd33a', '7': '49e07fa52b9bcee798f3a663f86e6cc1', '8': 'c60b723b3d95a46416b34c2cbefba3ed', '9': 'a13b8c3617a7bf854590833ddfb97f1f'} def __init__(self, page, image): symbols = list('%02d' % x for x in range(1, 11)) super(BNPKeyboard, self).__init__(symbols, 5, 2, StringIO(image.content), self.color, convert='RGB') self.check_symbols(self.symbols, page.browser.responses_dirname) class LoginPage(JsonPage): @staticmethod def render_template(tmpl, **values): for k, v in values.iteritems(): tmpl = tmpl.replace('{{ ' + k + ' }}', v) return tmpl @staticmethod def generate_token(length=11): chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz' return ''.join((chars[randint(0, len(chars)-1)] for _ in xrange(length))) def build_doc(self, text): try: return super(LoginPage, self).build_doc(text) except json.JSONDecodeError: # XXX When login is successful, server sends HTML instead of JSON, # we can ignore it. return {} def on_load(self): if self.url.startswith('https://mabanqueprivee.'): self.browser.switch('mabanqueprivee') error = cast(self.get('errorCode'), int, 0) if error: codes = [201, 21510, 203, 202, 1001] msg = self.get('message') if error in codes: raise BrowserIncorrectPassword(msg) self.logger.debug('Unexpected error at login: "%s" (code=%s)' % (msg, error)) def login(self, username, password): url = '/identification-wspl-pres/grille/%s' % self.get('data.grille.idGrille') keyboard = self.browser.open(url) vk = BNPKeyboard(self, keyboard) target = self.browser.BASEURL + 'SEEA-pa01/devServer/seeaserver' user_agent = self.browser.session.headers.get('User-Agent') or '' auth = self.render_template(self.get('data.authTemplate'), idTelematique=username, password=vk.get_string_code(password), clientele=user_agent) # XXX useless ? csrf = self.generate_token() response = self.browser.location(target, data={'AUTH': auth, 'CSRF': csrf}) if response.url.startswith('https://pro.mabanque.bnpparibas'): self.browser.switch('pro.mabanque') if response.url.startswith('https://banqueprivee.mabanque.bnpparibas'): self.browser.switch('banqueprivee.mabanque') class BNPPage(LoggedPage, JsonPage): def build_doc(self, text): try: return json.loads(text, parse_float=Decimal) except ValueError: raise BrowserUnavailable() def on_load(self): code = cast(self.get('codeRetour'), int, 0) if code == -30: self.logger.debug('End of session detected, try to relog...') self.browser.do_login() elif code: self.logger.debug('Unexpected error: "%s" (code=%s)' % (self.get('message'), code)) class AccountsPage(BNPPage): FAMILY_TO_TYPE = { 1: Account.TYPE_CHECKING, 2: Account.TYPE_SAVINGS, 3: Account.TYPE_DEPOSIT, 4: Account.TYPE_MARKET, 5: Account.TYPE_LIFE_INSURANCE, 6: Account.TYPE_LIFE_INSURANCE, 8: Account.TYPE_LOAN, 9: Account.TYPE_LOAN, } def iter_accounts(self, ibans): for f in self.path('data.infoUdc.familleCompte.*'): for a in f.get('compte'): yield Account.from_dict({ 'id': a.get('key'), 'label': a.get('libellePersoProduit') or a.get('libelleProduit'), 'currency': a.get('devise'), 'type': self.FAMILY_TO_TYPE.get(f.get('idFamilleCompte')) or Account.TYPE_UNKNOWN, 'balance': a.get('soldeDispo'), 'coming': a.get('soldeAVenir'), 'iban': ibans.get(a.get('key')), 'number': a.get('value') }) class AccountsIBANPage(BNPPage): def get_ibans_dict(self): return dict([(a['ibanCrypte'], a['iban']) for a in self.path('data.listeRib.*.infoCompte')]) class TransferInitPage(BNPPage): def get_ibans_dict(self): return dict([(a['ibanCrypte'], a['iban']) for a in self.path('data.infoVirement.listeComptesCrediteur.*')]) class Transaction(FrenchTransaction): PATTERNS = [(re.compile(u'^(?PCHEQUE)(?P.*)'), FrenchTransaction.TYPE_CHECK), (re.compile('^(?PFACTURE CARTE) DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*?)( CA?R?T?E? ?\d*X*\d*)?$'), FrenchTransaction.TYPE_CARD), (re.compile('^(?P(PRELEVEMENT|TELEREGLEMENT|TIP)) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?PPRLV( EUROPEEN)? SEPA) (?P.*?)( MDT/.*?)?( ECH/\d+)?( ID .*)?$'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?PECHEANCEPRET)(?P.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile('^(?PRETRAIT DAB) (?P
\d{2})/(?P\d{2})/(?P\d{2})( (?P\d+)H(?P\d+))?( \d+)? (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?PVIR(EMEN)?T? (RECU |FAVEUR )?(TIERS )?)\w+ \d+/\d+ \d+H\d+ \w+ (?P.*)$'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?PVIR(EMEN)?T? (EUROPEEN )?(SEPA )?(RECU |FAVEUR |EMIS )?(TIERS )?)(/FRM |/DE |/MOTIF |/BEN )?(?P.*?)(/.+)?$'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?PREMBOURST) CB DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?PREMBOURST)(?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?PCOMMISSIONS)(?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P(?PREMUNERATION).*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?PREMISE CHEQUES)(?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] class HistoryPage(BNPPage): CODE_TO_TYPE = { 1: Transaction.TYPE_CHECK, # Chèque émis 2: Transaction.TYPE_CHECK, # Chèque reçu 3: Transaction.TYPE_CASH_DEPOSIT, # Versement espèces 4: Transaction.TYPE_ORDER, # Virements reçus 5: Transaction.TYPE_ORDER, # Virements émis 6: Transaction.TYPE_LOAN_PAYMENT, # Prélèvements / amortissements prêts 7: Transaction.TYPE_CARD, # Paiements carte, 8: Transaction.TYPE_CARD, # Carte / Formule BNP Net, 9: Transaction.TYPE_UNKNOWN, # Opérations Titres 10: Transaction.TYPE_UNKNOWN, # Effets de Commerce 11: Transaction.TYPE_WITHDRAWAL, # Retraits d'espèces carte 12: Transaction.TYPE_UNKNOWN, # Opérations avec l'étranger 13: Transaction.TYPE_CARD, # Remises Carte 14: Transaction.TYPE_WITHDRAWAL, # Retraits guichets 15: Transaction.TYPE_BANK, # Intérêts/frais et commissions 16: Transaction.TYPE_UNKNOWN, # Tercéo 30: Transaction.TYPE_UNKNOWN, # Divers } COMING_TYPE_TO_TYPE = { 2: Transaction.TYPE_ORDER, # Prélèvement 3: Transaction.TYPE_CHECK, # Chèque 4: Transaction.TYPE_CARD, # Opération carte } def one(self, path, context=None): try: return list(self.path(path, context))[0] except IndexError: return None def iter_history(self): for op in self.get('data.listerOperations.compte.operationPassee') or []: codeFamille = cast(self.one('operationType.codeFamille', op), int) tr = Transaction.from_dict({ 'id': op.get('idOperation'), 'type': self.CODE_TO_TYPE.get(codeFamille) or Transaction.TYPE_UNKNOWN, 'category': op.get('categorie'), 'amount': self.one('montant.montant', op), }) tr.parse(raw=op.get('libelleOperation'), date=Date(op.get('dateOperation')), vdate=Date(self.one('montant.valueDate', op))) yield tr def iter_coming(self): for op in self.path('data.listerOperations.compte.operationAvenir.*.operation.*'): codeOperation = cast(op.get('codeOperation'), int, 0) # Coming transactions don't have real id tr = Transaction.from_dict({ 'type': self.COMING_TYPE_TO_TYPE.get(codeOperation) or Transaction.TYPE_UNKNOWN, 'amount': op.get('montant'), 'card': op.get('numeroPorteurCarte'), }) tr.parse(date=Date(op.get('dateOperation')), vdate=Date(op.get('valueDate')), raw=op.get('libelle')) yield tr class LifeInsurancesPage(BNPPage): investments_path = 'data.infosContrat.repartition.listeSupport.*' def iter_investments(self): for support in self.path(self.investments_path): inv = Investment() if 'codeIsin' in support: inv.code = inv.id = support['codeIsin'] inv.quantity = support['nbUC'] inv.unitvalue = support['valUC'] inv.label = support['libelle'] inv.valuation = support['montant'] inv.set_empty_fields(NotAvailable) yield inv class LifeInsurancesHistoryPage(BNPPage): def iter_history(self, coming): for op in self.get('data.listerMouvements.listeMouvements') or []: #We have not date for this statut so we just skit it if op.get('statut') == u'En cours': continue tr = Transaction.from_dict({ 'type': Transaction.TYPE_BANK, '_state': op.get('statut'), 'amount': op.get('montantNet'), }) tr.parse(date=Date(op.get('dateSaisie')), vdate=Date(op.get('dateEffet')), raw='%s %s' % (op.get('libelleMouvement'), op.get('canalSaisie') or '')) tr._op = op if (op.get('statut') == u'Traité') ^ coming: yield tr class LifeInsurancesDetailPage(LifeInsurancesPage): investments_path = 'data.detailMouvement.listeSupport.*' class MarketListPage(BNPPage): def get_list(self): return self.get('securityAccountsList') or [] class MarketSynPage(BNPPage): def get_list(self): return self.get('synSecurityAccounts') or [] class MarketPage(BNPPage): investments_path = 'listofPortfolios.*' def iter_investments(self): for support in self.path(self.investments_path): inv = Investment() inv.code = inv.id = support['securityCode'] inv.quantity = support['quantityOwned'] inv.unitvalue = support['currentQuote'] inv.unitprice = support['averagePrice'] inv.label = support['securityName'] inv.valuation = support['valorizationValuation'] inv.diff = support['profitLossValorisation'] inv.set_empty_fields(NotAvailable) yield inv class MarketHistoryPage(BNPPage): def iter_history(self): for op in self.get('contentList') or []: tr = Transaction.from_dict({ 'type': Transaction.TYPE_BANK, 'amount': op.get('movementAmount'), 'date': datetime.fromtimestamp(op.get('movementDate') / 1000), 'label': op.get('operationName'), }) tr.investments = [] inv = Investment() inv.code = op.get('securityCode') inv.quantity = op.get('movementQuantity') inv.label = op.get('securityName') inv.set_empty_fields(NotAvailable) tr.investments.append(inv) yield tr weboob-1.1/modules/bnporc/test.py000066400000000000000000000023441265717027300171310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from random import choice class BNPorcTest(BackendTest): MODULE = 'bnporc' def test_bank(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_coming(a)) list(self.backend.iter_history(a)) def test_msgs(self): threads = list(self.backend.iter_threads()) thread = self.backend.fillobj(choice(threads), ['root']) assert len(thread.root.content) weboob-1.1/modules/boursorama/000077500000000000000000000000001265717027300164645ustar00rootroot00000000000000weboob-1.1/modules/boursorama/__init__.py000066400000000000000000000015201265717027300205730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Gabriel Kerneis # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BoursoramaModule __all__ = ['BoursoramaModule'] weboob-1.1/modules/boursorama/browser.py000066400000000000000000000156571265717027300205370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gabriel Serme # Copyright(C) 2011 Gabriel Kerneis # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from collections import defaultdict from weboob.deprecated.browser import StateBrowser, BrowserIncorrectPassword from weboob.capabilities.bank import Account from .pages import (LoginPage, ProfilIncomplete, AccountsList, AccountHistory, CardHistory, UpdateInfoPage, AuthenticationPage, AccountLifeInsurance, AccountMarket, InvestmentDetail, LifeInsuranceHistory, NewWebsitePage) __all__ = ['Boursorama'] class BrowserIncorrectAuthenticationCode(BrowserIncorrectPassword): pass class Boursorama(StateBrowser): DOMAIN = 'www.boursorama.com' PROTOCOL = 'https' CERTHASH = ['6bdf8b6dd177bd417ddcb1cfb818ede153288e44115eb269f2ddd458c8461039', 'b290ef629c88f0508e9cc6305421c173bd4291175e3ddedbee05ee666b34c20e', '22418bc2676cac139aaf64cb36d14f4ad845ade64acbbd729463ef78cbe96b3e'] ENCODING = None # refer to the HTML encoding PAGES = {r'.*/connexion/securisation.*': AuthenticationPage, r'.*connexion.phtml.*': LoginPage, r'.*/connexion/profil-incomplet.phtml.*': ProfilIncomplete, r'.*/comptes/synthese.phtml': AccountsList, r'.*/comptes/banque/detail/mouvements.phtml.*': AccountHistory, r'.*/comptes/banque/cartes/mouvements.phtml.*': CardHistory, r'.*/comptes/assurancevie/mouvements.phtml.*': LifeInsuranceHistory, r'.*/comptes/epargne/mouvements.phtml.*': AccountHistory, r'.*/date_anniversaire.phtml.*': UpdateInfoPage, r'.*/detail.phtml.*': AccountLifeInsurance, r'.*/opcvm.phtml.*': InvestmentDetail, r'.*/bourse/trackers/etf.phtml.*': InvestmentDetail, r'.*/positions_engagements.phtml.*': AccountMarket, r'https://clients.boursorama.com/': NewWebsitePage, } __states__ = ('auth_token',) def __init__(self, config=None, *args, **kwargs): self.config = config self.auth_token = None kwargs['username'] = self.config['login'].get() kwargs['password'] = self.config['password'].get() StateBrowser.__init__(self, *args, **kwargs) def home(self): if not self.is_logged(): self.login() else: self.location('https://' + self.DOMAIN + '/comptes/synthese.phtml') def is_logged(self): return self.page is not None and not self.is_on_page(LoginPage) def handle_authentication(self): if self.is_on_page(AuthenticationPage): if self.config['enable_twofactors'].get(): self.page.send_sms() else: raise BrowserIncorrectAuthenticationCode( """Boursorama - activate the two factor authentication in boursorama config.""" """ You will receive SMS code but are limited in request per day (around 15)""" ) def login(self): assert isinstance(self.config['device'].get(), basestring) assert isinstance(self.config['enable_twofactors'].get(), bool) assert self.password.isdigit() if self.auth_token and self.config['pin_code'].get(): AuthenticationPage.authenticate(self) else: if not self.is_on_page(LoginPage): self.location('https://' + self.DOMAIN + '/connexion.phtml', no_login=True) self.page.login(self.username, self.password) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() #after login, we might be redirected to the two factor #authentication page self.handle_authentication() self.location('/comptes/synthese.phtml', no_login=True) #if the login was correct but authentication code failed, #we need to verify if bourso redirect us to login page or authentication page if self.is_on_page(LoginPage): raise BrowserIncorrectAuthenticationCode('Invalid PIN code') def get_accounts_list(self): if self.is_on_page(AuthenticationPage): self.login() if not self.is_on_page(AccountsList): self.location('/comptes/synthese.phtml') accounts = list(self.page.get_list()) for account in accounts: if account.type == Account.TYPE_LIFE_INSURANCE: self.location(account._detail_url) self.page.get_valuation_diff(account) return iter(accounts) def get_account(self, id): assert isinstance(id, basestring) if not self.is_on_page(AccountsList): self.location('/comptes/synthese.phtml') l = self.page.get_list() for a in l: if a.id == id: return a return None def get_history(self, account): link = account._link_id while link is not None: self.location(link) if not self.is_on_page(AccountHistory) and not self.is_on_page(CardHistory) and not self.is_on_page(LifeInsuranceHistory): raise NotImplementedError() for tr in self.page.get_operations(): yield tr link = self.page.get_next_url() def get_investment(self, account): if account.type not in (Account.TYPE_LIFE_INSURANCE, Account.TYPE_MARKET) or not account._detail_url: raise NotImplementedError() self.location(account._detail_url) seen = defaultdict(int) def slugify(label): label = label.upper().replace('FONDS EN EUROS (', '')[:12] slug = re.sub(r'[^A-Za-z0-9]', ' ', label).strip() slug = re.sub(r'\s+', '-', slug) if label in seen: counter = str(seen[label]) slug = slug[:-len(counter)] + counter seen[label] += 1 return slug for inv in self.page.get_investment(): if inv._detail_url: self.location(inv._detail_url) self.page.get_investment_detail(inv) if not inv.id: inv.id = inv.code = 'XX' + slugify(inv.label) yield inv def transfer(self, from_id, to_id, amount, reason=None): raise NotImplementedError() weboob-1.1/modules/boursorama/favicon.png000066400000000000000000000032271265717027300206230ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDVKV pHYs  tIME DSStEXtCommentCreated with GIMPWIDATx[lU]nCP.!AAD1^tD}1xK(a4 4*IF%SPPhׇ6Ιefɶ={|绝YȔ{ӱ ,VV`0h `8dBfcʆ V`*0^u|(t: mJcXAI& *m$ww4t) (p(Ux9,F`p{}5JA hPGo]_]Cg“?r,,$ Nr _L)!ϒkH=G^>Dz nT/pmsv w$u~Xv[[ oAA00:uvm°,Hd9T|xyKSGv!Sq @u6hh4gE@f+ c ±@vCmձ~dEA78TV_ eIF`pDުcEricRvvpBB=+[ QNb4!59ݜjfqB'@Uw _xݮ`uJ7oK0~KkR$H32;3)ۀ;(KxꕤXG]XxqzUg*T X2 ep~oh 3 _<^$0%y=a%aaє/nIO*Y`P jPK܊RJqEdȴ"*0 D@!  |~M.Y^U{]oZ4KnP"qg(SQ $B+`X1w5si[MHOE)ΧR# o9Qsi@ Bv ~X.{wH~4ciX1]7=sL;Փ(yH<&\ } hfJؗyXc'ޒ<7"E^"y@r:%1O2RXKZS"`f)=bO'vX i`nغ1o4"ZC5w,j}1K Q鬧U;-e%Fપ|y1[O1v 3(ʮj#r(l2EI1~)U-Y)o#~jv`+D-.]5V~,psREr_C΋kMQ2Jm5V1oؘ)Ws2L^cݪ-7U[+gҮJMg_(!No:v{zDz(7H+p~_mnn.#x/IENDB`weboob-1.1/modules/boursorama/module.py000066400000000000000000000045251265717027300203310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gabriel Serme # Copyright(C) 2011 Gabriel Kerneis # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, ValueBool, Value from .browser import Boursorama __all__ = ['BoursoramaModule'] class BoursoramaModule(Module, CapBank): NAME = 'boursorama' MAINTAINER = u'Gabriel Kerneis' EMAIL = 'gabriel@kerneis.info' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Boursorama' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe'), ValueBool('enable_twofactors', label='Send validation sms', default=False), Value('device', label='Device name', regexp='\w*', default=''), Value('pin_code', label='Sms code', required=False), ) BROWSER = Boursorama def create_default_browser(self): return self.create_browser(self.config) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): return self.browser.get_history(account) def iter_investment(self, account): return self.browser.get_investment(account) weboob-1.1/modules/boursorama/pages/000077500000000000000000000000001265717027300175635ustar00rootroot00000000000000weboob-1.1/modules/boursorama/pages/__init__.py000066400000000000000000000030621265717027300216750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Gabriel Kerneis # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .account_history import AccountHistory from .card_history import CardHistory from .accounts_list import AccountsList from .login import LoginPage, ProfilIncomplete, UpdateInfoPage, NewWebsitePage from .two_authentication import AuthenticationPage from .investment import AccountMarket, AccountLifeInsurance, InvestmentDetail from .lifeinsurance_history import LifeInsuranceHistory class AccountPrelevement(AccountsList): pass __all__ = ['LoginPage', 'ProfilIncomplete', 'AccountsList', 'AccountHistory', 'CardHistory', 'UpdateInfoPage', 'AuthenticationPage', 'AccountMarket', 'AccountLifeInsurance', 'InvestmentDetail', 'LifeInsuranceHistory', 'NewWebsitePage', ] weboob-1.1/modules/boursorama/pages/account_history.py000066400000000000000000000064161265717027300233610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Gabriel Kerneis # Copyright(C) 2009-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from urlparse import urlparse import re from weboob.deprecated.browser import Page from weboob.tools.capabilities.bank.transactions import FrenchTransaction class Transaction(FrenchTransaction): PATTERNS = [(re.compile(u'^CHQ\. (?P.*)'), FrenchTransaction.TYPE_CHECK), (re.compile('^(ACHAT|PAIEMENT) CARTE (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile('^(PRLV|TIP) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^RETRAIT DAB (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^VIR( SEPA)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^AVOIR (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^REM CHQ (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] class AccountHistory(Page): def get_operations(self): for form in self.document.xpath('//form[@name="marques"]'): for tr in form.xpath('.//tbody/tr'): if 'total' in tr.attrib.get('class', '') or 'style' in tr.attrib: continue date = self.parser.tocleanstring(tr.cssselect('td.operation span.DateOperation')[0]) span = tr.cssselect('td.operation span, td.operation a')[-1] # remove links for font in span.xpath('./font'): font.drop_tree() label = self.parser.tocleanstring(span) amount = self.parser.tocleanstring(tr.cssselect('td.amount')[0]) operation = Transaction() operation.parse(date=date, raw=label) operation.set_amount(amount) yield operation def get_next_url(self): items = self.document.getroot().cssselect('ul.menu-lvl-0 li') current = False for li in reversed(items): if li.attrib.get('class', '') == 'active': current = True elif current: a = li.find('a') if 'year' in a.attrib.get('href', ''): url = urlparse(self.url) return url.path + a.attrib['href'] else: return None weboob-1.1/modules/boursorama/pages/accounts_list.py000066400000000000000000000143441265717027300230150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Gabriel Kerneis # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from decimal import Decimal from weboob.capabilities.bank import Account from weboob.deprecated.browser import Page from weboob.tools.capabilities.bank.transactions import FrenchTransaction class AccountsList(Page): ACCOUNT_TYPES = {u'banque': Account.TYPE_CHECKING, u'épargne': Account.TYPE_SAVINGS, u'crédit': Account.TYPE_LOAN, u'assurance vie': Account.TYPE_LIFE_INSURANCE, u'bourse': Account.TYPE_MARKET, } def get_list(self): blocks = self.document.xpath('//div[@id="synthese-list"]//div[@class="block"]') for div in blocks: block_title = ''.join(div.xpath('.//span[@class="title"]/a/text()')).lower().strip() if block_title == 'assurance': # Only promotional fake accounts... continue for tr in div.getiterator('tr'): account = Account() account.id = None account._link_id = None account.type = self.ACCOUNT_TYPES.get(block_title, Account.TYPE_UNKNOWN) for td in tr.getiterator('td'): if td.get('class', '') == 'account-cb': try: a = td.xpath('./*/a[@class="gras"]')[0] except IndexError: # ignore account break account.type = Account.TYPE_CARD account.label, account.id = [s.strip() for s in self.parser.tocleanstring(td).rsplit('-', 1)] # Those cards immediately debits transactions on the linked checking account, so we ignore those accounts to avoid doubled transactions. if 'DEBIT IMMEDIAT' in account.label: break # Sometimes there is text after the card number: # # CARTE PREMIER #
MACHIN BIDULE TRUC - 1111********1111 # #
# Son échéance est le 31/03/2015.
En savoir plus
# So we have to remove all the shit after it. account.id = account.id.split(' ')[0] try: account._link_id = td.xpath('.//a')[0].get('href') # Try to use account._link_id for account.id to prevent duplicate accounts currentCB = re.search('currentCB=(.*)', account._link_id) if currentCB: account.id = currentCB.group(1) except KeyError: pass elif td.get('class', '') == 'account-name': try: span = td.xpath('./span[@class="label"]')[0] except IndexError: # ignore account break account.label = self.parser.tocleanstring(span) account.id = self.parser.tocleanstring(td).rsplit('-', 1)[-1].strip() try: account._link_id = td.xpath('.//a[not(./small[contains(@class, "icon")])]')[0].get('href') if 'souscription' in account._link_id: account._link_id = td.xpath('.//a')[1].get('href') account._detail_url = account._link_id except KeyError: pass elif td.get('class', '') == 'account-more-actions': for a in td.getiterator('a'): # For normal account, two "account-more-actions" # One for the account, one for the credit card. Take the good one if 'href' in a.attrib and "mouvements.phtml" in a.get('href') and "/cartes/" not in a.get('href'): account._link_id = a.get('href') elif td.get('class', '') == 'account-number': id = td.text id = id.strip(u' \n\t') account.id = id elif td.get('class', '') == 'account-total': span = td.find('span') if span is None: balance = td.text else: balance = span.text account.currency = account.get_currency(balance) balance = FrenchTransaction.clean_amount(balance) if balance != "": account.balance = Decimal(balance) else: account.balance = Decimal(0) else: # because of some weird useless if account.id is not None and (not account._link_id or 'moneycenter' not in account._link_id): yield account weboob-1.1/modules/boursorama/pages/card_history.py000066400000000000000000000052531265717027300226340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Gabriel Kerneis # Copyright(C) 2009-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.deprecated.browser import Page from weboob.tools.capabilities.bank.transactions import FrenchTransaction class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^(ACHAT |PAIEMENT )?CARTE (?P
\d{2})(?P\d{2})(?P\d{2}) (\d{2} )?(?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile('^RETRAIT DAB (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL) ] class CardHistory(Page): def get_operations(self): for form in self.document.xpath('//form[@name="marques"]'): for tr in form.xpath('.//tbody/tr'): tds = tr.xpath('./td') if tr.attrib.get('class', '') in ('total gras', 'visible-phone') or 'style' in tr.attrib or len(tds) < 3: continue date = self.parser.tocleanstring(tds[0]) label = self.parser.tocleanstring(tds[1]) amount = self.parser.tocleanstring(tds[2]) try: _id = tr.xpath('.//input[@type="hidden"]')[0].attrib['id'].split('_')[1] except (KeyError,IndexError): _id = 0 operation = Transaction(_id) operation.parse(date=date, raw=label) operation.set_amount(amount) yield operation def get_next_url(self): items = self.document.getroot().cssselect('ul.menu-lvl-1 li') current = False for li in reversed(items): if li.attrib.get('class', '') == 'active': current = True elif current: a = li.find('a') if 'year' in a.attrib.get('href', ''): return a.attrib['href'] else: return None weboob-1.1/modules/boursorama/pages/investment.py000066400000000000000000000111541265717027300223330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Simon Murail # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from lxml.etree import XPath from weboob.deprecated.browser import Page from weboob.capabilities.bank import Investment from weboob.browser.filters.standard import CleanDecimal Decimal = CleanDecimal(replace_dots=True).filter class AccountMarket(Page): def get_investment(self): for tr in self.document.xpath('//table[@id="liste-positions-engagements"]/tbody/tr'): cells = tr.xpath('./td') if len(cells) < 6: continue inv = Investment() inv.label = self.parser.tocleanstring(cells[0].xpath('.//a | .//b')[-1]) isin_div = cells[0].xpath('.//div') if len(isin_div) > 0: inv.id = inv.code = self.parser.tocleanstring(isin_div[0]) inv.quantity = Decimal(cells[1]) # 20,650
(+0,54%) inv.unitprice = Decimal(cells[2].xpath('text()')[0]) inv.unitvalue = Decimal(cells[3].xpath('text()')[0]) inv.valuation = Decimal(cells[4]) inv.diff = Decimal(cells[5]) inv._detail_url = None yield inv _el_to_string = XPath('string()') def el_to_string(el): return unicode(_el_to_string(el)) class IsinMixin(object): def get_isin(self, s): mobj = self._re_isin.search(s) if mobj: return mobj.group(1) class AccountLifeInsurance(IsinMixin, Page): _re_isin = re.compile(r'isin=(\w+)') _tr_list = XPath('//div[@id="content-gauche"]//table[@class="list"]/tbody/tr') _td_list = XPath('./td') _link = XPath('./td[1]/a/@href') def get_investment(self): for tr in self._tr_list(self.document): cells = list(el_to_string(td) for td in self._td_list(tr)) link = unicode(self._link(tr)[0]) ''' Boursorama table cells ---------------------- 0. Fonds 1. Date de valeur 2. Valeur de part 3. Nombre de parts 4. Contre valeur 5. Prix revient 6. +/- value en €* 7. +/- value en %* Investment model ---------------- label = StringField('Label of stocks') code = StringField('Identifier of the stock (ISIN code)') description = StringField('Short description of the stock') quantity = IntField('Quantity of stocks') unitprice = DecimalField('Buy price of one stock') unitvalue = DecimalField('Current value of one stock') valuation = DecimalField('Total current valuation of the Investment') diff = DecimalField('Difference between the buy cost and the current valuation') ''' inv = Investment() isin = self.get_isin(link) if isin: inv.id = inv.code = isin inv.label = cells[0] inv.quantity = Decimal(cells[3]) inv.valuation = Decimal(cells[4]) inv.unitprice = Decimal(cells[5]) inv.unitvalue = Decimal(cells[2]) inv.diff = Decimal(cells[6]) inv._detail_url = link if '/cours.phtml' in link else None yield inv def get_valuation_diff(self, account): account.valuation_diff = Decimal(self.document.xpath('//td[contains(text(), "Total des +/- values **")]/following-sibling::*[1]')) class InvestmentDetail(IsinMixin, Page): _re_isin = re.compile('(\w+)') _isin = XPath('//h2[@class and contains(concat(" ", normalize-space(@class), " "), " fv-isin ")]') _description = XPath('//p[@class="taj"] | //div[@class="taj"]') def get_investment_detail(self, inv): subtitle = el_to_string(self._isin(self.document)[0]) inv.id = inv.code = self.get_isin(subtitle) inv.description = el_to_string(self._description(self.document)[0]).strip() weboob-1.1/modules/boursorama/pages/lifeinsurance_history.py000066400000000000000000000054071265717027300245530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Baptiste Delpey # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Page from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.capabilities.bank import Investment from weboob.browser.filters.standard import CleanDecimal, Date from weboob.capabilities import NotAvailable Decimal = CleanDecimal(replace_dots=True).filter Date = Date().filter class LifeInsuranceHistory(Page): def get_operations(self): for tr in self.document.xpath('//div[@class="block no-hd"]//table[@class="list"]/tbody/tr'): tds = tr.xpath('./td') date = self.parser.tocleanstring(tds[0]) label = self.parser.tocleanstring(tds[1]) amount = self.parser.tocleanstring(tds[2]) operation = FrenchTransaction() operation.parse(date=date, raw=label) operation.set_amount(amount) if tds[0].xpath('./a'): operation.investments = self.get_investments(tds[0].xpath('./a')[0].attrib['href']) or NotAvailable yield operation def get_next_url(self): selected = self.document.xpath('//div[@class="pagination"]/ul/li[@class="selected active"]/a') link = self.document.xpath('//div[@class="pagination"]/ul/li[@class="next"]/a') if selected and link: selected = selected[0].attrib['href'] link = link[0].attrib['href'] if selected != link: return link def get_investments(self, link): invests = [] doc = self.browser.get_document(self.browser.openurl(link)) for table in doc.xpath('//div[@class="block" and not(@style)]//table'): for tr in table.xpath('./tr')[1:]: tds = tr.xpath('./td') inv = Investment() inv.label = self.parser.tocleanstring(tds[0]) inv.vdate = Date(self.parser.tocleanstring(tds[1])) inv.unitprice = Decimal(tds[2]) inv.quantity = Decimal(tds[3]) inv.valuation = Decimal(tds[4]) invests.append(inv) return invests weboob-1.1/modules/boursorama/pages/login.py000066400000000000000000000076351265717027300212600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import hashlib import urllib from weboob.deprecated.browser import Page, BrowserIncorrectPassword from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard class NewWebsitePage(Page): # New Website def on_loaded(self): self.browser.location('https://clients.boursorama.com/stop-essai') self.browser.login() class VirtKeyboard(MappedVirtKeyboard): symbols={'0':'cb9af3f561915702fc7f8ebaed8d5024', '1':'6154d49517dce772aedb581db6587f12', '2':'e8b1f8242ff536a807a91e521921a6ea', '3':'55ae6e699ff2a09c97e58dbad410d2d5', '4':'b23b8dfe923349f2b082b0a30965dd49', '5':'b0f2d0f28662c32ad82233313a4074f6', '6':'ffb10411571a767e9f6e7c8229a5bdac', '7':'ba8650fd57b2648ca91679d574150a9b', '8':'cbf9b18012499c023f1e78dcc3611cce', '9':'c70a99af7bc6a03f28b1217e58363ecf' } color=(0,0,0) def check_color(self, color): r, g, b = color return r > 240 and g > 240 and b > 240 def __init__(self, page): img = page.document.find("//img[@usemap='#login-pad_map']") img_file = page.browser.openurl(img.attrib['src']) MappedVirtKeyboard.__init__(self, img_file, page.document, img, self.color, convert='RGB') self.check_symbols(self.symbols, page.browser.responses_dirname) def get_symbol_code(self,md5sum): code = MappedVirtKeyboard.get_symbol_code(self,md5sum) return re.search("'(\w{3}\|)'", code).group(1) def get_string_code(self,string): code = '' for c in string: code += self.get_symbol_code(self.symbols[c]) return code def checksum(self, coords): x1, y1, x2, y2 = coords s = '' for y in range(y1, min(y2 + 1, self.height)): for x in range(x1, min(x2 + 1, self.width)): # strip pixels on borders if self.check_color(self.pixar[x, y]) and x > x1+2 and y > y1+2 and x < x2-2 and y < y2-2: s += "." else: s += " " return hashlib.md5(s).hexdigest() class LoginPage(Page): def on_loaded(self): pass # for td in self.document.getroot().cssselect('td.LibelleErreur'): # if td.text is None: # continue # msg = td.text.strip() # if 'indisponible' in msg: # raise BrowserUnavailable(msg) def login(self, login, password): vk = VirtKeyboard(self) form = self.document.xpath('//form[@name="identification"]')[0] args = {'login': login, 'password': vk.get_string_code(password), 'password_fake': '*' * len(password), 'org': '', 'redirect': '', } self.browser.location(form.attrib['action'], urllib.urlencode(args), no_login=True) class ProfilIncomplete(Page): def on_loaded(self): raise BrowserIncorrectPassword() class UpdateInfoPage(Page): def on_loaded(self): raise BrowserIncorrectPassword('Please update your login credentials') weboob-1.1/modules/boursorama/pages/two_authentication.py000066400000000000000000000102301265717027300240410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gabriel Serme # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import urllib2 from weboob.exceptions import BrowserQuestion from weboob.deprecated.browser import Page, BrowserIncorrectPassword from weboob.tools.value import Value class BrowserAuthenticationCodeMaxLimit(BrowserIncorrectPassword): pass class AuthenticationPage(Page): MAX_LIMIT = r"vous avez atteint le nombre maximum "\ "d'utilisation de l'authentification forte." SECURE_PAGE = "https://www.boursorama.com/comptes/connexion/securisation/index.phtml" REFERER = SECURE_PAGE headers = {"User-Agent": "Mozilla/5.0 (Windows; U; Windows " "NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8" " GTB7.1 (.NET CLR 3.5.30729)", "Referer": REFERER, } headers_ajax = {"User-Agent": "Mozilla/5.0 (Windows; U; Windows " "NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8" " GTB7.1 (.NET CLR 3.5.30729)", "Accept": "application/json", "X-Requested-With": "XMLHttpRequest", "X-Request": "JSON", "X-Brs-Xhr-Request": "true", "X-Brs-Xhr-Schema": "DATA+OUT", "Referer": REFERER, } def on_loaded(self): pass @classmethod def authenticate(cls, browser): browser.logger.info('Using the PIN Code %s to login', browser.auth_token) url = "https://" + browser.DOMAIN + "/ajax/banque/otp.phtml" data = "authentificationforteToken=%s&authentificationforteStep=otp&alertType=10100&org=%s&otp=%s&validate=" % (browser.auth_token, cls.REFERER, browser.config['pin_code'].get()) req = urllib2.Request(url, data, cls.headers_ajax) browser.open(req) url = "%s?" % (cls.SECURE_PAGE) data = "org=/&device=%s" % (browser.config['device'].get()) req = urllib2.Request(url, data, headers=cls.headers) browser.open(req) browser.auth_token = None def send_sms(self): """This function simulates the registration of a device on boursorama two factor authentification web page. I @param device device name to register @exception BrowserAuthenticationCodeMaxLimit when daily limit is consumed """ url = "https://%s/ajax/banque/otp.phtml?org=%s&alertType=10100" % (self.browser.DOMAIN, self.REFERER) req = urllib2.Request(url, headers=self.headers_ajax) response = self.browser.open(req) #extrat authentication token from response (in form) info = response.read() regex = re.compile(self.MAX_LIMIT) r = regex.search(info) if r: raise BrowserAuthenticationCodeMaxLimit("Vous avez atteint le nombre maximum d'utilisation de l'authentification forte") regex = re.compile(r"name=\\\"authentificationforteToken\\\" " r"value=\\\"(?P\w*?)\\\"") r = regex.search(info) self.browser.auth_token = r.group('value') #step2 url = "https://" + self.browser.DOMAIN + "/ajax/banque/otp.phtml" data = "authentificationforteToken=%s&authentificationforteStep=start&alertType=10100&org=%s&validate=" % (self.browser.auth_token, self.REFERER) req = urllib2.Request(url, data, self.headers_ajax) response = self.browser.open(req) raise BrowserQuestion(Value('pin_code', label='Enter the PIN Code')) weboob-1.1/modules/boursorama/test.py000066400000000000000000000021141265717027300200130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Gabriel Kerneis # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class BoursoramaTest(BackendTest): MODULE = 'boursorama' def test_boursorama(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_coming(a)) list(self.backend.iter_history(a)) weboob-1.1/modules/bouygues/000077500000000000000000000000001265717027300161545ustar00rootroot00000000000000weboob-1.1/modules/bouygues/__init__.py000066400000000000000000000001011265717027300202550ustar00rootroot00000000000000from .module import BouyguesModule __all__ = ['BouyguesModule'] weboob-1.1/modules/bouygues/browser.py000066400000000000000000000067011265717027300202150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from weboob.browser.exceptions import ServerError from weboob.exceptions import BrowserIncorrectPassword from .pages import BillsPage, HomePage, LoginPage, ProfilePage, SendSMSPage, SendSMSErrorPage from weboob.capabilities.messages import CantSendMessage __all__ = ['BouyguesBrowser'] class BouyguesBrowser(LoginBrowser): BASEURL = 'https://www.mon-compte.bouyguestelecom.fr/' TIMEOUT = 20 bills = URL('http://www.bouyguestelecom.fr/mon-compte/mes-factures/historique\?no_reference=(?P)', BillsPage) profile = URL('https://api-mc.bouyguestelecom.fr/client/me/header.json', ProfilePage) home = URL('https://www.bouyguestelecom.fr/mon-compte/', HomePage) login = URL('cas/login', LoginPage) sms_page = URL('http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/sendSMS.phtml', 'http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/confirmSendSMS.phtml', SendSMSPage) confirm = URL('http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/resultSendSMS.phtml') sms_error_page = URL('http://www.mobile.service.bbox.bouyguestelecom.fr/services/SMSIHD/SMS_erreur.phtml', SendSMSErrorPage) logged = False def do_login(self): if self.logged: return self.login.go() if self.home.is_here(): return self.page.login(self.username, self.password) if not self.home.is_here(): raise BrowserIncorrectPassword self.logged = True self.page.logged = True @need_login def post_message(self, message): self.sms_page.go() if self.sms_error_page.is_here(): raise CantSendMessage(self.page.get_error_message()) receivers = ";".join(list(message.receivers)) if message.receivers else self.username self.page.send_sms(message, receivers) if self.sms_error_page.is_here(): raise CantSendMessage(self.page.get_error_message()) self.confirm.open() @need_login def get_subscription_list(self): try: # Informations are available in the header.json file. # The only required field is the contract number # which is available is the source of the homepage too. # Possibly the json file contains more informations but # he appears to be unavailable sometimes. return self.profile.stay_or_go().get_list() except ServerError: return self.home.stay_or_go().get_list() @need_login def iter_bills(self, subscription): return self.bills.stay_or_go(ref=subscription._contract).get_bills(subid=subscription.id) weboob-1.1/modules/bouygues/favicon.png000066400000000000000000000121651265717027300203140ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDe) pHYs  tIME =ztEXtCommentCreated with GIMPWIDATx[}\U^wOw&L>'aen( +_kIU,]٥늉Z"bieD* DH"$o@&_J23~sy3ವުWy龿s=>/Pߩ`E|r' eZ CXQ? [&@ Bi^6Zi}ƗS;粥PcfW^3ZkwGɲ7\2{GU$APL`Ytͺ rimy.W7_dD#^vH Lp ahE)y`mmS(-sɔ$ &RpKJaoc|잮74@ޕfxͷ|0 L=U3n;'ܱP l@)h70,l.?.C ֜)w3@Cϼy_T Pl|ptHT jwju!"`/DiN*%;~ L t4h]=cf7pU 3 ]UA0A짓XtUlL!':pIDgz6z?Ȅ-j0`y?|vZmʈpofuנ fO} 3 S_}ڂ X)( h˂(+C㹯߶񍧞(ݡnNUMs@L 43D8f@,g5`6"bs0*F1^&DpSiPtc;\&[h=Ľ%sOc:` A΀, @<(X2'A3wH2+  d N" |0\_괺˯%5\O,d@\ˁ

̑{ƺzAp` wʐyPkZ2" h(@ Rar9OEkAÉ|b{n>!d2bLZ@ !0!q0;uzfjs܄syh|hr[rmzZHM5d:Ne*}Yts-Ny&^aq]2xmdͷL&$5{>JB#; fyy;6 $sc{W6wt=#gHspƧ uum nX[ f1=iL{{ !wю`ZQR'X!F;;אx.{y"o궿@+Jk'S]9X;D<@DV,^Zh'w@`L'gheŻAvKؤJXUH7PYP^<'Ug R޽F躤 3}ws3oS"@Xwg]vSD x9{aUjUu6ZCkغ|Vkغd 阀hak(x6%VntJ ,fk #wN  ~o+|O\;3AdU h}&Ҕvx;Ezx΃O¦4B[c{ 55k[J:(ǖ~uײN~uvN4/gv6>U"lU7  <}Y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  2x{݀wCSKKs11b1@N }: 7/(9ئf>эU/!ucse7Xc,]v;nJNaߣ5{ ;׆P1~/ط&ʹ'X8uTs9T̎Xi}y7݌-֥+ } |tmq!l@Bm( bX. from weboob.capabilities.bill import CapBill, Subscription, Bill, SubscriptionNotFound, BillNotFound from weboob.capabilities.messages import CantSendMessage, CapMessages, CapMessagesPost from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import BouyguesBrowser __all__ = ['BouyguesModule'] class BouyguesModule(Module, CapMessages, CapMessagesPost, CapBill): NAME = 'bouygues' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' VERSION = '1.1' DESCRIPTION = u'Bouygues Télécom French mobile phone provider' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('login', label='Login/Phone number'), ValueBackendPassword('password', label='Password')) BROWSER = BouyguesBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def post_message(self, message): if not message.content.strip(): raise CantSendMessage(u'Message content is empty.') self.browser.post_message(message) def iter_subscription(self): return self.browser.get_subscription_list() def get_subscription(self, _id): return find_object(self.iter_subscription(), id=_id, error=SubscriptionNotFound) def get_bill(self, _id): subid, billid = _id.split('.') subscription = self.get_subscription(subid) return find_object(self.iter_bills(subscription), id=billid, error=BillNotFound) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_bills(subscription) def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) return self.browser.open(bill._url).content weboob-1.1/modules/bouygues/pages.py000066400000000000000000000076711265717027300176400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.capabilities.messages import CantSendMessage from weboob.capabilities.bill import Bill, Subscription from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage from weboob.browser.filters.json import Dict from weboob.browser.filters.standard import CleanDecimal, CleanText, Env, Format, Regexp from weboob.browser.elements import DictElement, ItemElement, ListElement, method class LoginPage(HTMLPage): def login(self, login, password): form = self.get_form('//form[@id="log_data"]') form['username'] = login form['password'] = password form.submit() class HomePage(HTMLPage, LoggedPage): @method class get_list(ListElement): class item(ItemElement): klass = Subscription obj_label = CleanText('//span[@class="ecconumteleule"]') obj_subscriber = CleanText('//span[@class="economligneaseule eccobold"]') obj_id = Env('id') obj__contract = Env('contract') def parse(self, el): self.env['id'] = re.sub(r'[^\d\-\.]', '', el.xpath('//span[@class="ecconumteleule"]')[0].text) self.env['contract'] = re.search("tc_vars\[\"ID_contrat\"\] = '([0-9]+)'", self.page.data).group(1) class ProfilePage(JsonPage, LoggedPage): @method class get_list(DictElement): item_xpath = 'data/lignes' class item(ItemElement): klass = Subscription obj_id = CleanText(Dict('num_ligne')) obj__type = CleanText(Dict('type')) obj_label = Env('label') obj_subscriber = Format("%s %s %s", CleanText(Dict('civilite')), CleanText(Dict('prenom')), CleanText(Dict('nom'))) obj__contract = Env('contract') def parse(self, el): # add spaces number = iter(self.obj_id(el)) self.env['label'] = ' '.join(a+b for a, b in zip(number, number)) self.env['contract'] = re.search('\\"user_id\\":\\"([0-9]+)\\"', self.page.get('data.tag')).group(1) class SendSMSPage(HTMLPage): def send_sms(self, message, receivers): sms_number = CleanDecimal(Regexp(CleanText('//span[@class="txt12-o"][1]/strong'), '(\d*) SMS.*'))(self.doc) if sms_number == 0: msg = CleanText('//span[@class="txt12-o"][1]')(self.doc) raise CantSendMessage(msg) form = self.get_form('//form[@name="formSMS"]') form["fieldMsisdn"] = receivers form["fieldMessage"] = message.content form.submit() class SendSMSErrorPage(HTMLPage): def get_error_message(self): return CleanText('//span[@class="txt12-o"][1]')(self.doc) class BillsPage(HTMLPage): @method class get_bills(ListElement): item_xpath = '//div[@facture-id]' class item(ItemElement): klass = Bill obj__ref = CleanText('//input[@id="noref"]/@value') obj_id = CleanText('./@facture-id') obj_label = CleanText('./text()') obj_price = CleanDecimal(CleanText('./span', replace=[(u' € ', '.')])) obj_format = u"pdf" obj__url = Format('http://www.bouyguestelecom.fr/mon-compte/facture/download/index?id=%s', obj_id) weboob-1.1/modules/bouygues/test.py000066400000000000000000000015541265717027300175120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class BouyguesTest(BackendTest): MODULE = 'bouygues' def test_bouygues(self): pass weboob-1.1/modules/bp/000077500000000000000000000000001265717027300147135ustar00rootroot00000000000000weboob-1.1/modules/bp/__init__.py000066400000000000000000000014601265717027300170250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BPModule __all__ = ['BPModule'] weboob-1.1/modules/bp/browser.py000066400000000000000000000211511265717027300167500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from urlparse import urlsplit, parse_qsl from datetime import datetime from weboob.deprecated.browser import Browser, BrowserIncorrectPassword, BrowserBanned from weboob.deprecated.browser.parsers.iparser import RawParser from .pages import LoginPage, Initident, CheckPassword, repositionnerCheminCourant, BadLoginPage, AccountDesactivate, \ AccountList, AccountHistory, CardsList, UnavailablePage, AccountRIB, \ TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary from .pages.pro import RedirectPage, ProAccountsList, ProAccountHistory, ProAccountHistoryDownload, ProAccountHistoryCSV, HistoryParser, DownloadRib, RibPage from weboob.capabilities.bank import Transfer __all__ = ['BPBrowser', 'BProBrowser'] class BPBrowser(Browser): DOMAIN = 'voscomptesenligne.labanquepostale.fr' PROTOCOL = 'https' CERTHASH = ['184ccdf506ce87e66cba71ce754e48aa51720f346df56ed27399006c288a82ce', '5719e6295761eb6de357d5e0743a26b917c4346792aff657f585c83cd7eae8f7'] ENCODING = 'iso-8859-1' PAGES = {r'.*wsost/OstBrokerWeb/loginform.*' : LoginPage, r'.*authentification/repositionnerCheminCourant-identif.ea' : repositionnerCheminCourant, r'.*authentification/initialiser-identif.ea' : Initident, r'.*authentification/verifierMotDePasse-identif.ea' : CheckPassword, r'.*voscomptes/identification/identification.ea.*' : RedirectPage, r'.*synthese_assurancesEtComptes/afficheSynthese-synthese\.ea' : AccountList, r'.*synthese_assurancesEtComptes/rechercheContratAssurance-synthese.ea' : AccountList, r'.*voscomptes/canalXHTML/comptesCommun/imprimerRIB/init-imprimer_rib.ea.*' : (AccountRIB, RawParser()), r'.*voscomptes/synthese/3-synthese.ea' : RedirectPage, r'.*voscomptes/synthese/synthese.ea' : ProAccountsList, r'.*voscomptes/historiqueccp/historiqueccp.ea.*' : ProAccountHistory, r'.*voscomptes/telechargercomptes/telechargercomptes.ea.*' : ProAccountHistoryDownload, r'.*voscomptes/telechargercomptes/1-telechargercomptes.ea' : (ProAccountHistoryCSV, HistoryParser()), r'.*CCP/releves_ccp/releveCPP-releve_ccp\.ea' : AccountHistory, r'.*CNE/releveCNE/releveCNE-releve_cne\.ea' : AccountHistory, r'.*CB/releveCB/preparerRecherche-mouvementsCarteDD.ea.*' : AccountHistory, r'.*CB/releveCB/init-mouvementsCarteDD.ea.*' : CardsList, r'.*/virementSafran_aiguillage/init-saisieComptes\.ea' : TransferChooseAccounts, r'.*/virementSafran_aiguillage/formAiguillage-saisieComptes\.ea' : CompleteTransfer, r'.*/virementSafran_national/validerVirementNational-virementNational.ea' : TransferConfirm, r'.*/virementSafran_national/confirmerVirementNational-virementNational.ea' : TransferSummary, r'.*ost/messages\.CVS\.html\?param=0x132120c8.*' : BadLoginPage, r'.*ost/messages\.CVS\.html\?param=0x132120cb.*' : AccountDesactivate, r'https?://.*.labanquepostale.fr/delestage.html' : UnavailablePage, r'.*/voscomptes/rib/init-rib.ea' : DownloadRib, r'.*/voscomptes/rib/preparerRIB-rib.*' : RibPage, } login_url = 'https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb/loginform?TAM_OP=login&' \ 'ERROR_CODE=0x00000000&URL=%2Fvoscomptes%2FcanalXHTML%2Fidentif.ea%3Forigin%3Dparticuliers' accounts_url = "https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/comptesCommun/synthese_assurancesEtComptes/rechercheContratAssurance-synthese.ea" def __init__(self, *args, **kwargs): kwargs['parser'] = ('lxml',) Browser.__init__(self, *args, **kwargs) def home(self): self.login() def is_logged(self): return not self.is_on_page(LoginPage) def login(self): if not self.is_on_page(LoginPage): self.location(self.login_url, no_login=True) self.page.login(self.username, self.password) if self.is_on_page(BadLoginPage): raise BrowserIncorrectPassword() if self.is_on_page(AccountDesactivate): raise BrowserBanned() def get_accounts_list(self): self.location(self.accounts_url) return self.page.get_accounts_list() def get_account(self, id): if not self.is_on_page(AccountList): self.location(self.accounts_url) return self.page.get_account(id) def get_history(self, account): v = urlsplit(account._link_id) args = dict(parse_qsl(v.query)) args['typeRecherche'] = 10 self.location(self.buildurl(v.path, **args)) if self.is_on_page(AccountHistory): for tr in self.page.get_history(): yield tr for tr in self.get_coming(account): yield tr def get_coming(self, account): for card in account._card_links: self.location(card) if self.is_on_page(CardsList): for link in self.page.get_cards(): self.location(link) for tr in self._iter_card_tr(): yield tr else: for tr in self._iter_card_tr(): yield tr def _iter_card_tr(self): """ Iter all pages until there are no transactions. """ ops = self.page.get_history(deferred=True) while True: for tr in ops: yield tr link = self.page.get_next_link() if link is None: return self.location(link) ops = self.page.get_history(deferred=True) def make_transfer(self, from_account, to_account, amount): self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virement/virementSafran_aiguillage/init-saisieComptes.ea') self.page.set_accouts(from_account, to_account) #TODO: Check self.page.complete_transfer(amount) self.page.confirm() id_transfer = self.page.get_transfer_id() transfer = Transfer(id_transfer) transfer.amount = amount transfer.origin = from_account.label transfer.recipient = to_account.label transfer.date = datetime.now() return transfer class BProBrowser(BPBrowser): login_url = "https://banqueenligne.entreprises.labanquepostale.fr/wsost/OstBrokerWeb/loginform?TAM_OP=login&ERROR_CODE=0x00000000&URL=%2Fws_q47%2Fvoscomptes%2Fidentification%2Fidentification.ea%3Forigin%3Dprofessionnels" def login(self): BPBrowser.login(self) v = urlsplit(self.page.url) version = v.path.split('/')[1] self.base_url = 'https://banqueenligne.entreprises.labanquepostale.fr/%s' % version self.accounts_url = self.base_url + '/voscomptes/synthese/synthese.ea' def get_accounts_list(self): accounts = BPBrowser.get_accounts_list(self) for acc in accounts: self.location('%s/voscomptes/rib/init-rib.ea' % self.base_url) value = self.page.get_rib_value(acc.id) if value: self.location('%s/voscomptes/rib/preparerRIB-rib.ea?%s' % (self.base_url, value)) if self.is_on_page(RibPage): acc.iban = self.page.get_iban() yield acc weboob-1.1/modules/bp/favicon.png000066400000000000000000000033541265717027300170530ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDW pHYs  tIME 6X7tEXtCommentCreated with GIMPWGIDATxo?ٹձsq1$,@C !ԇ"$+@Rj*H R@.!;;]^f~}zر]f|Μ̈/J`Sx-D"@ D"дw?dḍ`Y 7 n)XlfIm,Į0q vn( -H cۓko;x`x%IP(85[(\^^7tD %]G:K߾ˬ}JLJvW~f2q|sx.^}y-m}$*xAxl;wٹ#^ӆsc[*<JRF67lc| GO;g1hHRxZّQQ!VV%/\+O?nvTleeLJ7ai/yd'jCM._4g/A[wz ~i3zx"OOl\q0v,ѸgY ]q)v:i7|*s {q*۝ ձ2GOLq.қ2o(7~d'@A*4KvXwޟX;1y@]N]S\JL_dmrT`݅vSN_Neu#[Mx4Δo߲+uQ5 Cmlu1LC+ܿ7ɶFc7rza^Y^Q[ vsZ_j=1{I?1 X܁tj7 Ϝ_1X^V*r)BqCTr6ut2wqS\I^lpBTvѧOԝBb?YT D"@ `Yh9IENDB`weboob-1.1/modules/bp/module.py000066400000000000000000000051321265717027300165530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, Account from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import BPBrowser, BProBrowser __all__ = ['BPModule'] class BPModule(Module, CapBank): NAME = 'bp' MAINTAINER = u'Nicolas Duhamel' EMAIL = 'nicolas@jombi.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'La Banque Postale' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe', regexp='^(\d{6}|)$'), Value('website', label='Type de compte', default='par', choices={'par': 'Particuliers', 'pro': 'Professionnels'})) def create_default_browser(self): b = {'par': BPBrowser, 'pro': BProBrowser} self.BROWSER = b[self.config['website'].get()] return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return self.browser.get_account(_id) def iter_history(self, account): if account.type == Account.TYPE_MARKET: raise NotImplementedError() for tr in self.browser.get_history(account): if not tr._coming: yield tr def iter_coming(self, account): for tr in self.browser.get_coming(account): if tr._coming: yield tr def transfer(self, id_from, id_to, amount, reason=None): from_account = self.get_account(id_from) to_account = self.get_account(id_to) #TODO: retourner le numero du virement #TODO: support the 'reason' parameter return self.browser.make_transfer(from_account, to_account, amount) weboob-1.1/modules/bp/pages/000077500000000000000000000000001265717027300160125ustar00rootroot00000000000000weboob-1.1/modules/bp/pages/__init__.py000066400000000000000000000025431265717027300201270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .login import LoginPage, Initident, CheckPassword,repositionnerCheminCourant, BadLoginPage, AccountDesactivate, UnavailablePage from .accountlist import AccountList, AccountRIB from .accounthistory import AccountHistory, CardsList from .transfer import TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary __all__ = ['LoginPage','Initident', 'CheckPassword', 'repositionnerCheminCourant', "AccountList", 'AccountHistory', 'BadLoginPage', 'AccountDesactivate', 'TransferChooseAccounts', 'CompleteTransfer', 'TransferConfirm', 'TransferSummary', 'UnavailablePage', 'CardsList', 'AccountRIB'] weboob-1.1/modules/bp/pages/accounthistory.py000066400000000000000000000125371265717027300214520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime import re from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.deprecated.browser import Page class Transaction(FrenchTransaction): PATTERNS = [(re.compile(u'^(?PCHEQUE)( N)? (?P.*)'), FrenchTransaction.TYPE_CHECK), (re.compile(r'^(?PACHAT CB) (?P.*) (?P

\d{2})\.(?P\d{2}).(?P\d{2}).*'), FrenchTransaction.TYPE_CARD), (re.compile('^(?P(PRELEVEMENT DE|TELEREGLEMENT|TIP)) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?PECHEANCEPRET)(?P.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile(r'^CARTE \w+ (?P
\d{2})/(?P\d{2})/(?P\d{2}) A (?P\d+)H(?P\d+) (?PRETRAIT DAB) (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(r'^(?PRETRAIT DAB) (?P
\d{2})/(?P\d{2})/(?P\d{2}) (?P\d+)H(?P\d+) (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(r'^(?PRETRAIT) (?P.*) (?P
\d{2})\.(?P\d{2})\.(?P\d{2})'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?PVIR(EMEN)?T?) (DE |POUR )?(?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?PREMBOURST)(?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?PCOMMISSIONS)(?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?PFRAIS POUR)(?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P(?PREMUNERATION).*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?PREMISE DE CHEQUES?) (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] class AccountHistory(Page): def get_next_link(self): for a in self.document.xpath('//a[@class="btn_crt"]'): txt = u''.join([txt.strip() for txt in a.itertext()]) if u'mois précédent' in txt: return a.attrib['href'] def get_history(self, deferred=False): """ deffered is True when we are on a card page. """ mvt_table = self.document.xpath("//table[@id='mouvements']", smart_strings=False)[0] mvt_ligne = mvt_table.xpath("./tbody/tr") operations = [] if deferred: # look for the card number, debit date, and if it is already debited txt = u''.join([txt.strip() for txt in self.document.xpath('//div[@class="infosynthese"]')[0].itertext()]) m = re.search(u'sur votre carte n°\*\*\*\*\*\*(\d+)\*', txt) card_no = u'inconnu' if m: card_no = m.group(1) m = re.search('(\d+)/(\d+)/(\d+)', txt) if m: debit_date = datetime.date(*map(int, reversed(m.groups()))) coming = 'En cours' in txt else: coming = False for mvt in mvt_ligne: op = Transaction() op.parse(date=mvt.xpath("./td/span")[0].text.strip(), raw=unicode(self.parser.tocleanstring(mvt.xpath('./td/span')[1]).strip())) if op.label.startswith('DEBIT CARTE BANCAIRE DIFFERE'): continue r = re.compile(r'\d+') tmp = mvt.xpath("./td/span/strong") if not tmp: tmp = mvt.xpath("./td/span") amount = None for t in tmp: if r.search(t.text): amount = t.text op.set_amount(amount) if deferred: op._cardid = 'CARTE %s' % card_no op.rdate = op.date op.date = debit_date # on card page, amounts are without sign if op.amount > 0: op.amount = - op.amount op._coming = coming operations.append(op) return operations class CardsList(Page): def get_cards(self): cards = [] for tr in self.document.xpath('//table[@class="dataNum"]/tbody/tr'): cards.append(tr.xpath('.//a')[0].attrib['href']) return cards weboob-1.1/modules/bp/pages/accountlist.py000066400000000000000000000123321265717027300207150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from cStringIO import StringIO import re from decimal import Decimal from weboob.capabilities.bank import Account, AccountNotFound from weboob.deprecated.browser import Page from weboob.exceptions import BrowserUnavailable from weboob.tools.misc import to_unicode from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.ordereddict import OrderedDict class AccountList(Page): def on_loaded(self): if self.document.xpath(u'//h2[text()="%s"]' % u'ERREUR'): raise BrowserUnavailable() self.accounts = OrderedDict() self.parse_table('comptes', Account.TYPE_CHECKING) self.parse_table('comptesEpargne', Account.TYPE_SAVINGS) self.parse_table('comptesTitres', Account.TYPE_MARKET) self.parse_table('comptesVie', Account.TYPE_DEPOSIT) self.parse_table('comptesRetraireEuros') def get_accounts_list(self): return self.accounts.itervalues() def parse_table(self, what, actype=Account.TYPE_UNKNOWN): tables = self.document.xpath("//table[@id='%s']" % what, smart_strings=False) if len(tables) < 1: return lines = tables[0].xpath(".//tbody/tr") for line in lines: account = Account() tmp = line.xpath("./td//a")[0] account.label = to_unicode(tmp.text) account.type = actype account._link_id = tmp.get("href") if 'BourseEnLigne' in account._link_id: account.type = Account.TYPE_MARKET tmp = line.xpath("./td/span/strong") if len(tmp) >= 2: tmp_id = tmp[0].text tmp_balance = tmp[1].text else: tmp_id = line.xpath("./td//span")[1].text tmp_balance = tmp[0].text account.id = tmp_id account.currency = account.get_currency(tmp_balance) account.balance = Decimal(FrenchTransaction.clean_amount(tmp_balance)) if account.id in self.accounts: a = self.accounts[account.id] a._card_links.append(account._link_id) if not a.coming: a.coming = Decimal('0.0') a.coming += account.balance else: account._card_links = [] self.accounts[account.id] = account page = self.browser.get_page(self.browser.openurl(self.browser.buildurl('/voscomptes/canalXHTML/comptesCommun/imprimerRIB/init-imprimer_rib.ea', ('compte.numero', account.id)))) account.iban = page.get_iban() def get_account(self, id): try: return self.accounts[id] except KeyError: raise AccountNotFound('Unable to find account: %s' % id) class AccountRIB(Page): iban_regexp = r'BankIdentiferCode(\w+)PSS' def __init__(self, *args, **kwargs): super(AccountRIB, self).__init__(*args, **kwargs) self.text = '' try: try: from pdfminer.pdfdocument import PDFDocument from pdfminer.pdfpage import PDFPage newapi = True except ImportError: from pdfminer.pdfparser import PDFDocument newapi = False from pdfminer.pdfparser import PDFParser, PDFSyntaxError from pdfminer.converter import TextConverter from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter except ImportError: self.logger.warning('Please install python-pdfminer to get IBANs') else: parser = PDFParser(StringIO(self.document)) try: if newapi: doc = PDFDocument(parser) else: doc = PDFDocument() parser.set_document(doc) doc.set_parser(parser) except PDFSyntaxError: return rsrcmgr = PDFResourceManager() out = StringIO() device = TextConverter(rsrcmgr, out) interpreter = PDFPageInterpreter(rsrcmgr, device) if newapi: pages = PDFPage.create_pages(doc) else: doc.initialize() pages = doc.get_pages() for page in pages: interpreter.process_page(page) self.text = out.getvalue() def get_iban(self): m = re.search(self.iban_regexp, self.text) if m: return unicode(m.group(1)) return None weboob-1.1/modules/bp/pages/login.py000066400000000000000000000100711265717027300174730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.deprecated.browser import Page, BrowserUnavailable, BrowserIncorrectPassword from weboob.tools.captcha.virtkeyboard import VirtKeyboard class UnavailablePage(Page): def on_loaded(self): raise BrowserUnavailable() class Keyboard(VirtKeyboard): symbols={'0':'daa52d75287bea58f505823ef6c8b96c', '1':'f5da96c2592803a8cdc5a928a2e4a3b0', '2':'9ff78367d5cb89cacae475368a11e3af', '3':'908a0a42a424b95d4d885ce91bc3d920', '4':'3fc069f33b801b3d0cdce6655a65c0ac', '5':'58a2afebf1551d45ccad79fad1600fc3', '6':'7fedfd9e57007f2985c3a1f44fb38ea1', '7':'389b8ef432ae996ac0141a2fcc7b540f', '8':'bf357ff09cc29ea544991642cd97d453', '9':'b744015eb89c1b950e13a81364112cd6', } color=(0xff, 0xff, 0xff) def __init__(self, page): m = re.search(r'background:url\("(.*?)"\)', ''.join(page.document.xpath('//script/text()'))) if m: img_url = m.group(1) size = 252 else: img_url = page.document.xpath('//img[@id="imageCVS"]')[0].attrib['src'] size = 146 coords = {} x, y, width, height = (0, 0, size/4, size/4) for i, _ in enumerate(page.document.xpath('//div[@id="imageclavier"]//button')): code = '%02d' % i coords[code] = (x+4, y+4, x+width-8, y+height-8) if (x + width + 1) >= size: y += height + 1 x = 0 else: x += width + 1 VirtKeyboard.__init__(self, page.browser.openurl(img_url), coords, self.color) self.check_symbols(self.symbols, page.browser.responses_dirname) def get_symbol_code(self,md5sum): code = VirtKeyboard.get_symbol_code(self,md5sum) return '%02d' % int(code.split('_')[-1]) def get_string_code(self,string): code = '' for c in string: code += self.get_symbol_code(self.symbols[c]) return code def get_symbol_coords(self, coords): # strip borders x1, y1, x2, y2 = coords return VirtKeyboard.get_symbol_coords(self, (x1+3, y1+3, x2-3, y2-3)) class LoginPage(Page): def login(self, login, pwd): vk = Keyboard(self) self.browser.select_form(name='formAccesCompte') self.browser.set_all_readonly(False) self.browser['password'] = vk.get_string_code(pwd) self.browser['username'] = login.encode(self.browser.ENCODING) self.browser.submit() class repositionnerCheminCourant(Page): def on_loaded(self): page = self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/securite/authentification/initialiser-identif.ea") if "vous ne disposez pas" in page.read(): raise BrowserIncorrectPassword("No online banking service for these ids") class Initident(Page): def on_loaded(self): self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/securite/authentification/verifierMotDePasse-identif.ea") class CheckPassword(Page): def on_loaded(self): self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/comptesCommun/synthese_assurancesEtComptes/init-synthese.ea") class BadLoginPage(Page): pass class AccountDesactivate(Page): pass weboob-1.1/modules/bp/pages/pro.py000066400000000000000000000104661265717027300171730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from dateutil.relativedelta import relativedelta from decimal import Decimal from weboob.browser.filters.standard import CleanText from weboob.deprecated.browser import Page from weboob.deprecated.browser.parsers.csvparser import CsvParser from weboob.capabilities.bank import Account, AccountNotFound from .accounthistory import Transaction, AccountHistory class RedirectPage(Page): pass class HistoryParser(CsvParser): FMTPARAMS = {'delimiter': ';'} class ProAccountsList(Page): ACCOUNT_TYPES = {u'Comptes titres': Account.TYPE_MARKET, u'Comptes épargne': Account.TYPE_SAVINGS, u'Comptes courants': Account.TYPE_CHECKING, } def get_accounts_list(self): for table in self.document.xpath('//div[@class="comptestabl"]/table'): try: account_type = self.ACCOUNT_TYPES[table.get('summary')] if not account_type: account_type = self.ACCOUNT_TYPES[table.xpath('./caption/text()')[0].strip()] except (IndexError,KeyError): account_type = Account.TYPE_UNKNOWN for tr in table.xpath('./tbody/tr'): cols = tr.findall('td') link = cols[0].find('a') if link is None: continue a = Account() a.type = account_type a.id, a.label = map(unicode, link.attrib['title'].split(' ', 1)) tmp_balance = self.parser.tocleanstring(cols[1]) a.currency = a.get_currency(tmp_balance) a.balance = Decimal(Transaction.clean_amount(tmp_balance)) a._card_links = [] a._link_id = link.attrib['href'] yield a def get_account(self, id): for account in self.get_accounts_list(): if account.id == id: return account raise AccountNotFound('Unable to find account: %s' % id) class ProAccountHistory(Page): def on_loaded(self): link = self.document.xpath('//a[contains(@href, "telechargercomptes.ea")]/@href')[0] self.browser.location(link) class ProAccountHistoryDownload(Page): def on_loaded(self): self.browser.select_form(name='telechargement') self.browser['dateDebutPeriode'] = (datetime.date.today() - relativedelta(months=11)).strftime('%d/%m/%Y') self.browser.submit() class ProAccountHistoryCSV(AccountHistory): def get_next_link(self): return False def get_history(self, deferred=False): operations = [] for line in self.document.rows: if len(line) < 4 or line[0] == 'Date': continue t = Transaction() t.parse(raw=line[1], date=line[0]) t.set_amount(line[2]) t._coming = False operations.append(t) operations = sorted(operations, lambda a, b: cmp(a.date, b.date), reverse=True) for op in operations: yield op class DownloadRib(Page): def get_rib_value(self, acc_id): opt = self.document.xpath('//div[@class="rechform"]//option') for o in opt: if acc_id in o.text: return o.xpath('./@value')[0] return None class RibPage(Page): def get_iban(self): if self.document.xpath('//div[@class="blocbleu"][2]//table[@class="datalist"]'): return CleanText()\ .filter(self.document.xpath('//div[@class="blocbleu"][2]//table[@class="datalist"]')[0])\ .replace(' ', '').strip() return None weboob-1.1/modules/bp/pages/transfer.py000066400000000000000000000050401265717027300202070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.capabilities.bank import TransferError from weboob.deprecated.browser import Page from weboob.tools.misc import to_unicode class TransferChooseAccounts(Page): def set_accouts(self, from_account, to_account): self.browser.select_form(name="AiguillageForm") self.browser["idxCompteEmetteur"] = [from_account.id] self.browser["idxCompteReceveur"] = [to_account.id] self.browser.submit() class CompleteTransfer(Page): def complete_transfer(self, amount): self.browser.select_form(name="virement_unitaire_saisie_saisie_virement_sepa") self.browser["montant"] = str(amount) self.browser.submit() class TransferConfirm(Page): def confirm(self): self.browser.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virement/virementSafran_national/confirmerVirementNational-virementNational.ea') class TransferSummary(Page): def get_transfer_id(self): p = self.document.xpath("//div[@id='main']/div/p")[0] #HACK for deal with bad encoding ... try: text = p.text except UnicodeDecodeError as error: text = error.object.strip() match = re.search("Votre virement N.+ ([0-9]+) ", text) if match: id_transfer = match.groups()[0] return id_transfer if text.startswith(u"Votre virement n'a pas pu"): if p.find('br') is not None: errmsg = to_unicode(p.find('br').tail).strip() raise TransferError('Unable to process transfer: %s' % errmsg) else: self.browser.logger.warning('Unable to find the error reason') self.browser.logger.error('Unable to parse the text result: %r' % text) raise TransferError('Unable to process transfer: %r' % text) weboob-1.1/modules/bred/000077500000000000000000000000001265717027300152265ustar00rootroot00000000000000weboob-1.1/modules/bred/__init__.py000066400000000000000000000014241265717027300173400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BredModule __all__ = ['BredModule'] weboob-1.1/modules/bred/bred/000077500000000000000000000000001265717027300161425ustar00rootroot00000000000000weboob-1.1/modules/bred/bred/__init__.py000066400000000000000000000000741265717027300202540ustar00rootroot00000000000000from .browser import BredBrowser __all__ = ['BredBrowser'] weboob-1.1/modules/bred/bred/browser.py000066400000000000000000000175341265717027300202110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import json from datetime import date from decimal import Decimal from weboob.capabilities.base import NotAvailable from weboob.capabilities.bank import Account, Transaction from weboob.exceptions import BrowserIncorrectPassword, BrowserHTTPError, BrowserUnavailable, ParseError from weboob.browser import DomainBrowser __all__ = ['BredBrowser'] class BredBrowser(DomainBrowser): BASEURL = 'https://www.bred.fr' def __init__(self, accnum, login, password, *args, **kwargs): super(BredBrowser, self).__init__(*args, **kwargs) self.login = login self.password = password self.accnum = accnum self.universes = None self.current_univers = None def do_login(self, login, password): r = self.open('/transactionnel/Authentication', data={'identifiant': login, 'password': password}) if 'gestion-des-erreurs/erreur-pwd' in r.url: raise BrowserIncorrectPassword('Bad login/password.') if 'gestion-des-erreurs/opposition' in r.url: raise BrowserIncorrectPassword('Your account is disabled') if '/pages-gestion-des-erreurs/erreur-technique' in r.url: raise BrowserUnavailable('A technical error occured') ACCOUNT_TYPES = {'000': Account.TYPE_CHECKING, '999': Account.TYPE_MARKET, '011': Account.TYPE_CARD, '023': Account.TYPE_SAVINGS, '078': Account.TYPE_SAVINGS, '080': Account.TYPE_SAVINGS, '027': Account.TYPE_SAVINGS, '037': Account.TYPE_SAVINGS, '730': Account.TYPE_DEPOSIT, } def api_open(self, *args, **kwargs): try: return super(BredBrowser, self).open(*args, **kwargs) except BrowserHTTPError: self.do_login(self.login, self.password) return super(BredBrowser, self).open(*args, **kwargs) def set_universes(self): universes = [] r = self.api_open('/transactionnel/services/applications/menu/getMenuUnivers') for univers in r.json()['content']['menus']: universes.append(univers['universKey']) if not universes: # There is just the default univers here. universes.append('') self.current_univers = '' else: # The following is needed to get the default univers in the list. self.move_to_univers(universes[0]) r = self.api_open('/transactionnel/services/applications/menu/getMenuUnivers') for univers in r.json()['content']['menus']: if univers['universKey'] not in universes: universes.append(univers['universKey']) self.universes = universes def move_to_univers(self, univers): x_token_bred = self.api_open('/transactionnel/services/rest/User/nonce?random=').json()['content'] data = {} data['all'] = 'true' data['univers'] = univers self.api_open('/transactionnel/services/rest/User/switch', data=json.dumps(data), headers={'x-token-bred': x_token_bred}) self.current_univers = univers def get_accounts_list(self): if not self.universes: self.set_universes() accounts = [] for univers in self.universes: if univers != self.current_univers: self.move_to_univers(univers) accounts.extend(self.get_list()) return accounts def get_list(self): r = self.api_open('/transactionnel/services/rest/Account/accounts') for content in r.json()['content']: if self.accnum != '00000000000' and content['numero'] != self.accnum: continue for poste in content['postes']: a = Account() a._number = content['numeroLong'] iban_response = self.api_open('/transactionnel/services/rest/Account/account/%s/iban' % a._number).json() a.iban = iban_response['content']['iban'] if 'content' in iban_response else NotAvailable a._nature = poste['codeNature'] a._consultable = poste['consultable'] a._univers = self.current_univers a.id = '%s.%s' % (a._number, a._nature) a.type = self.ACCOUNT_TYPES.get(poste['codeNature'], Account.TYPE_UNKNOWN) if 'numeroDossier' in poste and poste['numeroDossier']: a._file_number = poste['numeroDossier'] a.id += '.%s' % a._file_number if poste['postePortefeuille']: a.label = u'Portefeuille Titres' a.balance = Decimal(str(poste['montantTitres']['valeur'])) a.currency = poste['montantTitres']['monnaie']['code'].strip() yield a if 'libelle' not in poste: continue a.label = ' '.join([content['intitule'].strip(), poste['libelle'].strip()]) a.balance = Decimal(str(poste['solde']['valeur'])) a.currency = poste['solde']['monnaie']['code'].strip() yield a def get_history(self, account): if not account._consultable: raise NotImplementedError() if account._univers != self.current_univers: self.move_to_univers(account._univers) offset = 0 next_page = True seen = set() while next_page: r = self.api_open('/transactionnel/services/applications/operations/get/%(number)s/%(nature)s/00/%(currency)s/%(startDate)s/%(endDate)s/%(offset)s/%(limit)s' % {'number': account._number, 'nature': account._nature, 'currency': account.currency, 'startDate': '2000-01-01', 'endDate': date.today().strftime('%Y-%m-%d'), 'offset': offset, 'limit': 50 }) next_page = False offset += 50 transactions = [] for op in reversed(r.json()['content']['operations']): next_page = True t = Transaction() if op['id'] in seen: raise ParseError('There are several transactions with the same ID, probably an infinite loop') t.id = op['id'] seen.add(t.id) t.amount = Decimal(str(op['montant'])) t.date = date.fromtimestamp(op.get('dateDebit', op.get('dateOperation'))/1000) t.rdate = date.fromtimestamp(op.get('dateOperation', op.get('dateDebit'))/1000) t.vdate = date.fromtimestamp(op.get('dateValeur', op.get('dateDebit', op.get('dateOperation')))/1000) if 'categorie' in op: t.category = op['categorie'] t.label = op['libelle'] t.raw = ' '.join([op['libelle']] + op['details']) transactions.append(t) # Transactions are unsorted for t in sorted(transactions, key=lambda t: t.rdate, reverse=True): yield t weboob-1.1/modules/bred/dispobank/000077500000000000000000000000001265717027300172005ustar00rootroot00000000000000weboob-1.1/modules/bred/dispobank/__init__.py000066400000000000000000000001061265717027300213060ustar00rootroot00000000000000from .browser import DispoBankBrowser __all__ = ['DispoBankBrowser'] weboob-1.1/modules/bred/dispobank/browser.py000066400000000000000000000105131265717027300212350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, LoginResultPage, AccountsPage, EmptyPage, TransactionsPage __all__ = ['DispoBankBrowser'] class DispoBankBrowser(Browser): PROTOCOL = 'https' DOMAIN = 'www.dispobank.fr' CERTHASH = ['9b77dab9c84e1dc9e0798de561a6541ff15f038f60b36ca74c29be1def6c19a3', '375f1fed165d34aacaaf71674ab14ca6c1b38404cf748278714fde3c58385ff0', '0853a056453b56aea6a29085ef3f3721b18db2052aa8e84220720d44e0eb22af', 'a2b017a0cecf8e8bacf1e04c10d4fa647f5ade416fe64129bfc034ef95f310f5'] ENCODING = 'iso-8859-15' PAGES = {r'https://www.\w+.fr/mylittleform.*': LoginPage, r'https://www.\w+.fr/Andromede/MainAuth.*': LoginResultPage, r'https://www.\w+.fr/Andromede/Main': AccountsPage, r'https://www.\w+.fr/Andromede/Ecriture': TransactionsPage, r'https://www.\w+.fr/Andromede/applications/index.jsp': EmptyPage, r'https://www.bred.fr/': EmptyPage, r'https://www.dispobank.fr/?': LoginPage, } URLS = {'bred': {'home': 'https://www.bred.fr/Andromede/Main', 'login': 'https://www.bred.fr/mylittleform?type=1', }, 'dispobank': {'home': 'https://www.dispobank.fr', 'login': 'https://www.dispobank.fr', } } def __init__(self, accnum, *args, **kwargs): self.accnum = accnum self.website = 'dispobank' Browser.__init__(self, *args, **kwargs) def is_logged(self): return self.page is not None and not self.is_on_page(LoginPage) def home(self): if not self.is_logged(): self.login() else: self.location(self.URLS[self.website]['home']) def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(LoginPage): self.location(self.URLS[self.website]['login'], no_login=True) self.page.login(self.username, self.password) assert self.is_on_page((LoginResultPage, EmptyPage)) if self.is_on_page(LoginResultPage): error = self.page.get_error() if error is not None: raise BrowserIncorrectPassword(error) self.page.confirm() def get_accounts_list(self): if not self.is_on_page(AccountsPage): self.location('https://www.%s.fr/Andromede/Main' % self.website) return self.page.get_list() def get_account(self, id): assert isinstance(id, basestring) l = self.get_accounts_list() for a in l: if a.id == id: return a return None def get_history(self, account): numero_compte, numero_poste = account.id.split('.') data = {'typeDemande': 'recherche', 'motRecherche': '', 'numero_compte': numero_compte, 'numero_poste': numero_poste, 'detail': '', 'tri': 'date', 'sens': 'sort', 'monnaie': 'EUR', 'index_hist': 4 } self.location('https://www.%s.fr/Andromede/Ecriture' % self.website, urllib.urlencode(data)) assert self.is_on_page(TransactionsPage) return self.page.get_history() weboob-1.1/modules/bred/dispobank/pages.py000066400000000000000000000233401265717027300206530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from mechanize import FormNotFoundError from weboob.deprecated.mech import ClientForm ControlNotFoundError = ClientForm.ControlNotFoundError from decimal import Decimal, InvalidOperation import re from weboob.deprecated.browser import Page from weboob.tools.misc import to_unicode from weboob.tools.ordereddict import OrderedDict from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction class LoginPage(Page): def login(self, login, passwd): try: length = int(self.document.xpath('//input[@id="pass"]')[0].attrib['maxlength']) except (IndexError,KeyError): pass else: passwd = passwd[:length] self.browser.select_form(name='authen') try: self.browser['id'] = login.encode(self.browser.ENCODING) self.browser['pass'] = passwd.encode(self.browser.ENCODING) except ControlNotFoundError: self.browser.controls.append(ClientForm.TextControl('text', 'id', {'value': login.encode(self.browser.ENCODING)})) self.browser.controls.append(ClientForm.TextControl('text', 'pass', {'value': passwd.encode(self.browser.ENCODING)})) self.browser.submit(nologin=True) class LoginResultPage(Page): def on_loaded(self): for script in self.document.xpath('//script'): text = script.text if text is None: continue m = re.search("window.location.replace\('([^']+)'\);", text) if m: self.browser.location(m.group(1)) try: self.browser.select_form(name='banque') except FormNotFoundError: pass else: self.browser.set_all_readonly(False) accounts = OrderedDict() for tr in self.document.getroot().cssselect('table.compteTable > tbody > tr'): if len(tr.findall('td')) == 0: continue attr = tr.xpath('.//a')[0].attrib.get('onclick', '') m = re.search("value = '(\w+)';(checkAndSubmit\('\w+','(\w+)','(\w+)'\))?", attr) if m: typeCompte = m.group(1) tagName = m.group(3) if tagName is not None: value = self.document.xpath('//input[@name="%s"]' % m.group(3))[int(m.group(4))].attrib['value'] else: value = typeCompte accounts[value] = (typeCompte, tagName) try: typeCompte, tagName = accounts[self.browser.accnum] value = self.browser.accnum except KeyError: accnums = ', '.join(accounts.keys()) if self.browser.accnum != '00000000000': self.logger.warning(u'Unable to find account "%s". Available ones: %s' % (self.browser.accnum, accnums)) elif len(accounts) > 1: self.logger.warning('There are several accounts, please use "accnum" backend parameter to force the one to use (%s)' % accnums) value, (typeCompte, tagName) = accounts.popitem(last=False) self.browser['typeCompte'] = typeCompte if tagName is not None: self.browser[tagName] = [value] self.browser.submit() def confirm(self): self.browser.location('MainAuth?typeDemande=AC', no_login=True) def get_error(self): error = self.document.xpath('//td[@class="txt_norm2"]') if len(error) == 0: return None error = error[0] if error.find('b') is not None: error = error.find('b') return error.text.strip() class EmptyPage(Page): pass class BredBasePage(Page): def js2args(self, s): cur_arg = None args = {} # For example: # javascript:reloadApplication('nom_application', 'compte_telechargement', 'numero_poste', '000', 'numero_compte', '12345678901','monnaie','EUR'); for sub in re.findall("'([^']+)'", s): if cur_arg is None: cur_arg = sub else: args[cur_arg] = sub cur_arg = None return args class AccountsPage(BredBasePage): def get_list(self): for tr in self.document.xpath('//table[@class="compteTable"]/tr'): if not tr.attrib.get('class', '').startswith('ligne_'): continue cols = tr.findall('td') if len(cols) < 2: continue try: amount = sum([Decimal(FrenchTransaction.clean_amount(txt)) for txt in cols[-1].itertext() if len(txt.strip()) > 0]) except InvalidOperation: continue a = cols[0].find('a') if a is None: for a in cols[0].xpath('.//li/a'): args = self.js2args(a.attrib['href']) if 'numero_compte' not in args or 'numero_poste' not in args: self.logger.warning('Card link with strange args: %s' % args) continue account = Account() account.id = '%s.%s' % (args['numero_compte'], args['numero_poste']) account.label = u'Carte %s' % self.parser.tocleanstring(a) account.balance = amount account.type = account.TYPE_CARD account.currency = [account.get_currency(txt) for txt in cols[-1].itertext() if len(txt.strip()) > 0][0] yield account continue args = self.js2args(a.attrib['href']) if 'numero_compte' not in args or 'numero_poste' not in args: self.logger.warning('Account link for %r with strange args: %s' % (a.attrib.get('alt', a.text), args)) continue account = Account() account.id = u'%s.%s' % (args['numero_compte'], args['numero_poste']) account.label = to_unicode(a.attrib.get('alt', a.text.strip())) account.balance = amount account.currency = [account.get_currency(txt) for txt in cols[-1].itertext() if len(txt.strip()) > 0][0] yield account class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^RETRAIT G.A.B. \d+ (?P.*?)( CARTE .*)? LE (?P
\d{2})/(?P\d{2})/(?P\d{2}).*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^VIR(EMENT)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^PRLV (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?P.*) TRANSACTION( CARTE .*)? LE (?P
\d{2})/(?P\d{2})/(?P\d{2}) ?(.*)$'), FrenchTransaction.TYPE_CARD), (re.compile('^CHEQUE.*'), FrenchTransaction.TYPE_CHECK), (re.compile('^(CONVENTION \d+ )?COTISATION (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^REMISE (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^(?P.*)( \d+)? QUITTANCE .*'), FrenchTransaction.TYPE_ORDER), (re.compile('^CB PAIEM. EN \d+ FOIS \d+ (?P.*?) LE .* LE (?P
\d{2})/(?P\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_CARD), (re.compile('^.* LE (?P
\d{2})/(?P\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_UNKNOWN), ] class TransactionsPage(Page): def get_history(self): for tr in self.document.xpath('//div[@class="scrollTbody"]/table//tr'): cols = tr.findall('td') if len(cols) < 4: continue col_label = cols[1] if col_label.find('a') is not None: col_label = col_label.find('a') date = self.parser.tocleanstring(cols[0]) label = self.parser.tocleanstring(col_label) t = Transaction(col_label.attrib.get('id', '')) # an optional tooltip on page contain the second part of the transaction label. tooltip = self.document.xpath('//div[@id="tooltip%s"]' % t.id) raw = label if len(tooltip) > 0: raw += u' ' + u' '.join([txt.strip() for txt in tooltip[0].itertext()]) raw = re.sub(r'[ ]+', ' ', raw) t.parse(date, raw) # as only the first part of label is important to user, if there are no subpart # taken by FrenchTransaction regexps, reset the label as first part. if t.label == t.raw: t.label = label debit = self.parser.tocleanstring(cols[-2]) credit = self.parser.tocleanstring(cols[-1]) t.set_amount(credit, debit) yield t weboob-1.1/modules/bred/favicon.png000066400000000000000000000024201265717027300173570ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME .X1IDATx[}Hg~ƚCdkn-+hYJYt+6 v[Z(:6Ơ0velS em~Ykj/wleֻ&w{̓w!q =PLyė)OWB׶i)x|kmjW]|WvlPA5lP9ۈ"՝|m;Xy٠`݃c8oa$زA ~ m44~iBEs>Fṇ-m3snII*}, :hu]@pDžkЫBmo|2V.n&sdl0*+3AQC!46M4ՒMfٕ,4|%xQhK> ZO>DbcpL-&rlݜNú=BPxM-+W]vo&d=?hRB,qX- ʺsӢ\t3^7k%Y$`o:eO0\^NRTT"nUV}SoTV&Q/*AQΒpxcHK zu6rU/>v2*W %PLFYd*_ gF0~.*y9[k형&jJVâk߻]8s~Qkp-]D`2PD h X6ǔ^%(6  5%HMѣ0߈"3^s?1w]-@zP F}M!'3ǹ<T{dn=%|c W\o+y՝(;|@L7Л=r*Tgw>Gb `o /PO+ o}oNc_/:-@NG8lO!}R?% $ syFl0"/m]+x4N_K DeY|xȇ#RIq$[%p-p`Xܾ1Kn\r9#rXq *> Hs;IENDB`weboob-1.1/modules/bred/module.py000066400000000000000000000046361265717027300170760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .bred import BredBrowser from .dispobank import DispoBankBrowser __all__ = ['BredModule'] class BredModule(Module, CapBank): NAME = 'bred' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Bred' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe'), Value('website', label=u"Site d'accès", default='bred', choices={'bred': 'BRED', 'dispobank': 'DispoBank'}), Value('accnum', label=u'Numéro du compte bancaire (optionnel)', default='', masked=False) ) BROWSERS = {'bred': BredBrowser, 'dispobank': DispoBankBrowser, } def create_default_browser(self): self.BROWSER = self.BROWSERS[self.config['website'].get()] return self.create_browser(self.config['accnum'].get().replace(' ','').zfill(11), self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): return self.browser.get_history(account) weboob-1.1/modules/bred/test.py000066400000000000000000000017501265717027300165620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class BredTest(BackendTest): MODULE = 'bred' def test_bred(self): l = list(self.backend.iter_accounts()) a = l[0] list(self.backend.iter_history(a)) list(self.backend.iter_coming(a)) weboob-1.1/modules/btdigg/000077500000000000000000000000001265717027300155525ustar00rootroot00000000000000weboob-1.1/modules/btdigg/__init__.py000066400000000000000000000000751265717027300176650ustar00rootroot00000000000000from .module import BTDiggModule __all__ = ['BTDiggModule'] weboob-1.1/modules/btdigg/browser.py000066400000000000000000000023271265717027300176130ustar00rootroot00000000000000# -*- coding: utf-8 -*- import urllib from weboob.deprecated.browser import Browser from .pages.index import IndexPage from .pages.torrents import TorrentsPage, TorrentPage __all__ = ['BTDiggBrowser'] class BTDiggBrowser(Browser): DOMAIN = 'btdigg.org' PROTOCOL = 'https' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = {'https://btdigg.org/': IndexPage, 'https://btdigg.org/search?.*q=[^?]*': TorrentsPage, 'https://btdigg.org/search?.*info_hash=[^?]*': TorrentPage, } def home(self): return self.location('https://btdigg.org') def iter_torrents(self, pattern): self.location('https://btdigg.org/search?q=%s' % urllib.quote_plus(pattern.encode('utf-8'))) assert self.is_on_page(TorrentsPage) return self.page.iter_torrents() def get_torrent(self, id): self.location('https://btdigg.org/search?info_hash=%s' % id) assert self.is_on_page(TorrentPage) return self.page.get_torrent(id) def get_torrent_file(self, id): self.location('https://btdigg.org/search?info_hash=%s' % id) assert self.is_on_page(TorrentPage) return self.page.get_torrent_file(id) weboob-1.1/modules/btdigg/module.py000066400000000000000000000017531265717027300174170ustar00rootroot00000000000000# -*- coding: utf-8 -*- from weboob.capabilities.torrent import CapTorrent from weboob.tools.backend import Module from .browser import BTDiggBrowser __all__ = ['BTDiggModule'] class BTDiggModule(Module, CapTorrent): NAME = 'btdigg' MAINTAINER = u'Matthieu Rakotojaona' EMAIL = 'matthieu.rakotojaona@gmail.com' VERSION = '1.1' DESCRIPTION = 'The BitTorrent DHT search engine.' LICENSE = 'CC0' BROWSER = BTDiggBrowser def create_default_browser(self): return self.create_browser() def get_torrent(self, id): return self.browser.get_torrent(id) def get_torrent_file(self, id): return self.browser.get_torrent_file(id) def iter_torrents(self, pattern): return self.browser.iter_torrents(pattern.replace(' ', '+')) #def fill_torrent(self, torrent, fields): # if 'description' in fields or fields == None: # return self.get_torrent(torrent.id) #OBJECTS = { # Torrent:fill_torrent #} weboob-1.1/modules/btdigg/pages/000077500000000000000000000000001265717027300166515ustar00rootroot00000000000000weboob-1.1/modules/btdigg/pages/__init__.py000066400000000000000000000000001265717027300207500ustar00rootroot00000000000000weboob-1.1/modules/btdigg/pages/index.py000066400000000000000000000001461265717027300203330ustar00rootroot00000000000000# -*- coding: utf-8 -*- from weboob.deprecated.browser import Page class IndexPage(Page): pass weboob-1.1/modules/btdigg/pages/torrents.py000066400000000000000000000061611265717027300211070ustar00rootroot00000000000000# -*- coding: utf-8 -*- from datetime import datetime, timedelta from urlparse import urlparse, parse_qs from weboob.tools.misc import get_bytes_size from weboob.deprecated.browser import Page,BrokenPageError from weboob.capabilities.torrent import Torrent, MagnetOnly from weboob.capabilities.base import NotAvailable class TorrentsPage(Page): def iter_torrents(self): try: table = self.document.getroot().cssselect('table.torrent_name_tbl') except BrokenPageError: return for i in range(0, len(table), 2): # Title title = table[i].cssselect('td.torrent_name a')[0] name = unicode(title.text) url = unicode(title.attrib['href']) # Other elems elems = table[i+1].cssselect('td') magnet = unicode(elems[0].cssselect('a')[0].attrib['href']) query = urlparse(magnet).query # xt=urn:btih:<...>&dn=<...> btih = parse_qs(query)['xt'][0] # urn:btih:<...> ih = btih.split(':')[-1] value, unit = elems[2].cssselect('span.attr_val')[0].text.split() valueago, valueunit, _ = elems[5].cssselect('span.attr_val')[0].text.split() delta = timedelta(**{valueunit: float(valueago)}) date = datetime.now() - delta url = unicode('https://btdigg.org/search?info_hash=%s' % ih) torrent = Torrent(ih, name) torrent.url = url torrent.size = get_bytes_size(float(value), unit) torrent.magnet = magnet torrent.seeders = NotAvailable torrent.leechers = NotAvailable torrent.description = NotAvailable torrent.files = NotAvailable torrent.date = date yield torrent class TorrentPage(Page): def get_torrent(self, id): trs = self.document.getroot().cssselect('table.torrent_info_tbl tr') # magnet download = trs[2].cssselect('td a')[0] if download.attrib['href'].startswith('magnet:'): magnet = unicode(download.attrib['href']) query = urlparse(magnet).query # xt=urn:btih:<...>&dn=<...> btih = parse_qs(query)['xt'][0] # urn:btih:<...> ih = btih.split(':')[-1] name = unicode(trs[3].cssselect('td')[1].text) value, unit = trs[5].cssselect('td')[1].text.split() valueago, valueunit, _ = trs[6].cssselect('td')[1].text.split() delta = timedelta(**{valueunit: float(valueago)}) date = datetime.now() - delta files = [] for tr in trs[15:]: files.append(unicode(tr.cssselect('td')[1].text)) torrent = Torrent(ih, name) torrent.url = unicode(self.url) torrent.size = get_bytes_size(float(value), unit) torrent.magnet = magnet torrent.seeders = NotAvailable torrent.leechers = NotAvailable torrent.description = NotAvailable torrent.files = files torrent.filename = NotAvailable torrent.date = date return torrent def get_torrent_file(self, id): raise MagnetOnly(self.get_torrent(id).magnet) weboob-1.1/modules/btdigg/test.py000066400000000000000000000030271265717027300171050ustar00rootroot00000000000000# -*- coding: utf-8 -*- from weboob.tools.test import BackendTest from weboob.capabilities.torrent import MagnetOnly from random import choice class BTDiggTest(BackendTest): MODULE = 'btdigg' def test_iter_torrents(self): # try something popular so we sometimes get a magnet-only torrent l = list(self.backend.iter_torrents('ubuntu linux')) self.assertTrue(len(l) == 10) for torrent in l: assert torrent.name assert torrent.url assert torrent.size assert torrent.magnet assert torrent.date self.assertEquals(40, len(torrent.id)) def test_get_random_torrentfile(self): torrent = choice(list(self.backend.iter_torrents('ubuntu linux'))) full_torrent = self.backend.get_torrent(torrent.id) try: self.backend.get_torrent_file(torrent.id) except MagnetOnly as e: assert e.magnet.startswith("magnet:") assert e.magnet == full_torrent.magnet def test_get_special_torrent(self): torrent = self.backend.get_torrent("c2e018a16bf28520687e400580be08934d00373a") assert torrent.name == u'Ubuntu Linux Toolbox - 1000+ Commands for Ubuntu and Debian Power Users~tqw~_darksiderg' assert len(torrent.files) == 3 assert torrent.size == float(3376414.72) assert torrent.url == "https://btdigg.org/search?info_hash=c2e018a16bf28520687e400580be08934d00373a" dt = torrent.date assert dt.year == 2011 assert dt.month == 2 weboob-1.1/modules/btmon/000077500000000000000000000000001265717027300154315ustar00rootroot00000000000000weboob-1.1/modules/btmon/__init__.py000066400000000000000000000014271265717027300175460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import BtmonModule __all__ = ['BtmonModule'] weboob-1.1/modules/btmon/browser.py000066400000000000000000000031341265717027300174670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import TorrentsPage, TorrentPage __all__ = ['BtmonBrowser'] class BtmonBrowser(Browser): DOMAIN = 'www.btmon.com' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.btmon.com/torrent/\?f=.*': TorrentsPage, 'http://www.btmon.com/.*torrent.html': TorrentPage, } def iter_torrents(self, pattern): self.location('http://www.btmon.com/torrent/?f=%s' % pattern.encode('utf-8')) assert self.is_on_page(TorrentsPage) return self.page.iter_torrents() def get_torrent(self, id): try: self.location('http://www.btmon.com/%s.html' % id) except BrowserHTTPNotFound: return if self.is_on_page(TorrentPage): return self.page.get_torrent() weboob-1.1/modules/btmon/favicon.png000066400000000000000000000033571265717027300175740ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME(DoIDATxmlEF (TVVʛz lP17CH4j_ 5DQ 'mH9ʁDm,(PiCgw[hO.7gY#F1bG1$@ 0 *T{MV:Mwv_tjxzIYƫ߃D`Ni27uߺa ƵF@14zT7)S8FOh2ƙDJV:UUiF}N `K&\xyڜn 5ؒ"ئd2ttw%jXg /V:JXH xSl 0Xj/6Zy|JO՞NZ1bĈ#FAdj9J'msXrPD~=EV l'8fS–t>as 6c=kv+w=-` (0Z[!`9fiQ_2ZD9TT@ ,>p=:ċt=gTgɒ_c\zŚLՀۥ{?((njq~dbkZVIO ahFrde)a˝pQO1?POBZJuؗSaϔC9rZ@Oڨ3:sELTFrs M–诵ePQ/eN ^Q!(o2nU6_җ#^t`Af*/t:r}`.g;Cu2a Wm&рj9F򻁕*U7S6s%7n0Cu ea B–geYu[-*p/I[ &`V!ly8!l&6F{J(a<D7 a#–5Mq@먱 \\[.QKF;!. from weboob.capabilities.torrent import CapTorrent, Torrent from weboob.tools.backend import Module from .browser import BtmonBrowser from urllib import quote_plus __all__ = ['BtmonModule'] class BtmonModule(Module, CapTorrent): NAME = 'btmon' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'BTMon BitTorrent database' LICENSE = 'AGPLv3+' BROWSER = BtmonBrowser def get_torrent(self, id): return self.browser.get_torrent(id) def get_torrent_file(self, id): torrent = self.browser.get_torrent(id) if not torrent: return None return self.browser.openurl(torrent.url.encode('utf-8')).read() def iter_torrents(self, pattern): return self.browser.iter_torrents(quote_plus(pattern.encode('utf-8'))) def fill_torrent(self, torrent, fields): if 'description' in fields: tor = self.get_torrent(torrent.id) torrent.description = tor.description torrent.magnet = tor.magnet torrent.files = tor.files torrent.url = tor.url return torrent OBJECTS = { Torrent:fill_torrent } weboob-1.1/modules/btmon/pages.py000066400000000000000000000107451265717027300171110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import string from weboob.capabilities.torrent import Torrent from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page from weboob.tools.misc import get_bytes_size class TorrentsPage(Page): def iter_torrents(self): for div in self.parser.select(self.document.getroot(),'div.list_tor'): name = NotAvailable size = NotAvailable seeders = NotAvailable leechers = NotAvailable right_div = self.parser.select(div,'div.list_tor_right',1) try: seeders = int(self.parser.select(right_div,'b.green',1).text) except ValueError: seeders = 0 try: leechers = int(self.parser.select(right_div,'b.red',1).text) except ValueError: leechers = 0 sizep = self.parser.select(right_div,'p')[0] sizespan = self.parser.select(sizep,'span')[0] nsize = float(sizespan.text_content().split(':')[1].split()[0]) usize = sizespan.text_content().split()[-1].upper() size = get_bytes_size(nsize,usize) a = self.parser.select(div,'a.list_tor_title',1) href = a.attrib.get('href','') name = unicode(a.text_content()) id = unicode(href.strip('/').split('.html')[0]) torrent = Torrent(id,name) torrent.url = NotLoaded torrent.filename = id torrent.magnet = NotLoaded torrent.size = size torrent.seeders = seeders torrent.leechers = leechers torrent.description = NotLoaded torrent.files = NotLoaded yield torrent class TorrentPage(Page): def get_torrent(self): seed = 0 leech = 0 description = NotAvailable url = NotAvailable magnet = NotAvailable title = NotAvailable id = unicode(self.browser.geturl().split('.html')[0].split('/')[-1]) div = self.parser.select(self.document.getroot(),'div#middle_content',1) title = u'%s'%self.parser.select(self.document.getroot(),'div#middle_content > h1',1).text slblock_values = self.parser.select(div,'div.sl_block b') if len(slblock_values) >= 2: seed = slblock_values[0].text leech = slblock_values[1].text href_t = self.parser.select(div,'a.down',1).attrib.get('href','') url = u'http://%s%s'%(self.browser.DOMAIN,href_t) magnet = unicode(self.parser.select(div,'a.magnet',1).attrib.get('href','')) divtabs = self.parser.select(div,'div#tabs',1) files_div = self.parser.select(divtabs,'div.body > div.doubleblock > div.leftblock') files = [] if len(files_div) > 0: size_text = self.parser.select(files_div,'h5',1).text for b in self.parser.select(files_div,'b'): div = b.getparent() files.append(div.text_content()) else: size_text = self.parser.select(divtabs,'h5',1).text_content() size_text = size_text.split('(')[1].split(')')[0].strip() size = float(size_text.split(',')[1].strip(string.letters)) u = size_text.split(',')[1].strip().translate(None,string.digits).strip('.').strip().upper() div_desc = self.parser.select(divtabs,'div#descriptionContent') if len(div_desc) > 0: description = unicode(div_desc[0].text_content()) torrent = Torrent(id, title) torrent.url = url torrent.filename = id torrent.magnet = magnet torrent.size = get_bytes_size(size, u) torrent.seeders = int(seed) torrent.leechers = int(leech) torrent.description = description torrent.files = files return torrent weboob-1.1/modules/btmon/test.py000066400000000000000000000026041265717027300167640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.base import NotLoaded from random import choice class BtmonTest(BackendTest): MODULE = 'btmon' def test_torrent(self): torrents = list(self.backend.iter_torrents('spiderman')) for torrent in torrents: assert torrent.id assert torrent.name assert torrent.description is NotLoaded assert torrent.files is NotLoaded # get the file of a random torrent # from the list (getting them all would be too long) if len(torrents): torrent = choice(torrents) self.backend.get_torrent_file(torrent.id) weboob-1.1/modules/caissedepargne/000077500000000000000000000000001265717027300172675ustar00rootroot00000000000000weboob-1.1/modules/caissedepargne/__init__.py000066400000000000000000000014461265717027300214050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CaisseEpargneModule __all__ = ['CaisseEpargneModule'] weboob-1.1/modules/caissedepargne/browser.py000066400000000000000000000150111265717027300213220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from urlparse import urlsplit from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.capabilities.bank import Account from .pages import LoginPage, IndexPage, ErrorPage, UnavailablePage, MarketPage, LifeInsurance, GarbagePage __all__ = ['CaisseEpargne'] class CaisseEpargne(Browser): DOMAIN = 'www.caisse-epargne.fr' PROTOCOL = 'https' CERTHASH = ['9a5af08c31a22a0dbc2724cec14ce9b1f8e297571c046c2210a16fa3a9f8fc2e', '0e0fa585a8901c206c4ebbc7ee33e00e17809d7086f224e1b226c46165a4b5ac'] PAGES = {'https://[^/]+/particuliers/ind_pauthpopup.aspx.*': LoginPage, 'https://[^/]+/Portail.aspx.*': IndexPage, 'https://[^/]+/login.aspx': ErrorPage, 'https://[^/]+/Pages/logout.aspx.*': ErrorPage, 'https://[^/]+/page_hs_dei_.*.aspx': UnavailablePage, 'https://[^/]+/Pages/Bourse.*': MarketPage, 'https://www.caisse-epargne.offrebourse.com/ReroutageSJR': MarketPage, 'https://www.caisse-epargne.offrebourse.com/Portefeuille': MarketPage, 'https://[^/]+/Assurance/Pages/Assurance.aspx': LifeInsurance, 'https://www.extranet2.caisse-epargne.fr.*': LifeInsurance, 'https://www.caisse-epargne.offrebourse.com/DetailMessage\?refresh=O': GarbagePage, } def __init__(self, nuser, *args, **kwargs): self.nuser = nuser self.DOMAIN = kwargs.pop('domain', self.DOMAIN) Browser.__init__(self, *args, **kwargs) def is_logged(self): return self.page is not None and not self.is_on_page((LoginPage,ErrorPage)) def home(self): if self.is_logged(): self.location(self.buildurl('/Portail.aspx')) else: self.login() def login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if self.is_logged(): return self._ua_handlers['_cookies'].cookiejar.clear() if not self.is_on_page(LoginPage): self.location(self.buildurl('/particuliers/ind_pauthpopup.aspx?mar=101®=&fctpopup=auth&cv=0'), no_login=True) self.page.login(self.username) if not self.page.login2(self.nuser, self.password): # perso self.page.login3(self.password) if not self.is_logged(): raise BrowserIncorrectPassword() v = urlsplit(self.page.url) self.DOMAIN = v.netloc def get_accounts_list(self): if self.is_on_page(IndexPage): self.page.go_list() else: self.location(self.buildurl('/Portail.aspx')) accounts = list(self.page.get_list()) for account in accounts: if account.type == Account.TYPE_MARKET: if not self.is_on_page(IndexPage): self.location(self.buildurl('/Portail.aspx?tache=CPTSYNT0')) self.page.go_history(account._info) # Some users may not have access to this. if not self.is_on_page(MarketPage): continue self.page.submit() if self.page.is_error(): continue self.location('https://www.caisse-epargne.offrebourse.com/Portefeuille') if self.is_on_page(GarbagePage): continue self.page.get_valuation_diff(account) return iter(accounts) def get_account(self, id): assert isinstance(id, basestring) l = self.get_accounts_list() for a in l: if a.id == id: return a return None def _get_history(self, info): if not info['link'].startswith('HISTORIQUE'): return if self.is_on_page(IndexPage): self.page.go_list() else: self.location(self.buildurl('/Portail.aspx?tache=CPTSYNT0')) self.page.go_history(info) while True: assert self.is_on_page(IndexPage) for tr in self.page.get_history(): yield tr if not self.page.go_next(): return def get_history(self, account): return self._get_history(account._info) def get_coming(self, account): for info in account._card_links: for tr in self._get_history(info): tr.type = tr.TYPE_CARD yield tr def get_investment(self, account): if account.type is not Account.TYPE_LIFE_INSURANCE and account.type is not Account.TYPE_MARKET: raise NotImplementedError() if self.is_on_page(IndexPage): self.page.go_list() else: self.location(self.buildurl('/Portail.aspx')) self.page.go_history(account._info) if account.type is Account.TYPE_MARKET: # Some users may not have access to this. if not self.is_on_page(MarketPage): return iter([]) self.page.submit() if self.page.is_error(): return iter([]) self.location('https://www.caisse-epargne.offrebourse.com/Portefeuille') elif account.type is Account.TYPE_LIFE_INSURANCE: try: self.page.go_life_insurance(account) self.page.submit() self.location('https://www.extranet2.caisse-epargne.fr%s' % self.page.get_cons_repart()) except IndexError: return iter([]) if self.is_on_page(GarbagePage): return iter([]) return self.page.iter_investment() weboob-1.1/modules/caissedepargne/favicon.png000066400000000000000000000101161265717027300214210ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME  -2GIDATxyxe_UG PG\FmqFqTzqq"U@;2(]qAP\ k $$Nҝ^4i {Tn#s0%+WH ~P@/(5hW'yGFPBnhĬ&'?+.QTDK/&qTVb,BJJMA"oKr*  ?#;f QJ)T:槟u\eXfpڄI)2@xȻ7vXIyrm>3m($~>G884+#ŗA_jmv}9gMJCn _+sb4b'iNGK'R|eHBSwmP onKvs@;ww HM&.e8K1JKN2zp~?RZ?_D͓}4v1fp=p8Bd*E{bb[TaQYNw74 ^"+FEIՓ\tc&%Մ_ښk"pWe% ]Z!ǃQRp:fRv8AC펱,i|8++== QsE_ Jeq#8JKmIT. bk']{!d*77\CQG@b~~{@_h>*\RMTN(-EIIrݤ֯d!xd sϥ;Ѽ^R멿ӞA\h~?FQ!z("$eY^*ﻃg4>g" 2|@E^(Dz˹a7-{ʮ AF{?5h *Da#XfFݰc({ °YpH>}N/0W!^`lxK4@Ds8zo&N v\X6V|xCIэk.7省gg쳅$kjwy;g$ngU8 =c7hǓs QTHŤ6r{|V:'Z<~4N'_J䛩`2.'l5I+ !ۢX(*ayQD6T(+5d z @l"hw0_^XhHb-$ ž\{9}i2 w?o/p5Dl"}%mv}k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/modules/caissedepargne/module.py000066400000000000000000000055431265717027300211350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.ordereddict import OrderedDict from .browser import CaisseEpargne __all__ = ['CaisseEpargneModule'] class CaisseEpargneModule(Module, CapBank): NAME = 'caissedepargne' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Caisse d\'Épargne' LICENSE = 'AGPLv3+' website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ 'www.caisse-epargne.fr': u'Caisse d\'Épargne', 'www.banquebcp.fr': u'Banque BCP', }.iteritems(), key=lambda k_v: (k_v[1], k_v[0]))]) CONFIG = BackendConfig(Value('website', label='Banque', choices=website_choices, default='www.caisse-epargne.fr'), ValueBackendPassword('login', label='Identifiant client', masked=False), ValueBackendPassword('password', label='Code personnel', regexp='\d+'), Value('nuser', label='User ID (optional)', default='')) BROWSER = CaisseEpargne def create_default_browser(self): return self.create_browser(nuser=self.config['nuser'].get(), username=self.config['login'].get(), password=self.config['password'].get(), domain=self.config['website'].get()) def iter_accounts(self): with self.browser: return self.browser.get_accounts_list() def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): with self.browser: return self.browser.get_history(account) def iter_coming(self, account): with self.browser: return self.browser.get_coming(account) def iter_investment(self, account): return self.browser.get_investment(account) weboob-1.1/modules/caissedepargne/pages.py000066400000000000000000000516221265717027300207460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.mech import ClientForm ControlNotFoundError = ClientForm.ControlNotFoundError from decimal import Decimal import re from weboob.deprecated.mech import ClientForm from weboob.tools.ordereddict import OrderedDict from weboob.deprecated.browser import Page, BrokenPageError, BrowserUnavailable, BrowserIncorrectPassword from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account, Investment from weboob.tools.capabilities.bank.transactions import FrenchTransaction class GarbagePage(Page): pass class _LogoutPage(Page): def on_loaded(self): try: raise BrowserIncorrectPassword(self.parser.tocleanstring(self.parser.select(self.document.getroot(), '.messErreur', 1))) except BrokenPageError: pass class LoginPage(_LogoutPage): def login(self, login): self.browser.select_form(name='Main') self.browser.set_all_readonly(False) self.browser['ctl01$CC_ind_pauthpopup$ctl01$CC_ind_ident$ctl01$CC_ind_inputuserid_sup$txnuabbd'] = login.encode('utf-8') self.browser['__EVENTTARGET'] = 'ctl01$CC_ind_pauthpopup$ctl01$CC_ind_ident$ctl01$CC_ind_inputuserid_sup$btnValider' self.browser.submit(nologin=True) def login2(self, nuser, passwd): self.browser.select_form(name='Main') self.browser.set_all_readonly(False) self.browser['__EVENTARGUMENT'] = 'idsrv=WE' m = None try: a = self.document.xpath('//a[@title="Valider"]')[0] except IndexError: pass else: m = re.match("javascript:RedirectToDeiPro\('([^']+)', \d+\);", a.attrib['href']) if m: self.browser['nuusager'] = nuser.encode('utf-8') self.browser['codconf'] = passwd.encode('utf-8') self.browser.form.action = m.group(1) self.browser.submit(nologin=True) return m is not None def login3(self, passwd): self.browser.select_form(name='Main') self.browser['codconf'] = passwd.encode('utf-8') a = self.document.xpath('//a[@title="Valider"]')[0] m = re.match("javascript:RedirectToDeiPart\('([^']+)'\);", a.attrib['href']) if not m: raise BrokenPageError('Unable to find validate URL') self.browser.form.action = m.group(1) self.browser.submit(nologin=True) class ErrorPage(_LogoutPage): pass class UnavailablePage(Page): def on_loaded(self): try: raise BrowserUnavailable(self.parser.select(self.document.getroot(), 'div#message_error_hs', 1).text.strip()) except BrokenPageError: raise BrowserUnavailable() class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^CB (?P.*?) FACT (?P
\d{2})(?P\d{2})(?P\d{2})', re.IGNORECASE), FrenchTransaction.TYPE_CARD), (re.compile('^RET(RAIT)? DAB (?P
\d+)-(?P\d+)-.*', re.IGNORECASE), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^RET(RAIT)? DAB (?P.*?) (?P
\d{2})(?P\d{2})(?P\d{2}) (?P\d{2})H(?P\d{2})', re.IGNORECASE), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^VIR(EMENT)?(\.PERIODIQUE)? (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_TRANSFER), (re.compile('^PRLV (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_ORDER), (re.compile('^CHEQUE.*', re.IGNORECASE), FrenchTransaction.TYPE_CHECK), (re.compile('^(CONVENTION \d+ )?COTIS(ATION)? (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_BANK), (re.compile(r'^\* (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_BANK), (re.compile('^REMISE (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^(?P.*)( \d+)? QUITTANCE .*', re.IGNORECASE), FrenchTransaction.TYPE_ORDER), (re.compile('^CB [\d\*]+ (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_CARD), ] class IndexPage(Page): ACCOUNT_TYPES = {u'Epargne liquide': Account.TYPE_SAVINGS, u'Compte Courant': Account.TYPE_CHECKING, u'Mes comptes': Account.TYPE_CHECKING, u'Mon épargne': Account.TYPE_SAVINGS, u'Mes autres comptes': Account.TYPE_SAVINGS, u'Compte Epargne et DAT': Account.TYPE_SAVINGS, u'Plan et Contrat d\'Epargne': Account.TYPE_SAVINGS, u'Titres': Account.TYPE_MARKET, u'Compte titres': Account.TYPE_MARKET, } def on_loaded(self): # This page is sometimes an useless step to the market website. bourse_link = self.document.xpath(u'//div[@id="MM_COMPTE_TITRE_pnlbourseoic"]//a[contains(text(), "Accédez à la consultation")]') if len(bourse_link) == 1: self.browser.location(bourse_link[0].attrib['href']) def _get_account_info(self, a): m = re.search("PostBack(Options)?\([\"'][^\"']+[\"'],\s*['\"]([HISTORIQUE_\w|SYNTHESE_ASSURANCE_CNP|BOURSE|COMPTE_TITRE][\d\w&]+)?['\"]", a.attrib.get('href', '')) if m is None: return None else: # it is in form CB&12345[&2]. the last part is only for new website # and is necessary for navigation. link = m.group(2) parts = link.split('&') info = {} if len(parts) > 1: info['type'] = parts[0] info['id'] = parts[1] else: id = re.search("([\d]+)", a.attrib.get('title')) info['type'] = link info['id'] = id.group(1) if info['type'] == 'SYNTHESE_ASSURANCE_CNP': info['acc_type'] = Account.TYPE_LIFE_INSURANCE if info['type'] in ('BOURSE', 'COMPTE_TITRE'): info['acc_type'] = Account.TYPE_MARKET info['link'] = link return info def _add_account(self, accounts, link, label, account_type, balance): info = self._get_account_info(link) if info is None: self.logger.warning('Unable to parse account %r: %r' % (label, link)) return account = Account() account.id = info['id'] account.iban = u'FR76' + info['id'] account._info = info account.label = label account.type = info['acc_type'] if 'acc_type' in info else account_type account.balance = Decimal(FrenchTransaction.clean_amount(balance)) if balance else self.get_balance(account) account.currency = account.get_currency(balance) account._card_links = [] if account._info['type'] == 'HISTORIQUE_CB' and account.id in accounts: a = accounts[account.id] if not a.coming: a.coming = Decimal('0.0') a.coming += account.balance a._card_links.append(account._info) return accounts[account.id] = account def get_balance(self, account): if not account.type == Account.TYPE_LIFE_INSURANCE: return NotAvailable self.go_history(account._info) balance = self.browser.page.document.xpath('.//tr[td[contains(text(), ' + account.id + ')]]/td[contains(@class, "somme")]') if len(balance) > 0: balance = self.parser.tocleanstring(balance[0]) balance = Decimal(FrenchTransaction.clean_amount(balance)) if balance != u'' else NotAvailable else: balance = NotAvailable self.go_list() return balance def get_list(self): accounts = OrderedDict() # Old website for table in self.document.xpath('//table[@cellpadding="1"]'): account_type = Account.TYPE_UNKNOWN for tr in table.xpath('./tr'): tds = tr.findall('td') if tr.attrib.get('class', '') == 'DataGridHeader': account_type = self.ACCOUNT_TYPES.get(tds[1].text.strip()) or\ self.ACCOUNT_TYPES.get(self.parser.tocleanstring(tds[2])) or\ self.ACCOUNT_TYPES.get(self.parser.tocleanstring(tds[3]), Account.TYPE_UNKNOWN) else: # On the same row, there are many accounts (for example a # check accound and a card one). if len(tds) > 4: for i, a in enumerate(tds[2].xpath('./a')): label = self.parser.tocleanstring(a) balance = self.parser.tocleanstring(tds[-2].xpath('./a')[i]) self._add_account(accounts, a, label, account_type, balance) # Only 4 tds on banque de la reunion website. elif len(tds) == 4: for i, a in enumerate(tds[1].xpath('./a')): label = self.parser.tocleanstring(a) balance = self.parser.tocleanstring(tds[-1].xpath('./a')[i]) self._add_account(accounts, a, label, account_type, balance) if len(accounts) == 0: # New website for table in self.document.xpath('//div[@class="panel"]'): title = table.getprevious() if title is None: continue account_type = self.ACCOUNT_TYPES.get(self.parser.tocleanstring(title), Account.TYPE_UNKNOWN) for tr in table.xpath('.//tr'): tds = tr.findall('td') for i in xrange(len(tds)): a = tds[i].find('a') if a is not None: break if a is None: continue label = self.parser.tocleanstring(tds[0]) balance = self.parser.tocleanstring(tds[-1]) self._add_account(accounts, a, label, account_type, balance) return accounts.itervalues() def go_list(self): self.browser.select_form(name='main') self.browser.set_all_readonly(False) self.browser['__EVENTARGUMENT'] = 'CPTSYNT0' self.browser.controls.append(ClientForm.TextControl('text', 'm_ScriptManager', {'value': ''})) # Ugly check to determine if we are on the new or old website. try: self.browser['MM$m_CH$IsMsgInit'] except ControlNotFoundError: self.logger.debug('New website') self.browser['__EVENTTARGET'] = 'MM$m_PostBack' self.browser['m_ScriptManager'] = 'MM$m_UpdatePanel|MM$m_PostBack' else: self.logger.debug('Old website') self.browser['__EVENTTARGET'] = 'Menu_AJAX' self.browser['m_ScriptManager'] = 'm_ScriptManager|Menu_AJAX' try: self.browser.controls.remove(self.browser.find_control(name='Cartridge$imgbtnMessagerie', type='image')) self.browser.controls.remove(self.browser.find_control(name='MM$m_CH$ButtonImageFondMessagerie', type='image')) self.browser.controls.remove(self.browser.find_control(name='MM$m_CH$ButtonImageMessagerie', type='image')) except ControlNotFoundError: pass self.browser.submit() def go_history(self, info): self.browser.select_form(name='main') self.browser.set_all_readonly(False) self.browser['__EVENTTARGET'] = 'MM$SYNTHESE' self.browser['__EVENTARGUMENT'] = info['link'] try: self.browser['MM$m_CH$IsMsgInit'] = '0' except ControlNotFoundError: # Not available on new website. pass self.browser.controls.append(ClientForm.TextControl('text', 'm_ScriptManager', {'value': ''})) self.browser['m_ScriptManager'] = 'MM$m_UpdatePanel|MM$SYNTHESE' try: self.browser.controls.remove(self.browser.find_control(name='Cartridge$imgbtnMessagerie', type='image')) self.browser.controls.remove(self.browser.find_control(name='MM$m_CH$ButtonImageFondMessagerie', type='image')) self.browser.controls.remove(self.browser.find_control(name='MM$m_CH$ButtonImageMessagerie', type='image')) except ControlNotFoundError: pass self.browser.submit() def get_history(self): i = 0 ignore = False for tr in self.document.xpath('//table[@cellpadding="1"]/tr') + self.document.xpath('//tr[@class="rowClick" or @class="rowHover"]'): tds = tr.findall('td') if len(tds) < 4: continue # if there are more than 4 columns, ignore the first one. i = min(len(tds) - 4, 1) if tr.attrib.get('class', '') == 'DataGridHeader': if tds[2].text == u'Titulaire': ignore = True else: ignore = False continue if ignore: continue # Remove useless details detail = tr.cssselect('div.detail') if len(detail) > 0: detail[0].drop_tree() t = Transaction() date = u''.join([txt.strip() for txt in tds[i+0].itertext()]) raw = u' '.join([txt.strip() for txt in tds[i+1].itertext()]) debit = u''.join([txt.strip() for txt in tds[-2].itertext()]) credit = u''.join([txt.strip() for txt in tds[-1].itertext()]) t.parse(date, re.sub(r'[ ]+', ' ', raw)) if t.date is NotAvailable or 'Tot Dif' in t.raw: continue t.set_amount(credit, debit) yield t i += 1 def go_next(self): # link = self.document.xpath('//a[contains(@id, "lnkSuivante")]') if len(link) == 0 or 'disabled' in link[0].attrib: return False account_type = 'COMPTE' m = re.search('HISTORIQUE_(\w+)', link[0].attrib['href']) if m: account_type = m.group(1) self.browser.select_form(name='main') self.browser.set_all_readonly(False) self.browser['__EVENTTARGET'] = 'MM$HISTORIQUE_%s$lnkSuivante' % account_type self.browser['__EVENTARGUMENT'] = '' try: self.browser['MM$m_CH$IsMsgInit'] = 'N' except ControlNotFoundError: # New website pass self.browser.controls.append(ClientForm.TextControl('text', 'm_ScriptManager', {'value': ''})) self.browser['m_ScriptManager'] = 'MM$m_UpdatePanel|MM$HISTORIQUE_COMPTE$lnkSuivante' try: self.browser.controls.remove(self.browser.find_control(name='Cartridge$imgbtnMessagerie', type='image')) self.browser.controls.remove(self.browser.find_control(name='MM$m_CH$ButtonImageFondMessagerie', type='image')) self.browser.controls.remove(self.browser.find_control(name='MM$m_CH$ButtonImageMessagerie', type='image')) except ControlNotFoundError: pass self.browser.submit() return True def go_life_insurance(self, account): link = self.document.xpath('//table[@summary="Mes contrats d\'assurance vie"]/tbody/tr[td[contains(text(), ' + account.id + ') ]]//a')[0] m = re.search("PostBack(Options)?\([\"'][^\"']+[\"'],\s*['\"](REDIR_ASS_VIE[\d\w&]+)?['\"]", link.attrib.get('href', '')) if m is not None: self.browser.select_form(name='main') self.browser.set_all_readonly(False) self.browser['__EVENTTARGET'] = 'MM$SYNTHESE_ASSURANCE_CNP' self.browser['__EVENTARGUMENT'] = m.group(2) try: self.browser['MM$m_CH$IsMsgInit'] = '0' except ControlNotFoundError: # Not available on new website. pass self.browser.controls.append(ClientForm.TextControl('text', 'm_ScriptManager', {'value': ''})) self.browser['m_ScriptManager'] = 'MM$m_UpdatePanel|MM$SYNTHESE' try: self.browser.controls.remove(self.browser.find_control(name='Cartridge$imgbtnMessagerie', type='image')) self.browser.controls.remove(self.browser.find_control(name='MM$m_CH$ButtonImageFondMessagerie', type='image')) self.browser.controls.remove(self.browser.find_control(name='MM$m_CH$ButtonImageMessagerie', type='image')) except ControlNotFoundError: pass self.browser.submit() class MarketPage(Page): def is_error(self): try: return self.document.xpath('//caption')[0].text == "Erreur" except IndexError: return False def parse_decimal(self, td): value = self.parser.tocleanstring(td) if value and value != '-': return Decimal(FrenchTransaction.clean_amount(value)) else: return NotAvailable def submit(self): self.browser.select_form(nr=1) self.browser.submit() def iter_investment(self): for tbody in self.document.xpath(u'//table[@summary="Contenu du portefeuille valorisé"]/tbody'): inv = Investment() inv.label = self.parser.tocleanstring(tbody.xpath('./tr[1]/td[1]/a/span')[0]) inv.code = self.parser.tocleanstring(tbody.xpath('./tr[1]/td[1]/a')[0]).split(' - ')[1] inv.quantity = self.parse_decimal(tbody.xpath('./tr[2]/td[2]')[0]) inv.unitvalue = self.parse_decimal(tbody.xpath('./tr[2]/td[3]')[0]) inv.unitprice = self.parse_decimal(tbody.xpath('./tr[2]/td[5]')[0]) inv.valuation = self.parse_decimal(tbody.xpath('./tr[2]/td[4]')[0]) inv.diff = self.parse_decimal(tbody.xpath('./tr[2]/td[7]')[0]) yield inv def get_valuation_diff(self, account): valuation_diff = re.sub(r'\(.*\)', '', self.document.xpath(u'//td[contains(text(), "values latentes")]/following-sibling::*[1]')[0].text) account.valuation_diff = Decimal(FrenchTransaction.clean_amount(valuation_diff)) class LifeInsurance(MarketPage): def get_cons_repart(self): return self.document.xpath('//tr[@id="sousMenuConsultation3"]/td/div/a')[0].attrib['href'] def iter_investment(self): for tr in self.document.xpath(u'//table[@class="boursedetail"]/tr[@class and not(@class="total")]'): inv = Investment() libelle = self.parser.tocleanstring(tr.xpath('./td[1]')[0]).split(' ') inv.label, inv.code = self.split_label_code(libelle) diff = self.parse_decimal(tr.xpath('./td[6]')[0]) inv.quantity = self.parse_decimal(tr.xpath('./td[2]')[0]) inv.unitvalue = self.parse_decimal(tr.xpath('./td[3]')[0]) inv.unitprice = self.calc(inv.unitvalue, diff) inv.valuation = self.parse_decimal(tr.xpath('./td[5]')[0]) inv.diff = self.get_diff(inv.valuation, self.calc(inv.valuation, diff)) yield inv def calc(self, value, diff): if value is NotAvailable or diff is NotAvailable: return NotAvailable return Decimal(value) / (1 + Decimal(diff)/100) def get_diff(self, valuation, calc): if valuation is NotAvailable or calc is NotAvailable: return NotAvailable return valuation - calc def split_label_code(self, libelle): m = re.search('FR\d+', libelle[-1]) if m: return ' '.join(libelle[:-1]), libelle[-1] else: return ' '.join(libelle), NotAvailable weboob-1.1/modules/caissedepargne/test.py000066400000000000000000000017711265717027300206260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CaisseEpargneTest(BackendTest): MODULE = 'caissedepargne' def test_caisse_epargne(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/canalplus/000077500000000000000000000000001265717027300162745ustar00rootroot00000000000000weboob-1.1/modules/canalplus/__init__.py000066400000000000000000000014441265717027300204100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CanalplusModule __all__ = ['CanalplusModule'] weboob-1.1/modules/canalplus/browser.py000066400000000000000000000076531265717027300203440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Nicolas Duhamel, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import requests import urllib import lxml.etree from weboob.deprecated.browser import Browser from weboob.deprecated.browser.decorators import id2url from .pages import ChannelsPage, VideoPage from .video import CanalplusVideo from weboob.capabilities.collection import CollectionNotFound __all__ = ['CanalplusBrowser'] class XMLParser(object): def parse(self, data, encoding=None): if encoding is None: parser = None else: parser = lxml.etree.XMLParser(encoding=encoding, strip_cdata=False) return lxml.etree.XML(data.get_data(), parser) class CanalplusBrowser(Browser): DOMAIN = u'service.canal-plus.com' ENCODING = 'utf-8' PAGES = { r'http://service.canal-plus.com/video/rest/initPlayer/cplus/': ChannelsPage, r'http://service.canal-plus.com/video/rest/search/cplus/.*': VideoPage, r'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/(?P.+)': VideoPage, r'http://service.canal-plus.com/video/rest/getMEAs/cplus/.*': VideoPage, } #We need lxml.etree.XMLParser to read CDATA PARSER = XMLParser() FORMATS = { 'sd': 0, 'hd': -1, } def __init__(self, quality, *args, **kwargs): Browser.__init__(self, parser=self.PARSER, *args, **kwargs) self.quality = self.FORMATS.get(quality, self.FORMATS['hd']) def home(self): self.location('http://service.canal-plus.com/video/rest/initPlayer/cplus/') def search_videos(self, pattern): self.location('http://service.canal-plus.com/video/rest/search/cplus/' + urllib.quote_plus(pattern.replace('/', '').encode('utf-8'))) return self.page.iter_results() @id2url(CanalplusVideo.id2url) def get_video(self, url, video=None): self.location(url) video = self.page.get_video(video) video.url = u'%s' % self.read_url(video.url)[self.quality] return video def read_url(self, url): r = requests.get(url, stream=True) buf = r.iter_lines() return [line for line in buf if not line.startswith('#')] def iter_resources(self, split_path): if not self.is_on_page(ChannelsPage): self.home() channels = self.page.get_channels() if len(split_path) == 0: for channel in channels: if channel.path_level == 1: yield channel elif len(split_path) == 1: for channel in channels: if channel.path_level == 2 and split_path == channel.parent_path: yield channel elif len(split_path) == 2: subchannels = self.iter_resources(split_path[0:1]) try: channel = [subchannel for subchannel in subchannels if split_path == subchannel.split_path][0] self.location("http://service.canal-plus.com/video/rest/getMEAs/cplus/%s" % channel._link_id) assert self.is_on_page(VideoPage) for video in self.page.iter_channel(): yield video except IndexError: raise CollectionNotFound(split_path) else: raise CollectionNotFound(split_path) weboob-1.1/modules/canalplus/favicon.png000066400000000000000000000012141265717027300204250ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME  ()ttEXtCommentCreated with GIMPWIDATx1@JA )lDA/g>#R B$0o&c+Mf~*DDDDDDDDDI\@,!<y0un+ IGw^/qw b1ά{I)%͇RJe8^zkm#mO nyWZ~DQp`)n}LZVaZAqsf35`<Ǐ7 ?XJ!u\.v?Fʡ:(RnZ-uj 5uhY X.6. P@5KweY0Pa²,ezN-@Gֳ\|>N&4^3͔R 9,n}G>O\\(p\A4Me@u]W c|K읾BIENDB`weboob-1.1/modules/canalplus/module.py000066400000000000000000000050731265717027300201400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.capabilities.video import CapVideo, BaseVideo from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value from .browser import CanalplusBrowser from .video import CanalplusVideo from weboob.capabilities.collection import CapCollection __all__ = ['CanalplusModule'] class CanalplusModule(Module, CapVideo, CapCollection): NAME = 'canalplus' MAINTAINER = u'Nicolas Duhamel' EMAIL = 'nicolas@jombi.fr' VERSION = '1.1' DESCRIPTION = 'Canal Plus French TV' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('quality', label='Quality of videos', choices=['hd', 'sd'], default='hd')) BROWSER = CanalplusBrowser def create_default_browser(self): return self.create_browser(quality=self.config['quality'].get()) def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): with self.browser: return self.browser.search_videos(pattern) def get_video(self, _id): m = re.match('https?://www\.canal-?plus\.fr/.*\?vid=(\d+)', _id) if m: _id = m.group(1) with self.browser: return self.browser.get_video(_id) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields with self.browser: video = self.browser.get_video(CanalplusVideo.id2url(video.id), video) if 'thumbnail' in fields and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) return video OBJECTS = {CanalplusVideo: fill_video} def iter_resources(self, objs, split_path): if BaseVideo in objs: with self.browser: return self.browser.iter_resources(split_path) weboob-1.1/modules/canalplus/pages.py000066400000000000000000000101531265717027300177450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Nicolas Duhamel, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime import re from weboob.deprecated.browser import Page from weboob.capabilities.collection import Collection from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.capabilities.image import BaseImage from .video import CanalplusVideo class ChannelsPage(Page): def get_channels(self): """ Extract all possible channels (paths) from the page """ channels = list() for elem in self.document[2].getchildren(): for e in elem.getchildren(): if e.tag == "NOM": fid, name = self._clean_name(e.text) channels.append(Collection([fid], name)) elif e.tag == "SELECTIONS": for select in e: sub_fid, subname = self._clean_name(select[1].text) sub = Collection([fid, sub_fid], subname) sub._link_id = select[0].text channels.append(sub) return channels def _clean_name(self, name): name = unicode(name.strip()) if name == name.upper(): name = name.capitalize() friendly_id = re.sub(ur"['/_ \(\)\-\+]+", u'-', name).strip(u'-').lower() return friendly_id, name class VideoPage(Page): def parse_video(self, el, video=None): _id = el.find('ID').text if _id == '-1': # means the video is not found return None if not video: video = CanalplusVideo(_id) infos = el.find('INFOS') video.title = u'' for part in infos.find('TITRAGE'): if len(part.text.strip()) == 0: continue if len(video.title) > 0: video.title += u' — ' video.title += part.text.strip() video.description = unicode(infos.find('DESCRIPTION').text) media = el.find('MEDIA') url = media.find('IMAGES').find('PETIT').text if url: video.thumbnail = BaseImage(url) video.thumbnail.url = video.thumbnail.id else: video.thumbnail = NotAvailable for format in media.find('VIDEOS'): if format.text is None: continue if format.tag == 'HLS': video.ext = u'm3u8' video.url = unicode(format.text) break day, month, year = map(int, infos.find('PUBLICATION').find('DATE').text.split('/')) hour, minute, second = map(int, infos.find('PUBLICATION').find('HEURE').text.split(':')) video.date = datetime(year, month, day, hour, minute, second) return video def iter_results(self): for vid in self.document.getchildren(): video = self.parse_video(vid) video.url = NotLoaded yield video def iter_channel(self): for vid in self.document.getchildren(): yield self.parse_video_channel(vid) def parse_video_channel(self, el): _id = el[0].text video = CanalplusVideo(_id) video.title = u'%s' % el[2][5][0].text video.date = datetime.now() return video def get_video(self, video): _id = self.group_dict['id'] for vid in self.document.getchildren(): if _id not in vid.find('ID').text: continue return self.parse_video(vid, video) weboob-1.1/modules/canalplus/test.py000066400000000000000000000026551265717027300176350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo class CanalPlusTest(BackendTest): MODULE = 'canalplus' def test_canalplus(self): l = list(self.backend.search_videos(u'guignol')) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and (v.url.startswith('rtmp://') or v.url.startswith('http://')), 'URL for video "%s" not found: %s' % (v.id, v.url)) def test_ls(self): l = list(self.backend.iter_resources((BaseVideo, ), [])) self.assertTrue(len(l) > 0) l = list(self.backend.iter_resources((BaseVideo, ), [u'sport'])) self.assertTrue(len(l) > 0) weboob-1.1/modules/canalplus/video.py000066400000000000000000000017201265717027300177540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import BaseVideo class CanalplusVideo(BaseVideo): swf_player = False @classmethod def id2url(cls, _id): return 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' % _id weboob-1.1/modules/canaltp/000077500000000000000000000000001265717027300157345ustar00rootroot00000000000000weboob-1.1/modules/canaltp/__init__.py000066400000000000000000000014371265717027300200520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CanalTPModule __all__ = ['CanalTPModule'] weboob-1.1/modules/canaltp/browser.py000066400000000000000000000054231265717027300177750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime, date, time from weboob.deprecated.browser import Browser from weboob.tools.misc import to_unicode from weboob.deprecated.browser import BrokenPageError __all__ = ['CanalTP'] class CanalTP(Browser): DOMAIN = 'widget.canaltp.fr' def __init__(self, **kwargs): Browser.__init__(self, '', **kwargs) def iter_station_search(self, pattern): url = u'http://widget.canaltp.fr/Prochains_departs_15122009/dev/gare.php?txtrech=%s' % unicode(pattern) result = self.openurl(url.encode('utf-8')).read() for station in result.split('&'): try: _id, name = station.split('=') except ValueError: continue else: yield _id, to_unicode(name) def iter_station_departures(self, station_id, arrival_id=None): url = u'http://widget.canaltp.fr/Prochains_departs_15122009/dev/index.php?gare=%s' % unicode(station_id) result = self.openurl(url.encode('utf-8')).read() result = result departure = '' for line in result.split('&'): if '=' not in line: raise BrokenPageError('Unable to parse result: %s' % line) key, value = line.split('=', 1) if key == 'nomgare': departure = value elif key.startswith('ligne'): _type, unknown, _time, arrival, served, late, late_reason = value.split(';', 6) yield {'type': to_unicode(_type), 'time': datetime.combine(date.today(), time(*[int(x) for x in _time.split(':')])), 'departure': to_unicode(departure), 'arrival': to_unicode(arrival).strip(), 'late': late and time(0, int(late.split()[0])) or time(), 'late_reason': to_unicode(late_reason).replace('\n', '').strip()} def home(self): pass def login(self): pass def is_logged(self): """ Do not need to be logged """ return True weboob-1.1/modules/canaltp/favicon.png000066400000000000000000000046101265717027300200700ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME %p IDATx_l[W?{'cvhײt*֍l&h݀h{ U4!&D44^[6 ֔]4N$c_Ã='{^{}Ͽ΁-ْkZDG1 v@at.nG;W_I`߀A>/oG̺_< <e/G6/* ݐ?n%A`l)n΍ [cNK̖bȰujcGǜ%m QiKUA3@rL v{oVk b= n|;n"_{.ۖt˘_OwAugXm`2vN."{%UP#^JL= `5_,eQƧ3& بl̩v Zd}M|gg"/`? gϞLRSo! sxΜ#;{$})pUysoBԄRJyuF*9!OF,jȞ;Au  S^#ƛhb "b .4Z6{tj@gTq5m] 񇧟% n4TjCdU̷*nΔh[ݭ244ѣG"Hș3gVhn\O=Ky- i\ENq5[,E'ܼ?7cn>G$8_XDSqf ]P2B$q^Z)Vk%W& w~$5 6Sur* .:u3_C{&ܹ Bk&ŪE\w"jNX?Oui)]LZ- \ϋH׬j! %"穅qdVX0kV\X*d\VUR Gm~c}_x? S pYǨzvh D"\@" 蘽*0`r== 3|0>~$7LjumlvJ%.NtXP}.[%*V'N,68q>x< qE*v';*JnbQ@%0|Y: N= |7rM: q*LaF/HRLs#VXj[y ?)d332l7|CS32loGOc+qX'JA$㯹r06-I?Ah ~'adoɖlɖb}?IENDB`weboob-1.1/modules/canaltp/module.py000066400000000000000000000033211265717027300175720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.travel import CapTravel, Station, Departure from weboob.tools.backend import Module from .browser import CanalTP __all__ = ['CanalTPModule'] class CanalTPModule(Module, CapTravel): NAME = 'canaltp' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = "French trains" BROWSER = CanalTP def iter_station_search(self, pattern): for _id, name in self.browser.iter_station_search(pattern): yield Station(_id, name) def iter_station_departures(self, station_id, arrival_id=None, date=None): for i, d in enumerate(self.browser.iter_station_departures(station_id, arrival_id)): departure = Departure(i, d['type'], d['time']) departure.departure_station = d['departure'] departure.arrival_station = d['arrival'] departure.late = d['late'] departure.information = d['late_reason'] yield departure weboob-1.1/modules/canaltp/test.py000066400000000000000000000020241265717027300172630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CanalTPTest(BackendTest): MODULE = 'canaltp' def test_canaltp(self): stations = list(self.backend.iter_station_search('defense')) self.assertTrue(len(stations) > 0) list(self.backend.iter_station_departures(stations[0].id)) weboob-1.1/modules/cappedtv/000077500000000000000000000000001265717027300161205ustar00rootroot00000000000000weboob-1.1/modules/cappedtv/__init__.py000066400000000000000000000001261265717027300202300ustar00rootroot00000000000000# -*- coding: utf-8 -*- from .module import CappedModule __all__ = ['CappedModule'] weboob-1.1/modules/cappedtv/browser.py000066400000000000000000000115071265717027300201610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Lord # # This module is free software. It comes without any warranty, to # the extent permitted by applicable law. You can redistribute it # and/or modify it under the terms of the Do What The Fuck You Want # To Public License, Version 2, as published by Sam Hocevar. See # http://sam.zoy.org/wtfpl/COPYING for more details. import urllib import datetime from weboob.capabilities.base import NotAvailable from weboob.tools.misc import to_unicode from weboob.deprecated.browser import Page from weboob.deprecated.browser import BrokenPageError from weboob.deprecated.browser import Browser from weboob.deprecated.browser.decorators import id2url from weboob.capabilities.image import BaseImage from weboob.capabilities.video import BaseVideo from weboob.tools.ordereddict import OrderedDict __all__ = ['CappedBrowser'] class CappedVideo(BaseVideo): def __init__(self, *args, **kwargs): BaseVideo.__init__(self, *args, **kwargs) self.nsfw = False self.ext = u'mp4' @classmethod def id2url(cls, _id): return 'http://capped.tv/%s' % _id # parser for search pages class IndexPage(Page): def iter_videos(self): # When no results are found, the website returns random results sb = self.parser.select(self.document.getroot(), 'div.search form input.searchbox', 1) if sb.value == 'No Results Found': return #Extracting meta data from results page vidbackdrop_list = self.parser.select(self.document.getroot(), 'div.vidBackdrop ') for vidbackdrop in vidbackdrop_list: url = self.parser.select(vidbackdrop, 'a', 1).attrib['href'] _id = url[2:] video = CappedVideo(_id) video.set_empty_fields(NotAvailable, ('url',)) video.title = to_unicode(self.parser.select(vidbackdrop, 'div.vidTitle a', 1).text) video.author = to_unicode(self.parser.select(vidbackdrop, 'div.vidAuthor a', 1).text) thumbnail_url = 'http://cdn.capped.tv/pre/%s.png' % _id video.thumbnail = BaseImage(thumbnail_url) video.thumbnail.url = to_unicode(video.thumbnail.id) #we get the description field duration_tmp = self.parser.select(vidbackdrop, 'div.vidInfo', 1) #we remove tabs and spaces duration_tmp2 = duration_tmp.text[7:] #we remove all fields exept time duration_tmp3 = duration_tmp2.split(' ')[0] #we transform it in datetime format parts = duration_tmp3.split(':') if len(parts) == 1: hours = minutes = 0 seconds = parts[0] elif len(parts) == 2: hours = 0 minutes, seconds = parts elif len(parts) == 3: hours, minutes, seconds = parts else: raise BrokenPageError('Unable to parse duration %r' % duration_tmp) video.duration = datetime.timedelta(hours=int(hours), minutes=int(minutes), seconds=int(seconds)) yield video # parser for the video page class VideoPage(Page): def get_video(self, video=None): _id = to_unicode(self.group_dict['id']) if video is None: video = CappedVideo(_id) video.set_empty_fields(NotAvailable) title_tmp = self.parser.select(self.document.getroot(), 'title', 1) video.title = to_unicode(title_tmp.text.strip()) # Videopages doesn't have duration information (only results pages) video.url = u'http://cdn.capped.tv/vhq/%s.mp4' % _id return video class CappedBrowser(Browser): DOMAIN = 'capped.tv' PROTOCOL = 'http' ENCODING = None PAGES = OrderedDict(( (r'http://capped\.tv/?', IndexPage), (r'http://capped\.tv/newest', IndexPage), (r'http://capped\.tv/mostviews', IndexPage), (r'http://capped\.tv/leastviews', IndexPage), (r'http://capped\.tv/monthtop', IndexPage), (r'http://capped\.tv/monthbottom', IndexPage), (r'http://capped\.tv/alpha', IndexPage), (r'http://capped\.tv/ahpla', IndexPage), (r'http://capped\.tv/search\?s\=(?P.+)', IndexPage), (r'http://capped\.tv/(?P.+)', VideoPage), )) @id2url(CappedVideo.id2url) def get_video(self, url, video=None): self.location(url) assert self.is_on_page(VideoPage), 'Should be on video page.' return self.page.get_video(video) def search_videos(self, pattern): self.location('/search?s=%s' % (urllib.quote_plus(pattern.encode('utf-8')))) assert self.is_on_page(IndexPage) return self.page.iter_videos() def latest_videos(self): self.home() assert self.is_on_page(IndexPage) return self.page.iter_videos() weboob-1.1/modules/cappedtv/favicon.png000066400000000000000000000013211265717027300202500ustar00rootroot00000000000000PNG  IHDR@@% sRGBgAMA a pHYsodfIDAThCj0D9 9O0C cBKBզB;;1Jڷ3+yi<8pfi3ϳ_qlt:-J$BzJr=2H4ջ?= 6k˲n7mGFl0 bP $XUĝ'z*'^xCG0H@X/|>3`B~ CxpGH)5\`1ŗٶ`J彳%e Dz4]Hw/z!ݽУ&<Qj$d}פ3<1@u `gpgz O'kJ5 eIx 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) self.backend.browser.openurl(v.url) l = list(self.backend.search_videos('weboob')) self.assertTrue(len(l) == 0) def test_latest(self): l = list(self.backend.iter_resources([BaseVideo], [u'latest'])) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) weboob-1.1/modules/carrefourbanque/000077500000000000000000000000001265717027300174765ustar00rootroot00000000000000weboob-1.1/modules/carrefourbanque/__init__.py000066400000000000000000000014521265717027300216110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CarrefourBanqueModule __all__ = ['CarrefourBanqueModule'] weboob-1.1/modules/carrefourbanque/browser.py000066400000000000000000000037231265717027300215400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, HomePage, TransactionsPage __all__ = ['CarrefourBanque'] class CarrefourBanque(LoginBrowser): BASEURL = 'https://www.carrefour-banque.fr' login = URL('/espace-client/connexion', LoginPage) home = URL('/espace-client$', HomePage) transactions = URL('/espace-client/(?P.*)/solde-dernieres-operations.*', TransactionsPage) def do_login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.login.go() self.page.enter_login(self.username) self.page.enter_password(self.password) if not self.home.is_here(): raise BrowserIncorrectPassword() @need_login def get_accounts_list(self): self.home.stay_or_go() return self.page.get_list() @need_login def iter_history(self, account): self.home.stay_or_go() self.location(account._link) assert self.transactions.is_here() return self.page.get_history(account) weboob-1.1/modules/carrefourbanque/favicon.png000066400000000000000000000026511265717027300216350ustar00rootroot00000000000000PNG  IHDR@@iqbKGDC pHYs B(xtIME  56IDATx[lTE"(.!(6Rm"x!H!<`4Fd_LLH4Ƈ1QH1FQ/Xh@Qk4"Y4p9ggΙٙohYB恫ˁ߀qKC!w@u/^xʞgqq.5aq/@|80a8:i/2yOFȕYE5U3EXrȦHE`%pM_lHY%tpC_OnCgyf KS%Ou&@4yY c],M)`6 ':ajPy׾f31jɭ\!_ŷ"Bu:-!M,= Xr@+S'B.`kYpꙥ<@GݚΫmUb_lUhorh2$OZYW?+qܭ1Ϩ\~a#)b!$^xxCB^@:`B~'C:=SG"#plFA`YGd-x ,w$iЂl Cu y'G暟a0lgJK>/Eh+<.Up!5W$׀k(p[@6I "bV9"Vw/'Wm :\W4ŭ@kBi:+ј#:B"v6[5pO>VN:WVk8ZiQ\ǝ {70k4*8͘:zK#98:K۔i2 ̳$"J5??":' S:!,/gBSI3g9W+1:[Uq/=]P Vp\/e#gjPm{2Ӎع?dg ^Ņ{DX ,o]m^*w|xv_ƹ)$>g" mWh1Q:m ؞|Tu6?(|RDI.,'u `JC |x|:mQdlуjHBz& '&jLNr/1dK`r0mv4 y{ߐ 3 o]Z#oWx"RYeMc@mxx4)N; *P'yjk=u5t_BS窾4Xwmdv'@\'T|0JIt\Pe JA"Ԉ| 4pE0IENDB`weboob-1.1/modules/carrefourbanque/module.py000066400000000000000000000036421265717027300213420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.base import find_object from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import CarrefourBanque __all__ = ['CarrefourBanqueModule'] class CarrefourBanqueModule(Module, CapBank): NAME = 'carrefourbanque' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Carrefour Banque' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label=u'Votre Identifiant Internet', masked=False), ValueBackendPassword('password', label=u"Code d'accès", regexp=u'\d+')) BROWSER = CarrefourBanque def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): return self.browser.iter_history(account) weboob-1.1/modules/carrefourbanque/pages.py000066400000000000000000000055201265717027300211510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from decimal import Decimal from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import Regexp, CleanText, CleanDecimal from weboob.browser.filters.html import Link from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction class LoginPage(HTMLPage): def enter_login(self, username): form = self.get_form(nr=1) form['name'] = username form.submit() def enter_password(self, password): form = self.get_form(nr=1) form['pass'] = password form.submit() class HomePage(LoggedPage, HTMLPage): @method class get_list(ListElement): item_xpath = '//div[@class="three_contenu_table"]' class item(ItemElement): klass = Account def condition(self): return len(self.el.xpath('.//div[@class="catre_col_two"]/h2')) > 0 def obj_balance(self): if len(self.el.xpath('.//div[@class="catre_col_one"]/h2')) > 0: return -CleanDecimal(CleanText('.//div[@class="catre_col_one"]/h2'), replace_dots=True)(self) else: return Decimal('0') obj_id = CleanText('.//div[@class="carte_col_leftcol"]/p') & Regexp(pattern=r'(\d+)') obj_label = CleanText('.//div[@class="carte_col_leftcol"]/h2') obj_currency = FrenchTransaction.Currency('.//div[@class="catre_col_two"]/h2') obj__link = Link('.//a[contains(@href, "solde-dernieres-operations")]') class Transaction(FrenchTransaction): PATTERNS = [(re.compile(r'^(?P.*?) (?P
\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_CARD)] class TransactionsPage(LoggedPage, HTMLPage): @method class get_history(Transaction.TransactionsElement): head_xpath = '//table[@id="creditHistory"]//thead/tr/th' item_xpath = '//table[@id="creditHistory"]/tbody/tr' class item(Transaction.TransactionElement): obj_id = None obj_type = Transaction.TYPE_CARD weboob-1.1/modules/carrefourbanque/test.py000066400000000000000000000017751265717027300210410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CarrefourBanqueTest(BackendTest): MODULE = 'carrefourbanque' def test_carrefourbanque(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/cci/000077500000000000000000000000001265717027300150505ustar00rootroot00000000000000weboob-1.1/modules/cci/__init__.py000066400000000000000000000014241265717027300171620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CciModule __all__ = ['CciModule'] weboob-1.1/modules/cci/browser.py000066400000000000000000000024451265717027300171120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from weboob.capabilities.job import BaseJobAdvert from .pages import SearchPage __all__ = ['CciBrowser'] class CciBrowser(PagesBrowser): BASEURL = 'http://www.cci.fr' search_page = URL('/web/recrutement/les-offres-d-emploi', SearchPage) def search_job(self, pattern): return self.search_page.go().iter_job_adverts(pattern=pattern) def get_job_advert(self, _id, advert): if advert is None: advert = BaseJobAdvert(_id) return self.search_page.stay_or_go().get_job_advert(obj=advert) weboob-1.1/modules/cci/favicon.png000066400000000000000000000403121265717027300172030ustar00rootroot00000000000000PNG  IHDR@@iq pHYs   cHRMz%u0`:o_F@PIDATx@@   0#"9 >  S;+( ?- 褻 o1#$  &TN 5>2%k  ee 8>9(F X  \m&   ,* *  ڣL  !)J?-4(! ?/>ߋ6 S@-4+ >0 C  8, '4) aL"!=̠  1' *7,t  1Ж  #  292$j   &Ϟ, !"@5% )!_D2v' jJ@=H"MB. , 0% ʁ0aS;%3&(2#% )!;6 & A5 gL65&eV=XD/X@- %  )! & 'ʅ OE1Q?,  GP! :+  fo 4/#$h=-  .u>+3(r`E}  &! (' +NA8&s bo+ )""7+=/ ," WC_ =6%eH 邚h   A;+  /%#   'PfR;8)dždOB/ `P & $ 3%UX>K<*K7&TuQ C9(E-A8   ? mV= +әUE0B4)!!D7'   ;D19)  l &+2% Q>8*($ D5&0] %"-"Q>,  ,"- *! Q>  0(>0  ;  VH5;,!^G1    h% K  ydGg  !=.  F'ZI5?0#h  !&,$ Z <*.A6% ;-   " cP)$   !! )! O>"g$ a-!%  -," $ %%#    dF 8*"44( ,1Q@ (!0( nZ  &'H# Y# 6]K!  VM>" aJ4󜤘 U@!":NO  M))&,< 4S͙+94. 'A0" z O ,#}aif  Zk܅   mI"z#%9M  UF2 NT&6}*8,C  0(6  +$2%    9 7+  \ޝ晬Pu  '1 FF ~ x `W(!7I  J>*  x!%HL!/; #" 6(9 (>K8/ n^.#q- -(K -&   KM6+~-#)* LF G? O? QC(*  OI UEn&ge +91 C% `H3O  5'<<- T `Xl6+ ZE5) pW;2  hZw 7  99,+}Cg [I7&o<䲞 -h6 q+χ SǯA/2+<5 J/>2#   J<* .75%cN6C7( Ė#." kU(:,xa 3. SG QC YM gT*!  |}J 6&     !2(O?,YH3' 7- (! %J >= ]Ns` eT ^Q9AR  ~yeI+! /$;. !,!@:*"L8( %J  7+=0=/*@6 SE&  mV>>Ǿ  {oTG2: u5(-!F3$6(! 4卿>"NP ({~% <  ` %  K6(8) * "Mw؉$!(*0!  $   D0"xU,]sK [[4.!   B$  Q)eN8kA2B5&[ukJH  h   ]$D3$t| 7    65+     YF1` {K  ~^OC/ S( ( /%NZN7{79(0(]-#s]BdM@- OC/ڈkMqA4$|>1"*!rb   .3$2-6'5*t2'Gq2*&" #2'51$9a   8+ +"   z_DK" ) YC/  ծ$0a~zIENDB`weboob-1.1/modules/cci/module.py000066400000000000000000000032331265717027300167100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.job import CapJob, BaseJobAdvert from weboob.tools.value import Value from .browser import CciBrowser __all__ = ['CciModule'] class CciModule(Module, CapJob): NAME = 'cci' DESCRIPTION = u'cci website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = CciBrowser CONFIG = BackendConfig(Value('metier', label='Job name', masked=False, default='')) def search_job(self, pattern=None): return self.browser.search_job(pattern) def advanced_search_job(self): return self.browser.search_job(pattern=self.config['metier'].get()) def get_job_advert(self, _id, advert=None): return self.browser.get_job_advert(_id, advert) def fill_obj(self, advert, fields): return self.get_job_advert(advert.id, advert) OBJECTS = {BaseJobAdvert: fill_obj} weboob-1.1/modules/cci/pages.py000066400000000000000000000060171265717027300165250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, TableElement, method from weboob.browser.filters.standard import Filter, CleanText, Format, Env, DateTime, TableCell, Join from weboob.browser.filters.html import Link, CleanHTML from weboob.capabilities.job import BaseJobAdvert class Child(Filter): def filter(self, el): return list(el[0].iterchildren()) class SearchPage(HTMLPage): @method class iter_job_adverts(TableElement): item_xpath = '//tr[position() > 1]' head_xpath = "//tr[1]/td[@class='titreCol2Tableau']/text()" col_place = u'Région' col_job_name = u'Filière' col_id = u'Intitulé du poste' col_society_name = u'CCI(R)' class item(ItemElement): klass = BaseJobAdvert def validate(self, advert): if advert and 'pattern' in self.env and self.env['pattern']: return self.env['pattern'].upper() in advert.title.upper() or \ self.env['pattern'].upper() in advert.job_name.upper() return True obj_id = CleanText(Link(Child(TableCell('id'))), replace=[('#', '')]) obj_title = Format('%s - %s', CleanText(TableCell('id')), CleanText(TableCell('job_name'))) obj_society_name = Format(u'CCI %s', CleanText(TableCell('society_name'))) obj_place = CleanText(TableCell('place')) obj_job_name = CleanText(TableCell('id')) @method class get_job_advert(ItemElement): klass = BaseJobAdvert obj_url = Format('%s#%s', Env('url'), Env('id')) obj_description = Join('\r\n', 'div/fieldset/*[(@class="titreParagraphe" or @class="normal")]', textCleaner=CleanHTML) obj_title = CleanText('div/span[@class="intituleposte"]') obj_job_name = CleanText('div/span[@class="intituleposte"]') obj_society_name = Format('CCI %s', CleanText('div/span[@class="crci crcititle"]')) obj_publication_date = DateTime(CleanText('div/fieldset/p[@class="dateOffre"]'), dayfirst=True) def parse(self, el): self.el = el.xpath('//div[@id="%s"]/div' % self.obj.id)[0] self.env['url'] = self.page.url self.env['id'] = self.obj.id weboob-1.1/modules/cci/test.py000066400000000000000000000020721265717027300164020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CciTest(BackendTest): MODULE = 'cci' def test_cci_search(self): l = list(self.backend.search_job()) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) weboob-1.1/modules/champslibres/000077500000000000000000000000001265717027300167665ustar00rootroot00000000000000weboob-1.1/modules/champslibres/__init__.py000066400000000000000000000014511265717027300211000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ChampslibresModule __all__ = ['ChampslibresModule'] weboob-1.1/modules/champslibres/browser.py000066400000000000000000000047641265717027300210360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, HomePage, HistoryPage, RentedPage __all__ = ['ChampslibresBrowser'] # Browser class ChampslibresBrowser(Browser): PROTOCOL = 'http' ENCODING = 'utf-8' PAGES = { '.*login.*': LoginPage, '.*home\?lang=frf.*': HomePage, 'http://.*/index.aspx\?IdPage=429': HistoryPage, '.*patroninfo.*': RentedPage, } iduser = None def is_logged(self): return self.page \ and not self.page.document.getroot().xpath('//input[contains(@id, "pin")]') def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(HomePage): self.location('https://sbib.si.leschampslibres.fr/iii/cas/login?null', no_login=True) self.page.login(self.username, self.password) # Get home and get ID self.location('http://opac.si.leschampslibres.fr/iii/encore/home?lang=frf', no_login=True) self.iduser = self.page.get_id() self.logger.debug('Get ID ' + self.iduser) if not self.is_logged(): raise BrowserIncorrectPassword() def get_rented_books_list(self): if not self.is_on_page(RentedPage): self.location('https://sbib.si.leschampslibres.fr/patroninfo~S1*frf/%s/items' % self.iduser) return self.page.get_list() def renew(self, id): if not self.is_on_page(RentedPage): self.location('https://sbib.si.leschampslibres.fr/patroninfo~S1*frf/%s/items' % self.iduser) self.page.renew(id) self.page.confirm_renew() return self.page.read_renew(id) # TODO def get_booked_books_list(self): return [] weboob-1.1/modules/champslibres/favicon.png000066400000000000000000000202501265717027300211200ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME9ށJ IDATxڥy\W}?wyKUuujI,;-ɋdxc08 30gd$! !! 1Ƌdl,/$K%nRUoU%a^wU]oo_Jsc 硵F)E{Bq`ܭ{u3B J)mZ_Yziq… jJ__TZ`^}ܗ+]TR !Ja{޼yt ٳ,\JBizZq9 ]{9ᔟ5çO+V<R(7oa$Igv6˽|[ڂҐ Ymg g3.1BA988hʿ*5 Ry^gs /pQ4E+8uhsA)=:c,JYTJuU ʕKjb{#@ WJaCI@u YJy\q]< ̥iӧO?iyYcؖ\V;w~4s8g1S!T( *ZiQjRe)ų%i4# %YBi'ILV;OӴZ˳>sロ[o4M$7>>oZYVrAXJ Z{A}?<PZű$Z^vΝ; DDe$Irعsuo~={q/~'NI8yeH<裼‹l۶7y'SSS #$ °JI*Zk! +x$Z)|/@*T )_(,/%BO(ȳa9nڴ}/333 =úurmH!ط% Ry>B8Z&}h]4z g,* Ji$ILREB V+\w,jhR%(O9_8ETsRbffcǎnz1m;v|mZk"S3'#^~ O]8q͛022UkT^~ wf۶mAe˘ĉ㌎kjNji5yQ.axpAX Hp&Ѫ+=z]vlr6l"==lwRSBFiɑ9'>*Ak'IHM1w-O}S 7DL59f2W g8^ji*7݄{k9?y&ϣۋ1<˙f1qn|CAYVJIQcf;RJtw_pV0dWZքa\Ș9t ,۰U :¯na"MWo i8bhHXb=ebxFkԎ,R\<"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R$J^>h}%СLLsP /R(B僤YVj+Fier4jH&BdRjZQTr=llp]I涬kڨP"O~'֪E\ $eE~A6q_G{)3zs|oѫLJ3t|-Q45kCޕ'ټc޽;B6za$G_4ګ,:C|'$*d5,^|%8 Vz OiQ$C/~j[җDUZcA UtK# "Ve߳|ſe,InyZ|ÿ{fH)5x?B6tZ$a%#M ϯ& >9*aOkիf>|F/o~%Kh6#rc-%Bz9u iӫ8~{n=AG9MZPJ0tfwU˛h6j-V=-GdXgIaj,=VR\nqӹJXzϞel|Z^u\QRlNSYBrCŦdy)pJOk< f Cɝwl13‰ y"UGX>EOOi39`謡 (aDZ%˯h,Ёe;<~hGmwx4W_ wgz7;ٻwwQ|9A֬y$ٺ~R37nGs=WƘRz3gP x/fdd kPa :7XNNr/7ъ,]rq\}g%q14z_={lrGVp*8("VJEHAAR QQX&+ $9,Ǚ}⸅@y<# QC&4fͷ¶{jZ9:e@?+<>>L66pܹ28pѢE.V8[Jk qPNڂm& Sɩժ$IY>,yAΑga4LI Ap)iAȢEkR&#֚{wsRJi?aˬ_鉉{p&Ms9K.ڻ{\jrKe5Psezk||۷oĦMػw/MCZ뛬 JtɵsRq9A~~%/IDAT^+RNyW)w/u{phOIENDB`weboob-1.1/modules/champslibres/module.py000066400000000000000000000043351265717027300206320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.library import CapBook from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import ChampslibresBrowser __all__ = ['ChampslibresModule'] class ChampslibresModule(Module, CapBook): NAME = 'champslibres' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' DESCRIPTION = 'Champs Libres (Rennes) Library' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('login', label='Account ID', regexp='^\d{1,15}|$'), ValueBackendPassword('password', label='Password of account'), ) BROWSER = ChampslibresBrowser def create_default_browser(self): browser = self.create_browser(self.config['login'].get(), self.config['password'].get()) # we have to force the login before to lauch any actions browser.login() return browser def get_rented(self): for book in self.browser.get_rented_books_list(): yield book def get_booked(self): raise NotImplementedError() def renew_book(self, id): return self.browser.renew(id) def iter_books(self): #for book in self.get_booked(): # yield book for book in self.get_rented(): yield book def get_book(self, _id): raise NotImplementedError() def search_books(self, _string): raise NotImplementedError() weboob-1.1/modules/champslibres/pages.py000066400000000000000000000062671265717027300204520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import date from weboob.capabilities.library import Book, Renew from weboob.deprecated.browser import Page from weboob.deprecated.mech import ClientForm from weboob.tools.html import html2text class SkipPage(Page): pass class HomePage(Page): def on_loaded(self): link = self.document.find('//a[@id="patronRSSFeedLinkComponent"]') self.id = link.attrib['href'].split('/')[4] def get_id(self): return self.id def txt2date(s): split = s.split('-') return date(int(split[2]) + 2000, int(split[1]), int(split[0])) class RentedPage(Page): def get_list(self): for tr in self.document.getroot().xpath('//tr[@class="patFuncEntry"]'): id = tr.xpath('td/input')[0].attrib["value"] book = Book(id) bigtitle = tr.xpath('td[@class="patFuncTitle"]/label/a')[0].text book.name = bigtitle.split('/')[0] book.author = bigtitle.split('/')[1] date = tr.xpath('td[@class="patFuncStatus"]')[0].text book.date = txt2date(date.replace('RETOUR', '')) yield book def renew(self, id): # find the good box input = self.document.find('//input[@value="%s"]' % id) self.browser.select_form("checkout_form") self.browser.form.set_all_readonly(False) self.browser.controls.append(ClientForm.TextControl('text', input.attrib['name'], {'value': id})) self.browser.controls.append(ClientForm.TextControl('text', 'requestRenewSome', {'value': 'requestRenewSome'})) self.browser.submit() def confirm_renew(self): self.browser.select_form("checkout_form") self.browser.form.set_all_readonly(False) self.browser.submit(name='renewsome') def read_renew(self, id): for tr in self.document.getroot().xpath('//tr[@class="patFuncEntry"]'): if len(tr.xpath('td/input[@value="%s"]' % id)) > 0: message = self.browser.parser.tostring(tr.xpath('td[@class="patFuncStatus"]')[0]) renew = Renew(id) renew.message = html2text(message).replace('\n', '') return renew class HistoryPage(Page): pass class BookedPage(Page): # TODO: book some books... pass class LoginPage(Page): def login(self, login, passwd): self.browser.select_form(nr=0) self.browser.form.set_all_readonly(False) self.browser['code'] = login self.browser['pin'] = passwd self.browser.submit() weboob-1.1/modules/champslibres/test.py000066400000000000000000000015741265717027300203260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class ChampslibresTest(BackendTest): MODULE = 'champslibres' def test_champslibres(self): pass weboob-1.1/modules/chronopost/000077500000000000000000000000001265717027300165105ustar00rootroot00000000000000weboob-1.1/modules/chronopost/__init__.py000066400000000000000000000014421265717027300206220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ChronopostModule __all__ = ['ChronopostModule'] weboob-1.1/modules/chronopost/browser.py000066400000000000000000000025571265717027300205560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser from .pages import IndexPage, TrackPage __all__ = ['ChronopostBrowser'] class ChronopostBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'www.chronopost.fr' ENCODING = None PAGES = { 'http://www.chronopost.fr/transport-express/livraison-colis': IndexPage, 'http://www.chronopost.fr/transport-express/livraison-colis/.*accueil/suivi.*': TrackPage, } def get_tracking_info(self, _id): self.home() assert self.is_on_page(IndexPage) self.page.track_package(_id) assert self.is_on_page(TrackPage) return self.page.get_info(_id) weboob-1.1/modules/chronopost/favicon.png000066400000000000000000000040701265717027300206440ustar00rootroot00000000000000PNG  IHDR@@iqIDATxY lUE} @X0=т@"AVAYھ,"KK4D uAbQ- 1Ģ@-@~K+nr2ܹwΝfkK.K.K.R5S^F2i@ #U@0^dN|p&SR׀"HgB^dAVm΀Qʄ7':`={ #V"cɬ7R  .?Z7ݩJ߁y|(A`Wj~ " k4)m, P#v.`; BӞlO+g9 &P dQPQnYlf;43 |2oҶBD`:if|?>fXV4etQVܕ`:`.3M}n9}3ߩrI*kg0n`h ]Y߉L{r ۃ9QΨ`s$Mq0X^x3I\)0钽,`$gW43_GRF"f:_cJNYm]=Cqs MdGUtk(xiNYg)T 9_:wet鈡p+~oZj,/JrKy%^;lϓ1Xn3̰t`Bt!`g/9dnv%NV>u1bӁ U vJteĠ^DgO#XMxe::#SeØ}K>?$pvB pX{x=lx)}>o%.BA<{LgatI:03*!*#0>U))>RŠa=4DOqt)Vtf0Z]b_Wѳ2ox"?0%WNQm/4qjst(n Ё_ 'Q=?H"YGpHjL}#h$?LfEEJ\3{搰zbEsJmXQa5癍4JK@)R 3LI}jm$ h@a֧>uX ]!LX@ fDn6/zZ?tǔ0̖Үnš6y=Y 4^J!2 1sHcd`XG˨ t^()/V:0(g:ʮ?O}NM"I-!x17 I:-F?̃l,(棈Hwyi$ F V:ߟjׄltk~I-Ӟ+ZOAD 1о(k{y4}#aCPZBz&U4̭Io(,;hQTt*+;!1K>ԯ6 v HO~m%\p S*@C k[I(3̃Pԙi4F h]BސQocȥdIK.K.K.KKry_AIENDB`weboob-1.1/modules/chronopost/module.py000066400000000000000000000023371265717027300203540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.parcel import CapParcel from weboob.tools.backend import Module from .browser import ChronopostBrowser __all__ = ['ChronopostModule'] class ChronopostModule(Module, CapParcel): NAME = 'chronopost' DESCRIPTION = u'Chronopost website' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' BROWSER = ChronopostBrowser def get_parcel_tracking(self, id): with self.browser: return self.browser.get_tracking_info(id) weboob-1.1/modules/chronopost/pages.py000066400000000000000000000050411265717027300201610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from dateutil.parser import parse as parse_date from weboob.capabilities.parcel import Parcel, Event from weboob.capabilities import NotAvailable from weboob.deprecated.browser import Page class IndexPage(Page): def track_package(self, _id): self.browser.select_form(predicate=lambda form: form.attrs.get('id', '') == 'suivreEnvoi') self.browser['chronoNumbers'] = _id.encode('utf-8') self.browser.submit() class TrackPage(Page): def get_info(self, id): if len(self.document.xpath('//libelle[@nom="MSG_AUCUN_EVT"]')) > 0: return None p = Parcel(id) p.arrival = NotAvailable p.history = [] for i, tr in enumerate(self.document.xpath('//table[@class="tabListeEnvois"]//tr')): tds = tr.findall('td') if len(tds) < 3: continue ev = Event(i) ev.location = unicode(tds[1].text) if tds[1].text else None ev.activity = unicode(tds[1].find('br').tail) if tds[-1].text is not None: ev.activity += ', ' + self.parser.tocleanstring(tds[-1]) date = re.sub('[a-z]+', '', self.parser.tocleanstring(tds[0])).strip() date = re.sub('(\d+)/(\d+)/(\d+)', r'\3-\2-\1', date) ev.date = parse_date(date) p.history.append(ev) p.info = ' '.join([t.strip() for t in self.document.xpath('//div[@class="numeroColi2"]')[0].itertext()][1:]) if u'Livraison effectuée' in p.history[0].activity: p.status = p.STATUS_ARRIVED elif u"en cours d'acheminement" in p.history[0].activity or \ u"en cours de livraison" in p.history[0].activity or \ u"Envoi entré dans le pays de destination" in p.history[0].activity: p.status = p.STATUS_IN_TRANSIT return p weboob-1.1/modules/chronopost/test.py000066400000000000000000000016151265717027300200440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class ChronopostTest(BackendTest): MODULE = 'chronopost' def test_chronopost(self): raise NotImplementedError() weboob-1.1/modules/cic/000077500000000000000000000000001265717027300150505ustar00rootroot00000000000000weboob-1.1/modules/cic/__init__.py000066400000000000000000000014311265717027300171600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CICModule __all__ = ['CICModule'] weboob-1.1/modules/cic/browser.py000066400000000000000000000214441265717027300171120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . try: from urlparse import urlsplit, parse_qsl, urlparse except ImportError: from urllib.parse import urlsplit, parse_qsl, urlparse from datetime import datetime, timedelta from random import randint from weboob.tools.compat import basestring from weboob.browser.browsers import LoginBrowser, need_login from weboob.browser.profiles import Wget from weboob.browser.url import URL from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities.bank import Transfer, TransferError from .pages import LoginPage, LoginErrorPage, AccountsPage, UserSpacePage, \ OperationsPage, CardPage, ComingPage, NoOperationsPage, \ TransfertPage, ChangePasswordPage, VerifCodePage, EmptyPage __all__ = ['CICBrowser'] class CICBrowser(LoginBrowser): PROFILE = Wget() BASEURL = 'https://www.cic.fr' login = URL('/sb/fr/banques/particuliers/index.html', '/(?P.*)/fr/$', '/(?P.*)/fr/banques/accueil.html', '/(?P.*)/fr/banques/particuliers/index.html', LoginPage) login_error = URL('/(?P.*)/fr/identification/default.cgi', LoginErrorPage) accounts = URL('/(?P.*)/fr/banque/situation_financiere.cgi', '/(?P.*)/fr/banque/situation_financiere.html', AccountsPage) user_space = URL('/(?P.*)/fr/banque/espace_personnel.aspx', UserSpacePage) operations = URL('/(?P.*)/fr/banque/mouvements.cgi.*', '/(?P.*)/fr/banque/mouvements.html.*', '/(?P.*)/fr/banque/nr/nr_devbooster.aspx.*', OperationsPage) coming = URL('/(?P.*)/fr/banque/mvts_instance.cgi.*', ComingPage) card = URL('/(?P.*)/fr/banque/operations_carte.cgi.*', CardPage) noop = URL('/(?P.*)/fr/banque/CR/arrivee.asp.*', NoOperationsPage) info = URL('/(?P.*)/fr/banque/BAD.*', EmptyPage) transfert = URL('/(?P.*)/fr/banque/virements/vplw_vi.html', EmptyPage) transfert_2 = URL('/(?P.*)/fr/banque/virements/vplw_cmweb.aspx.*', TransfertPage) change_pass = URL('/(?P.*)/fr/validation/change_password.cgi', ChangePasswordPage) verify_pass = URL('/(?P.*)/fr/validation/verif_code.cgi.*', VerifCodePage) empty = URL('/(?P.*)/fr/banques/index.html', '/(?P.*)/fr/banque/paci_beware_of_phishing.*', '/(?P.*)/fr/validation/(?!change_password|verif_code).*', '/(?P.*)/fr/banque/paci_engine/static_content_manager.aspx', '/(?P.*)/fr/banque/DELG_Gestion.*', EmptyPage) currentSubBank = None __states__ = ['currentSubBank'] def do_login(self): self.login.go() if not self.page.logged: self.page.login(self.username, self.password) if not self.page.logged or self.login_error.is_here(): raise BrowserIncorrectPassword() self.getCurrentSubBank() @need_login def get_accounts_list(self): return self.accounts.stay_or_go(subbank=self.currentSubBank).iter_accounts() def get_account(self, id): assert isinstance(id, basestring) for a in self.get_accounts_list(): if a.id == id: return a def getCurrentSubBank(self): # the account list and history urls depend on the sub bank of the user url = urlparse(self.url) self.currentSubBank = url.path.lstrip('/').split('/')[0] def list_operations(self, page_url): if page_url.startswith('/') or page_url.startswith('https'): self.location(page_url) else: self.location('%s/%s/fr/banque/%s' % (self.BASEURL, self.currentSubBank, page_url)) if not self.operations.is_here(): return iter([]) return self.pagination(lambda: self.page.get_history()) def get_history(self, account): transactions = [] last_debit = None for tr in self.list_operations(account._link_id): # to prevent redundancy with card transactions, we do not # store 'RELEVE CARTE' transaction. if tr.raw != 'RELEVE CARTE': transactions.append(tr) elif last_debit is None: last_debit = (tr.date - timedelta(days=10)).month coming_link = self.page.get_coming_link() if self.operations.is_here() else None if coming_link is not None: for tr in self.list_operations(coming_link): transactions.append(tr) month = 0 for card_link in account._card_links: v = urlsplit(card_link) args = dict(parse_qsl(v.query)) # useful with 12 -> 1 if int(args['mois']) < month: month = month + 1 else: month = int(args['mois']) for tr in self.list_operations(card_link): if month > last_debit: tr._is_coming = True transactions.append(tr) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return transactions def transfer(self, account, to, amount, reason=None): # access the transfer page self.transfert.go(subbank=self.currentSubBank) # fill the form form = self.page.get_form(xpath="//form[@id='P:F']") try: form['data_input_indiceCompteADebiter'] = self.page.get_from_account_index(account) form['data_input_indiceCompteACrediter'] = self.page.get_to_account_index(to) except ValueError as e: raise TransferError(e.message) form['[t:dbt%3adouble;]data_input_montant_value_0_'] = '%s' % str(amount).replace('.', ',') if reason is not None: form['[t:dbt%3astring;x(27)]data_input_libelleCompteDebite'] = reason form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite'] = reason del form['_FID_GoCancel'] del form['_FID_DoValidate'] form['_FID_DoValidate.x'] = str(randint(3, 125)) form['_FID_DoValidate.y'] = str(randint(3, 22)) form.submit() # look for known errors content = self.page.get_unicode_content() insufficient_amount_message = u'Le montant du virement doit être positif, veuillez le modifier' maximum_allowed_balance_message = u'Montant maximum autorisé au débit pour ce compte' if insufficient_amount_message in content: raise TransferError('The amount you tried to transfer is too low.') if maximum_allowed_balance_message in content: raise TransferError('The maximum allowed balance for the target account has been / would be reached.') # look for the known "all right" message ready_for_transfer_message = u'Confirmer un virement entre vos comptes' if ready_for_transfer_message not in content: raise TransferError('The expected message "%s" was not found.' % ready_for_transfer_message) # submit the confirmation form form = self.page.get_form(xpath="//form[@id='P:F']") del form['_FID_DoConfirm'] form['_FID_DoConfirm.x'] = str(randint(3, 125)) form['_FID_DoConfirm.y'] = str(randint(3, 22)) submit_date = datetime.now() form.submit() # look for the known "everything went well" message content = self.page.get_unicode_content() transfer_ok_message = u'Votre virement a été exécuté' if transfer_ok_message not in content: raise TransferError('The expected message "%s" was not found.' % transfer_ok_message) # We now have to return a Transfer object transfer = Transfer(submit_date.strftime('%Y%m%d%H%M%S')) transfer.amount = amount transfer.origin = account transfer.recipient = to transfer.date = submit_date return transfer weboob-1.1/modules/cic/favicon.png000066400000000000000000000031561265717027300172100ustar00rootroot00000000000000PNG  IHDR@@iqbKGD___4ƍ pHYs  tIME pvtEXtCommentCreated with GIMPWIDATx{lSU?]u+kvɺ! &T01Ѩ5?ƨ5 0,"21Fۭtt}{1n]I&{~{:::::::::::::?|.4`Mm%%!>? ro|+LR5*?7Z@S##xCSlr:e&E%& B(|B0Lр!DŽ1wӢiE\BVl.-("sf:'5viSS0"UV@8p6oM2~  Ÿ(TT6VS;4RW㼥ǏF}v.3sI}I۟}[i)`gc^1'g`m}Y $Pa̹N]UnW~îi*RY}F@ɩ(>$V9Z5k[\q>;(rýEGzp[XT$'eIJdP!?Haxb U%c0RQagm]elllLSTUEQUdEz441Y$D8g8ߗ4$okB"!aEF\ ĹU3XʱsK#_|{"#O}qYgL8r"b8'?uTcS⬦n&*+ضɓ'M.O΄cw4o0h`o[i<c6DcrZVV!TU3ޱTX'_*GVkf1#ɢG''h(j֌Ϫ3Ḧme3&ZhnUeNhr ̢4Ϫ=E7-KO -U8-LF[ hv44.-v {wOZCM{ܨ,$M{ݱ40D6oXɻ<^yh5Y<{~m˒Lϕk=璄G}m T rк&2wy[|wtd80]sK\loh8) -մ]A QLO$N2^Y?iQxh#{׷`*_@`Fv41<ғg{|եes # PVTĞ{V) 輅lYryKoߞȪ|GPip`m9iY(H(M懓Q;}~qn?x0ͥeoޤ[@UUE%4ct9ȱEYyom#%Oώ]?{np 67bs?Jg F֔Ъf%zxf1]n6TPZXHBQ Dh)$N srdWFttttttttttttttttto Z$gcIENDB`weboob-1.1/modules/cic/module.py000066400000000000000000000055711265717027300167170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal import string from weboob.capabilities.bank import CapBank, AccountNotFound, Recipient, Account from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import CICBrowser __all__ = ['CICModule'] class CICModule(Module, CapBank): NAME = 'cic' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = u'CIC' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe')) BROWSER = CICBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): for account in self.browser.get_accounts_list(): yield account def get_account(self, _id): account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_coming(self, account): for tr in self.browser.get_history(account): if tr._is_coming: yield tr def iter_history(self, account): for tr in self.browser.get_history(account): if not tr._is_coming: yield tr def iter_transfer_recipients(self, ignored): for account in self.browser.get_accounts_list(): recipient = Recipient() recipient.id = account.id recipient.label = account.label yield recipient def transfer(self, account, to, amount, reason=None): if isinstance(account, Account): account = account.id account = str(account).strip(string.letters) to = str(to).strip(string.letters) try: assert account.isdigit() assert to.isdigit() amount = Decimal(amount) except (AssertionError, ValueError): raise AccountNotFound() return self.browser.transfer(account, to, amount, reason) weboob-1.1/modules/cic/pages.py000066400000000000000000000270001265717027300165200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . try: from urlparse import urlparse, parse_qs except ImportError: from urllib.parse import urlparse, parse_qs from decimal import Decimal, InvalidOperation import re from dateutil.relativedelta import relativedelta from weboob.browser.pages import HTMLPage, FormNotFound, LoggedPage from weboob.browser.elements import ListElement, ItemElement, SkipItem, method from weboob.browser.filters.standard import Filter, Env, CleanText, CleanDecimal, Field, TableCell from weboob.browser.filters.html import Link from weboob.exceptions import BrowserIncorrectPassword, ParseError from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.date import parse_french_date class LoginPage(HTMLPage): REFRESH_MAX = 10.0 def login(self, login, passwd): form = self.get_form(name='ident') form['_cm_user'] = login form['_cm_pwd'] = passwd form.submit() @property def logged(self): return self.doc.xpath('//div[@id="e_identification_ok"]') class LoginErrorPage(HTMLPage): pass class EmptyPage(LoggedPage, HTMLPage): REFRESH_MAX = 10.0 class UserSpacePage(LoggedPage, HTMLPage): pass class ChangePasswordPage(LoggedPage, HTMLPage): def on_load(self): raise BrowserIncorrectPassword('Please change your password') class VerifCodePage(LoggedPage, HTMLPage): def on_load(self): raise BrowserIncorrectPassword('Unable to login: website asks a code from a card') class TransfertPage(LoggedPage, HTMLPage): def get_account_index(self, direction, account): for div in self.doc.getroot().cssselect(".dw_dli_contents"): inp = div.cssselect("input")[0] if inp.name != direction: continue acct = div.cssselect("span.doux")[0].text.replace(" ", "") if account.endswith(acct): return inp.attrib['value'] else: raise ValueError("account %s not found" % account) def get_from_account_index(self, account): return self.get_account_index('data_input_indiceCompteADebiter', account) def get_to_account_index(self, account): return self.get_account_index('data_input_indiceCompteACrediter', account) def get_unicode_content(self): return self.content.decode(self.detect_encoding()) class AccountsPage(LoggedPage, HTMLPage): TYPES = {'C/C': Account.TYPE_CHECKING, 'Livret': Account.TYPE_SAVINGS, 'Pret': Account.TYPE_LOAN, 'Compte Courant': Account.TYPE_CHECKING, 'Compte Cheque': Account.TYPE_CHECKING, 'Compte Epargne': Account.TYPE_SAVINGS, } @method class iter_accounts(ListElement): item_xpath = '//tr' flush_at_end = True class item(ItemElement): klass = Account def condition(self): if len(self.el.xpath('./td')) < 2: return False first_td = self.el.xpath('./td')[0] return (("i" in first_td.attrib.get('class', '') or "p" in first_td.attrib.get('class', '')) and first_td.find('a') is not None) class Label(Filter): def filter(self, text): return text.lstrip(' 0123456789').title() class Type(Filter): def filter(self, label): for pattern, actype in AccountsPage.TYPES.iteritems(): if label.startswith(pattern): return actype return Account.TYPE_UNKNOWN obj_id = Env('id') obj_label = Label(CleanText('./td[1]/a/node()[not(contains(@class, "doux"))]')) obj_coming = Env('coming') obj_balance = Env('balance') obj_currency = FrenchTransaction.Currency('./td[2] | ./td[3]') obj__link_id = Link('./td[1]/a') obj__card_links = [] obj_type = Type(Field('label')) def parse(self, el): link = el.xpath('./td[1]/a')[0].get('href', '') if link.startswith('POR_SyntheseLst'): raise SkipItem() url = urlparse(link) p = parse_qs(url.query) if 'rib' not in p and 'webid' not in p: raise SkipItem() for td in el.xpath('./td[2] | ./td[3]'): try: balance = CleanDecimal('.', replace_dots=True)(td) except InvalidOperation: continue else: break else: raise ParseError('Unable to find balance for account %s' % CleanText('./td[1]/a')(el)) id = p['rib'][0] if 'rib' in p else p['webid'][0] # Handle cards if id in self.parent.objects: account = self.parent.objects[id] if not account.coming: account.coming = Decimal('0.0') account.coming += balance account._card_links.append(link) raise SkipItem() self.env['id'] = id # Handle real balances page = self.page.browser.open(link).page coming = page.find_amount(u"Opérations à venir") if page else None accounting = page.find_amount(u"Solde comptable") if page else None if accounting is not None and accounting + (coming or Decimal('0')) != balance: self.page.logger.warning('%s + %s != %s' % (accounting, coming, balance)) if accounting is not None: balance = accounting self.env['balance'] = balance self.env['coming'] = coming or NotAvailable class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^VIR(EMENT)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^PRLV (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?P.*) CARTE \d+ PAIEMENT CB\s+(?P
\d{2})(?P\d{2}) ?(.*)$'), FrenchTransaction.TYPE_CARD), (re.compile('^RETRAIT DAB (?P
\d{2})(?P\d{2}) (?P.*) CARTE [\*\d]+'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^CHEQUE( (?P.*))?$'), FrenchTransaction.TYPE_CHECK), (re.compile('^(F )?COTIS\.? (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(REMISE|REM CHQ) (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] _is_coming = False class Pagination(object): def next_page(self): try: form = self.page.get_form('//form[@id="paginationForm"]') except FormNotFound: return text = CleanText.clean(form.el) m = re.search(u'(\d+) / (\d+)', text or '', flags=re.MULTILINE) if not m: return cur = int(m.group(1)) last = int(m.group(2)) if cur == last: return form['page'] = str(cur + 1) return form.request class OperationsPage(LoggedPage, HTMLPage): @method class get_history(Pagination, Transaction.TransactionsElement): head_xpath = '//table[@class="liste"]//thead//tr/th' item_xpath = '//table[@class="liste"]//tbody/tr' class item(Transaction.TransactionElement): condition = lambda self: len(self.el.xpath('./td')) >= 4 and len(self.el.xpath('./td[@class="i g" or @class="p g" or contains(@class, "_c1")]')) > 0 class OwnRaw(Filter): def __call__(self, item): parts = [txt.strip() for txt in TableCell('raw')(item)[0].itertext() if len(txt.strip()) > 0] # To simplify categorization of CB, reverse order of parts to separate # location and institution. if parts[0].startswith('PAIEMENT CB'): parts.reverse() return u' '.join(parts) obj_raw = Transaction.Raw(OwnRaw()) def find_amount(self, title): try: td = self.doc.xpath(u'//th[contains(text(), "%s")]/../td' % title)[0] except IndexError: return None else: return Decimal(FrenchTransaction.clean_amount(td.text)) def get_coming_link(self): try: a = self.doc.xpath(u'//a[contains(text(), "Opérations à venir")]')[0] except IndexError: return None else: return a.attrib['href'] class ComingPage(OperationsPage, LoggedPage): @method class get_history(Pagination, Transaction.TransactionsElement): head_xpath = '//table[@class="liste"]//thead//tr/th/text()' item_xpath = '//table[@class="liste"]//tbody/tr' col_date = u"Date de l'annonce" class item(Transaction.TransactionElement): obj__is_coming = True class CardPage(OperationsPage, LoggedPage): @method class get_history(Pagination, ListElement): class list_cards(ListElement): item_xpath = '//table[@class="liste"]/tbody/tr/td/a' class item(ItemElement): def __iter__(self): card_link = self.el.get('href') history_url = '%s/%s/fr/banque/%s' % (self.page.browser.BASEURL, self.page.browser.currentSubBank, card_link) page = self.page.browser.location(history_url).page for op in page.get_history(): yield op class list_history(Transaction.TransactionsElement): head_xpath = '//table[@class="liste"]//thead/tr/th' item_xpath = '//table[@class="liste"]/tbody/tr' def parse(self, el): label = CleanText('//div[contains(@class, "lister")]//p[@class="c"]')(el) if not label: return label = re.findall('(\d+ [^ ]+ \d+)', label)[-1] # use the trick of relativedelta to get the last day of month. self.env['debit_date'] = parse_french_date(label) + relativedelta(day=31) class item(Transaction.TransactionElement): condition = lambda self: len(self.el.xpath('./td')) >= 4 obj_raw = Transaction.Raw('./td[last()-2] | ./td[last()-1]') obj_type = Transaction.TYPE_CARD obj_date = Env('debit_date') obj_rdate = Transaction.Date(TableCell('date')) class NoOperationsPage(OperationsPage, LoggedPage): def get_history(self): return iter([]) weboob-1.1/modules/cic/test.py000066400000000000000000000017401265717027300164030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CICTest(BackendTest): MODULE = 'cic' def test_cic(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/citelis/000077500000000000000000000000001265717027300157465ustar00rootroot00000000000000weboob-1.1/modules/citelis/__init__.py000066400000000000000000000014441265717027300200620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CitelisModule __all__ = ['CitelisModule'] weboob-1.1/modules/citelis/browser.py000066400000000000000000000062551265717027300200130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import Account from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, SummaryPage, UselessPage, TransactionSearchPage, TransactionsPage, TransactionsCsvPage __all__ = ['CitelisBrowser'] class CitelisBrowser(Browser): PROTOCOL = 'https' DOMAIN = 'adminpayment.citelis.fr' ENCODING = 'UTF-8' CERTHASH = '3cccf1cdd31264a864bc206fc96257a6cd1602b5766054304a6b3c3768414c84' PAGES = { '%s://%s/userManager\.do\?reqCode=prepareLogin.*' % (PROTOCOL, DOMAIN): LoginPage, '%s://%s/summarySearch\.do\?reqCode=search.*' % (PROTOCOL, DOMAIN): SummaryPage, '%s://%s/userManager\.do\?reqCode=goToHomePage.+' % (PROTOCOL, DOMAIN): UselessPage, '%s://%s/userManager\.do\?org.apache.+' % (PROTOCOL, DOMAIN): UselessPage, '%s://%s/menu\.do\?reqCode=prepareSearchTransaction.+' % (PROTOCOL, DOMAIN): TransactionSearchPage, '%s://%s/transactionSearch\.do\?reqCode=search.+' % (PROTOCOL, DOMAIN): TransactionsPage, '%s://%s/documents/transaction/l_TransactionSearchWebBooster\.jsp.+' % (PROTOCOL, DOMAIN): (TransactionsCsvPage, 'csv') } def __init__(self, merchant_id, *args, **kwargs): self.merchant_id = merchant_id Browser.__init__(self, *args, **kwargs) def login(self): if not self.is_on_page(LoginPage): self.location('%s://%s/userManager.do?reqCode=prepareLogin' % (self.PROTOCOL, self.DOMAIN)) self.page.login(self.merchant_id, self.username, self.password) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() def is_logged(self): return not self.is_on_page(LoginPage) def get_accounts_list(self): self.location('%s://%s/summarySearch.do?reqCode=search' % (self.PROTOCOL, self.DOMAIN)) account = Account() account.id = u'1' account.currency = 'EUR' account.balance = self.page.get_balance() account.label = u'Synthèse financière' return [account] def iter_history(self, account): assert account.id == '1' if not self.is_on_page(TransactionSearchPage): self.location('%s://%s/menu.do?reqCode=prepareSearchTransaction&init=true&screen=new' % (self.PROTOCOL, self.DOMAIN)) self.page.search() self.location(self.page.get_csv_url()) for transaction in self.page.iter_transactions(): yield transaction weboob-1.1/modules/citelis/favicon.png000066400000000000000000000111111265717027300200740ustar00rootroot00000000000000PNG  IHDR@@iqIDAT g]}9잳ٰ$B.(IHL&I"RFD+# URRV*;SgPaZjՎLUdԪcC% ِ^u/$lfjgGK!lN*I$I++NL$UTJVd}=C٢d( 22 a saTRx3#XR"YRYll%YV,J!B-TBL#LuPO⠙u HNFm6}穜r> $gc;VPXD_ E'h0 a$+ )2w]ޑNQr:5zm3td E,  }2" I @A I8*Vh^fc<W y*~2*[-[p| ¢ө$$!)IA ( =,:Ŧ'iߪz~qԞ 8еj7J'TXV:tN(@AAAAA ( $" ۴EיvuQ{v6r}-bqpN_'kѢC' -:tMBPJ DGHR"ULTk I))%馋Ll1Cs*jO&Yf Rr-.UlUI-af\tӢ]ӉJPKu互f0ɽE3^7ٷ}&/;SIm%CsL[{(vfk6XiG̔n*FI\j ׋RoQ}|^}1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X\/IՂ\/.+m5EtR JnM1GE5(>IJΤ~".f݌fL;'QᰔH9Wk>kHIENDB`weboob-1.1/modules/citelis/module.py000066400000000000000000000037641265717027300176170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from weboob.capabilities.bank import CapBank, AccountNotFound from .browser import CitelisBrowser __all__ = ['CitelisModule'] class CitelisModule(Module, CapBank): NAME = 'citelis' DESCRIPTION = u'Citélis' MAINTAINER = u'Laurent Bachelier' EMAIL = 'laurent@bachelier.name' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = CitelisBrowser CONFIG = BackendConfig( ValueBackendPassword('merchant_id', label='Merchant ID', masked=False), ValueBackendPassword('login', label='Account ID', masked=False), ValueBackendPassword('password', label='Password')) def create_default_browser(self): return self.create_browser(self.config['merchant_id'].get(), self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): for account in self.iter_accounts(): if account.id == _id: return account raise AccountNotFound() def iter_history(self, account): return self.browser.iter_history(account) weboob-1.1/modules/citelis/pages.py000066400000000000000000000106361265717027300174250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal import datetime import re from weboob.deprecated.browser import Page, BrowserIncorrectPassword from weboob.tools.capabilities.bank.transactions import FrenchTransaction class Transaction(FrenchTransaction): @classmethod def clean_amount(cls, text): text = text.strip() # Convert "American" UUU.CC format to "French" UUU,CC format if re.search(r'\d\.\d\d$', text): text = text.replace(',', ' ').replace('.', ',') return FrenchTransaction.clean_amount(text) class LoginPage(Page): def login(self, merchant_id, login, password): self.browser.select_form(name='loginForm') self.browser['merchant'] = merchant_id.encode(self.browser.ENCODING) self.browser['login'] = login.encode(self.browser.ENCODING) self.browser['password'] = password.encode(self.browser.ENCODING) self.browser.submit() class SummaryPage(Page): def clean_amount(self, el, debit): amount = Decimal(Transaction.clean_amount(el.text_content())) if amount == Decimal('0.00'): return None if debit and amount > Decimal('0'): return -1 * amount return amount def get_balance(self): zone = self.parser.select(self.document.getroot(), '#ActionZone_Euro', 1) for tr in self.parser.select(zone, '#transactionError tr'): tds = self.parser.select(tr, 'td') if tds and tds[0].text_content().strip() == 'Total': debit, credit = self.parser.select(tr, 'td.amount', 4)[-2:] # keep the last 2 debit = self.clean_amount(debit, debit=True) credit = self.clean_amount(credit, debit=False) amount = credit or debit return amount class UselessPage(Page): def on_loaded(self): for error in self.document.xpath('//li[@class="error"]'): raise BrowserIncorrectPassword(self.parser.tocleanstring(error)) class TransactionSearchPage(Page): def search(self, accepted=True, refused=False): self.browser.select_form(name='transactionSearchForm') self.browser['selectedDateCriteria'] = ['thisweek'] # TODO ask for more self.browser['transactionAccepted'] = ['0'] if accepted else [] self.browser['transactionRefused'] = ['0'] if refused else [] # simulate the javascript nonce = self.parser.select(self.document.getroot(), '#menu li.global a')[0] \ .attrib['href'].partition('CSRF_NONCE=')[2] self.browser.form.action = '%s://%s/transactionSearch.do?reqCode=%s&org.apache.catalina.filters.CSRF_NONCE=%s&screen=new' % (self.browser.PROTOCOL, self.browser.DOMAIN, 'search', nonce) self.browser.submit() class TransactionsPage(Page): def get_csv_url(self): for a in self.parser.select(self.document.getroot(), '.exportlinks a'): if len(self.parser.select(a, 'span.csv')): return a.attrib['href'] class TransactionsCsvPage(Page): def guess_format(self, amount): if re.search(r'\d\.\d\d$', amount): date_format = "%m/%d/%Y" else: date_format = "%d/%m/%Y" time_format = "%H:%M:%S" return date_format + ' ' + time_format def iter_transactions(self): ID = 0 DATE = 2 AMOUNT = 4 CARD = 7 NUMBER = 8 for row in self.document.rows: t = Transaction(row[ID]) date = row[DATE] amount = row[AMOUNT] datetime_format = self.guess_format(amount) t.set_amount(amount) t.parse(datetime.datetime.strptime(date, datetime_format), row[CARD] + ' ' + row[NUMBER]) yield t weboob-1.1/modules/citelis/test.py000066400000000000000000000017771265717027300173130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CitelisTest(BackendTest): MODULE = 'citelis' def test_citelis(self): l = list(self.backend.iter_accounts()) assert len(l) a = l[0] l = list(self.backend.iter_history(a)) assert len(l) weboob-1.1/modules/citibank/000077500000000000000000000000001265717027300160765ustar00rootroot00000000000000weboob-1.1/modules/citibank/__init__.py000066400000000000000000000014441265717027300202120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CitibankModule __all__ = ['CitibankModule'] weboob-1.1/modules/citibank/browser.py000066400000000000000000000214361265717027300201410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014, 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from weboob.browser.pages import HTMLPage, JsonPage, RawPage from weboob.capabilities.bank import Account, AccountNotFound, Transaction from weboob.exceptions import BrowserIncorrectPassword from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from .parser import StatementParser, clean_label import re import os from datetime import datetime from tempfile import mkstemp from subprocess import STDOUT from weboob.tools.compat import check_output from time import sleep __all__ = ['Citibank'] class SomePage(HTMLPage): @property def logged(self): return bool(self.doc.xpath(u'//a[text()="Sign Off"]')) class IndexPage(SomePage): def extra(self): APPEND = r'jQuery\( "form" \).each\(function\(\) {' \ r'if\(isValidUrl\(jQuery\(this\).attr\("action"\)\)\){' \ r'jQuery\(this\).append\(([^)]+)\);}}\);' script = self.doc.xpath( '//script[contains(text(),"XXX_Extra")]/text()')[0] script = re.sub(APPEND, lambda m: 'return %s;' % m.group(1), script) script = re.sub(r'jQuery\(document\)[^\n]+\n', '', script) for x in re.findall('function ([^(]+)\(', script): script += '\nvar x = %s(); if (x) print(x);' % x scriptFd, scriptName = mkstemp('.js') os.write(scriptFd, script) os.close(scriptFd) html = check_output(["d8", scriptName], stderr=STDOUT) os.remove(scriptName) return re.findall(r'name=([^ ]+) value=([^>]+)>', html) class AccountsPage(JsonPage): logged = True def inner_ids_dict(self): return dict((prod['parsedAccountName'][-4:], prod['accountInstanceId']) for bean in self.doc['summaryViewBeanList'] for cat in bean['accountsSummaryViewObj']['categoryList'] for prod in cat['products'] if cat['categoryType'] == 'CRD') class AccDetailsPage(JsonPage): logged = True def account(self): detact = self.doc['accountDetailsAndActivity'] details = detact['accountDetails'] account = Account() account.type = Account.TYPE_CARD account.label = re.sub(r'<[^>]+>', '', detact['accountName']) account.id = account.label[-4:] for bal in details['accountBalances']: label, value = bal['label'], (bal['value'] or ['0'])[0] if label == u'Current Balance:': account.currency = Account.get_currency(value) account.balance = -AmTr.decimal_amount(value) elif label == u'Total Revolving Credit Line:': account.cardlimit = AmTr.decimal_amount(value) elif label.startswith(u'Minimum Payment Due'): d = re.match(r'.*(..-..-....):$', label).group(1) account.paydate = datetime.strptime(d, '%m-%d-%Y') account.paymin = AmTr.decimal_amount(value) return account def transactions(self): return sorted(self.unsorted_trans(), lambda a, b: cmp(a.date, b.date), reverse=True) def unsorted_trans(self): for jnl in self.doc['accountDetailsAndActivity']['accountActivity'] \ ['postedTransactionJournals']: tdate = jnl['columns'][0]['activityColumn'][0] label = jnl['columns'][1]['activityColumn'][0] amount = jnl['columns'][3]['activityColumn'][0] xdescs = dict((x['label'], x['value'][0]) for x in jnl['extendedDescriptions']) pdate = xdescs[u'Posted Date :'] ref = xdescs.get(u'Reference Number:') or u'' if amount.startswith(u'(') and amount.endswith(u')'): amount = AmTr.decimal_amount(amount[1:-1]) else: amount = -AmTr.decimal_amount(amount) label = clean_label(label) trans = Transaction(ref) trans.date = datetime.strptime(tdate, '%m-%d-%Y') trans.rdate = datetime.strptime(pdate, '%m-%d-%Y') trans.type = Transaction.TYPE_UNKNOWN trans.raw = label trans.label = label trans.amount = amount yield trans class StatementsPage(SomePage): def dates(self): return [x[:10] for x in self.doc.xpath( u'//select[@id="currentStatementsDate"]/option/@value') if re.match(u'^\d\d\d\d-\d\d-\d\d All$', x)] class StatementPage(RawPage): logged = True def __init__(self, *args, **kwArgs): RawPage.__init__(self, *args, **kwArgs) self._parser = StatementParser(self.doc) def is_sane(self): return self._parser.read_first_date_range() is not None def transactions(self): return sorted(self._parser.read_transactions(), cmp=lambda t1, t2: cmp(t2.date, t1.date)) class Citibank(LoginBrowser): """ Citibank website uses some kind of Javascript magic during login negotiation, hence a real JS interpreter is being used to log in. External dependencies: V8 JavaScript Engine (http://code.google.com/p/v8/). MuPDF (http://www.mupdf.com). Tested on Arch Linux snapshot of 2014-11-11 (official and user packages). Only a single credit card account is currently supported. Contributions are welcome! """ BASEURL = 'https://online.citibank.com' MAX_RETRIES = 10 TIMEOUT = 30.0 index = URL(r'/US/JPS/portal/Index.do', IndexPage) signon = URL(r'/US/JSO/signon/ProcessUsernameSignon.do', SomePage) accounts = URL(r'/US/REST/accountsPanel' r'/getCustomerAccounts.jws\?ttc=(?P.*)$', AccountsPage) accdetails = URL(r'/US/REST/accountDetailsActivity' r'/getAccountDetailsActivity.jws\?accountID=(?P.*)$', AccDetailsPage) statements = URL(r'/US/NCSC/doccenter/flow.action\?TTC=1079&' 'accountID=(?P.*)$', StatementsPage) statement = URL(r'/US/REST/doccenterresource/downloadStatementsPdf.jws\?' r'selectedIndex=0&date=(?P....-..-..)&' r'downloadFormat=pdf', StatementPage) unknown = URL('/.*$', SomePage) def get_account(self, id_): innerId = self.to_accounts().inner_ids_dict().get(id_) if innerId: return self.to_account(innerId).account() raise AccountNotFound() def iter_accounts(self): for innerId in self.to_accounts().inner_ids_dict().values(): yield self.to_account(innerId).account() def iter_history(self, account): innerId = self.to_accounts().inner_ids_dict()[account.id] for trans in self.to_account(innerId).transactions(): yield trans for date in self.to_statements(innerId).dates(): for trans in self.to_statement(date).transactions(): yield trans def to_account(self, innerId): return self.to_page(self.accdetails, accountID=innerId) def to_accounts(self): return self.to_page(self.accounts, ttc='742') def to_statements(self, innerId): return self.to_page(self.statements, accountID=innerId) def to_statement(self, date): # Sometimes the website returns non-PDF file. # It recovers if we repeat whole browsing sequence all the way # from home page up to the statement. MAX_DELAY=10 for i in xrange(self.MAX_RETRIES): if self.to_page(self.statement, date=date).is_sane(): return self.page sleep(min(MAX_DELAY, 1 << i)) self.do_login() innerId = self.to_accounts().inner_ids_dict().values()[0] self.to_account(innerId) self.to_statements(innerId) @need_login def to_page(self, url, **data): return self.page if url.is_here(**data) else url.go(data=data, **data) def do_login(self): self.session.cookies.clear() data = dict([('username', self.username), ('password', self.password)]+ self.index.go().extra()) if not self.signon.go(data=data).logged: raise BrowserIncorrectPassword() weboob-1.1/modules/citibank/favicon.png000066400000000000000000000077561265717027300202500ustar00rootroot00000000000000PNG  IHDR@@% gAMA a cHRMz&u0`:pQ<bKGDIDAThZ{Uu}|Gro䒷!<"c .-u֊v.*bki}`+.Q"+Q!!䝛3sٻ|Cp+Ǭgog!t'mhD%mꉶabp8]p&f;ht Eo @۩cwҤ}nJ` ֜yX 3AdQjbV84g l@2.aubȕUl$/lF!* %wVu>lgݾŽ,om-3KYl] z$%V R錑=s_¹oF͋-(5dhm-ͼ+3{>層Zu`!ΣORP!$DÚv=UP:AJj6t+'9# H-TL}A',^BGƀ"XXDܹ]^=/"R<>b4My[kQ[士s.l@fH}q ?nd肫Ǔ;U5^g oo;xglB}1j Dd(S]@_Wrz^>HJ*dj,PX*ClMT4d#"9<$2<{$Ƹtpї}ᡁ탍eږt^8 bug;FR]>04'gv\&;~d`O(0RIN.qÞjM恧!?M/><󅵧V ;.mj#D5(e]k4r^sƬ}Z#UحXu^4-gv]lڞ?J(Z{˻{H-^.4hռ.`v7lv_~y90}3"Å W2٢Ϲ [ÌNtq9uqMw|yw<îR62 c;G.Wh?:gvǴ-63ڼf~mÓTWt aI_,4Ĥ(LQ)Ͼ޶[ޝۆQӄfgn6l.vMi! Jj1 T**Wb >7/7/XYW}w]YzZݸ/s_~*eĥ |m[}]\j v ]C`bд Ň/<zw/!! Ή | Q(h3X9kNgk7wz7i,TBJ>}so[Vo_W"E<kplˇ\GkB >+z<|jiB 443(%͟>H7,] ~k]Z:-nAeڒ/?~M)`5dFGWݼoSL<X B_2}{^5ZwRY(<԰8RMʜδPTUiwR#kN^|˽[D wo?|A4bS;ɮ+VF`Wݏuwg4Ě%ߔCf[]Hgmç޴J[yݖz],RF{ք͡SԼ*O] 3+=Q醽|pޗOlrEM?-&*%O=w&Ed#zG޶;(Q:Vxj#Z]4w-|LogJ\s }{f-*,el`jkbQiM;T,Uٶ:h~/UZ6Zcm͋^2)4*czK#Fm8sjOHGa ʑL<LRCd"KR/@LJO0 ay%d<# +bH-qlsfֶЀpy&̳2ũP*xG@UEUx,s""!|(jUj&$y!&U Jh&RBb@2ȧPX]=tE;͆wWz>4(BqT a YSCfzF{čzE86@cA۾ܾ0~~}h&@g9AN '>  'yBzIlO*%tEXtdate:create2014-10-11T13:21:44-05:00l%tEXtdate:modify2014-10-11T13:21:19-05:004IENDB`weboob-1.1/modules/citibank/module.py000066400000000000000000000033331265717027300177370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Citibank __all__ = ['CitibankModule'] class CitibankModule(Module, CapBank): NAME = 'citibank' MAINTAINER = u'Oleg Plakhotniuk' EMAIL = 'olegus8@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Citibank' CONFIG = BackendConfig( ValueBackendPassword('username', label='Username', masked=False), ValueBackendPassword('password', label='Password')) BROWSER = Citibank def create_default_browser(self): return self.create_browser(self.config['username'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.iter_accounts() def get_account(self, id_): return self.browser.get_account(id_) def iter_history(self, account): return self.browser.iter_history(account) weboob-1.1/modules/citibank/parser.py000066400000000000000000000157511265717027300177550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import Transaction from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.tools.date import closest_date from weboob.tools.pdf import decompress_pdf from weboob.tools.tokenizer import ReTokenizer import datetime import re def clean_label(text): """ Web view and statements use different label formatting. User shouldn't be able to see the difference, so we need to make labels from both sources look the same. """ for pattern in [r' \d+\.\d+ +POUND STERLING', u'Subject to Foreign Fee', u'Description']: text = re.sub(pattern, u'', text, re.UNICODE) return re.sub(r' +', u' ', text.strip().upper(), re.UNICODE) def formatted(read_func): """ Reads boilerplate PDF formatting around the data of interest. """ def wrapped(self, pos): startPos = pos pos, ws = self.read_whitespace(pos) pos, bt = self.read_layout_bt(pos) pos, tf = self.read_layout_tf(pos) pos, tm = self.read_layout_tm(pos) pos, data = read_func(self, pos) pos, et = self.read_layout_et(pos) if ws is None or bt is None or tf is None \ or tm is None or data is None or et is None: return startPos, None else: return pos, data return wrapped class StatementParser(object): """ Each "read_*" method takes position as its argument, and returns next token position if read was successful, or the same position if it was not. """ LEX = [ ('date_range', r'^\((\d{2}/\d{2}/\d{2})-(\d{2}/\d{2}/\d{2})\) Tj$'), ('amount', r'^\((-?\$\d+(,\d{3})*\.\d{2})\) Tj$'), ('date', r'^\((\d{2}/\d{2})\) Tj$'), ('text', r'^\((.*)\) Tj$'), ('layout_tf', r'^.* Tf$'), ('layout_tm', r'^' + (6*r'([^ ]+) ') + r'Tm$'), ('layout_bt', r'^BT$'), ('layout_et', r'^ET$'), ('whitespace', r'^$') ] def __init__(self, pdf): self._pdf = decompress_pdf(pdf) self._tok = ReTokenizer(self._pdf, '\n', self.LEX) def read_transactions(self): # Read statement dates range. date_from, date_to = self.read_first_date_range() # Read transactions. pos = 0 while not self._tok.tok(pos).is_eof(): pos, trans = self.read_transaction(pos, date_from, date_to) if trans: yield trans else: pos += 1 def read_first_date_range(self): pos = 0 while not self._tok.tok(pos).is_eof(): pos, date_range = self.read_date_range(pos) if date_range is not None: return date_range else: pos += 1 def read_date_range(self, pos): t = self._tok.tok(pos) if t.is_date_range(): return (pos+1, [datetime.datetime.strptime(v, '%m/%d/%y') for v in t.value()]) else: return (pos, None) def read_transaction(self, pos, date_from, date_to): startPos = pos pos, tdate = self.read_date(pos) pos, pdate = self.read_date(pos) # Early check to call read_multiline_desc() only when needed. if tdate is None: return startPos, None pos, desc = self.read_multiline_desc(pos) pos, amount = self.read_amount(pos) if desc is None or amount is None: return startPos, None else: # Sometimes one date is missing. pdate = pdate or tdate tdate = closest_date(tdate, date_from, date_to) pdate = closest_date(pdate, date_from, date_to) trans = Transaction() trans.date = tdate trans.rdate = pdate trans.type = Transaction.TYPE_UNKNOWN trans.raw = desc trans.label = desc trans.amount = -amount return pos, trans def read_multiline_desc(self, pos): """ Read transaction description which can span over multiple lines. Amount must always follow the multiline description. But multiline description might be split by page break. After reading first line of the description, we skip everything which is not an amount and which has different horizontal offset than the first read line. """ startPos = pos descs = [] xofs = None while not self._tok.tok(pos).is_eof(): pos, desc_tm = self.read_text(pos) if desc_tm is None: if not descs: break prev_pos = pos pos, amount = self.read_amount(pos) if amount is not None: pos = prev_pos break pos += 1 else: desc, tm = desc_tm if xofs is None: _, _, _, _, xofs, _ = tm _, _, _, _, xofs_new, _ = tm if xofs == xofs_new: descs.append(desc) else: pos += 1 if descs: return pos, clean_label(' '.join(descs)) else: return startPos, None def __getattr__(self, name): if name.startswith('read_'): return lambda pos: self._tok.simple_read(name[5:], pos) raise AttributeError() @formatted def read_date(self, pos): return self._tok.simple_read('date', pos, lambda v: datetime.datetime.strptime(v, '%m/%d')) @formatted def read_amount(self, pos): return self._tok.simple_read('amount', pos, lambda xs: AmTr.decimal_amount(xs[0])) def read_text(self, pos): startPos = pos pos, ws = self.read_whitespace(pos) pos, bt = self.read_layout_bt(pos) pos, tf = self.read_layout_tf(pos) pos, tm = self.read_layout_tm(pos) pos, text = self._tok.simple_read('text', pos, lambda v: unicode(v, errors='ignore')) pos, et = self.read_layout_et(pos) if ws is None or bt is None or tf is None \ or tm is None or text is None or et is None: return startPos, None else: return pos, (text, tm) weboob-1.1/modules/citibank/test.py000066400000000000000000000021761265717027300174350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from itertools import chain class CitibankTest(BackendTest): MODULE = 'citibank' def test_history(self): """ Test that there's at least one transaction in the whole history. """ b = self.backend ts = chain(*[b.iter_history(a) for a in b.iter_accounts()]) t = next(ts, None) self.assertNotEqual(t, None) weboob-1.1/modules/cmb/000077500000000000000000000000001265717027300150535ustar00rootroot00000000000000weboob-1.1/modules/cmb/__init__.py000066400000000000000000000014231265717027300171640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Johann Broudin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CmbModule __all__ = ['CmbModule'] weboob-1.1/modules/cmb/favicon.png000066400000000000000000000121161265717027300172070ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDM*E pHYs  tIME , dF|tEXtCommentCreated with GIMPWIDATx͛yp?o9'ɞ A @(V U+PĹUwzZ;ҪwNzպ[Ve*,ͅM$+YNINHA}f~3m><`ok2= o-hMR]p ,Qq6 ?(zz ôQxu9?oi p?;<仗  m^o~]SÇP7\i}5YN}0㛷)Ͼn,fܯ1"~7k98NDM ρ  ?$D?KO'׿(*BA65!ADBZZZgPzzpkjz^zi4p"Ѳ^( ϼzRRW3OЄ׫AW%ߡCp^\[[SUkWy^e}1jf"p0nC G68+ [0:sOFnM nm-=SVvmcժQq4SF|9n}=o|渜|>zS4&ZVP1ݧifM$צNECI!@!{矫).,-E$& 3rrpF650@z}g4i0"h@ඵ pt]5~A<|Xv6ZN$ԩctSWMsWr@orcr<+W֩ L-!<tK#.}3 f|=I1=_5Ɔi7. mdDl,B86S ?\Q0D΅Ea.΁8E\Fa;sn$tH OY L}3ラ/n}=zWd2dC==[]liA3moz0Yh'"22'N߁΢(7Ǹ DBЏ;pA66ҽn!@#O1q񈸸Hs4oO,g4x{cP.sL:"%Q2?`mB'G* Fdk+}WPvQ - t-3S%e{>Zo39k1f‚DSͤ">tu!;:j̖/Ǹ2Dz:ژԤ< ˔u@hjr@8ٖhY!#  ‡^/M>{647hmEnn@`XuԒ7N PJuS8"> cNz>ٵhZﺕe9QXs~2+U/+JVjuDB4 ^ب_X.՟Af"@, с^\`oڄ!- sDt44Gb.$!b5w$&b\z)Y݋h99_HM)+zM1JKI:5vdehܳyfX}| ϠF3]]cpOGL_P6e ڤI GEz@O q>O1u*Q܃;pmn,-Pq-# pՈ | qs;#ɓx~SmԒkhPE ;:p|p=\4ٻ=<<7ވAvv#p>MͤϞ,%QY΍CG^}c;q?XPC025Uy{ #|,Kϙ76} Z2V^K gϛ˱l~ rdGRj DF>0p|?UqQXHp0 V^=^A߇ӧ3-B$$څ{;v RؼgN\#C!tDtN-[^}czY={ @/.(,D<?}|wAGw`>z^7> vi#[T<78@]w@q>tIp穧^~Y)vM)DSgf" qEKKSYSQTDʕ<,nEԩZc|0 2,epD?^}YB0 kA/ja rr^x1"%?X}Ոdz6l0-Cde64l݊efBRζm*4  =\ЀqW GopqM 7?zc|udw7") =?_55Ȧ&ٳЦLA(yTqm+0YY8}>VӐMߕt{Fd06mΎ'N RA|σ L anØ8oF9{S!SS?~<ڬYد5}$Eɓyu+uq+*7,K.TI| x ?U {F7nUξ}|7AsƏٹijbNE"* mD>_6Pi^X\ic/)/z;KJ0,9x==xns*ĤIȪ*zz qw˖lq<^Rm = =>~xה6mRCVWe7Q:s~nĸ*]2BS5n̥KѦNUyϧfEKN9x5q>!&g^d rֆ[S{7&kyU!~{6W ڔ.P^iSDb̕+1,A7N)@MQTD"Db"$xՃ#23&MBT{(-B<89 /6F}..Nu-B/*R{VVb?\޹^7=tt޽φ)g8HA jHk11\`") kf׬sRdC5_Lu*f" FE梍6qs5}؛Nxc%]NUx;v_+t.]*9 pvF_ !֪vW 0Jme/i dFDz:G9|X̙яy)maWh`~ք;N-"uv"pqW}P{?f1,)޵ j_V:g 5 лeW{jg&"І?Lf(IENDB`weboob-1.1/modules/cmb/module.py000066400000000000000000000214731265717027300167210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Johann Broudin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.bank import Account, Transaction from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from weboob.capabilities.base import NotAvailable from weboob.exceptions import BrowserIncorrectPassword, BrowserHTTPError, ParseError from weboob.browser import Browser from re import match, compile, sub from decimal import Decimal from lxml import etree from datetime import date from StringIO import StringIO __all__ = ['CmbModule'] class CmbModule(Module, CapBank): NAME = 'cmb' MAINTAINER = u'Johann Broudin' EMAIL = 'Johann.Broudin@6-8.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Crédit Mutuel de Bretagne' CONFIG = BackendConfig( ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe', masked=True)) LABEL_PATTERNS = [ ( # card compile('^CARTE (?P.*)'), Transaction.TYPE_CARD, '%(text)s' ), ( # order compile('^PRLV (?P.*)'), Transaction.TYPE_ORDER, '%(text)s' ), ( # withdrawal compile('^RET DAB (?P.*)'), Transaction.TYPE_WITHDRAWAL, '%(text)s' ), ( # loan payment compile('^ECH (?P.*)'), Transaction.TYPE_LOAN_PAYMENT, '%(text)s' ), ( # transfer compile('^VIR (?P.*)'), Transaction.TYPE_TRANSFER, '%(text)s' ), ( # payback compile('^ANN (?P.*)'), Transaction.TYPE_PAYBACK, '%(text)s' ), ( # bank compile('^F (?P.*)'), Transaction.TYPE_BANK, '%(text)s' ), ( # deposit compile('^VRST (?P.*)'), Transaction.TYPE_DEPOSIT, '%(text)s' ) ] BROWSER = Browser islogged = False def login(self): data = { 'codeEspace': 'NO', 'codeEFS': '01', 'codeSi': '001', 'noPersonne': self.config['login'].get(), 'motDePasse': self.config['password'].get() } try: self.browser.open("https://www.cmb.fr/domiweb/servlet/Identification", data=data) self.browser.open("https://www.cmb.fr/domiweb/prive/espacesegment/selectionnerAbonnement/0-selectionnerAbonnement.act") except BrowserHTTPError: raise BrowserIncorrectPassword() else: self.islogged=True # Go on pro space when there is one. self.browser.open("https://www.cmb.fr/domiweb/prive/espacesegment/selectionnerAbonnement/1-selectionnerAbonnement.act?espace=PR&indice=0") def iter_accounts(self): if not self.islogged: self.login() data = self.browser.open("https://www.cmb.fr/domiweb/prive/particulier/releve/0-releve.act").content parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: title = tree.xpath('/html/head/title')[0].text if title == u"Utilisateur non identifié": self.login() data = self.browser.open("https://www.cmb.fr/domiweb/prive/particulier/releve/0-releve.act").content parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) table = tree.xpath('/html/body/table') if len(table) == 0: raise ParseError() else: raise ParseError() for tr in tree.xpath('/html/body//table[contains(@class, "Tb")]/tr'): if tr.get('class', None) not in ('LnTit', 'LnTot', 'LnMnTiers', None): account = Account() td = tr.xpath('td') a = td[1].xpath('a') account.label = unicode(a[0].text).strip() href = a[0].get('href') m = match(r"javascript:releve\((.*),'(.*)','(.*)'\)", href) if not m: continue account.id = unicode(m.group(1) + m.group(2) + m.group(3)) account._cmbvaleur = m.group(1) account._cmbvaleur2 = m.group(2) account._cmbtype = m.group(3) balance = u''.join([txt.strip() for txt in td[2].itertext()]) balance = balance.replace(',', '.').replace(u"\xa0", '') account.balance = Decimal(balance) span = td[4].xpath('a/span') if len(span): coming = span[0].text.replace(' ', '').replace(',', '.') coming = coming.replace(u"\xa0", '') account.coming = Decimal(coming) else: account.coming = NotAvailable yield account def get_account(self, _id): for account in self.iter_accounts(): if account.id == _id: return account raise AccountNotFound() def iter_history(self, account): if not self.islogged: self.login() page = "https://www.cmb.fr/domiweb/prive/particulier/releve/" if account._cmbtype == 'D': page += "10-releve.act" else: page += "2-releve.act" page +="?noPageReleve=1&indiceCompte=" page += account._cmbvaleur page += "&typeCompte=" page += account._cmbvaleur2 page += "&deviseOrigineEcran=EUR" data = self.browser.open(page).content parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) tables = tree.xpath('/html/body/table') if len(tables) == 0: title = tree.xpath('/html/head/title')[0].text if title == u"Utilisateur non identifié": self.login() data = self.browser.open(page).content parser = etree.HTMLParser() tree = etree.parse(StringIO(data), parser) tables = tree.xpath('/html/body/table') if len(tables) == 0: raise ParseError() else: raise ParseError() i = 0 for table in tables: if table.get('id') != "tableMouvements": continue for tr in table.getiterator('tr'): if (tr.get('class') != 'LnTit' and tr.get('class') != 'LnTot'): operation = Transaction() td = tr.xpath('td') div = td[1].xpath('div') d = div[0].text.split('/') operation.date = date(*reversed([int(x) for x in d])) div = td[2].xpath('div') label = div[0].xpath('a')[0].text.replace('\n', '') operation.raw = unicode(' '.join(label.split())) for pattern, _type, _label in self.LABEL_PATTERNS: mm = pattern.match(operation.raw) if mm: operation.type = _type operation.label = sub('[ ]+', ' ', _label % mm.groupdict()).strip() break amount = td[3].text if amount.count(',') != 1: amount = td[4].text amount = amount.replace(',', '.').replace(u'\xa0', '') operation.amount = Decimal(amount) else: amount = amount.replace(',', '.').replace(u'\xa0', '') operation.amount = - Decimal(amount) i += 1 yield operation weboob-1.1/modules/cmso/000077500000000000000000000000001265717027300152535ustar00rootroot00000000000000weboob-1.1/modules/cmso/__init__.py000066400000000000000000000014241265717027300173650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CmsoModule __all__ = ['CmsoModule'] weboob-1.1/modules/cmso/favicon.png000066400000000000000000000044401265717027300174100ustar00rootroot00000000000000PNG  IHDR@@iqbKGDC pHYs  tIME /*!tEXtCommentCreated with GIMPWIDATxݛ{lUE?[hKPEB*EdB4&+`4eCdWACf}BD|@]⢨A RE(1=Ћ}>.'s~gf|37s.!ZN rKR7cY ~P{i:!Sţ!o$8,H7"x"<@ Vo:Ղ >$A%8+T{C;a0pGw{;qO!)N/AJwq\:SAà@N{z?)g`JW+u$դgkWn*\)8kPn/efJ TGdEljlDA4jy&%%I r1c=; 7(a}g+`Y+^03p\ Iz aMxS |CJJ<ѡL0bm#éS%Il*|0ӧ6&Mj{gς#c5c:YUUP(b4~o@}7%)VHlaǎj L^+/0%NlJKE 5P~Qz:ѣh4<.ƌۢ2N1O7Z--MwSo6~$ɞ^d8YVV{ @bbPR"[/1BVSgϖ9"k~X>YmVU \3SK 7ʕG}q1l染_ֵwK8[!7Y}'Nm$]}TVQ!-3Yu*+}FlYMl|dlc/^~YVV/vlŊEs8,ӝdWy'綾d+W3%KdiiNQnbxiӲpik!} 9/) /bHNl/4C~?O~D̛a ͏*p+*"nO6^PU}xR@J3W~>^j*>`ddO<'kGAuuP[pty`(*s@ޮzꮭEEEx ԸNT\ 5С&:{ut&+ʷߖ#{]-rse;v>Ylϓ˝ g7nt7![FklLWڵ/=L³:jBY^nr+e>*fWn0"g{ָVR";p VPeNcanҬYhsFL. from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, AccountsPage, TransactionsPage __all__ = ['CmsoMobileBrowser'] class CmsoMobileBrowser(Browser): PROTOCOL = 'https' DOMAIN = 'www.cmso.com' ENCODING = 'iso-8859-1' PAGES = {'https://www.cmso.com/domimobile/m.jsp\?a=signin.*': LoginPage, 'https://www.cmso.com/domimobile/m.jsp\?a=sommaire.*': AccountsPage, 'https://www.cmso.com/domimobile/m.jsp\?a=solde.*': TransactionsPage, 'https://www.cmso.com/domimobile/m.jsp\?rels=.*': TransactionsPage, } def is_logged(self): return self.page is not None and not self.is_on_page(LoginPage) def home(self): if self.is_logged(): self.location('https://www.cmso.com/domimobile/m.jsp?a=sommaire') else: self.login() def login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if self.is_logged(): return if not self.is_on_page(LoginPage): self.location('https://www.cmso.com/domimobile/m.jsp?a=signin&b=sommaire', no_login=True) self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() def get_accounts_list(self): if not self.is_on_page(AccountsPage): self.location('https://www.cmso.com/domimobile/m.jsp?a=sommaire') return self.page.get_list() def get_history(self, account): if not self.is_on_page(AccountsPage): self.location('https://www.cmso.com/domimobile/m.jsp?a=sommaire') link = account._link while link is not None: self.location(link) assert self.is_on_page(TransactionsPage) for tr in self.page.get_history(): yield tr link = self.page.get_next_link() weboob-1.1/modules/cmso/mobile/pages.py000066400000000000000000000065351265717027300202040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from decimal import Decimal import re from weboob.deprecated.browser import Page from weboob.capabilities.bank import Account from ..transaction import Transaction class LoginPage(Page): def login(self, login, passwd): self.browser.select_form(name='formIdentification') self.browser['noPersonne'] = login.encode(self.browser.ENCODING) self.browser['motDePasse'] = passwd.encode(self.browser.ENCODING) self.browser.submit(nologin=True) class AccountsPage(Page): def get_list(self): names = set() for li in self.document.xpath('//div[@class="affichMontant"]/ul/li/a'): account = Account() account.label = unicode(li.cssselect('div.row-lib u')[0].text.strip()) account.id = re.sub('[ \.\-]+', '', account.label) while account.id in names: account.id = account.id + '1' names.add(account.id) account.balance = Decimal(li.cssselect('p.row-right')[0].text.strip().replace(' ', '').replace(u'\xa0', '').replace(',', '')) account._link = li.attrib['href'] yield account class TransactionsPage(Page): months = [u'janvier', u'février', u'mars', u'avril', u'mai', u'juin', u'juillet', u'août', u'septembre', u'octobre', u'novembre', u'décembre'] def get_next_link(self): a = self.document.getroot().cssselect('div#nav-sub p.row-right a') if len(a) == 0: return None return a[0].attrib['href'] def get_history(self): for div in self.document.xpath('//ol[@class="affichMontant"]/li/div'): t = Transaction() raw = div.xpath('.//div[@class="row-lib"]')[0].text date = div.xpath('.//span')[0].text.strip() m = re.match('(\d+)(er)? ([^ ]+)( \d+)?$', date) if m: dd = int(m.group(1)) mm = self.months.index(m.group(3)) + 1 if m.group(4) is not None: yy = int(m.group(4)) else: d = datetime.date.today() try: d = d.replace(month=mm, day=dd) except ValueError: d = d.replace(year=d.year-1, month=mm, day=dd) yy = d.year date = datetime.date(yy, mm, dd) else: self.logger.error('Unable to parse date %r' % date) continue t.parse(date, re.sub(r'[ ]+', ' ', raw)) t.amount = Decimal(div.xpath('.//span')[-1].text.strip().replace(' ', '').replace(u'\xa0', '').replace(',', '')) yield t weboob-1.1/modules/cmso/module.py000066400000000000000000000043071265717027300171160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from .mobile.browser import CmsoMobileBrowser from .web.browser import CmsoProBrowser __all__ = ['CmsoModule'] class CmsoModule(Module, CapBank): NAME = 'cmso' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Crédit Mutuel Sud-Ouest' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe'), Value('website', label='Type de compte', default='par', choices={'par': 'Particuliers', 'pro': 'Professionnels'})) BROWSER = CmsoMobileBrowser def create_default_browser(self): b = {'par': CmsoMobileBrowser, 'pro': CmsoProBrowser} self.BROWSER = b[self.config['website'].get()] return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): return self.browser.get_history(account) weboob-1.1/modules/cmso/test.py000066400000000000000000000017341265717027300166110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CmsoTest(BackendTest): MODULE = 'cmso' def test_cmso(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/cmso/transaction.py000066400000000000000000000044261265717027300201600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.tools.capabilities.bank.transactions import FrenchTransaction class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^RET DAB (?P
\d{2})/?(?P\d{2})(/?(?P\d{2}))? (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('CARTE (?P
\d{2})/(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile('^(?PVIR(EMEN)?T? (SEPA)?(RECU|FAVEUR)?)( /FRM)?(?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^PRLV (?P.*)( \d+)?$'), FrenchTransaction.TYPE_ORDER), (re.compile('^(CHQ|CHEQUE) .*$'), FrenchTransaction.TYPE_CHECK), (re.compile('^(AGIOS /|FRAIS) (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(CONVENTION \d+ |F )?COTIS(ATION)? (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^REMISE (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^(?P.*)( \d+)? QUITTANCE .*'), FrenchTransaction.TYPE_ORDER), (re.compile('^.* LE (?P
\d{2})/(?P\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_UNKNOWN), ] weboob-1.1/modules/cmso/web/000077500000000000000000000000001265717027300160305ustar00rootroot00000000000000weboob-1.1/modules/cmso/web/__init__.py000066400000000000000000000000001265717027300201270ustar00rootroot00000000000000weboob-1.1/modules/cmso/web/browser.py000066400000000000000000000061111265717027300200640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 smurail # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from dateutil.relativedelta import relativedelta from itertools import chain from weboob.exceptions import BrowserHTTPError, BrowserIncorrectPassword from weboob.browser import LoginBrowser, URL, need_login from weboob.tools.date import LinearDateGuesser from .pages import LoginPage, AccountsPage, HistoryPage, ChoiceLinkPage, SubscriptionPage, UselessPage class CmsoProBrowser(LoginBrowser): BASEURL = 'https://www.cmso.com/' login = URL('/banque/assurance/credit-mutuel/pro/accueil\?espace=professionnels', LoginPage) choice_link = URL('/domiweb/accueil.jsp', ChoiceLinkPage) subscription = URL('/domiweb/prive/espacesegment/selectionnerAbonnement/0-selectionnerAbonnement.act', SubscriptionPage) accounts = URL('/domiweb/prive/professionnel/situationGlobaleProfessionnel/0-situationGlobaleProfessionnel.act', AccountsPage) history = URL('/domiweb/prive/professionnel/situationGlobaleProfessionnel/1-situationGlobaleProfessionnel.act', HistoryPage) useless = URL('/domiweb/prive/particulier/modificationMotDePasse/0-expirationMotDePasse.act', UselessPage) def do_login(self): self.login.stay_or_go() try: self.page.login(self.username, self.password) except BrowserHTTPError as e: # Yes, I know... In the Wild Wild Web, nobody respects nothing if e.response.status_code == 500: raise BrowserIncorrectPassword() else: raise else: self.subscription.go() @need_login def get_accounts_list(self): self.accounts.go() return self.page.iter_accounts() @need_login def get_history(self, account): if account._history_url.startswith('javascript:'): raise NotImplementedError() # Query history for 6 last months def format_date(d): return datetime.date.strftime(d, '%d/%m/%Y') today = datetime.date.today() period = (today - relativedelta(months=6), today) query = {'date': ''.join(map(format_date, period))} # Let's go self.location(account._history_url) first_page = self.page rest_page = self.history.go(data=query) date_guesser = LinearDateGuesser() return chain(first_page.iter_history(date_guesser=date_guesser), reversed(list(rest_page.iter_history(date_guesser=date_guesser)))) weboob-1.1/modules/cmso/web/pages.py000066400000000000000000000110571265717027300175050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 smurail # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import datetime from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, CleanDecimal, Regexp, DateGuesser, Env from weboob.browser.filters.html import Link from weboob.capabilities.bank import Account from ..transaction import Transaction __all__ = ['LoginPage'] class UselessPage(HTMLPage): pass class ChoiceLinkPage(HTMLPage): def on_load(self): link_line = self.doc.xpath('//script')[-1].text m = re.search(r'lien\("(.*)"', link_line) if m: self.browser.location(m.group(1)) class SubscriptionPage(HTMLPage): def on_load(self): for div in self.doc.xpath('//div[@class="listeAbonnementsBox"]'): site_type = div.xpath('./div[1]')[0].text if site_type == 'Professionnel': link = div.xpath('./div[2]')[0].attrib['onclick'] m = re.search(r"href='(.*)'", link) if m: self.browser.location(m.group(1)) class LoginPage(HTMLPage): def login(self, username, password): form = self.get_form('//form[@id="formAuth"]') form['noPersonne'] = username form['motDePasse'] = password[:16] form.submit() class CMSOPage(HTMLPage): @property def logged(self): if len(self.doc.xpath('//b[text()="Session interrompue"]')) > 0: return False return True class CmsoListElement(ListElement): item_xpath = '//table[@class="Tb" and tr[1][@class="LnTit"]]/tr[@class="LnA" or @class="LnB"]' class AccountsPage(CMSOPage): @method class iter_accounts(CmsoListElement): class item(ItemElement): klass = Account obj__history_url = Link('./td[1]/a') obj_label = CleanText('./td[1]') obj_id = obj__history_url & Regexp(pattern="indCptSelectionne=(\d+)") | None obj_balance = CleanDecimal('./td[2]', replace_dots=True) def validate(self, obj): if obj.id is None: obj.id = obj.label.replace(' ', '') return True class CmsoTransactionElement(ItemElement): klass = Transaction def condition(self): return len(self.el) >= 5 and not self.el.get('id', '').startswith('libelleLong') class HistoryPage(CMSOPage): def iter_history(self, *args, **kwargs): if self.doc.xpath('//a[@href="1-situationGlobaleProfessionnel.act"]'): return self.iter_history_rest_page(*args, **kwargs) return self.iter_history_first_page(*args, **kwargs) @method class iter_history_first_page(CmsoListElement): class item(CmsoTransactionElement): def validate(self, obj): return obj.date >= datetime.date.today().replace(day=1) def date(selector): return DateGuesser(CleanText(selector), Env('date_guesser')) | Transaction.Date(selector) obj_date = date('./td[1]') obj_vdate = date('./td[2]') # Each row is followed by a "long labelled" version obj_raw = Transaction.Raw('./following-sibling::tr[1][starts-with(@id, "libelleLong")]/td[3]') obj_amount = Transaction.Amount('./td[5]', './td[4]') def condition(self): return len(self.el) >= 5 and not self.el.get('id', '').startswith('libelleLong') and len(self.el.xpath('.//i')) > 0 @pagination @method class iter_history_rest_page(CmsoListElement): next_page = Link('//span[has-class("Rappel")]/following-sibling::*[1][@href]') class item(CmsoTransactionElement): obj_date = Transaction.Date('./td[2]') obj_vdate = Transaction.Date('./td[1]') obj_raw = Transaction.Raw('./td[3]') obj_amount = Transaction.Amount('./td[5]', './td[4]') weboob-1.1/modules/colisprive/000077500000000000000000000000001265717027300164715ustar00rootroot00000000000000weboob-1.1/modules/colisprive/__init__.py000066400000000000000000000014441265717027300206050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ColispriveModule __all__ = ['ColispriveModule'] weboob-1.1/modules/colisprive/browser.py000066400000000000000000000021521265717027300205260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import TrackPage, ErrorPage class ColispriveBrowser(PagesBrowser): track_page = URL('https://www.colisprive.com/moncolis/pages/detailColis.aspx\?numColis=(?P.+)', TrackPage) error_page = URL('https://www.colisprive.fr', ErrorPage) def get_tracking_info(self, _id): return self.track_page.go(id=_id).get_info(_id) weboob-1.1/modules/colisprive/module.py000066400000000000000000000023531265717027300203330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.parcel import CapParcel from .browser import ColispriveBrowser __all__ = ['ColispriveModule'] class ColispriveModule(Module, CapParcel): NAME = 'colisprive' DESCRIPTION = u'Colisprive parcel tracking website' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' BROWSER = ColispriveBrowser def get_parcel_tracking(self, _id): return self.browser.get_tracking_info(_id) weboob-1.1/modules/colisprive/pages.py000066400000000000000000000053441265717027300201500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import date from weboob.browser.pages import HTMLPage from weboob.capabilities.parcel import Parcel, Event, ParcelNotFound def update_status(p, status): if p.status < status: p.status = status class TrackPage(HTMLPage): def get_info(self, _id): p = Parcel(_id) statustr = self.doc.xpath('//tr[@class="bandeauText"]')[0] status = statustr.xpath('td')[1].text p.info = status p.status = p.STATUS_UNKNOWN p.history = [] for i, tr in enumerate(self.doc.xpath('//table[@class="tableHistoriqueColis"]//tr[@class="bandeauText"]')): tds = tr.findall('td') try: if tds[0].attrib['class'] != "tdText": continue except: continue ev = Event(i) ev.location = None ev.activity = tds[1].text if u"Votre colis a été expédié par votre webmarchand" in ev.activity: update_status(p, p.STATUS_PLANNED) elif u"Votre colis est pris en charge par Colis Privé" in ev.activity: update_status(p, p.STATUS_IN_TRANSIT) elif u"Votre colis est arrivé sur notre agence régionale" in ev.activity: update_status(p, p.STATUS_IN_TRANSIT) elif u"Votre colis est en cours de livraison" in ev.activity: update_status(p, p.STATUS_IN_TRANSIT) elif u"Votre colis a été livré" in ev.activity: update_status(p, p.STATUS_ARRIVED) ev.date = date(*reversed([int(x) for x in tds[0].text.split('/')])) p.history.append(ev) try: datelivre = self.doc.xpath('//div[@class="NoInstNoRecla"]') clean = datelivre[0].text if "Votre colis a déja été livré" in clean: p.status = p.STATUS_ARRIVED except: pass return p class ErrorPage(HTMLPage): def get_info(self, _id): raise ParcelNotFound("No such ID: %s" % _id) weboob-1.1/modules/colissimo/000077500000000000000000000000001265717027300163135ustar00rootroot00000000000000weboob-1.1/modules/colissimo/__init__.py000066400000000000000000000014421265717027300204250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ColissimoModule __all__ = ['ColissimoModule'] weboob-1.1/modules/colissimo/browser.py000066400000000000000000000026331265717027300203540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.json import json from weboob.browser import DomainBrowser from weboob.exceptions import BrowserBanned from weboob.browser.profiles import Android __all__ = ['ColissimoBrowser'] class ColissimoBrowser(DomainBrowser): BASEURL = 'http://www.laposte.fr' PROFILE = Android() api_key = '6b252eb30d3afb15c47cf3fccee3dc17352dc2d6' def get_tracking_info(self, _id): json_data = self.open('/outilsuivi/web/suiviInterMetiers.php?key=%s&method=json&code=%s' % (self.api_key, _id)).text if json_data is None: raise BrowserBanned('You are banned of the colissimo API (too many requests from your IP)') return json.loads(json_data) weboob-1.1/modules/colissimo/favicon.png000066400000000000000000000016571265717027300204570ustar00rootroot00000000000000PNG  IHDR@@iqbKGDC pHYs  tIME %tEXtCommentCreated with GIMPWIDATxMSUu)0c ,$ !] ĄH"ΐ@\1b Yą ʅ 'WP1*c3tE_fھyc4}==1c1c1cy2O3FF/%)_y.Э+0 |T붸PDDd8v ;:@ݻ]  AfWgwkĹ;5x'RvǍ+s|k|#qgD oE)rP~T֎(P=l "CAHm7Ԛ9fmo%;sy+\ȃ a!AS.BzX_`rwyB`D Ljeߙ|ns x?}rm:"8ɉsWBǚ[][e9[cr:6Ey /}W7.ZwFj*a[JՓ!)TFKiGJuyuft1iDҜ^ ~oYk2fz pde}2H7 n 5@.ks:komDq AЂLvL@/}&__bUeyzs8Z+[i֎,9\TMDX-ԃKTr=ȱk oΣ,r=xnZ~ec1c1c1<):ȉqIENDB`weboob-1.1/modules/colissimo/module.py000066400000000000000000000041651265717027300201600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.parcel import CapParcel, Parcel, Event, ParcelNotFound from weboob.tools.backend import Module from .browser import ColissimoBrowser from datetime import date __all__ = ['ColissimoModule'] class ColissimoModule(Module, CapParcel): NAME = 'colissimo' DESCRIPTION = u'Colissimo parcel tracking website' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' BROWSER = ColissimoBrowser def get_parcel_tracking(self, _id): # 13 is the magic length of colissimo tracking ids if len(_id) != 13: raise ParcelNotFound(u"Colissimo ID's must have 13 print character") data = self.browser.get_tracking_info(_id) p = Parcel(_id) label = data['message'] if data['error']: raise ParcelNotFound(label + u" (id = %s@%s)" % (_id, self.name)) p.info = label # TODO, need to know the delivery message if u"remis au gardien ou" in label or u"Votre colis est livré" in label: p.status = p.STATUS_ARRIVED elif u"pas encore pris en charge par La Poste" in label: p.status = p.STATUS_PLANNED else: p.status = p.STATUS_IN_TRANSIT ev = Event(0) ev.activity = label ev.date = date(*reversed([int(x) for x in data['date'].split("/")])) p.history = [ev] return p weboob-1.1/modules/cragr/000077500000000000000000000000001265717027300154105ustar00rootroot00000000000000weboob-1.1/modules/cragr/__init__.py000066400000000000000000000014331265717027300175220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CragrModule __all__ = ['CragrModule'] weboob-1.1/modules/cragr/favicon.png000066400000000000000000000043411265717027300175450ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDוBM pHYs  tIME *9CaIDATxpT?/?MM7ԲZ+QM*BǢ#8eT?૩q:jb+e NձӾN鯴uXM$!?wv|M۽mNNɽs=|Ϲr!bhA'V7T@0&*:"a[mwNa#w*OD:V@u}\IQ@^G_VϺHWns|XAq' KJ<X/J3|ma9~ Xaz` T7^?~eqkj f*%*s0`c?D,Gg܎ 6`qX < 2R</ * OxxhJʳ [4r 52P_MCM#|  %.R?#v~iT<(<79 lt$UI@X脣%#`UҀkкx,5V$i!>-rCi. /@`NMCo`+ƖP)\-"˥bR .?)`ܴ y4e>/vU٧ ,x,qb/ Pi yB GC)w[=TNE[X7Cx,P:{ 3QReѷ_Spu wɱ;$N|ʅFn{1*4ۃ6Ewʙ w>`}hh xh}c=)`$ kX~*VȗF= zx4 .pJ MR/ʲRdiXZ*|#K4VlKTIi4lJrR ,þT-V$ h k\uXof@C$v8$B&$e hA,+K,S :$p羦HC ..@IF󚼄Ohhe HI9~ү59R? (i4'_Q>Z*Rq X}<I}4?R-bVة9筡rn9Պݝl1*6=oϑlUSڎi=?ln\Bv7^w@Pr$-s]ܦ 7]*P0}5 " SԉRx1K 2("V oS[|{P>;n'FL$(\NE%v&*_b!'tyZZ9r8e\JTlOH_Cy )JMþXɸQ@8Jݩ\a^Ov|#뜔GM~Cz dmuv&ľcm<T 9\+5* ǯL&X XU;qV7z'wgՔi&杞 bݟ!}dVM>s-iI$In `s<8u5UD@P%v\Y˒rMce!d8r߸VFIENDB`weboob-1.1/modules/cragr/mobile/000077500000000000000000000000001265717027300166575ustar00rootroot00000000000000weboob-1.1/modules/cragr/mobile/__init__.py000066400000000000000000000000001265717027300207560ustar00rootroot00000000000000weboob-1.1/modules/cragr/mobile/browser.py000066400000000000000000000257741265717027300207330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2013 Romain Bignon, Xavier Guerrin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.tools.date import LinearDateGuesser from weboob.capabilities.bank import Transfer, TransferError from .pages import LoginPage, AccountsList import mechanize from datetime import datetime import re __all__ = ['CragrMobile'] class CragrMobile(Browser): PROTOCOL = 'https' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] # a session id that is sometimes added, and should be ignored when matching pages SESSION_REGEXP = '(?:|%s[A-Z0-9]+)' % re.escape(r';jsessionid=') is_logging = False def __init__(self, website, *args, **kwargs): self.DOMAIN = website self.PAGES = {'https://[^/]+/': LoginPage, 'https://[^/]+/.*\.c.*': AccountsList, 'https://[^/]+/login/process%s' % self.SESSION_REGEXP: AccountsList, 'https://[^/]+/accounting/listAccounts': AccountsList, 'https://[^/]+/accounting/listOperations': AccountsList, 'https://[^/]+/accounting/showAccountDetail.+': AccountsList, 'https://[^/]+/accounting/showMoreAccountOperations.*': AccountsList, } Browser.__init__(self, *args, **kwargs) def viewing_html(self): """ As the fucking HTTP server returns a document in unknown mimetype 'application/vnd.wap.xhtml+xml' it is not recognized by mechanize. So this is a fucking hack. """ return True def is_logged(self): logged = self.page and self.page.is_logged() or self.is_logging self.logger.debug('logged: %s' % (logged and 'yes' or 'no')) return logged def login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) # Do we really need to login? if self.is_logged(): self.logger.debug('already logged in') return self.is_logging = True # Are we on the good page? if not self.is_on_page(LoginPage): self.logger.debug('going to login page') Browser.home(self) self.logger.debug('attempting to log in') self.page.login(self.username, self.password) self.is_logging = False if not self.is_logged(): raise BrowserIncorrectPassword() self.addheaders = [ ['User-agent', self.USER_AGENTS['desktop_firefox']] ] def get_accounts_list(self): self.logger.debug('accounts list required') self.home() return self.page.get_list() def home(self): """ Ensure we are both logged and on the accounts list. """ self.logger.debug('accounts list page required') if self.is_on_page(AccountsList) and self.page.is_accounts_list(): self.logger.debug('already on accounts list') return # simply go to http(s)://the.doma.in/ Browser.home(self) if self.is_on_page(LoginPage): if not self.is_logged(): # So, we are not logged on the login page -- what about logging ourselves? self.login() # we assume we are logged in # for some regions, we may stay on the login page once we're # logged in, without being redirected... if self.is_on_page(LoginPage): # ... so we have to move by ourselves self.move_to_accounts_list() def move_to_accounts_list(self): """ For regions where you can stay on http(s)://the.doma.in/ while you are logged in, move to the accounts list """ self.location('%s://%s/accounting/listAccounts' % (self.PROTOCOL, self.DOMAIN)) def get_account(self, id): assert isinstance(id, basestring) l = self.get_accounts_list() for a in l: if a.id == ('%s' % id): return a return None def get_history(self, account): # some accounts may exist without a link to any history page if account._link_id is None: return history_url = account._link_id operations_count = 0 # 1st, go on the account page self.logger.debug('going on: %s' % history_url) self.location('https://%s%s' % (self.DOMAIN, history_url)) if self.page is None: return # Some regions have a "Show more" (well, actually "Voir les 25 # suivants") link we have to use to get all the operations. # However, it does not show only the 25 next results, it *adds* them # to the current view. Therefore, we have to parse each new page using # an offset, in order to ignore all already-fetched operations. # This especially occurs on CA Centre. use_expand_url = bool(self.page.expand_history_page_url()) date_guesser = LinearDateGuesser() while True: # we skip "operations_count" operations on each page if we are in the case described above operations_offset = operations_count if use_expand_url else 0 for page_operation in self.page.get_history(date_guesser, operations_count, operations_offset): operations_count += 1 yield page_operation history_url = self.page.expand_history_page_url() if use_expand_url else self.page.next_page_url() if not history_url: break self.logger.debug('going on: %s' % history_url) self.location('https://%s%s' % (self.DOMAIN, history_url)) def dict_find_value(self, dictionary, value): """ Returns the first key pointing on the given value, or None if none is found. """ for k, v in dictionary.iteritems(): if v == value: return k return None def do_transfer(self, account, to, amount, reason=None): """ Transfer the given amount of money from an account to another, tagging the transfer with the given reason. """ # access the transfer page transfer_page_unreachable_message = u'Could not reach the transfer page.' self.home() if not self.page.is_accounts_list(): raise TransferError(transfer_page_unreachable_message) operations_url = self.page.operations_page_url() self.location('https://%s%s' % (self.DOMAIN, operations_url)) transfer_url = self.page.transfer_page_url() abs_transfer_url = 'https://%s%s' % (self.DOMAIN, transfer_url) self.location(abs_transfer_url) if not self.page.is_transfer_page(): raise TransferError(transfer_page_unreachable_message) source_accounts = self.page.get_transfer_source_accounts() target_accounts = self.page.get_transfer_target_accounts() # check that the given source account can be used if account not in source_accounts.values(): raise TransferError('You cannot use account %s as a source account.' % account) # check that the given source account can be used if to not in target_accounts.values(): raise TransferError('You cannot use account %s as a target account.' % to) # separate euros from cents amount_euros = int(amount) amount_cents = int((amount * 100) - (amount_euros * 100)) # let's circumvent https://github.com/jjlee/mechanize/issues/closed#issue/17 # using http://wwwsearch.sourceforge.net/mechanize/faq.html#usage adjusted_response = self.response().get_data().replace('
', '
') response = mechanize.make_response(adjusted_response, [('Content-Type', 'text/html')], abs_transfer_url, 200, 'OK') self.set_response(response) # fill the form self.select_form(nr=0) self['numCompteEmetteur'] = ['%s' % self.dict_find_value(source_accounts, account)] self['numCompteBeneficiaire'] = ['%s' % self.dict_find_value(target_accounts, to)] self['montantPartieEntiere'] = '%s' % amount_euros self['montantPartieDecimale'] = '%02d' % amount_cents if reason is not None: self['libelle'] = reason self.submit() # look for known errors content = unicode(self.response().get_data(), 'utf-8') insufficient_amount_message = u'Montant insuffisant.' maximum_allowed_balance_message = u'Solde maximum autorisé dépassé.' if content.find(insufficient_amount_message) != -1: raise TransferError('The amount you tried to transfer is too low.') if content.find(maximum_allowed_balance_message) != -1: raise TransferError('The maximum allowed balance for the target account has been / would be reached.') # look for the known "all right" message ready_for_transfer_message = u'Vous allez effectuer un virement' if not content.find(ready_for_transfer_message): raise TransferError('The expected message "%s" was not found.' % ready_for_transfer_message) # submit the last form self.select_form(nr=0) submit_date = datetime.now() self.submit() # look for the known "everything went well" message content = unicode(self.response().get_data(), 'utf-8') transfer_ok_message = u'Vous venez d\'effectuer un virement du compte' if not content.find(transfer_ok_message): raise TransferError('The expected message "%s" was not found.' % transfer_ok_message) # We now have to return a Transfer object # the final page does not provide any transfer id, so we'll use the submit date transfer = Transfer(submit_date.strftime('%Y%m%d%H%M%S')) transfer.amount = amount transfer.origin = account transfer.recipient = to transfer.date = submit_date return transfer #def get_coming_operations(self, account): # if not self.is_on_page(AccountComing) or self.page.account.id != account.id: # self.location('/NS_AVEEC?ch4=%s' % account._link_id) # return self.page.get_operations() weboob-1.1/modules/cragr/mobile/pages/000077500000000000000000000000001265717027300177565ustar00rootroot00000000000000weboob-1.1/modules/cragr/mobile/pages/__init__.py000066400000000000000000000015161265717027300220720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .accounts_list import AccountsList from .login import LoginPage __all__ = ['AccountsList', 'LoginPage'] weboob-1.1/modules/cragr/mobile/pages/accounts_list.py000066400000000000000000000410711265717027300232050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from datetime import date from weboob.capabilities.bank import Account from .base import CragrBasePage from .tokenextractor import TokenExtractor from weboob.tools.capabilities.bank.transactions import FrenchTransaction class Transaction(FrenchTransaction): PATTERNS = [ (re.compile('^(Vp|Vt|Vrt|Virt|Vir(ement)?)\s*(?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?P(Tip|Plt|Prlv|PRELEVT|Prelevement)\s*.*)', re.IGNORECASE), FrenchTransaction.TYPE_ORDER), (re.compile('^Cheque\s*(?P(No)?.*)', re.IGNORECASE), FrenchTransaction.TYPE_CHECK), (re.compile('^(?PRem\s*Chq\s*.*)', re.IGNORECASE), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^Ret(rait)?\s*Dab\s*((?P
\d{2})(?P\d{2})(?P\d{2}))?\s*(?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^Paiement\s*Carte\s*(?P
\d{2})(?P\d{2})(?P\d{2})\s*(?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_CARD), (re.compile('^(?P.*CAPITAL.*ECHEANCE.*)', re.IGNORECASE), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile('^(\*\*)?(?P(frais|cotis(ation)?)\s*.*)', re.IGNORECASE), FrenchTransaction.TYPE_BANK), (re.compile('^(?PInterets\s*.*)', re.IGNORECASE), FrenchTransaction.TYPE_BANK), (re.compile('^(?PPrelev\.\s*(C\.r\.d\.s\.|R\.s\.a\.|C\.a\.p\.s\.|C\.s\.g|P\.s\.))', re.IGNORECASE), FrenchTransaction.TYPE_BANK), (re.compile('^(ACH.)?CARTE (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_CARD), (re.compile('^RET.CARTE (?P.*)', re.IGNORECASE), FrenchTransaction.TYPE_WITHDRAWAL), ] class AccountsList(CragrBasePage): """ Unlike most pages used with the Browser class, this class represents several pages, notably accounts list, history and transfer. This is due to the Credit Agricole not having a clear pattern to identify a page based on its URL. """ def is_accounts_list(self): """ Returns True if the current page appears to be the page dedicated to list the accounts. """ # we check for the presence of a "mes comptes titres" link_id link = self.document.xpath('/html/body//a[contains(text(), "comptes titres")]') return bool(link) def is_account_page(self): """ Returns True if the current page appears to be a page dedicated to list the history of a specific account. """ # tested on CA Lorraine, Paris, Toulouse title_spans = self.document.xpath('/html/body//div[@class="dv"]/span') for title_span in title_spans: title_text = title_span.text_content().strip().replace("\n", '') if (re.match('.*Compte.*n.*[0-9]+', title_text, flags=re.IGNORECASE)): return True return False def is_transfer_page(self): """ Returns True if the current page appears to be the page dedicated to order transfers between accounts. """ source_account_select_field = self.document.xpath('/html/body//form//select[@name="numCompteEmetteur"]') target_account_select_field = self.document.xpath('/html/body//form//select[@name="numCompteBeneficiaire"]') return bool(source_account_select_field) and bool(target_account_select_field) def get_list(self): """ Returns the list of available bank accounts """ for div in self.document.getiterator('div'): if div.attrib.get('class', '') in ('dv', 'headline') and div.getchildren()[0].tag in ('a', 'br'): self.logger.debug("Analyzing div %s" % div) # Step 1: extract text tokens tokens = [] required_tokens = {} optional_tokens = {} token_extractor = TokenExtractor() for token in token_extractor.extract_tokens(div): self.logger.debug('Extracted text token: "%s"' % token) tokens.append(token) # Step 2: analyse tokens for token in tokens: if self.look_like_account_number(token): required_tokens['account_number'] = token elif self.look_like_amount(token): required_tokens['account_amount'] = token elif self.look_like_account_name(token): required_tokens['account_name'] = token elif self.look_like_account_owner(token): if 'account_owner' in optional_tokens and 'account_name' not in required_tokens: required_tokens['account_name'] = optional_tokens['account_owner'] optional_tokens['account_owner'] = token # Step 3: create account objects if len(required_tokens) >= 3: account = Account() account.label = required_tokens['account_name'] account.id = required_tokens['account_number'] account.balance = FrenchTransaction.clean_amount(required_tokens['account_amount']) account.currency = account.get_currency(required_tokens['account_amount']) # we found almost all required information to create an account object self.logger.debug('Found account %s with number %s and balance = %.2f' % (account.label, account.id, account.balance)) # we may have found the owner name too if optional_tokens.get('account_owner') is not None: # well, we could add it to the label, but is this really required? self.logger.debug(' the owner appears to be %s' % optional_tokens['account_owner']) # we simply lack the link to the account history... which remains optional first_link = div.find('a') if first_link is not None: account._link_id = first_link.get('href') self.logger.debug(' the history link appears to be %s' % account._link_id) else: account._link_id = None yield account def get_history(self, date_guesser, start_index=0, start_offset=0): """ Returns the history of a specific account. Note that this function expects the current page to be the one dedicated to this history. start_index is the id used for the first created operation. start_offset allows ignoring the `n' first Transactions on the page. """ # tested on CA Lorraine, Paris, Toulouse # avoir parsing the page as an account-dedicated page if it is not the case if not self.is_account_page(): return # Step 1: extract text tokens tokens = [] token_extractor = TokenExtractor() for div in self.document.getiterator('div'): if div.attrib.get('class', '') in ('dv'): self.logger.debug("Analyzing div %s" % div) for token in token_extractor.extract_tokens(div): self.logger.debug('Extracted text token: "%s"' % token) tokens.append(token) # Step 2: convert tokens into operations # Notes: # * the code below expects pieces of information to be in the date-label-amount order; # could we achieve a heuristic smart enough to guess this order? # * unlike the former code, we parse every operation operations = [] current_operation = {} for token in tokens: self.logger.debug('Analyzing token: "%s"' % token) date_analysis = self.look_like_date_only(token) if date_analysis: current_operation = {} current_operation['date'] = date_analysis.groups()[0] else: date_desc_analysis = self.look_like_date_and_description(token) if date_desc_analysis: current_operation = {} current_operation['date'] = date_desc_analysis.groups()[0] current_operation['label'] = date_desc_analysis.groups()[1] elif self.look_like_amount(token): # we consider the amount is the last information we get for an operation current_operation['amount'] = FrenchTransaction.clean_amount(token) if current_operation.get('label') is not None and current_operation.get('date') is not None: self.logger.debug('Parsed operation: %s: %s: %s' % (current_operation['date'], current_operation['label'], current_operation['amount'])) operations.append(current_operation) current_operation = {} else: if current_operation.get('label') is not None: current_operation['label'] = u'%s %s' % (current_operation['label'], token) else: current_operation['label'] = token # Step 3: yield adequate transactions index = start_index for op in operations[start_offset:]: self.logger.debug('will yield the following transaction with index %d: %s: %s: %s' % (index, op['date'], op['label'], op['amount'])) transaction = Transaction(index) index += 1 transaction.amount = op['amount'] transaction.parse(self.date_from_string(op['date'], date_guesser), re.sub('\s+', ' ', op['label'])) yield transaction def get_transfer_accounts(self, select_name): """ Returns the accounts proposed for a transfer in a select field. This method assumes the current page is the one dedicated to transfers. select_name is the name of the select field to analyze """ if not self.is_transfer_page(): return False source_accounts = {} source_account_options = self.document.xpath('/html/body//form//select[@name="%s"]/option' % select_name) for option in source_account_options: source_account_value = option.get('value', -1) if (source_account_value != -1): matches = re.findall('^[A-Z0-9]+.*([0-9]{11}).*$', self.extract_text(option)) if matches: source_accounts[source_account_value] = matches[0] return source_accounts def get_transfer_source_accounts(self): return self.get_transfer_accounts('numCompteEmetteur') def get_transfer_target_accounts(self): return self.get_transfer_accounts('numCompteBeneficiaire') def expand_history_page_url(self): """ When on a page dedicated to list the history of a specific account (see is_account_page), returns the link to expand the history with 25 more results, or False if the link is not present. """ # tested on CA centre france a = self.document.xpath('/html/body//div[@class="headline"]//a[contains(text(), "Voir les 25 suivants")]') if not a: return False else: return a[0].get('href', '') def next_page_url(self): """ When on a page dedicated to list the history of a specific account (see is_account_page), returns the link to the next page, or False if the link is not present. """ # tested on CA Lorraine, Paris, Toulouse a = self.document.xpath('/html/body//div[@class="navlink"]//a[contains(text(), "Suite")]') if not a: return False else: return a[0].get('href', '') def operations_page_url(self): """ Returns the link to the "Opérations" page. This function assumes the current page is the accounts list (see is_accounts_list) """ link = self.document.xpath(u'/html/body//a[contains(text(), "Opérations")]') return link[0].get('href') def transfer_page_url(self): """ Returns the link to the "Virements" page. This function assumes the current page is the operations list (see operations_page_url) """ link = self.document.xpath('/html/body//a[@accesskey=1]/@href') return link[0] def extract_text(self, xml_elmt): """ Given an XML element, returns its inner text in a reasonably readable way """ data = u'' for text in xml_elmt.itertext(): data = data + u'%s ' % text data = re.sub(' +', ' ', data.replace("\n", ' ').strip()) return data def fallback_date(self): """ Returns a fallback, default date. """ return date(date.today().year, 1, 1) def date_from_string(self, string, date_guesser): """ Builds a date object from a 'DD/MM' string """ matches = re.search('\s*([012]?[0-9]|3[01])\s*/\s*(0?[1-9]|1[012])\s*$', string) if matches is None: return self.fallback_date() return date_guesser.guess_date(int(matches.group(1)), int(matches.group(2))) def look_like_account_owner(self, string): """ Returns a date object built from a given day/month pair. """ result = re.match('^\s*(M\.|Mr|Mme|Mlle|Mle|Monsieur|Madame|Mademoiselle)', string, re.IGNORECASE) self.logger.debug('Does "%s" look like an account owner? %s', string, ('yes' if result else 'no')) return result def look_like_account_name(self, string): """ Returns True of False depending whether string looks like an account name. """ result = (len(string) >= 3 and not self.look_like_account_owner(string)) self.logger.debug('Does "%s" look like an account name? %s', string, ('yes' if result else 'no')) return result def look_like_account_number(self, string): """ Returns either False or a SRE_Match object depending whether string looks like an account number. """ # An account is a 11 digits number (no more, no less) result = re.match('[^\d]*\d{11}[^\d]*', string) self.logger.debug('Does "%s" look like an account number? %s', string, ('yes' if result else 'no')) return result def look_like_amount(self, string): """ Returns either False or a SRE_Match object depending whether string looks like an amount. """ # It seems the Credit Agricole always mentions amounts using two decimals result = re.match('-?[\d ]+[\.,]\d{2}', string) self.logger.debug('Does "%s" look like an amount? %s', string, ('yes' if result else 'no')) return result def look_like_date_only(self, string): """ Returns either False or a SRE_Match object depending whether string looks like an isolated date. """ result = re.search('^\s*((?:[012][0-9]|3[01])/(?:0[1-9]|1[012]))\s*$', string) self.logger.debug('Does "%s" look like a date (and only a date)? %s', string, ('yes' if result else 'no')) return result def look_like_date_and_description(self, string): """ Returns either False or a SRE_Match object depending on whether string looks like a date+description pair. """ result = re.search('^\s*((?:[012][0-9]|3[01])/(?:0[1-9]|1[012]))\s+(.+)\s*$', string) self.logger.debug('Does "%s" look like a date+description pair? %s', string, ('yes' if result else 'no')) return result weboob-1.1/modules/cragr/mobile/pages/base.py000066400000000000000000000035461265717027300212520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Page from weboob.deprecated.browser import BrowserUnavailable class CragrBasePage(Page): def on_loaded(self): # Check for an error for div in self.document.getiterator('div'): if div.attrib.get('class', '') == 'dv' and div.getchildren()[0].tag in ('img') and div.getchildren()[0].attrib.get('alt', '') == 'Attention': # Try to find a detailed error message if div.getchildren()[1].tag == 'span': raise BrowserUnavailable(div.find('span').find('b').text) elif div.getchildren()[1].tag == 'b': # I haven't encountered this variation in the wild, # but I wouldn't be surprised if it existed # given the similar differences between regions. raise BrowserUnavailable(div.find('b').find('span').text) raise BrowserUnavailable() def is_logged(self): return not self.document.xpath('/html/body//form//input[@name = "code"]') and \ not self.document.xpath('/html/body//form//input[@name = "userPassword"]') weboob-1.1/modules/cragr/mobile/pages/login.py000066400000000000000000000036661265717027300214530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.mech import ClientForm ControlNotFoundError = ClientForm.ControlNotFoundError from .base import CragrBasePage class LoginPage(CragrBasePage): def login(self, login, password): self.browser.select_form(nr=0) self.browser.set_all_readonly(False) try: self.browser['numero'] = login self.browser['code'] = password except ControlNotFoundError: try: self.browser['userLogin'] = login self.browser['userPassword'] = password except ControlNotFoundError: self.browser.controls.append(ClientForm.TextControl('text', 'numero', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', 'code', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', 'userLogin', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', 'userPassword', {'value': ''})) self.browser['numero'] = login self.browser['code'] = password self.browser['userLogin'] = login self.browser['userPassword'] = password self.browser.submit() weboob-1.1/modules/cragr/mobile/pages/tokenextractor.py000066400000000000000000000040371265717027300234100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . class TokenExtractor(object): """ Extracts texts token from an HTML document """ def __init__(self): self.iterated_elements = [] def clear(self): """ Reset any content stored within a TokenExtractor object. Useful to start a new parsing without creating a new instance. """ self.iterated_elements = [] def element_iterated_already(self, html_element): if html_element in self.iterated_elements: return True for ancestor in html_element.iterancestors(): if ancestor in self.iterated_elements: return True return False def extract_tokens(self, html_element): if self.element_iterated_already(html_element): return self.iterated_elements.append(html_element) for text in html_element.itertext(): text = text.replace(u'\xa0', ' ') text = text.replace("\n", ' ') for token in self.split_text_into_smaller_tokens(text): if self.token_looks_relevant(token): yield token.strip() @staticmethod def split_text_into_smaller_tokens(text): for subtext1 in text.split('\t'): yield subtext1 @staticmethod def token_looks_relevant(token): return len(token.strip()) > 1 weboob-1.1/modules/cragr/module.py000066400000000000000000000113511265717027300172500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Xavier Guerrin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import AccountNotFound, CapBank from weboob.tools.backend import Module, BackendConfig from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import ValueBackendPassword, Value from .web.browser import Cragr from .mobile.browser import CragrMobile __all__ = ['CragrModule'] class CragrModule(Module, CapBank): NAME = 'cragr' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Crédit Agricole' LICENSE = 'AGPLv3+' website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ 'm.ca-alpesprovence.fr': u'Alpes Provence', 'm.ca-alsace-vosges.fr': u'Alsace-Vosges', 'm.ca-anjou-maine.fr': u'Anjou Maine', 'm.ca-aquitaine.fr': u'Aquitaine', 'm.ca-atlantique-vendee.fr': u'Atlantique Vendée', 'm.ca-briepicardie.fr': u'Brie Picardie', 'm.ca-cb.fr': u'Champagne Bourgogne', 'm.ca-centrefrance.fr': u'Centre France', 'm.ca-centreloire.fr': u'Centre Loire', 'm.ca-centreouest.fr': u'Centre Ouest', 'm.ca-centrest.fr': u'Centre Est', 'm.ca-charente-perigord.fr': u'Charente Périgord', 'm.ca-cmds.fr': u'Charente-Maritime Deux-Sèvres', 'm.ca-corse.fr': u'Corse', 'm.ca-cotesdarmor.fr': u'Côtes d\'Armor', 'm.ca-des-savoie.fr': u'Des Savoie', 'm.ca-finistere.fr': u'Finistere', 'm.ca-franchecomte.fr': u'Franche-Comté', 'm.ca-guadeloupe.fr': u'Guadeloupe', 'm.ca-illeetvilaine.fr': u'Ille-et-Vilaine', 'm.ca-languedoc.fr': u'Languedoc', 'm.ca-loirehauteloire.fr': u'Loire Haute Loire', 'm.ca-lorraine.fr': u'Lorraine', 'm.ca-martinique.fr': u'Martinique Guyane', 'm.ca-morbihan.fr': u'Morbihan', 'm.ca-nmp.fr': u'Nord Midi-Pyrénées', 'm.ca-nord-est.fr': u'Nord Est', 'm.ca-norddefrance.fr': u'Nord de France', 'm.ca-normandie-seine.fr': u'Normandie Seine', 'm.ca-normandie.fr': u'Normandie', 'm.ca-paris.fr': u'Ile-de-France', 'm.ca-pca.fr': u'Provence Côte d\'Azur', 'm.ca-reunion.fr': u'Réunion', 'm.ca-sudmed.fr': u'Sud Méditerranée', 'm.ca-sudrhonealpes.fr': u'Sud Rhône Alpes', 'm.ca-toulouse31.fr': u'Toulouse 31', # m.ca-toulousain.fr redirects here 'm.ca-tourainepoitou.fr': u'Tourraine Poitou', 'm.ca-valdefrance.fr': u'Val de France', 'm.lefil.com': u'Pyrénées Gascogne', }.iteritems())]) CONFIG = BackendConfig(Value('website', label=u'Région', choices=website_choices), ValueBackendPassword('login', label=u'N° de compte', masked=False), ValueBackendPassword('password', label=u'Code personnel', regexp=r'\d{6}')) BROWSER = Cragr def create_default_browser(self): try: return self.create_browser(self.config['website'].get(), self.config['login'].get(), self.config['password'].get()) except Cragr.WebsiteNotSupported: self.logger.debug('falling-back on mobile version') self.BROWSER = CragrMobile return self.create_browser(self.config['website'].get(), self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): return self.browser.get_history(account) def iter_investment(self, account): with self.browser: for inv in self.browser.iter_investment(account): yield inv def transfer(self, account, to, amount, reason=None): return self.browser.do_transfer(account, to, amount, reason) weboob-1.1/modules/cragr/test.py000066400000000000000000000017441265717027300167470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CrAgrTest(BackendTest): MODULE = 'cragr' def test_cragr(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/cragr/web/000077500000000000000000000000001265717027300161655ustar00rootroot00000000000000weboob-1.1/modules/cragr/web/__init__.py000066400000000000000000000000001265717027300202640ustar00rootroot00000000000000weboob-1.1/modules/cragr/web/browser.py000066400000000000000000000362121265717027300202260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import urllib from urlparse import urlparse from weboob.capabilities.bank import Account from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.tools.date import LinearDateGuesser from .pages import HomePage, LoginPage, LoginErrorPage, AccountsPage, \ SavingsPage, TransactionsPage, UselessPage, CardsPage, \ LifeInsurancePage, MarketPage, LoansPage, PerimeterPage, \ ChgPerimeterPage __all__ = ['Cragr'] class Cragr(Browser): PROTOCOL = 'https' ENCODING = 'ISO-8859-1' PAGES = {'https?://[^/]+/': HomePage, 'https?://[^/]+/particuliers.html': HomePage, 'https?://[^/]+/stb/entreeBam': LoginPage, 'https?://[^/]+/stb/entreeBam\?.*typeAuthentification=CLIC_ALLER.*': LoginPage, 'https?://[^/]+/stb/entreeBam\?.*pagePremVisite.*': UselessPage, 'https?://[^/]+/stb/entreeBam\?.*Interstitielle.*': UselessPage, 'https?://[^/]+/stb/entreeBam\?.*act=Tdbgestion': UselessPage, 'https?://[^/]+/stb/entreeBam\?.*act=Synthcomptes': AccountsPage, 'https?://[^/]+/stb/entreeBam\?.*act=Synthcredits': LoansPage, 'https?://[^/]+/stb/entreeBam\?.*act=Synthepargnes': SavingsPage, 'https?://[^/]+/stb/.*act=Releves.*': TransactionsPage, 'https?://[^/]+/stb/collecteNI\?.*sessionAPP=Releves.*': TransactionsPage, 'https?://[^/]+/stb/.*/erreur/.*': LoginErrorPage, 'https?://[^/]+/stb/entreeBam\?.*act=Messagesprioritaires': UselessPage, 'https?://[^/]+/stb/collecteNI\?.*fwkaction=Cartes.*': CardsPage, 'https?://[^/]+/stb/collecteNI\?.*fwkaction=Detail.*sessionAPP=Cartes.*': CardsPage, 'https?://www.cabourse.credit-agricole.fr/netfinca-titres/servlet/com.netfinca.frontcr.account.WalletVal\?nump=.*': MarketPage, 'https://assurance-personnes.credit-agricole.fr:443/filiale/entreeBam\?identifiantBAM=.*': LifeInsurancePage, 'https?://[^/]+/stb/entreeBam\?.*act=Perimetre': PerimeterPage, 'https?://[^/]+/stb/entreeBam\?.*act=ChgPerim.*': ChgPerimeterPage, } new_login_domain = ['m.ca-normandie.fr'] new_login = False class WebsiteNotSupported(Exception): pass def __init__(self, website, *args, **kwargs): if website in self.new_login_domain: self.DOMAIN = re.sub('^m\.', 'w2.', website) self.new_login = True else: self.DOMAIN = re.sub('^m\.', 'www.', website) self.accounts_url = None self.savings_url = None self._sag = None # updated while browsing self.code_caisse = None # constant for a given website self.perimeters = None self.current_perimeter = None self.broken_perimeters = list() Browser.__init__(self, *args, **kwargs) def home(self): self.login() def is_logged(self): return self.page is not None and not self.is_on_page(HomePage) and self.page.get_error() is None def login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) # Do we really need to login? if self.is_logged(): self.logger.debug('already logged in') return self._sag = None if not self.is_on_page(HomePage): self.location(self.absurl('/'), no_login=True) if self.new_login: self.page.go_to_auth() else: # On the homepage, we get the URL of the auth service. url = self.page.get_post_url() if url is None: raise self.WebsiteNotSupported() # First, post account number to get the password prompt. data = {'CCPTE': self.username.encode(self.ENCODING), 'canal': 'WEB', 'hauteur_ecran': 768, 'largeur_ecran': 1024, 'liberror': '', 'matrice': 'true', 'origine': 'vitrine', 'situationTravail': 'BANCAIRE', 'typeAuthentification': 'CLIC_ALLER', 'urlOrigine': self.page.url, 'vitrine': 0, } self.location(url, urllib.urlencode(data)) assert self.is_on_page(LoginPage) # Then, post the password. self.page.login(self.username, self.password) if self.new_login: url = self.page.get_accounts_url() else: # The result of POST is the destination URL. url = self.page.get_result_url() if not url.startswith('http'): raise BrowserIncorrectPassword(url) self.location(url) if self.is_on_page(LoginErrorPage): raise BrowserIncorrectPassword() if self.page is None: raise self.WebsiteNotSupported() if not self.is_on_page(AccountsPage): # Sometimes the home page is Releves. new_url = re.sub('act=([^&=]+)', 'act=Synthcomptes', self.page.url, 1) self.location(new_url) if not self.is_on_page(AccountsPage): raise self.WebsiteNotSupported() if self.code_caisse is None: scripts = self.page.document.xpath('//script[contains(., " codeCaisse")]') self.code_caisse = re.search('var +codeCaisse *= *"([0-9]+)"', scripts[0].text).group(1) # Store the current url to go back when requesting accounts list. self.accounts_url = re.sub('sessionSAG=[^&]+', 'sessionSAG={0}', self.page.url) # we can deduce the URL to "savings" and "loan" accounts from the regular accounts one self.savings_url = re.sub('act=([^&=]+)', 'act=Synthepargnes', self.accounts_url, 1) self.loans_url = re.sub('act=([^&=]+)', 'act=Synthcredits', self.accounts_url, 1) if self.page.check_perimeters() and not self.broken_perimeters: self.perimeter_url = re.sub('act=([^&=]+)', 'act=Perimetre', self.accounts_url, 1) self.chg_perimeter_url = '%s%s' % (re.sub('act=([^&=]+)', 'act=ChgPerim', self.accounts_url, 1), '&typeaction=ChgPerim') self.location(self.perimeter_url.format(self.sag)) self.page.check_multiple_perimeters() def go_perimeter(self, perimeter): # If this fails, there is no point in retrying with same cookies. self.location(self.perimeter_url.format(self.sag), no_login=True) if self.page.get_error() is not None: self.login() self.location(self.perimeter_url.format(self.sag)) if len(self.perimeters) > 2: perimeter_link = self.page.get_perimeter_link(perimeter) if perimeter_link: self.location(perimeter_link) self.location(self.chg_perimeter_url.format(self.sag), no_login=True) if self.page.get_error() is not None: self.broken_perimeters.append(perimeter) def get_accounts_list(self, no_move=False): l = list() if self.perimeters and not no_move: for perimeter in [p for p in self.perimeters if p not in self.broken_perimeters]: if self.current_perimeter != perimeter: self.go_perimeter(perimeter) for account in self.get_list(): if not account in l: l.append(account) else: l = self.get_list() return l def get_list(self): accounts_list = [] # regular accounts if not self.is_on_page(AccountsPage): self.location(self.accounts_url.format(self.sag)) accounts_list.extend(self.page.get_list()) # credit cards for cards_page in self.page.cards_pages(): self.location(cards_page) assert self.is_on_page(CardsPage) accounts_list.extend(self.page.get_list()) # loan accounts self.location(self.loans_url.format(self.sag)) if self.is_on_page(LoansPage): for account in self.page.get_list(): if account not in accounts_list: accounts_list.append(account) # savings accounts self.location(self.savings_url.format(self.sag)) if self.is_on_page(SavingsPage): for account in self.page.get_list(): if account not in accounts_list: accounts_list.append(account) return accounts_list def get_account(self, id, no_move=False): assert isinstance(id, basestring) l = self.get_accounts_list(no_move) for a in l: if a.id == ('%s' % id): return a return None def get_history(self, account): if account.type in (Account.TYPE_MARKET, Account.TYPE_LIFE_INSURANCE): self.logger.warning('This account is not supported') return # some accounts may exist without a link to any history page if account._link is None: return did_move = False if account._perimeter != self.current_perimeter: self.go_perimeter(account._perimeter) did_move = True # card accounts need to get an updated link if account.type == Account.TYPE_CARD: account = self.get_account(account.id, no_move=True) date_guesser = LinearDateGuesser() self.location(account._link.format(self.sag)) if self.is_on_page(CardsPage): for tr in self.page.get_history(date_guesser): yield tr else: url = self.page.get_order_by_date_url() while url: self.location(url) assert self.is_on_page(TransactionsPage) for tr in self.page.get_history(date_guesser): yield tr url = self.page.get_next_url() # Ugly hack needed for for following card accounts history if did_move: self.get_accounts_list() def iter_investment(self, account): if not account._link or account.type not in (Account.TYPE_MARKET, Account.TYPE_LIFE_INSURANCE): self.logger.warning('This account is not supported') return if account._perimeter != self.current_perimeter: self.go_perimeter(account._perimeter) if account.type == Account.TYPE_MARKET: new_location = self.moveto_market_website(account) self.location(new_location) elif account.type == Account.TYPE_LIFE_INSURANCE: new_location = self.moveto_insurance_website(account) self.location(new_location, urllib.urlencode({})) for inv in self.page.iter_investment(): yield inv if account.type == Account.TYPE_MARKET: self.quit_market_website() elif account.type == Account.TYPE_LIFE_INSURANCE: self.quit_insurance_website() def moveto_market_website(self, account): response = self.openurl(account._link % self.sag).read() self._sag = None # https://www.cabourse.credit-agricole.fr/netfinca-titres/servlet/com.netfinca.frontcr.navigation.AccueilBridge?TOKEN_ID= m = re.search('document.location="([^"]+)"', response) if m: url = m.group(1) else: self.logger.warn('Unable to go to market website') raise self.WebsiteNotSupported() self.openurl(url) parsed = urlparse(url) url = '%s://%s/netfinca-titres/servlet/com.netfinca.frontcr.account.WalletVal?nump=%s:%s' return url % (parsed.scheme, parsed.netloc, account.id, self.code_caisse) def quit_market_website(self): parsed = urlparse(self.geturl()) exit_url = '%s://%s/netfinca-titres/servlet/com.netfinca.frontcr.login.ContextTransferDisconnect' % (parsed.scheme, parsed.netloc) doc = self.get_document(self.openurl(exit_url), encoding='utf-8') form = doc.find('//form[@name="formulaire"]') # 'act' parameter allows page recognition, this parameter is ignored by # server self.location(form.attrib['action'] + '&act=Synthepargnes') self.update_sag() def moveto_insurance_website(self, account): doc = self.get_document(self.openurl(account._link % self.sag), encoding='utf-8') self._sag = None # POST to https://assurance-personnes.credit-agricole.fr/filiale/ServletReroutageCookie form = doc.find('//form[@name="formulaire"]') data = { 'page': form.inputs['page'].attrib['value'], 'cMaxAge': '-1', } script = doc.find('//script').text for value in ('cMaxAge', 'cName', 'cValue'): m = re.search('%s.value *= *"([^"]+)"' % value, script) if m: data[value] = m.group(1) else: raise self.WebsiteNotSupported() doc = self.get_document(self.openurl(form.attrib['action'], urllib.urlencode(data)), encoding='utf-8') # POST to https://assurance-personnes.credit-agricole.fr:443/filiale/entreeBam?identifiantBAM=xxx form = doc.find('//form[@name="formulaire"]') return form.attrib['action'] def quit_insurance_website(self): exit_url = 'https://assurance-personnes.credit-agricole.fr/filiale/entreeBam?actCrt=Synthcomptes&sessionSAG=%s&stbpg=pagePU&act=&typeaction=reroutage_retour&site=BAMG2&stbzn=bnc' doc = self.get_document(self.openurl(exit_url % self.sag), encoding='utf-8') form = doc.find('//form[@name="formulaire"]') # 'act' parameter allows page recognition, this parameter is ignored by # server self.location(form.attrib['action'] + '&act=Synthepargnes') self.update_sag() @property def sag(self): if not self._sag: self.update_sag() return self._sag def update_sag(self): if not self.is_logged(): self.login() script = self.page.document.xpath("//script[contains(.,'idSessionSag =')]") self._sag = re.search('idSessionSag = "([^"]+)";', script[0].text).group(1) weboob-1.1/modules/cragr/web/pages.py000066400000000000000000000552041265717027300176440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2015 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal import re from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account, Investment from weboob.deprecated.browser import Page, BrokenPageError, BrowserIncorrectPassword from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction from weboob.tools.date import parse_french_date class BasePage(Page): def get_error(self): try: error = self.document.xpath('//h1[@class="h1-erreur"]')[0] self.logger.error('Error detected: %s', error.text_content().strip()) return error except IndexError: return None class HomePage(BasePage): def get_post_url(self): for script in self.document.xpath('//script'): text = script.text if text is None: continue m = re.search(r'var chemin = "([^"]+)"', text, re.MULTILINE) if m: return m.group(1) return None def go_to_auth(self): self.browser.select_form('bamaccess') self.browser.submit(no_login=True) class LoginPage(BasePage): def on_loaded(self): if self.document.xpath('//font[@class="taille2"]'): raise BrowserIncorrectPassword() def login(self, username, password): imgmap = {} for td in self.document.xpath('//table[@id="pave-saisie-code"]/tr/td'): a = td.find('a') num = a.text.strip() if num.isdigit(): imgmap[num] = int(a.attrib['tabindex']) - 1 self.browser.select_form(name='formulaire') self.browser.set_all_readonly(False) if self.browser.new_login: self.browser['CCPTE'] = username self.browser['CCCRYC'] = ','.join(['%02d' % imgmap[c] for c in password]) self.browser['CCCRYC2'] = '0' * len(password) self.browser.submit(nologin=True) def get_result_url(self): return self.parser.tocleanstring(self.document.getroot()) def get_accounts_url(self): for script in self.document.xpath('//script'): text = script.text if text is None: continue m = re.search(r'idSessionSag = "([^"]+)"', script.text) if m: idSessionSag = m.group(1) return '%s%s%s%s' % (self.url, '?sessionSAG=', idSessionSag, '&stbpg=pagePU&actCrt=Synthcomptes&stbzn=btn&act=Synthcomptes') class UselessPage(BasePage): pass class LoginErrorPage(BasePage): pass class _AccountsPage(BasePage): COL_LABEL = 0 COL_ID = 2 COL_VALUE = 4 COL_CURRENCY = 5 NB_COLS = 7 TYPES = {u'CCHQ': Account.TYPE_CHECKING, # par u'CCOU': Account.TYPE_CHECKING, # pro u'DAV PEA': Account.TYPE_CHECKING, u'LIV A': Account.TYPE_SAVINGS, u'LDD': Account.TYPE_SAVINGS, u'PEL': Account.TYPE_SAVINGS, u'CEL': Account.TYPE_SAVINGS, u'CODEBIS': Account.TYPE_SAVINGS, u'LJMO': Account.TYPE_SAVINGS, u'CSL': Account.TYPE_SAVINGS, u'LEP': Account.TYPE_SAVINGS, u'TIWI': Account.TYPE_SAVINGS, u'CSL LSO': Account.TYPE_SAVINGS, u'CSL CSP': Account.TYPE_SAVINGS, u'PRET PERSO': Account.TYPE_LOAN, u'P. HABITAT': Account.TYPE_LOAN, u'PRET 0%': Account.TYPE_LOAN, u'INV PRO': Account.TYPE_LOAN, u'PEA': Account.TYPE_MARKET, u'CPS': Account.TYPE_MARKET, u'TITR': Account.TYPE_MARKET, u'TITR CTD': Account.TYPE_MARKET, u'réserves de crédit': Account.TYPE_CHECKING, u'prêts personnels': Account.TYPE_LOAN, u'crédits immobiliers': Account.TYPE_LOAN, u'épargne disponible': Account.TYPE_SAVINGS, u'épargne à terme': Account.TYPE_DEPOSIT, u'épargne boursière': Account.TYPE_MARKET, u'assurance vie et capitalisation': Account.TYPE_LIFE_INSURANCE, } def get_list(self): account_type = Account.TYPE_UNKNOWN for tr in self.document.xpath('//table[@class="ca-table"]/tr'): try: title = tr.xpath('.//h3/text()')[0].lower().strip() except IndexError: pass else: account_type = self.TYPES.get(title, Account.TYPE_UNKNOWN) if not tr.attrib.get('class', '').startswith('colcelligne'): continue cols = tr.findall('td') if not cols or len(cols) < self.NB_COLS: continue account = Account() account.id = self.parser.tocleanstring(cols[self.COL_ID]) account.label = self.parser.tocleanstring(cols[self.COL_LABEL]) account.type = account_type or self.TYPES.get(account.label, Account.TYPE_UNKNOWN) balance = self.parser.tocleanstring(cols[self.COL_VALUE]) # we have to ignore those accounts, because using NotAvailable # makes boobank and probably many others crash if balance in ('indisponible', ''): continue account.balance = Decimal(Transaction.clean_amount(balance)) account.currency = account.get_currency(self.parser.tocleanstring(cols[self.COL_CURRENCY])) account._link = None self.set_link(account, cols) account._perimeter = self.browser.current_perimeter yield account def set_link(self, account, cols): raise NotImplementedError() def cards_pages(self): # Use a set because it is possible to see several times the same link. links = set() for line in self.document.xpath('//table[@class="ca-table"]/tr[@class="ligne-connexe"]'): try: link = line.xpath('.//a/@href')[0] except IndexError: pass else: if not link.startswith('javascript:'): links.add(link) return links def check_perimeters(self): return len(self.document.xpath('//a[@title="Espace Autres Comptes"]')) class PerimeterPage(BasePage): def get_current(self): try: current_elem = self.document.xpath('//div[@id="libPerimetre"]/span[@class="texte"]')[0] except IndexError: # The user need to validate CGU, can't do it for him. return self.browser.current_perimeter = re.search(': (.*)$', self.parser.tocleanstring(current_elem)).group(1).lower() def check_multiple_perimeters(self): self.browser.perimeters = list() self.get_current() if self.browser.current_perimeter is None: return self.browser.perimeters.append(self.browser.current_perimeter) multiple = self.document.xpath(u'//p[span/a[contains(text(), "Accès")]]') if not multiple: assert self.document.xpath(u'//div[contains(text(), "Périmètre en cours de chargement. Merci de patienter quelques secondes.")]') # We change perimeter in this case to add the second one. self.browser.location(self.browser.chg_perimeter_url.format(self.browser.sag)) for p in multiple: self.browser.perimeters.append(' '.join(p.find('label').text.lower().split())) def get_perimeter_link(self, perimeter): for p in self.document.xpath(u'//p[span/a[contains(text(), "Accès")]]'): if perimeter in ' '.join(p.find('label').text.lower().split()): link = p.xpath('./span/a')[0].attrib['href'] return link class ChgPerimeterPage(PerimeterPage): def on_loaded(self): if self.get_error() is not None: return self.get_current() if not self.browser.current_perimeter.lower() in [' '.join(p.lower().split()) for p in self.browser.perimeters]: assert len(self.browser.perimeters) == 1 self.browser.perimeters.append(self.browser.current_perimeter) class CardsPage(BasePage): def get_list(self): TABLE_XPATH = '//table[caption[@class="caption tdb-cartes-caption" or @class="ca-table caption"]]' cards_tables = self.document.xpath(TABLE_XPATH) if cards_tables: self.logger.debug('There are several cards') xpaths = { '_id': './caption/span[@class="tdb-cartes-num"]', 'label1': './caption/span[contains(@class, "tdb-cartes-carte")]', 'label2': './caption/span[@class="tdb-cartes-prop"]', 'balance': './/tr/td[@class="cel-num"]', 'currency': '//table/caption//span/text()[starts-with(.,"Montants en ")]', 'link': './/tr//a/@href[contains(., "fwkaction=Detail")]', } else: self.logger.debug('There is only one card') xpaths = { '_id': './/tr/td[@class="cel-texte"]', 'label1': './/tr[@class="ligne-impaire ligne-bleu"]/th', 'label2': './caption/span[@class="tdb-cartes-prop"]/b', 'balance': './/tr[last()-1]/td[@class="cel-num"] | .//tr[last()-2]/td[@class="cel-num"]', 'currency': '//table/caption//span/text()[starts-with(.,"Montants en ")]', } TABLE_XPATH = '(//table[@class="ca-table"])[1]' cards_tables = self.document.xpath(TABLE_XPATH) for table in cards_tables: get = lambda name: self.parser.tocleanstring(table.xpath(xpaths[name])[0]) account = Account() account.type = account.TYPE_CARD account.id = ''.join(get('_id').split()[1:]) account.label = '%s - %s' % (get('label1'), re.sub('\s*-\s*$', '', get('label2'))) try: account.balance = Decimal(Transaction.clean_amount(table.xpath(xpaths['balance'])[-1].text)) account.currency = account.get_currency(self.document .xpath(xpaths['currency'])[0].replace("Montants en ", "")) except IndexError: account.balance = Decimal('0.0') if 'link' in xpaths: try: account._link = table.xpath(xpaths['link'])[-1] except IndexError: account._link = None else: account._link = re.sub('[\n\r\t]+', '', account._link) else: account._link = self.url account._perimeter = self.browser.current_perimeter yield account def get_history(self, date_guesser): seen = set() lines = self.document.xpath('(//table[@class="ca-table"])[2]/tr') debit_date = None for i, line in enumerate(lines): is_balance = line.xpath('./td/@class="cel-texte cel-neg"') # It is possible to have three or four columns. cols = [self.parser.tocleanstring(td) for td in line.xpath('./td')] date = cols[0] label = cols[1] amount = cols[-1] t = Transaction() t.set_amount(amount) t.label = t.raw = label if is_balance: m = re.search('(\d+ [^ ]+ \d+)', label) if not m: raise BrokenPageError('Unable to read card balance in history: %r' % label) debit_date = parse_french_date(m.group(1)) # Skip the first line because it is balance if i == 0: continue t.date = t.rdate = debit_date # Consider the second one as a positive amount to reset balance to 0. t.amount = -t.amount else: day, month = map(int, date.split('/', 1)) t.rdate = date_guesser.guess_date(day, month) t.date = debit_date t.type = t.TYPE_CARD try: t.id = t.unique_id(seen) except UnicodeEncodeError: self.logger.debug(t) self.logger.debug(t.label) raise yield t class AccountsPage(_AccountsPage): def set_link(self, account, cols): iban = None a = cols[0].find('a') if a is not None: account._link = a.attrib['href'].replace(' ', '%20') page = self.browser.get_page(self.browser.openurl(account._link)) account._link = re.sub('sessionSAG=[^&]+', 'sessionSAG={0}', account._link) url = page.get_iban_url() if url: page = self.browser.get_page(self.browser.openurl(url)) iban = account.iban = page.get_iban() elif iban: # In case there is no available IBAN on this account (for # example saving account), calculate it from the previous # IBAN. bankcode = iban[4:9] counter = iban[9:14] key = 97 - ((int(bankcode) * 89 + int(counter) * 15 + int(account.id) * 3) % 97) account.iban = iban[:4] + bankcode + counter + account.id + str(key) class LoansPage(_AccountsPage): COL_ID = 1 NB_COLS = 6 def set_link(self, account, cols): account.balance = -abs(account.balance) class SavingsPage(_AccountsPage): COL_ID = 1 def set_link(self, account, cols): if not account._link: a = cols[0].xpath('descendant::a[contains(@href, "CATITRES")]') if a: url = 'https://%s/stb/entreeBam?sessionSAG=%%s&stbpg=pagePU&site=CATITRES&typeaction=reroutage_aller' account._link = url % self.browser.request.host a = cols[0].xpath("descendant::a[contains(@href, \"'PREDICA','CONTRAT'\")]") if a: account.type = Account.TYPE_LIFE_INSURANCE url = 'https://%s/stb/entreeBam?sessionSAG=%%s&stbpg=pagePU&site=PREDICA&' \ 'typeaction=reroutage_aller&sdt=CONTRAT¶mpartenaire=%s' account._link = url % (self.browser.request.host, account.id) class TransactionsPage(BasePage): def get_iban_url(self): for link in self.document.xpath('//a[contains(text(), "IBAN")]'): m = re.search("\('([^']+)'", link.get('href', '')) if m: return m.group(1) return None def get_iban(self): s = '' for font in self.document.xpath('(//td[font/b/text()="IBAN"])[1]/table//font'): s += self.parser.tocleanstring(font) return s def get_next_url(self): links = self.document.xpath('//span[@class="pager"]/a[@class="liennavigationcorpspage"]') if len(links) < 1: return None img = links[-1].find('img') if img.attrib.get('alt', '') == 'Page suivante': return links[-1].attrib['href'] return None def get_order_by_date_url(self): try: link = self.document.xpath('//table[@class="ca-table"]/thead//a[text()="Date"]')[0].attrib['href'] except IndexError: link = self.url return link COL_DATE = 0 COL_TEXT = 1 COL_DEBIT = None COL_CREDIT = -1 TYPES = {'Paiement Par Carte': Transaction.TYPE_CARD, 'Remise Carte': Transaction.TYPE_CARD, 'Retrait Au Distributeur': Transaction.TYPE_WITHDRAWAL, 'Frais': Transaction.TYPE_BANK, 'Cotisation': Transaction.TYPE_BANK, 'Virement Emis': Transaction.TYPE_TRANSFER, 'Virement': Transaction.TYPE_TRANSFER, 'Cheque Emis': Transaction.TYPE_CHECK, 'Remise De Cheque': Transaction.TYPE_DEPOSIT, 'Prelevement': Transaction.TYPE_ORDER, 'Prelevt': Transaction.TYPE_ORDER, 'Prelevmnt': Transaction.TYPE_ORDER, 'Remboursement De Pret': Transaction.TYPE_LOAN_PAYMENT, } def get_history(self, date_guesser): for tr in self.document.xpath('//table[@class="ca-table"]//tr'): parent = tr.getparent() while parent is not None and parent.tag != 'table': parent = parent.getparent() if parent.attrib.get('class', '') != 'ca-table': continue if tr.attrib.get('class', '') == 'tr-thead': heads = tr.findall('th') for i, head in enumerate(heads): key = self.parser.tocleanstring(head) if key == u'Débit': self.COL_DEBIT = i - len(heads) if key == u'Crédit': self.COL_CREDIT = i - len(heads) if key == u'Libellé': self.COL_TEXT = i if not tr.attrib.get('class', '').startswith('ligne-'): continue cols = tr.findall('td') # On loan accounts, there is a ca-table with a summary. Skip it. if tr.find('th') is not None or len(cols) < 3: continue t = Transaction() col_text = cols[self.COL_TEXT] if len(col_text.xpath('.//br')) == 0: col_text = cols[self.COL_TEXT+1] raw = self.parser.tocleanstring(col_text) date = self.parser.tocleanstring(cols[self.COL_DATE]) credit = self.parser.tocleanstring(cols[self.COL_CREDIT]) if self.COL_DEBIT is not None: debit = self.parser.tocleanstring(cols[self.COL_DEBIT]) else: debit = '' day, month = map(int, date.split('/', 1)) t.date = date_guesser.guess_date(day, month) t.rdate = t.date t.raw = raw # On some accounts' history page, there is a tag in columns. if col_text.find('font') is not None: col_text = col_text.find('font') t.category = unicode(col_text.text.strip()) t.label = re.sub('(.*) (.*)', r'\2', t.category).strip() sub_label = col_text.find('br').tail if sub_label is not None and (len(t.label) < 3 or t.label == t.category or len(re.findall('[^\w\s]', sub_label))/float(len(sub_label)) < len(re.findall('\d', t.label))/float(len(t.label))): t.label = unicode(sub_label.strip()) # Sometimes, the category contains the label, even if there is another line with it again. t.category = re.sub('(.*) .*', r'\1', t.category).strip() t.type = self.TYPES.get(t.category, t.TYPE_UNKNOWN) # Parse operation date in label (for card transactions for example) m = re.match('(?P.*) (?P
[0-3]\d)/(?P[0-1]\d)$', t.label) if not m: m = re.match('^(?P
[0-3]\d)/(?P[0-1]\d) (?P.*)$', t.label) if m: if t.type in (t.TYPE_CARD, t.TYPE_WITHDRAWAL): t.rdate = date_guesser.guess_date(int(m.groupdict()['dd']), int(m.groupdict()['mm']), change_current_date=False) t.label = m.groupdict()['text'].strip() # Strip city or other useless information from label. t.label = re.sub('(.*) .*', r'\1', t.label).strip() t.set_amount(credit, debit) yield t class MarketPage(BasePage): COL_ID = 1 COL_QUANTITY = 2 COL_UNITVALUE = 3 COL_VALUATION = 4 COL_UNITPRICE = 5 COL_DIFF = 6 def iter_investment(self): for line in self.document.xpath('//table[contains(@class, "ca-data-table")]/descendant::tr[count(td)=8]'): cells = line.findall('td') inv = Investment() inv.label = unicode(cells[self.COL_ID].find('div/a').text.strip()) inv.code = cells[self.COL_ID].find('div/br').tail.strip() inv.quantity = self.parse_decimal(cells[self.COL_QUANTITY].find('span').text) inv.valuation = self.parse_decimal(cells[self.COL_VALUATION].text) inv.diff = self.parse_decimal(cells[self.COL_DIFF].text_content()) if "%" in cells[self.COL_UNITPRICE].text and "%" in cells[self.COL_UNITVALUE].text: inv.unitvalue = inv.valuation / inv.quantity inv.unitprice = (inv.valuation - inv.diff) / inv.quantity else: inv.unitprice = self.parse_decimal(cells[self.COL_UNITPRICE].text) inv.unitvalue = self.parse_decimal(cells[self.COL_UNITVALUE].text) yield inv def parse_decimal(self, value): v = value.strip() if v == '-' or v == '': return NotAvailable return Decimal(Transaction.clean_amount(value)) class LifeInsurancePage(MarketPage): COL_ID = 0 COL_QUANTITY = 3 COL_UNITVALUE = 1 COL_VALUATION = 4 def iter_investment(self): for line in self.document.xpath('//table[@summary and count(descendant::td) > 1]/tbody/tr'): cells = line.findall('td') if len(cells) < 5: continue inv = Investment() inv.label = unicode(cells[self.COL_ID].text_content().strip()) a = cells[self.COL_ID].find('a') if a is not None: try: inv.code = a.attrib['id'] except KeyError: #For "Mandat d'arbitrage" which is a recapitulatif of more investement continue else: inv.code = NotAvailable inv.quantity = self.parse_decimal(cells[self.COL_QUANTITY].text_content()) inv.unitvalue = self.parse_decimal(cells[self.COL_UNITVALUE].text_content()) inv.valuation = self.parse_decimal(cells[self.COL_VALUATION].text_content()) inv.unitprice = NotAvailable inv.diff = NotAvailable yield inv weboob-1.1/modules/creditcooperatif/000077500000000000000000000000001265717027300176405ustar00rootroot00000000000000weboob-1.1/modules/creditcooperatif/__init__.py000066400000000000000000000015101265717027300217460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Kevin Pouget, based on Romain Bignon work # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CreditCooperatifModule __all__ = ['CreditCooperatifModule'] weboob-1.1/modules/creditcooperatif/favicon.png000066400000000000000000000121541265717027300217760ustar00rootroot00000000000000PNG  IHDR@@iq pHYs  tIME *\ IDATxyUu?߽o}eeXV{8'qYUUJU+uU*]VmSEndwcv$6v̀0,``VfY߻w}<LbHi4.s~g9#3JKyLW 3F:Q=U9ci-D'53k)9L=G:oJ DnI4@E[y9&}D&9?ӹmlc툋M7B{ K<6kl } V!AȀ-{8$zW3=7Q)9Q`ʡ9 ,yBʖjDC9ؿNHl`.)@F!RMA¨AZT>yUC%{ _g &YЄap~f\ :hP1NPbjb<8ox848^1[oѳ'7. e "#u":#s zyY=B)I;Gzt*PHv`<ĂTzT JbX(h7X X['0Vc)kՅe5,">zV>4,c|CШǦt.Fgif`` *F%@`EZKjDpd\gO)Io~M#U6U 6&gKyN}B'= pPPbɇ 4f xb [EOF .7*_chi!BD=7r.^13#AE"3V@_!`JN>R o|>Xd6Aկ(=:>#!Jv`.a]Lf^2x8G\1`v3+*]p_Ԥß$ )†j[_?!Rf<ĀW`Eh.jMj7M9Rde+#d`; *|befuE@ X FZ`}%g#HjinRA# `'0^+ŒnxaU)mJp `P"jFKj06 9Xjp% {OAiӍrR8׀&= Q 2/4\S2d"`%Y|Ւ8b6ٴx# )P~E c,Z8ee AOŷ'%w.f'cßH0;_~e3dZ B0(aWKh29,MSt)'|A%!@wǁg,nɽS Q$xTC*V9{`SXg-g=?oye9Pd-3+z`0`̱|GO~ 5 D x˓%.XhyAiW5'TK%0-i3lvVy2)x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boob-1.1/modules/creditcooperatif/module.py000066400000000000000000000053321265717027300215020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Kevin Pouget # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.base import find_object from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .perso.browser import CreditCooperatif as CreditCooperatifPerso from .pro.browser import CreditCooperatif as CreditCooperatifPro __all__ = ['CreditCooperatifModule'] class CreditCooperatifModule(Module, CapBank): NAME = 'creditcooperatif' MAINTAINER = u'Kevin Pouget' EMAIL = 'weboob@kevin.pouget.me' VERSION = '1.1' DESCRIPTION = u'Crédit Coopératif' LICENSE = 'AGPLv3+' auth_type = {'particular': "Interface Particuliers", 'weak' : "Code confidentiel (pro)", 'strong': "Sesame (pro)"} CONFIG = BackendConfig(Value('auth_type', label='Type de compte', choices=auth_type, default="particular"), ValueBackendPassword('login', label='Code utilisateur', masked=False), ValueBackendPassword('password', label='Code confidentiel ou code PIN')) def create_default_browser(self): if self.config['auth_type'].get() == 'particular': self.BROWSER = CreditCooperatifPerso return self.create_browser(self.config['login'].get(), self.config['password'].get()) else: self.BROWSER = CreditCooperatifPro return self.create_browser(self.config['login'].get(), self.config['password'].get(), strong_auth=self.config['auth_type'].get() == "strong") def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): return self.browser.get_history(account) def iter_coming(self, account): return self.browser.get_coming(account) weboob-1.1/modules/creditcooperatif/perso/000077500000000000000000000000001265717027300207705ustar00rootroot00000000000000weboob-1.1/modules/creditcooperatif/perso/__init__.py000066400000000000000000000000001265717027300230670ustar00rootroot00000000000000weboob-1.1/modules/creditcooperatif/perso/browser.py000066400000000000000000000061311265717027300230260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Kevin Pouget # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable from .pages import LoginPage, CreditLoggedPage, AccountsPage, TransactionsPage, TransactionsJSONPage, ComingTransactionsPage __all__ = ['CreditCooperatif'] class CreditCooperatif(LoginBrowser): BASEURL = "https://www.credit-cooperatif.coop" loginpage = URL('/portail//particuliers/login.do', LoginPage) loggedpage = URL('/portail/particuliers/authentification.do', CreditLoggedPage) accountspage = URL('/portail/particuliers/mescomptes/synthese.do', AccountsPage) transactionpage = URL('/portail/particuliers/mescomptes/relevedesoperations.do', TransactionsPage) transactjsonpage = URL('/portail/particuliers/mescomptes/relevedesoperationsjson.do', TransactionsJSONPage) comingpage = URL('/portail/particuliers/mescomptes/synthese/operationsencourslien.do', ComingTransactionsPage) def do_login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.loginpage.stay_or_go() self.page.login(self.username, self.password) if self.loggedpage.is_here(): error = self.page.get_error() if error is None: return else: raise BrowserUnavailable("not on the login page") raise BrowserIncorrectPassword(error) @need_login def get_accounts_list(self): self.accountspage.stay_or_go() return self.page.get_list() @need_login def get_history(self, account): data = {'accountExternalNumber': account.id} self.transactionpage.go(data=data) data = {'iDisplayLength': 400, 'iDisplayStart': 0, 'iSortCol_0': 0, 'iSortingCols': 1, 'sColumns': '', 'sEcho': 1, 'sSortDir_0': 'asc', } self.transactjsonpage.go(data=data) return self.page.get_transactions() @need_login def get_coming(self, account): data = {'accountExternalNumber': account.id} self.comingpage.go(data=data) assert self.comingpage.is_here() return self.page.get_transactions() weboob-1.1/modules/creditcooperatif/perso/pages.py000066400000000000000000000140151265717027300224420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Kevin Pouget, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.tools.json import json from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage from weboob.browser.filters.standard import Filter, Format, CleanText, CleanDecimal from weboob.browser.elements import ListElement, ItemElement, method class LoginPage(HTMLPage): def login(self, login, password): form = self.get_form(xpath='//form[@id="AuthForm"]') form['j_username'] = login.encode('iso-8859-15') form['j_password'] = password.encode('iso-8859-15') form.submit() class CreditLoggedPage(HTMLPage): def get_error(self): div = self.doc.xpath('//div[@class="errorForm-msg"]') if len(div) == 0: return None msg = u', '.join([li.text.strip() for li in div[0].xpath('.//li')]) return re.sub('[\r\n\t\xa0]+', ' ', msg) class AddType(Filter): types = {u'COMPTE NEF': Account.TYPE_CHECKING, u'CPTE A VUE': Account.TYPE_CHECKING, u'LIVRET AGIR': Account.TYPE_SAVINGS} def filter(self, str_type): for key, acc_type in self.types.items(): if key == str_type: return acc_type return Account.TYPE_UNKNOWN class AccountsPage(LoggedPage, HTMLPage): @method class get_list(ListElement): item_xpath = '//table[has-class("table-synthese")]' class item(ItemElement): klass = Account obj_label = Format('%s %s', CleanText('.//h2[@class="tt_compte"][1]'), CleanText('.//ul[@class="nClient"]/li[1]')) obj_id = CleanText('.//ul[@class="nClient"]/li[last()]', symbols=u'N°') obj_type = AddType(CleanText('.//h2[@class="tt_compte"][1]')) obj_balance = CleanDecimal('.//td[@class="sum_solde"]//span[last()]', replace_dots=True) obj_currency = u'EUR' class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^(?PRETRAIT DAB) (?P
\d{2})-(?P\d{2})-([\d\-]+)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^RETRAIT DAB (?P
\d{2})-(?P\d{2})-([\d\-]+) (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^CARTE (?P
\d{2})(?P\d{2}) \d+ (?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile('^VIR COOPA (?P
\d{2})/(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^COOPA (?P
\d{2})/(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^VIR(EMENT|EMT| SEPA EMET :)? (?P.*?)(- .*)?$'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(PRLV|PRELEVEMENT) SEPA (?P.*?)(- .*)?$'), FrenchTransaction.TYPE_ORDER), (re.compile('^(PRLV|PRELEVEMENT) (?P.*?)(- .*)?$'), FrenchTransaction.TYPE_ORDER), (re.compile('^CHEQUE.*'), FrenchTransaction.TYPE_CHECK), (re.compile('^(AGIOS /|FRAIS) (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^ABONNEMENT (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^REMISE (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^(?P.*)( \d+)? QUITTANCE .*'), FrenchTransaction.TYPE_ORDER), (re.compile('^.* LE (?P
\d{2})/(?P\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_UNKNOWN), ] class TransactionsPage(LoggedPage, HTMLPage): pass class TransactionsJSONPage(LoggedPage, JsonPage): ROW_DATE = 0 ROW_TEXT = 2 ROW_CREDIT = -1 ROW_DEBIT = -2 def get_transactions(self): seen = set() for tr in self.doc['exportData'][1:]: t = Transaction() t.parse(tr[self.ROW_DATE], tr[self.ROW_TEXT]) t.set_amount(tr[self.ROW_CREDIT], tr[self.ROW_DEBIT]) t.id = t.unique_id(seen) yield t class ComingTransactionsPage(LoggedPage, HTMLPage): ROW_REF = 0 ROW_TEXT = 1 ROW_DATE = 2 ROW_CREDIT = -1 ROW_DEBIT = -2 def get_transactions(self): data = [] for script in self.doc.xpath('//script'): txt = script.text if txt is None: continue pattern = 'var jsonData =' start = txt.find(pattern) if start < 0: continue txt = txt[start+len(pattern):start+txt[start:].find(';')] data = json.loads(txt) break for tr in data: t = Transaction() t.parse(tr[self.ROW_DATE], tr[self.ROW_TEXT]) t.set_amount(tr[self.ROW_CREDIT], tr[self.ROW_DEBIT]) yield t weboob-1.1/modules/creditcooperatif/pro/000077500000000000000000000000001265717027300204405ustar00rootroot00000000000000weboob-1.1/modules/creditcooperatif/pro/__init__.py000066400000000000000000000000001265717027300225370ustar00rootroot00000000000000weboob-1.1/modules/creditcooperatif/pro/browser.py000066400000000000000000000072531265717027300225040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Kevin Pouget # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, AccountsPage, ITransactionsPage, TransactionsPage, ComingTransactionsPage, CardTransactionsPage __all__ = ['CreditCooperatif'] class CreditCooperatif(Browser): PROTOCOL = 'https' ENCODING = 'iso-8859-15' DOMAIN = "www.coopanet.com" PAGES = {'https://www.coopanet.com/banque/sso/.*': LoginPage, 'https://www.coopanet.com/banque/cpt/incoopanetj2ee.do.*': AccountsPage, 'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkReleveAction=X&numeroExterne=.*': TransactionsPage, 'https://www.coopanet.com/banque/cpt/cpt/relevecompte.do\?tri_page=.*': TransactionsPage, 'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkOpCB=X&numeroExterne=.*': CardTransactionsPage, 'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkOpEC=X&numeroExterne=.*': ComingTransactionsPage, 'https://www.coopanet.com/banque/cpt/cpt/operationEnCours.do.*': ComingTransactionsPage, } def __init__(self, *args, **kwargs): self.strong_auth = kwargs.pop('strong_auth', False) Browser.__init__(self, *args, **kwargs) def home(self): self.location("/banque/sso/") assert self.is_on_page(LoginPage) def is_logged(self): return not self.is_on_page(LoginPage) def login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert isinstance(self.strong_auth, bool) if self.is_logged(): return if not self.is_on_page(LoginPage): self.home() self.page.login(self.username, self.password, self.strong_auth) if not self.is_logged(): raise BrowserIncorrectPassword() def get_accounts_list(self): self.location(self.buildurl('/banque/cpt/incoopanetj2ee.do?ssomode=ok')) return self.page.get_list() def _get_history(self, link): self.location(link) while True: assert self.is_on_page(ITransactionsPage) for tr in self.page.get_history(): yield tr next_url = self.page.get_next_url() if next_url is None: return self.location(next_url) def get_history(self, account): return self._get_history('/banque/cpt/cpt/situationcomptes.do?lnkReleveAction=X&numeroExterne='+ account.id) def get_coming(self, account): # credit cards transactions for tr in self._get_history('/banque/cpt/cpt/situationcomptes.do?lnkOpCB=X&numeroExterne='+ account.id): yield tr # coming transactions for tr in self._get_history('/banque/cpt/cpt/situationcomptes.do?lnkOpEC=X&numeroExterne='+ account.id): yield tr weboob-1.1/modules/creditcooperatif/pro/pages.py000066400000000000000000000146021265717027300221140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Kevin Pouget # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal import re import time from weboob.deprecated.browser import Page from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction class LoginPage(Page): def login(self, login, pin, strong_auth): form_nb = 1 if strong_auth else 0 indentType = "RENFORCE" if strong_auth else "MDP" self.browser.select_form(name='loginCoForm', nr=form_nb) self.browser['codeUtil'] = login.encode(self.browser.ENCODING) self.browser['motPasse'] = pin.encode(self.browser.ENCODING) assert self.browser['identType'] == indentType self.browser.submit(nologin=True) class AccountsPage(Page): ACCOUNT_TYPES = {u'COMPTE NEF': Account.TYPE_CHECKING} CPT_ROW_ID = 0 CPT_ROW_NAME = 1 CPT_ROW_NATURE = 2 CPT_ROW_BALANCE = 3 CPT_ROW_ENCOURS = 4 def is_error(self): for par in self.document.xpath('//p[@class=acctxtnoirlien]'): if par.text is not None and u"La page demandée ne peut pas être affichée." in par.text: return True return False def get_list(self): for trCompte in self.document.xpath('//table[@id="compte"]/tbody/tr'): tds = trCompte.findall('td') account = Account() account.id = tds[self.CPT_ROW_ID].text.strip() account.label = unicode(tds[self.CPT_ROW_NAME].text.strip()) account_type_str = "".join([td.text for td in tds[self.CPT_ROW_NATURE].xpath('.//td[@class="txt"]')]).strip() account.type = self.ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN) account.balance = Decimal(FrenchTransaction.clean_amount(self.parser.tocleanstring(tds[self.CPT_ROW_BALANCE]))) account.coming = Decimal(FrenchTransaction.clean_amount(self.parser.tocleanstring( tds[self.CPT_ROW_ENCOURS]))) account.currency = account.get_currency(tds[self.CPT_ROW_BALANCE].find("a").text) yield account return class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^RETRAIT DAB (?P.*?).*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?P.*) RETRAIT DU (?P
\d{2})(?P\d{2})(?P\d{2}) .*'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^CARTE \d+ .*'), FrenchTransaction.TYPE_CARD), (re.compile('^VIR(EMENT)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(PRLV|PRELEVEMENT) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^CHEQUE.*'), FrenchTransaction.TYPE_CHECK), (re.compile('^(AGIOS /|FRAIS) (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^ABONNEMENT (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^REMISE (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile('^(?P.*)( \d+)? QUITTANCE .*'), FrenchTransaction.TYPE_ORDER), (re.compile('^.* LE (?P
\d{2})/(?P\d{2})/(?P\d{2})$'), FrenchTransaction.TYPE_UNKNOWN), ] class ITransactionsPage(Page): def get_next_url(self): # can be 'Suivant' or ' Suivant' next = self.document.xpath("//a[normalize-space(text()) = 'Suivant']") if not next: return None return next[0].attrib["href"] def get_history(self): raise NotImplementedError() class TransactionsPage(ITransactionsPage): TR_DATE = 0 TR_TEXT = 2 TR_DEBIT = 3 TR_CREDIT = 4 TABLE_NAME = 'operation' def get_history(self): for tr in self.document.xpath('//table[@id="%s"]/tbody/tr' % self.TABLE_NAME): tds = tr.findall('td') def get_content(td): ret = self.parser.tocleanstring(td) return ret.replace(u"\xa0", " ").strip() date = get_content(tds[self.TR_DATE]) raw = get_content(tds[self.TR_TEXT]) debit = get_content(tds[self.TR_DEBIT]) credit = get_content(tds[self.TR_CREDIT]) t = Transaction() t.parse(date, re.sub(r'[ ]+', ' ', raw)) t.set_amount(credit, debit) yield t class ComingTransactionsPage(TransactionsPage): TR_DATE = 2 TR_TEXT = 1 TR_DEBIT = -2 TR_CREDIT = -1 TABLE_NAME = 'operationAVenir' class CardTransactionsPage(ITransactionsPage): COM_TR_COMMENT = 0 COM_TR_DATE = 1 COM_TR_TEXT = 2 COM_TR_VALUE = 3 def get_history(self): comment = None for tr in self.document.xpath('//table[@id="operation"]/tbody/tr'): tds = tr.findall('td') def get_content(td): ret = td.text return ret.replace(u"\xa0", " ").strip() raw = get_content(tds[self.COM_TR_TEXT]) if comment is None: comment = get_content(tds[self.COM_TR_COMMENT]) raw = "%s (%s) " % (raw, comment) debit = get_content(tds[self.COM_TR_VALUE]) date = get_content(tds[self.COM_TR_DATE]) if comment is not None: #date is 'JJ/MM'. add '/YYYY' date += comment[comment.rindex("/"):] else: date += "/%d" % time.localtime().tm_year t = Transaction() t.parse(date, re.sub(r'[ ]+', ' ', raw)) t.set_amount("", debit) yield t weboob-1.1/modules/creditcooperatif/test.py000066400000000000000000000020471265717027300211740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Kevin Pouget # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CreditCooperatifTest(BackendTest): MODULE = 'creditcooperatif' def test_creditcoop(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) list(self.backend.iter_coming(a)) weboob-1.1/modules/creditdunord/000077500000000000000000000000001265717027300170005ustar00rootroot00000000000000weboob-1.1/modules/creditdunord/__init__.py000066400000000000000000000014441265717027300211140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CreditDuNordModule __all__ = ['CreditDuNordModule'] weboob-1.1/modules/creditdunord/browser.py000066400000000000000000000130401265717027300210330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import urllib from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.capabilities.bank import Account from .pages import LoginPage, AccountsPage, ProAccountsPage, TransactionsPage, ProTransactionsPage, IbanPage, RedirectPage, AVPage __all__ = ['CreditDuNordBrowser'] class CreditDuNordBrowser(Browser): PROTOCOL = 'https' ENCODING = 'UTF-8' PAGES = {'https://[^/]+/?': LoginPage, 'https://[^/]+/.*\?.*_pageLabel=page_erreur_connexion.*': LoginPage, 'https://[^/]+/swm/redirectCDN.html': RedirectPage, 'https://[^/]+/vos-comptes/particuliers(\?.*)?': AccountsPage, 'https://[^/]+/vos-comptes/particuliers/transac_tableau_de_bord(\?.*)?': AccountsPage, 'https://[^/]+/vos-comptes/particuliers/V1_transactional_portal_page_.*': AVPage, 'https://[^/]+/vos-comptes/.*/transac/particuliers.*': TransactionsPage, 'https://[^/]+/vos-comptes/(?Pprofessionnels|entreprises).*': ProAccountsPage, 'https://[^/]+/vos-comptes/.*/transac/(professionnels|entreprises).*': ProTransactionsPage, 'https://[^/]+/vos-comptes/IPT/cdnProxyResource/transacClippe/RIB_impress.asp.*': IbanPage, } account_type = 'particuliers' def __init__(self, website, *args, **kwargs): self.DOMAIN = website Browser.__init__(self, *args, **kwargs) def is_logged(self): return self.page is not None and not self.is_on_page(LoginPage) def home(self): if self.is_logged(): self.location(self.buildurl('/vos-comptes/%s' % self.account_type)) self.location(self.page.document.xpath(u'//a[contains(text(), "Synthèse")]')[0].attrib['href']) else: self.login() def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.location('https://' + self.DOMAIN, no_login=True) self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() m = re.match('https://[^/]+/vos-comptes/(\w+).*', self.page.url) if m: self.account_type = m.group(1) def get_accounts_list(self, iban=True): if not self.is_on_page(AccountsPage): self.home() accounts = [] self.location(self.page.get_av_link()) if self.is_on_page(AVPage): for a in self.page.get_av_accounts(): self.location(a._link, urllib.urlencode(a._args)) self.location(a._link.replace("_attente", "_detail_contrat_rep"), urllib.urlencode(a._args)) self.page.fill_valuation_diff(a) accounts.append(a) self.home() for a in self.page.get_list(): accounts.append(a) if iban: self.page.iban_page() link = self.page.iban_go() for a in [a for a in accounts if a._acc_nb]: self.location('%s%s' % (link, a._acc_nb)) a.iban = self.page.get_iban() return iter(accounts) def get_account(self, id): assert isinstance(id, basestring) l = self.get_accounts_list(iban=False) for a in l: if a.id == id: return a return None def iter_transactions(self, link, args, is_coming=None): if args is None: return while args is not None: self.location(link, urllib.urlencode(args)) assert self.is_on_page(TransactionsPage) self.page.is_coming = is_coming for tr in self.page.get_history(): yield tr is_coming = self.page.is_coming args = self.page.get_next_args(args) def get_history(self, account): for tr in self.iter_transactions(account._link, account._args): yield tr for tr in self.get_card_operations(account): yield tr def get_card_operations(self, account): for link_args in account._card_ids: for tr in self.iter_transactions(account._link, link_args, True): yield tr def get_investment(self, account): if not account._inv: return iter([]) if (account.type == Account.TYPE_MARKET): self.location(account._link, urllib.urlencode(account._args)) return self.page.get_market_investment() elif (account.type == Account.TYPE_LIFE_INSURANCE): self.location(account._link, urllib.urlencode(account._args)) self.location(account._link.replace("_attente", "_detail_contrat_rep"), urllib.urlencode(account._args)) return self.page.get_deposit_investment() return iter([]) weboob-1.1/modules/creditdunord/favicon.png000066400000000000000000000040671265717027300211420ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME GlIDATx}lU?Z[%:k*@s4qJdd73MX6ML/۲,efˌ!dd2Z]$p^ oc Cp }\z{{}iWins>o9ʶmf>Tyma7۳&K@>a.O5εY@y&(Q^mk.(Ks@󝔯kqvf(=` PB!PZe֯k9`pƀs?Ӕ " O/ZybH1f I<e%f0,U`l*WĜYQ oˁo͆2p\eY z4P(UC)dk5Y x´T(dpFy&$] A5PY_[kY=r5@2W >pA$Q~:H(6vFYt$QMFbY_5$Wni;)xE`jEXHopj{vH0efJ?[WӁ`p?0KZ%K sʇ&E亣>QN umd oˀ <1X4,I+GkI/[H|dd2`[µ=:eƐfrZ.L%9YT6 '+,Cq0;ƩC<.qIٶj(4EY$<gJ;-C?$OvѮ5Dy$!!aB,S,C9?OQp7U÷L=b `v7; 8 rh/+,C_\vo?>z.NA^M<"vұMeˤ_] 薡 ?oO#f6dzkct'r]p,4'L" 'z#}|$3; vp<oW K抶^T^mX>TB /; "y@GbDܷP=i-[B+"ԋʫp*V _? n<i]Yh&tP)_&kۊ?c4ZC30YZW.aG)Z/UZ%a%GwH[>엲88<m]ڽn?Yr`i S٦_UTK[9W,]o2s eY,w+w՜ߊGREHB%7@K%l^uPʙS<㸌Ld/gxxio2(m!06f18l14Ctb0%?2R3xr\`v>?nigfIENDB`weboob-1.1/modules/creditdunord/module.py000066400000000000000000000066261265717027300206510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import ValueBackendPassword, Value from .browser import CreditDuNordBrowser __all__ = ['CreditDuNordModule'] class CreditDuNordModule(Module, CapBank): NAME = 'creditdunord' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Crédit du Nord, Banque Courtois, Kolb, Tarneaud' LICENSE = 'AGPLv3+' website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ 'www.credit-du-nord.fr': u'Crédit du Nord', 'www.banque-courtois.fr': u'Banque Courtois', 'www.banque-kolb.fr': u'Banque Kolb', 'www.banque-rhone-alpes.fr': u'Banque Rhône-Alpes', 'www.tarneaud.fr': u'Tarneaud', }.iteritems(), key=lambda k_v: (k_v[1], k_v[0]))]) CONFIG = BackendConfig(Value('website', label='Banque', choices=website_choices, default='www.credit-du-nord.fr'), ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Code confidentiel')) BROWSER = CreditDuNordBrowser def create_default_browser(self): return self.create_browser(self.config['website'].get(), self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): with self.browser: for account in self.browser.get_accounts_list(): yield account def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): with self.browser: account = self.browser.get_account(account.id) transactions = list(self.browser.get_history(account)) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return [tr for tr in transactions if not tr._is_coming] def iter_coming(self, account): with self.browser: account = self.browser.get_account(account.id) transactions = list(self.browser.get_card_operations(account)) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return [tr for tr in transactions if tr._is_coming] def iter_investment(self, account): with self.browser: account = self.browser.get_account(account.id) return self.browser.get_investment(account) weboob-1.1/modules/creditdunord/pages.py000077500000000000000000000475361265717027300204730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from urllib import quote, urlencode from decimal import Decimal import re from cStringIO import StringIO from io import BytesIO from weboob.deprecated.browser import Page, BrokenPageError, BrowserIncorrectPassword from weboob.tools.json import json from weboob.capabilities.bank import Account, Investment from weboob.capabilities import NotAvailable from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.captcha.virtkeyboard import GridVirtKeyboard class CDNVirtKeyboard(GridVirtKeyboard): symbols = {'0': '3de2346a63b658c977fce4da925ded28', '1': 'c571018d2dc267cdf72fafeeb9693037', '2': '72d7bad4beb833d85047f6912ed42b1d', '3': 'fbfce4677a8b2f31f3724143531079e3', '4': '54c723c5b0b5848a0475b4784100b9e0', '5': 'd00164307cacd4ca21b930db09403baa', '6': '101adc6f5d03df0f512c3ec2bef88de9', '7': '3b48f598209718397eb1118d81cf07ba', '8': '881f0acdaba2c44b6a5e64331f4f53d3', '9': 'a47d9a0a2ebbc65a0e625f20cb07822b', } margin = 1 color = (0xff,0xf7,0xff) nrow = 4 ncol = 4 def __init__(self, browser, crypto, grid): f = BytesIO(browser.openurl('/sec/vk/gen_ui?modeClavier=0&cryptogramme=%s' % crypto).read()) super(CDNVirtKeyboard, self).__init__(range(16), self.ncol, self.nrow, f, self.color) self.check_symbols(self.symbols, browser.responses_dirname) self.codes = grid def check_color(self, pixel): for p in pixel: if p > 0xd0: return False return True def get_string_code(self, string): res = [] ndata = self.nrow * self.ncol for nbchar, c in enumerate(string): index = self.get_symbol_code(self.symbols[c]) res.append(self.codes[(nbchar * ndata) + index]) return ','.join(res) class RedirectPage(Page): def on_loaded(self): for script in self.document.xpath('//script'): self.browser.location(re.search(r'href="([^"]+)"', script.text).group(1), no_login=True) class LoginPage(Page): def login(self, username, password): login_selector = self.document.xpath('//input[@id="codsec"]') if login_selector: if not password.isdigit() or not len(password) == 6: raise BrowserIncorrectPassword('The credentials have changed on website %s. Please update them.' % self.browser.DOMAIN) self.vk_login(username, password) else: self.classic_login(username,password) def vk_login(self, username, password): res = self.browser.openurl('/sec/vk/gen_crypto?estSession=0').read() crypto = re.search(r"'crypto': '([^']+)'", res).group(1) grid = re.search(r"'grid': \[([^\]]+)]", res).group(1).split(',') vk = CDNVirtKeyboard(self.browser, crypto, grid) data = {'user_id': username, 'codsec': vk.get_string_code(password), 'cryptocvcs': crypto, 'vk_op': 'auth', } self.browser.location(self.browser.buildurl('/swm/redirectCDN.html'), urlencode(data), no_login=True) def classic_login(self, username, password): m = re.match('www.([^\.]+).fr', self.browser.DOMAIN) if not m: bank_name = 'credit-du-nord' self.logger.error('Unable to find bank name for %s' % self.browser.DOMAIN) else: bank_name = m.group(1) data = {'bank': bank_name, 'pagecible': 'vos-comptes', 'password': password.encode(self.browser.ENCODING), 'pwAuth': 'Authentification+mot+de+passe', 'username': username.encode(self.browser.ENCODING), } self.browser.location(self.browser.buildurl('/saga/authentification'), urlencode(data), no_login=True) class CDNBasePage(Page): def get_from_js(self, pattern, end, is_list=False): """ find a pattern in any javascript text """ value = None for script in self.document.xpath('//script'): txt = script.text if txt is None: continue start = txt.find(pattern) if start < 0: continue while True: if value is None: value = '' else: value += ',' value += txt[start+len(pattern):start+txt[start+len(pattern):].find(end)+len(pattern)] if not is_list: break txt = txt[start+len(pattern)+txt[start+len(pattern):].find(end):] start = txt.find(pattern) if start < 0: break return value def get_execution(self): return self.get_from_js("name: 'execution', value: '", "'") def iban_go(self): return '%s%s' % ('/vos-comptes/IPT/cdnProxyResource', self.get_from_js('C_PROXY.StaticResourceClientTranslation( "', '"')) class AccountsPage(CDNBasePage): COL_HISTORY = 2 COL_FIRE_EVENT = 3 COL_ID = 4 COL_LABEL = 5 COL_BALANCE = -1 TYPES = {'CARTE': Account.TYPE_CARD, 'COMPTE COURANT': Account.TYPE_CHECKING, 'COMPTE EPARGNE': Account.TYPE_SAVINGS, 'COMPTE SUR LIVRET': Account.TYPE_SAVINGS, 'LIVRET': Account.TYPE_SAVINGS, 'P.E.A.': Account.TYPE_MARKET, 'PEA': Account.TYPE_MARKET, 'TITRES': Account.TYPE_MARKET, } def get_account_type(self, label): for pattern, actype in self.TYPES.iteritems(): if label.startswith(pattern) or label.endswith(pattern): return actype return Account.TYPE_UNKNOWN def get_history_link(self): return self.parser.strip(self.get_from_js(",url: Ext.util.Format.htmlDecode('", "'")) def get_av_link(self): return self.document.xpath('//a[contains(text(), "Consultation")]')[0].attrib['href'] def get_list(self): accounts = [] txt = self.get_from_js('_data = new Array(', ');', is_list=True) if txt is None: raise BrokenPageError('Unable to find accounts list in scripts') data = json.loads('[%s]' % txt.replace("'", '"')) for line in data: a = Account() a.id = line[self.COL_ID].replace(' ', '') a._acc_nb = a.id.split('_')[0] if len(a.id.split('_')) > 1 else None fp = StringIO(unicode(line[self.COL_LABEL]).encode(self.browser.ENCODING)) a.label = self.parser.tocleanstring(self.parser.parse(fp, self.browser.ENCODING).xpath('//div[@class="libelleCompteTDB"]')[0]) # This account can be multiple life insurance accounts if a.label == 'ASSURANCE VIE-BON CAPI-SCPI-DIVERS *': continue a.balance = Decimal(FrenchTransaction.clean_amount(line[self.COL_BALANCE])) a.currency = a.get_currency(line[self.COL_BALANCE]) a.type = self.get_account_type(a.label) if line[self.COL_HISTORY] == 'true': a._inv = False a._link = self.get_history_link() a._args = {'_eventId': 'clicDetailCompte', '_ipc_eventValue': '', '_ipc_fireEvent': '', 'deviseAffichee': 'DEVISE', 'execution': self.get_execution(), 'idCompteClique': line[self.COL_ID], } else: a._inv = True a._args = {'_ipc_eventValue': line[self.COL_ID], '_ipc_fireEvent': line[self.COL_FIRE_EVENT], } a._link = self.document.xpath('//form[@name="changePageForm"]')[0].attrib['action'] if a.id.find('_CarteVisa') >= 0: accounts[-1]._card_ids.append(a._args) if not accounts[-1].coming: accounts[-1].coming = Decimal('0.0') accounts[-1].coming += a.balance continue a._card_ids = [] accounts.append(a) return accounts def iban_page(self): self.browser.select_form(name="changePageForm") self.browser.form.set_all_readonly(False) self.browser['_ipc_fireEvent'] = 'V1_rib' self.browser['_ipc_eventValue'] = 'bouchon=bouchon' self.browser.submit() class AVPage(CDNBasePage): COL_LABEL = 0 COL_BALANCE = 3 ARGS = ['IndiceClassement', 'IndiceCompte', 'Banque', 'Agence', 'Classement', 'Serie', 'SScompte', 'Categorie', 'IndiceSupport', 'NumPolice', 'LinkHypertext'] def get_params(self, text): url = self.get_from_js('document.detail.action="', '";') args = {} l = [] for sub in re.findall("'([^']*)'", text): l.append(sub) for i, key in enumerate(self.ARGS): args[key] = unicode(l[self.ARGS.index(key)]).encode(self.browser.ENCODING) return url, args def get_av_accounts(self): for tr in self.document.xpath('//table[@class="datas"]/tr[not(@class)]'): cols = tr.findall('td') if len(cols) != 4: continue a = Account() a.label = self.parser.tocleanstring(cols[self.COL_LABEL]) a.type = Account.TYPE_LIFE_INSURANCE a.balance = Decimal(FrenchTransaction.clean_amount(self.parser.tocleanstring(cols[self.COL_BALANCE]))) a._link, a._args = self.get_params(cols[self.COL_LABEL].find('span/a').attrib['href']) a.id = '%s%s' % (a._args['IndiceSupport'], a._args['NumPolice']) a._acc_nb = None a._card_ids = [] a._inv = True yield a class ProAccountsPage(AccountsPage): COL_ID = 0 COL_BALANCE = 1 ARGS = ['Banque', 'Agence', 'Classement', 'Serie', 'SSCompte', 'Devise', 'CodeDeviseCCB', 'LibelleCompte', 'IntituleCompte', 'Indiceclassement', 'IndiceCompte', 'NomClassement'] def params_from_js(self, text): l = [] for sub in re.findall("'([^']*)'", text): l.append(sub) if len(l) <= 1: #For account that have no history return None, None kind = self.group_dict['kind'] url = '/vos-comptes/IPT/appmanager/transac/' + kind + '?_nfpb=true&_windowLabel=portletInstance_18&_pageLabel=page_synthese_v1' + '&_cdnCltUrl=' + "/transacClippe/" + quote(l.pop(0)) args = {} for input in self.document.xpath('//form[@name="detail"]/input'): args[input.attrib['name']] = input.attrib.get('value', '') for i, key in enumerate(self.ARGS): args[key] = unicode(l[self.ARGS.index(key)]).encode(self.browser.ENCODING) args['PageDemandee'] = 1 args['PagePrecedente'] = 1 return url, args def get_list(self): for tr in self.document.xpath('//table[@class="datas"]//tr'): if tr.attrib.get('class', '') == 'entete': continue cols = tr.findall('td') a = Account() a.label = unicode(cols[self.COL_ID].xpath('.//span[@class="left-underline"]')[0].text.strip()) a.type = self.get_account_type(a.label) balance = self.parser.tocleanstring(cols[self.COL_BALANCE]) a.balance = Decimal(FrenchTransaction.clean_amount(balance)) a.currency = a.get_currency(balance) a._link, a._args = self.params_from_js(cols[self.COL_ID].find('a').attrib['href']) a._acc_nb = cols[self.COL_ID].xpath('.//span[@class="right-underline"]')[0].text.replace(' ', '').strip() if a._args: a.id = '%s%s%s' % (a._acc_nb, a._args['IndiceCompte'], a._args['Indiceclassement']) else: a.id = a._acc_nb a._card_ids = [] a._inv = False yield a def iban_page(self): self.browser.location(self.document.xpath('.//a[contains(text(), "Impression IBAN")]')[0].attrib['href']) class IbanPage(Page): def get_iban(self): try: return unicode(self.document.xpath('.//td[@width="315"]/font')[0].text.replace(' ', '').strip()) except AttributeError: return NotAvailable class Transaction(FrenchTransaction): PATTERNS = [(re.compile(r'^(?PRET DAB \w+ .*?) LE (?P
\d{2})(?P\d{2})$'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(r'^VIR(EMENT)?( INTERNET)?(\.| )?(DE)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(r'^PRLV (SEPA )?(DE )?(?P.*?)( Motif :.*)?$'), FrenchTransaction.TYPE_ORDER), (re.compile(r'^CB (?P.*) LE (?P
\d{2})\.?(?P\d{2})$'), FrenchTransaction.TYPE_CARD), (re.compile(r'^CHEQUE.*'), FrenchTransaction.TYPE_CHECK), (re.compile(r'^(CONVENTION \d+ )?COTISATION (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile(r'^REM(ISE)?\.?( CHQ\.)? .*'), FrenchTransaction.TYPE_DEPOSIT), (re.compile(r'^(?P.*?)( \d{2}.*)? LE (?P
\d{2})\.?(?P\d{2})$'), FrenchTransaction.TYPE_CARD), ] class TransactionsPage(CDNBasePage): COL_ID = 0 COL_DATE = 1 COL_DEBIT_DATE = 2 COL_LABEL = 3 COL_VALUE = -1 is_coming = None def get_next_args(self, args): if self.is_last(): return None args['_eventId'] = 'clicChangerPageSuivant' args['execution'] = self.get_execution() args.pop('idCompteClique', None) return args def is_last(self): for script in self.document.xpath('//script'): txt = script.text if txt is None: continue if txt.find('clicChangerPageSuivant') >= 0: return False return True def set_coming(self, t): if self.is_coming is not None and t.raw.startswith('TOTAL DES') and t.amount > 0: # ignore card credit and next transactions are already debited self.is_coming = False return True if self.is_coming is None and t.raw.startswith('ACHATS CARTE'): # Ignore card debit return True t._is_coming = bool(self.is_coming) return False def get_history(self): txt = self.get_from_js('ListeMvts_data = new Array(', ');') if txt is None: no_trans = self.get_from_js('js_noMvts = new Ext.Panel(', ')') if no_trans is not None: # there is no transactions for this account, this is normal. return else: # No history on this account return data = json.loads('[%s]' % txt.replace('"', '\\"').replace("'", '"')) for line in data: t = Transaction() if self.is_coming is not None: t.type = t.TYPE_CARD date = self.parser.strip(line[self.COL_DEBIT_DATE]) else: date = self.parser.strip(line[self.COL_DATE]) raw = self.parser.strip(line[self.COL_LABEL]) t.parse(date, raw) t.set_amount(line[self.COL_VALUE]) if t.date is NotAvailable: continue if self.set_coming(t): continue yield t def get_market_investment(self): COL_LABEL = 0 COL_QUANTITY = 1 COL_UNITPRICE = 2 COL_UNITVALUE = 3 COL_VALUATION = 4 COL_PERF = 5 for table in self.document.xpath('//table[@class="datas-large"]'): for tr in table.xpath('.//tr[not(@class="entete")]'): cols = tr.findall('td') if len(cols) < 7: continue delta = 0 if len(cols) == 9: delta = 1 inv = Investment() inv.code = self.parser.tocleanstring(cols[COL_LABEL + delta].xpath('.//span')[1]) inv.label = self.parser.tocleanstring(cols[COL_LABEL + delta].xpath('.//span')[0]) inv.quantity = self.parse_decimal(cols[COL_QUANTITY + delta]) inv.unitprice = self.parse_decimal(cols[COL_UNITPRICE + delta]) inv.unitvalue = self.parse_decimal(cols[COL_UNITVALUE + delta]) inv.valuation = self.parse_decimal(cols[COL_VALUATION + delta]) inv.diff = self.parse_decimal(cols[COL_PERF + delta]) yield inv def get_deposit_investment(self): COL_LABEL = 0 COL_QUANTITY = 3 COL_UNITVALUE = 4 COL_VALUATION = 5 for tr in self.document.xpath('//table[@class="datas"]/tr[not(@class="entete")]'): cols = tr.findall('td') inv = Investment() inv.label = self.parser.tocleanstring(cols[COL_LABEL].xpath('.//a')[0]) inv.code = self.parser.tocleanstring(cols[COL_LABEL]).replace(inv.label, "") inv.quantity = self.parse_decimal(cols[COL_QUANTITY]) inv.unitvalue = self.parse_decimal(cols[COL_UNITVALUE]) inv.valuation = self.parse_decimal(cols[COL_VALUATION]) yield inv def parse_decimal(self, string): value = self.parser.tocleanstring(string) if value == '-': return NotAvailable return Decimal(Transaction.clean_amount(value)) def fill_valuation_diff(self, account): account.valuation_diff = self.parse_decimal(self.document.xpath(u'//td[span[contains(text(), "dont +/- value : ")]]//b')[0]) class ProTransactionsPage(TransactionsPage): def get_next_args(self, args): if len(self.document.xpath('//a[contains(text(), "Suivant")]')) > 0: args['PageDemandee'] = int(args.get('PageDemandee', 1)) + 1 return args return None def parse_transactions(self): transactions = {} for script in self.document.xpath('//script'): txt = script.text if txt is None: continue for i, key, value in re.findall('listeopecv\[(\d+)\]\[\'(\w+)\'\]="(.*)";', txt): i = int(i) if i not in transactions: transactions[i] = {} transactions[i][key] = value return transactions.iteritems() def get_history(self): for i, tr in self.parse_transactions(): t = Transaction() date = tr['date'] raw = self.parser.strip('

%s

' % (' '.join([tr['typeope'], tr['LibComp']]))) t.parse(date, raw) t.set_amount(tr['mont']) if t.date is NotAvailable: continue if self.set_coming(t): continue yield t weboob-1.1/modules/creditdunord/test.py000066400000000000000000000020001265717027300203210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CreditDuNordTest(BackendTest): MODULE = 'creditdunord' def test_creditdunord(self): l = list(self.backend.iter_accounts()) a = l[0] list(self.backend.iter_history(a)) list(self.backend.iter_coming(a)) weboob-1.1/modules/creditmutuel/000077500000000000000000000000001265717027300170205ustar00rootroot00000000000000weboob-1.1/modules/creditmutuel/__init__.py000066400000000000000000000014531265717027300211340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CreditMutuelModule __all__ = ['CreditMutuelModule'] weboob-1.1/modules/creditmutuel/browser.py000066400000000000000000000263621265717027300210660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . try: from urlparse import urlparse except ImportError: from urllib.parse import urlparse from datetime import datetime from random import randint from weboob.tools.compat import basestring from weboob.browser.browsers import LoginBrowser, need_login from weboob.browser.profiles import Wget from weboob.browser.url import URL from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities.bank import Transfer, TransferError, Account from .pages import LoginPage, LoginErrorPage, AccountsPage, UserSpacePage, \ OperationsPage, CardPage, ComingPage, NoOperationsPage, \ TransfertPage, ChangePasswordPage, VerifCodePage, \ EmptyPage, PorPage, IbanPage, NewHomePage, RedirectPage, \ LIAccountsPage __all__ = ['CreditMutuelBrowser'] class CreditMutuelBrowser(LoginBrowser): PROFILE = Wget() TIMEOUT = 30 BASEURL = 'https://www.creditmutuel.fr' login = URL('/groupe/fr/index.html', '/(?P.*)/fr/$', '/(?P.*)/fr/banques/accueil.html', '/(?P.*)/fr/banques/particuliers/index.html', LoginPage) login_error = URL('/(?P.*)/fr/identification/default.cgi', LoginErrorPage) accounts = URL('/(?P.*)/fr/banque/situation_financiere.cgi', '/(?P.*)/fr/banque/situation_financiere.html', AccountsPage) user_space = URL('/(?P.*)/fr/banque/espace_personnel.aspx', UserSpacePage) operations = URL('/(?P.*)/fr/banque/mouvements.cgi.*', '/(?P.*)/fr/banque/mouvements.html.*', '/(?P.*)/fr/banque/nr/nr_devbooster.aspx.*', OperationsPage) coming = URL('/(?P.*)/fr/banque/mvts_instance.cgi.*', ComingPage) card = URL('/(?P.*)/fr/banque/operations_carte.cgi.*', CardPage) noop = URL('/(?P.*)/fr/banque/CR/arrivee.asp.*', NoOperationsPage) info = URL('/(?P.*)/fr/banque/BAD.*', EmptyPage) transfert = URL('/(?P.*)/fr/banque/virements/vplw_vi.html', EmptyPage) transfert_2 = URL('/(?P.*)/fr/banque/virements/vplw_cmweb.aspx.*', TransfertPage) change_pass = URL('/(?P.*)/fr/validation/change_password.cgi', ChangePasswordPage) verify_pass = URL('/(?P.*)/fr/validation/verif_code.cgi.*', VerifCodePage) empty = URL('/(?P.*)/fr/banques/index.html', '/(?P.*)/fr/banque/paci_beware_of_phishing.*', '/(?P.*)/fr/validation/(?!change_password|verif_code).*', '/(?P.*)/fr/banque/paci_engine/static_content_manager.aspx', '/(?P.*)/fr/banque/DELG_Gestion.*', EmptyPage) por = URL('/(?P.*)/fr/banque/POR_ValoToute.aspx', '/(?P.*)/fr/banque/POR_SyntheseLst.aspx', PorPage) li = URL('/(?P.*)/fr/assurances/profilass.aspx\?domaine=epargne', '/(?P.*)/fr/assurances/consultation/WI_ASSAVI', LIAccountsPage) iban = URL('/(?P.*)/fr/banque/rib.cgi', IbanPage) new_home = URL('/fr/banque/pageaccueil.html', '/fr/banque/welcome_pack.html', NewHomePage) new_accounts = URL('/fr/banque/comptes-et-contrats.html', AccountsPage) new_operations = URL('/fr/banque/mouvements.cgi', '/fr/banque/mouvements.html', OperationsPage) new_por = URL('/fr/banque/POR_ValoToute.aspx', '/fr/banque/POR_SyntheseLst.aspx', PorPage) new_iban = URL('/fr/banque/rib.cgi', IbanPage) redirect = URL('/fr/banque/paci_engine/static_content_manager.aspx', RedirectPage) currentSubBank = None is_new_website = False __states__ = ['currentSubBank'] def do_login(self): # Clear cookies. self.do_logout() self.login.go() if not self.page.logged: self.page.login(self.username, self.password) if not self.page.logged or self.login_error.is_here(): raise BrowserIncorrectPassword() if not self.is_new_website: self.getCurrentSubBank() @need_login def get_accounts_list(self): if self.currentSubBank is None and not self.is_new_website: self.getCurrentSubBank() accounts = [] if not self.is_new_website: for a in self.accounts.stay_or_go(subbank=self.currentSubBank).iter_accounts(): accounts.append(a) self.iban.go(subbank=self.currentSubBank).fill_iban(accounts) self.por.go(subbank=self.currentSubBank).add_por_accounts(accounts) for acc in self.li.go(subbank=self.currentSubBank).iter_li_accounts(): accounts.append(acc) else: for a in self.new_accounts.stay_or_go().iter_accounts(): accounts.append(a) self.new_iban.go().fill_iban(accounts) self.new_por.go().add_por_accounts(accounts) return accounts def get_account(self, id): assert isinstance(id, basestring) for a in self.get_accounts_list(): if a.id == id: return a def getCurrentSubBank(self): # the account list and history urls depend on the sub bank of the user url = urlparse(self.url) self.currentSubBank = url.path.lstrip('/').split('/')[0] def list_operations(self, page_url): if page_url.startswith('/') or page_url.startswith('https'): self.location(page_url) elif not self.is_new_website: self.location('%s/%s/fr/banque/%s' % (self.BASEURL, self.currentSubBank, page_url)) else: self.location('%s/fr/banque/%s' % (self.BASEURL, page_url)) if self.li.is_here(): return self.page.iter_history() if not self.operations.is_here(): return iter([]) return self.pagination(lambda: self.page.get_history()) def get_history(self, account): transactions = [] last_debit = None if not account._link_id: return iter([]) for tr in self.list_operations(account._link_id): # to prevent redundancy with card transactions, we do not # store 'RELEVE CARTE' transaction. if not tr.raw.startswith('RELEVE CARTE'): transactions.append(tr) elif last_debit is None: last_debit = tr.date coming_link = self.page.get_coming_link() if self.operations.is_here() else None if coming_link is not None: for tr in self.list_operations(coming_link): transactions.append(tr) for card_link in account._card_links: for tr in self.list_operations(card_link): if last_debit is None or tr.date > last_debit: tr._is_coming = True transactions.append(tr) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return transactions def get_investment(self, account): if account._is_inv: if account.type == Account.TYPE_MARKET: if not self.is_new_website: self.por.go(subbank=self.currentSubBank) else: self.new_por.go() self.page.send_form(account) elif account.type == Account.TYPE_LIFE_INSURANCE: self.location(account._link_inv) return self.page.iter_investment() return iter([]) def transfer(self, account, to, amount, reason=None): if self.is_new_website: raise NotImplementedError() # access the transfer page self.transfert.go(subbank=self.currentSubBank) # fill the form form = self.page.get_form(xpath="//form[@id='P:F']") try: form['data_input_indiceCompteADebiter'] = self.page.get_from_account_index(account) form['data_input_indiceCompteACrediter'] = self.page.get_to_account_index(to) except ValueError as e: raise TransferError(e.message) form['[t:dbt%3adouble;]data_input_montant_value_0_'] = '%s' % str(amount).replace('.', ',') if reason is not None: form['[t:dbt%3astring;x(27)]data_input_libelleCompteDebite'] = reason form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite'] = reason del form['_FID_GoCancel'] del form['_FID_DoValidate'] form['_FID_DoValidate.x'] = str(randint(3, 125)) form['_FID_DoValidate.y'] = str(randint(3, 22)) form.submit() # look for known errors content = self.page.get_unicode_content() insufficient_amount_message = u'Le montant du virement doit être positif, veuillez le modifier' maximum_allowed_balance_message = u'Montant maximum autorisé au débit pour ce compte' if insufficient_amount_message in content: raise TransferError('The amount you tried to transfer is too low.') if maximum_allowed_balance_message in content: raise TransferError('The maximum allowed balance for the target account has been / would be reached.') # look for the known "all right" message ready_for_transfer_message = u'Confirmer un virement entre vos comptes' if ready_for_transfer_message not in content: raise TransferError('The expected message "%s" was not found.' % ready_for_transfer_message) # submit the confirmation form form = self.page.get_form(xpath="//form[@id='P:F']") del form['_FID_DoConfirm'] form['_FID_DoConfirm.x'] = str(randint(3, 125)) form['_FID_DoConfirm.y'] = str(randint(3, 22)) submit_date = datetime.now() form.submit() # look for the known "everything went well" message content = self.page.get_unicode_content() transfer_ok_message = u'Votre virement a été exécuté' if transfer_ok_message not in content: raise TransferError('The expected message "%s" was not found.' % transfer_ok_message) # We now have to return a Transfer object transfer = Transfer(submit_date.strftime('%Y%m%d%H%M%S')) transfer.amount = amount transfer.origin = account transfer.recipient = to transfer.date = submit_date return transfer weboob-1.1/modules/creditmutuel/favicon.png000066400000000000000000000034331265717027300211560ustar00rootroot00000000000000PNG  IHDR@@iqIDATx՛]hU(i1Ec`KZJ 5Qd RԊ1.*J)`%$*> #OU[(y1XWmAmIMjMdw>L&9prw9{s9!&OgQ P AR+MW)&@^@1ZakB7W򭂁ww 2.K+(QO(/CBDK`B,d'"`r5ÓaYAXR Pw5Py G`}qi$0a^mzǀ*_e'(g-/0^[_"$ZJb S6Ν{}j,:s),55YTMMIS = X6&ҕ+cg.Iґ#ҍ7J0/x!V`vWGF κJYbmɅ,r Kx\*S>ΟWUq@鷆0(ɓR6[,X>/  uw5A{TOOuR)kᅨD}}V ^l+鍎|,a|ҦYA%,o"!e2łϻ LΙ3rA*j*eRmtڜ?+ǥ_o/BBRS ZXn1s08hn6Ion?L)_ (XfTy緵'.]*K`CAD#ɍAJGqWݺKEA\u/}S8SIg)wmN ? Rqܑ{E(4:}QʍΟ7A]xAN9 &&G萎=33VfYFئOpI Сv9$+7˚'?V/voǎYٝ3gygó8bB.:k)-'sZ&~b%1}AJ &mpwC"l--vmua~رZ[˿,?ryll._yV[!g8< ̸yOCIf:9  pbb۠˚e2ݖx`a)>~)9#mV/BCC0=]>~xt@YKRݩu D3&:=D_j!?jr)'Y(9''Ү]K@A_/v^}uIrke7B>-o޸%W2I]]P~X2zzN=yC_ Uz]XgsY4T8]3@Aر39~=4/+{4X Ǡm]d,Jo-, 8Ppj0hrIRkV. 5߾uD,LmA.d~=| |9,ث,/M쯔dLwgϛ7Þ=av|9?O=liIy.ǮnA[RyYy=a`=Q]]ccq5~\^Qzp?/hZ7$[Z/5 %'IENDB`weboob-1.1/modules/creditmutuel/module.py000066400000000000000000000060451265717027300206640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal import string from weboob.capabilities.bank import CapBank, AccountNotFound, Recipient, Account from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import CreditMutuelBrowser __all__ = ['CreditMutuelModule'] class CreditMutuelModule(Module, CapBank): NAME = 'creditmutuel' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = u'Crédit Mutuel' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', regexp='^\d{1,13}\w$', masked=False), ValueBackendPassword('password', label='Mot de passe')) BROWSER = CreditMutuelBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): for account in self.browser.get_accounts_list(): yield account def get_account(self, _id): account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_coming(self, account): for tr in self.browser.get_history(account): if tr._is_coming: yield tr def iter_history(self, account): for tr in self.browser.get_history(account): if not tr._is_coming: yield tr def iter_investment(self, account): return self.browser.get_investment(account) def iter_transfer_recipients(self, ignored): for account in self.browser.get_accounts_list(): recipient = Recipient() recipient.id = account.id recipient.label = account.label yield recipient def transfer(self, account, to, amount, reason=None): if isinstance(account, Account): account = account.id account = str(account).strip(string.letters) to = str(to).strip(string.letters) try: assert account.isdigit() assert to.isdigit() amount = Decimal(amount) except (AssertionError, ValueError): raise AccountNotFound() return self.browser.transfer(account, to, amount, reason) weboob-1.1/modules/creditmutuel/pages.py000066400000000000000000000472221265717027300205000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . try: from urlparse import urlparse, parse_qs except ImportError: from urllib.parse import urlparse, parse_qs from decimal import Decimal, InvalidOperation import re from dateutil.relativedelta import relativedelta from weboob.browser.pages import HTMLPage, FormNotFound, LoggedPage from weboob.browser.elements import ListElement, ItemElement, SkipItem, method from weboob.browser.filters.standard import Filter, Env, CleanText, CleanDecimal, Field, TableCell, Regexp, Async, AsyncLoad, Date, ColumnNotFound from weboob.browser.filters.html import Link, Attr from weboob.exceptions import BrowserIncorrectPassword, ParseError from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account, Investment from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.date import parse_french_date class RedirectPage(LoggedPage, HTMLPage): def on_load(self): link = self.doc.xpath('//a[@id="P:F_1.R2:link"]') if link: self.browser.location(link[0].attrib['href']) class NewHomePage(LoggedPage, HTMLPage): def on_load(self): self.browser.is_new_website = True class LoginPage(HTMLPage): REFRESH_MAX = 10.0 def login(self, login, passwd): form = self.get_form(xpath='//form[contains(@name, "ident")]') form['_cm_user'] = login form['_cm_pwd'] = passwd form.submit() @property def logged(self): return self.doc.xpath('//div[@id="e_identification_ok"]') class LoginErrorPage(HTMLPage): pass class EmptyPage(LoggedPage, HTMLPage): REFRESH_MAX = 10.0 class UserSpacePage(LoggedPage, HTMLPage): pass class ChangePasswordPage(LoggedPage, HTMLPage): def on_load(self): raise BrowserIncorrectPassword('Please change your password') class VerifCodePage(LoggedPage, HTMLPage): def on_load(self): raise BrowserIncorrectPassword('Unable to login: website asks a code from a card') class TransfertPage(LoggedPage, HTMLPage): def get_account_index(self, direction, account): for div in self.doc.getroot().cssselect(".dw_dli_contents"): inp = div.cssselect("input")[0] if inp.name != direction: continue acct = div.cssselect("span.doux")[0].text.replace(" ", "") if account.endswith(acct): return inp.attrib['value'] else: raise ValueError("account %s not found" % account) def get_from_account_index(self, account): return self.get_account_index('data_input_indiceCompteADebiter', account) def get_to_account_index(self, account): return self.get_account_index('data_input_indiceCompteACrediter', account) def get_unicode_content(self): return self.content.decode(self.detect_encoding()) class AccountsPage(LoggedPage, HTMLPage): TYPES = {'C/C': Account.TYPE_CHECKING, 'Livret': Account.TYPE_SAVINGS, 'Pret': Account.TYPE_LOAN, 'Cic Immo': Account.TYPE_LOAN, 'Passeport Credit': Account.TYPE_LOAN, 'Compte Courant': Account.TYPE_CHECKING, 'Cpte Courant': Account.TYPE_CHECKING, 'Compte Cheque': Account.TYPE_CHECKING, 'Start': Account.TYPE_CHECKING, 'Compte Epargne': Account.TYPE_SAVINGS, 'Plan D\'Epargne': Account.TYPE_SAVINGS, 'Ldd': Account.TYPE_SAVINGS, 'Etalis': Account.TYPE_SAVINGS, } @method class iter_accounts(ListElement): item_xpath = '//tr' flush_at_end = True class item(ItemElement): klass = Account def condition(self): if len(self.el.xpath('./td')) < 2: return False first_td = self.el.xpath('./td')[0] return (("i" in first_td.attrib.get('class', '') or "p" in first_td.attrib.get('class', '')) and first_td.find('a') is not None) class Label(Filter): def filter(self, text): return text.lstrip(' 0123456789').title() class Type(Filter): def filter(self, label): for pattern, actype in AccountsPage.TYPES.iteritems(): if label.startswith(pattern): return actype return Account.TYPE_UNKNOWN obj_id = Env('id') obj_label = Label(CleanText('./td[1]/a/text() | ./td[1]/a/span[@class and not(contains(@class, "doux"))]')) obj_coming = Env('coming') obj_balance = Env('balance') obj_currency = FrenchTransaction.Currency('./td[2] | ./td[3]') obj__link_id = Link('./td[1]/a') obj__card_links = [] obj_type = Type(Field('label')) obj__is_inv = False obj__is_webid = Env('_is_webid') def parse(self, el): link = el.xpath('./td[1]/a')[0].get('href', '') if 'POR_SyntheseLst' in link: raise SkipItem() url = urlparse(link) p = parse_qs(url.query) if 'rib' not in p and 'webid' not in p: raise SkipItem() for td in el.xpath('./td[2] | ./td[3]'): try: balance = CleanDecimal('.', replace_dots=True)(td) except InvalidOperation: continue else: break else: raise ParseError('Unable to find balance for account %s' % CleanText('./td[1]/a')(el)) self.env['_is_webid'] = False if self.page.browser.is_new_website: id = CleanText('./td[1]/a/node()[contains(@class, "doux")]', replace=[(' ', '')])(el) else: if 'rib' in p: id = p['rib'][0] else: id = p['webid'][0] self.env['_is_webid'] = True # Handle cards if id in self.parent.objects: account = self.parent.objects[id] if not account.coming: account.coming = Decimal('0.0') account.coming += balance account._card_links.append(link) raise SkipItem() self.env['id'] = id # Handle real balances page = self.page.browser.open(link).page coming = page.find_amount(u"Opérations à venir") if page else None accounting = page.find_amount(u"Solde comptable") if page else None if accounting is not None and accounting + (coming or Decimal('0')) != balance: self.page.logger.warning('%s + %s != %s' % (accounting, coming, balance)) if accounting is not None: balance = accounting self.env['balance'] = balance self.env['coming'] = coming or NotAvailable class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^VIR(EMENT)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^PRLV (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?P.*) CARTE \d+ PAIEMENT CB\s+(?P
\d{2})(?P\d{2}) ?(.*)$'), FrenchTransaction.TYPE_CARD), (re.compile('^PAIEMENT PSC\s+(?P
\d{2})(?P\d{2}) (?P.*) CARTE \d+ ?(.*)$'), FrenchTransaction.TYPE_CARD), (re.compile('^RETRAIT DAB (?P
\d{2})(?P\d{2}) (?P.*) CARTE [\*\d]+'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^CHEQUE( (?P.*))?$'), FrenchTransaction.TYPE_CHECK), (re.compile('^(F )?COTIS\.? (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(REMISE|REM CHQ) (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] _is_coming = False class Pagination(object): def next_page(self): try: form = self.page.get_form('//form[@id="paginationForm"]') except FormNotFound: return text = CleanText.clean(form.el) m = re.search(u'(\d+) / (\d+)', text or '', flags=re.MULTILINE) if not m: return cur = int(m.group(1)) last = int(m.group(2)) if cur == last: return form['page'] = str(cur + 1) return form.request class OperationsPage(LoggedPage, HTMLPage): @method class get_history(Pagination, Transaction.TransactionsElement): head_xpath = '//table[@class="liste"]//thead//tr/th' item_xpath = '//table[@class="liste"]//tbody/tr' class item(Transaction.TransactionElement): condition = lambda self: len(self.el.xpath('./td')) >= 3 and len(self.el.xpath('./td[@class="i g" or @class="p g" or contains(@class, "_c1")]')) > 0 class OwnRaw(Filter): def __call__(self, item): el = TableCell('raw')(item)[0] # Remove hidden parts of labels: # hideifscript: Date de valeur XX/XX/XXXX # fd: Avis d'opéré for sub in el.xpath('.//*[has-class("hideifscript") or has-class("fd")]'): sub.drop_tree() parts = [txt.strip() for txt in el.itertext() if len(txt.strip()) > 0] # To simplify categorization of CB, reverse order of parts to separate # location and institution. if parts[0].startswith('PAIEMENT CB'): parts.reverse() return u' '.join(parts) obj_raw = Transaction.Raw(OwnRaw()) def find_amount(self, title): try: td = self.doc.xpath(u'//th[contains(text(), "%s")]/../td' % title)[0] except IndexError: return None else: return Decimal(FrenchTransaction.clean_amount(td.text)) def get_coming_link(self): try: a = self.doc.xpath(u'//a[contains(text(), "Opérations à venir")]')[0] except IndexError: return None else: return a.attrib['href'] class ComingPage(OperationsPage, LoggedPage): @method class get_history(Pagination, Transaction.TransactionsElement): head_xpath = '//table[@class="liste"]//thead//tr/th/text()' item_xpath = '//table[@class="liste"]//tbody/tr' col_date = u"Date de l'annonce" class item(Transaction.TransactionElement): obj__is_coming = True class CardPage(OperationsPage, LoggedPage): @method class get_history(Pagination, ListElement): class list_cards(ListElement): item_xpath = '//table[@class="liste"]/tbody/tr/td/a' class item(ItemElement): def __iter__(self): card_link = self.el.get('href') history_url = '%s/%s/fr/banque/%s' % (self.page.browser.BASEURL, self.page.browser.currentSubBank, card_link) page = self.page.browser.location(history_url).page for op in page.get_history(): yield op class list_history(Transaction.TransactionsElement): head_xpath = '//table[@class="liste"]//thead/tr/th' item_xpath = '//table[@class="liste"]/tbody/tr' col_commerce = u'Commerce' col_ville = u'Ville' def parse(self, el): label = CleanText('//div[contains(@class, "lister")]//p[@class="c"]')(el) if not label: return label = re.findall('(\d+ [^ ]+ \d+)', label)[-1] # use the trick of relativedelta to get the last day of month. self.env['debit_date'] = (parse_french_date(label) + relativedelta(day=31)).date() class item(Transaction.TransactionElement): condition = lambda self: len(self.el.xpath('./td')) >= 4 obj_raw = Transaction.Raw(Env('raw')) obj_type = Transaction.TYPE_CARD obj_date = Env('debit_date') obj_rdate = Transaction.Date(TableCell('date')) obj_amount = Env('amount') obj_original_amount = Env('original_amount') obj_original_currency = Env('original_currency') def parse(self, el): try: self.env['raw'] = "%s %s" % (CleanText().filter(TableCell('commerce')(self)[0].text), CleanText().filter(TableCell('ville')(self)[0].text)) except ColumnNotFound: self.env['raw'] = "%s" % (CleanText().filter(TableCell('commerce')(self)[0].text)) self.env['amount'] = CleanDecimal(replace_dots=True).filter(TableCell('credit')(self)[0].text) original_amount = TableCell('credit')(self)[0].xpath('./span')[0].text if original_amount: self.env['original_amount'] = CleanDecimal(replace_dots=True).filter(original_amount) self.env['original_currency'] = Account.get_currency(original_amount[1:-1]) else: self.env['original_amount'] = NotAvailable self.env['original_currency'] = NotAvailable class NoOperationsPage(OperationsPage, LoggedPage): def get_history(self): return iter([]) class LIAccountsPage(LoggedPage, HTMLPage): @method class iter_li_accounts(ListElement): item_xpath = '//table[@class]/tbody/tr[count(td)>4]' class item(ItemElement): klass = Account load_details = Attr('.//a', 'href') & AsyncLoad obj__link_id = Async('details', Link('//li/a[contains(text(), "Mouvements")]')) obj__link_inv = Link('./td[1]/a') obj_id = CleanText('./td[2]', replace=[(' ', '')]) obj_label = CleanText('./td[1]') obj_balance = CleanDecimal('./td[3]', replace_dots=True) obj_currency = FrenchTransaction.Currency('./td[4]') obj__card_links = [] obj_type = Account.TYPE_LIFE_INSURANCE obj__is_inv = True @method class iter_history(ListElement): item_xpath = '//table[@class="liste"]/tbody/tr' class item(ItemElement): klass = FrenchTransaction obj_date = Date(CleanText('./td[1]')) obj_rdate = Date(CleanText('./td[1]')) obj_raw = CleanText('./td[2]') obj_amount = CleanDecimal('./td[4]', replace_dots=True) obj_original_currency = FrenchTransaction.Currency('./td[4]') obj_type = Transaction.TYPE_BANK obj__is_coming = False @method class iter_investment(ListElement): item_xpath = '//table[@class="liste"]/tbody/tr[count(td)>7]' class item(ItemElement): klass = Investment obj_label = CleanText('./td[1]') obj_unitprice = CleanDecimal('./td[4]', default=NotAvailable, replace_dots=True) obj_vdate = Date(CleanText('./td[5]', replace=[('-', '')]), default=NotAvailable) obj_unitvalue = CleanDecimal('./td[6]', default=NotAvailable, replace_dots=True) obj_quantity = CleanDecimal('./td[7]', default=NotAvailable, replace_dots=True) obj_valuation = CleanDecimal('./td[8]', default=Decimal(0), replace_dots=True) def obj_code(self): return CleanText('./td[2]', replace=[('-', '')])(self) or NotAvailable class PorPage(LoggedPage, HTMLPage): def find_amount(self, title): return None def add_por_accounts(self, accounts): for ele in self.doc.xpath('//select[contains(@name, "POR_Synthese")]/option'): for a in accounts: if a.id.startswith(ele.attrib['value']): a._is_inv = True a.type = Account.TYPE_MARKET self.fill(a) break else: acc = Account() acc.id = ele.attrib['value'] if acc.id == '9999': # fake account continue acc.label = unicode(re.sub("\d", '', ele.text).strip()) acc._link_id = None acc.type = Account.TYPE_MARKET acc._is_inv = True self.fill(acc) accounts.append(acc) def fill(self, acc): self.send_form(acc) ele = self.browser.page.doc.xpath('.//table[@class="fiche bourse"]')[0] balance = CleanDecimal(ele.xpath('.//td[contains(@id, "Valorisation")]'), default=Decimal(0), replace_dots=True)(ele) acc.balance = balance + acc.balance if acc.balance else balance acc.currency = FrenchTransaction.Currency('.')(ele) acc.valuation_diff = CleanDecimal(ele.xpath('.//td[contains(@id, "Variation")]'), default=Decimal(0), replace_dots=True)(ele) def send_form(self, account): form = self.get_form(name="frmMere") form['POR_SyntheseEntete1$esdselLstPor'] = re.sub('\D', '', account.id) form.submit() @method class iter_investment(ListElement): item_xpath = '//table[@id="bwebDynamicTable"]/tbody/tr[not(@id="LigneTableVide")]' class item(ItemElement): klass = Investment obj_label = CleanText('.//td[1]/a') obj_code = CleanText('.//td[1]/a/@title') & Regexp(pattern='^([^ ]+)') obj_quantity = CleanDecimal('.//td[2]', default=Decimal(0), replace_dots=True) obj_unitprice = CleanDecimal('.//td[3]', default=Decimal(0), replace_dots=True) obj_unitvalue = CleanDecimal('.//td[4]', default=Decimal(0), replace_dots=True) obj_valuation = CleanDecimal('.//td[5]', default=Decimal(0), replace_dots=True) obj_diff = CleanDecimal('.//td[6]', default=Decimal(0), replace_dots=True) class IbanPage(LoggedPage, HTMLPage): def fill_iban(self, accounts): for ele in self.doc.xpath('//table[@class="liste"]/tr[@class]/td[1]'): for a in accounts: if a._is_webid: if a.label in CleanText('.//div[1]')(ele).title(): a.iban = CleanText('.//div[5]/em', replace=[(' ', '')])(ele) elif self.browser.is_new_website: if a.id in CleanText('.//div[5]/em', replace=[(' ','')])(ele).title(): a.iban = CleanText('.//div[5]/em', replace=[(' ', '')])(ele) else: if a.id[:-3] in CleanText('.//div[5]/em', replace=[(' ','')])(ele).title(): a.iban = CleanText('.//div[5]/em', replace=[(' ', '')])(ele) weboob-1.1/modules/creditmutuel/test.py000066400000000000000000000017641265717027300203610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class CreditMutuelTest(BackendTest): MODULE = 'creditmutuel' def test_crmut(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/cuisineaz/000077500000000000000000000000001265717027300163045ustar00rootroot00000000000000weboob-1.1/modules/cuisineaz/__init__.py000066400000000000000000000014371265717027300204220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import CuisineazModule __all__ = ['CuisineazModule'] weboob-1.1/modules/cuisineaz/browser.py000066400000000000000000000025561265717027300203510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import RecipePage, ResultsPage __all__ = ['CuisineazBrowser'] class CuisineazBrowser(PagesBrowser): BASEURL = 'http://www.cuisineaz.com' search = URL('recettes/recherche_v2.aspx\?recherche=(?P.*)', ResultsPage) recipe = URL('recettes/(?P<_id>.*).aspx', RecipePage) def iter_recipes(self, pattern): return self.search.go(pattern=pattern.replace(' ', '-')).iter_recipes() def get_recipe(self, _id, obj=None): return self.recipe.go(_id=_id).get_recipe(obj=obj) def get_comments(self, _id): return self.recipe.go(_id=_id).get_comments() weboob-1.1/modules/cuisineaz/favicon.png000066400000000000000000000025301265717027300204370ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME95oIDATxo[učKmRGnڦ"!I[)/F @`,`9ivX"h*heA$G$nl'H=%k;Y%iK X4sɀjCW݌FF{2F(z/h5bdO=SVQ+ufEY Vs ^n'Xqz9fwR"P b15%wc]ZkV!Sv  Ywy3^:dLS^6_W9E N:##+- ?eҖnalvӂ=g"H[ 7 @V\3爓&ܔ([apU#T (sH89=uw_q2`HNLMGi\~%h!y&k(SٯMZP!{ؘBZ7-jk%LKInR@uTϛWkw_K-[pƤE!fGt" pj;ڵ:h.wacѺ{,'mO6+UV"pƔ%yRUPQPƿ{'\";hhE݌@F%.@v6ZMV AVZrN٧SƧ}D. from weboob.capabilities.recipe import CapRecipe, Recipe from weboob.tools.backend import Module from .browser import CuisineazBrowser import unicodedata __all__ = ['CuisineazModule'] def strip_accents(s): return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn') class CuisineazModule(Module, CapRecipe): NAME = 'cuisineaz' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = u'Cuisine AZ French recipe website' LICENSE = 'AGPLv3+' BROWSER = CuisineazBrowser def get_recipe(self, id): return self.browser.get_recipe(id) def iter_recipes(self, pattern): # the search form does that so the url is clean of special chars # we go directly on search results by the url so we strip it too return self.browser.iter_recipes(strip_accents(unicode(pattern)).encode('utf-8')) def fill_recipe(self, recipe, fields): if 'nb_person' in fields or 'instructions' in fields: recipe = self.browser.get_recipe(recipe.id, recipe) if 'comments' in fields: recipe.comments = list(self.browser.get_comments(recipe.id)) return recipe OBJECTS = { Recipe: fill_recipe, } weboob-1.1/modules/cuisineaz/pages.py000066400000000000000000000105431265717027300177600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.recipe import Recipe, Comment from weboob.capabilities.base import NotAvailable from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, method, ListElement from weboob.browser.filters.standard import CleanText, Regexp, Env, Time from weboob.browser.filters.html import XPath, CleanHTML import re import datetime class CuisineazDuration(Time): klass = datetime.timedelta _regexp = re.compile(r'((?P\d+) h)?((?P\d+) min)?(?P\d+)?') kwargs = {'hours': 'hh', 'minutes': 'mm', 'seconds': 'ss'} class ResultsPage(HTMLPage): """ Page which contains results as a list of recipies """ @pagination @method class iter_recipes(ListElement): item_xpath = '//div[@id="divRecette"]' def next_page(self): next = CleanText('//li[@class="next"]/span/a/@href', default=None)(self) if next: return next class item(ItemElement): klass = Recipe def condition(self): return Regexp(CleanText('./div[has-class("searchTitle")]/h2/a/@href'), '/recettes/(.*).aspx', default=None)(self.el) obj_id = Regexp(CleanText('./div[has-class("searchTitle")]/h2/a/@href'), '/recettes/(.*).aspx') obj_title = CleanText('./div[has-class("searchTitle")]/h2/a') obj_thumbnail_url = CleanText('./div[has-class("searchImg")]/span/img[@data-src!=""]/@data-src|./div[has-class("searchImg")]/div/span/img[@src!=""]/@src', default=None) obj_short_description = CleanText('./div[has-class("searchIngredients")]') class RecipePage(HTMLPage): """ Page which contains a recipe """ @method class get_recipe(ItemElement): klass = Recipe obj_id = Env('_id') obj_title = CleanText('//div[@id="ficheRecette"]/h1') obj_picture_url = CleanText('//img[@id="shareimg" and @src!=""]/@src', default=None) obj_thumbnail_url = CleanText('//img[@id="shareimg" and @src!=""]/@src', default=None) def obj_preparation_time(self): _prep = CuisineazDuration(CleanText('//span[@id="ctl00_ContentPlaceHolder_LblRecetteTempsPrepa"]'))(self) return int(_prep.total_seconds() / 60) def obj_cooking_time(self): _cook = CuisineazDuration(CleanText('//span[@id="ctl00_ContentPlaceHolder_LblRecetteTempsCuisson"]'))(self) return int(_cook.total_seconds() / 60) def obj_nb_person(self): nb_pers = CleanText('//span[@id="ctl00_ContentPlaceHolder_LblRecetteNombre"]')(self) return [nb_pers] if nb_pers else NotAvailable def obj_ingredients(self): ingredients = [] for el in XPath('//div[@id="ingredients"]/ul/li')(self): ingredients.append(CleanText('.')(el)) return ingredients obj_instructions = CleanHTML('//div[@id="preparation"]/span[@class="instructions"]') @method class get_comments(ListElement): item_xpath = '//div[@class="comment pb15 row"]' class item(ItemElement): klass = Comment obj_author = CleanText('./div[has-class("comment-left")]/div/div/div[@class="fs18 txtcaz mb5 first-letter"]') obj_text = CleanText('./div[has-class("comment-right")]/div/p') obj_id = CleanText('./@id') def obj_rate(self): return len(XPath('./div[has-class("comment-right")]/div/div/div/span/span[@class="icon icon-star"]')(self)) weboob-1.1/modules/cuisineaz/test.py000066400000000000000000000022721265717027300176400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest import itertools class CuisineazTest(BackendTest): MODULE = 'cuisineaz' def test_recipe(self): recipes = list(itertools.islice(self.backend.iter_recipes(u'purée'), 0, 20)) assert len(recipes) for recipe in recipes: full_recipe = self.backend.get_recipe(recipe.id) assert full_recipe.instructions assert full_recipe.ingredients assert full_recipe.title weboob-1.1/modules/dailymotion/000077500000000000000000000000001265717027300166425ustar00rootroot00000000000000weboob-1.1/modules/dailymotion/__init__.py000066400000000000000000000001071265717027300207510ustar00rootroot00000000000000from .module import DailymotionModule __all__ = ['DailymotionModule'] weboob-1.1/modules/dailymotion/browser.py000066400000000000000000000051521265717027300207020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from urllib import quote_plus from weboob.deprecated.browser import Browser from weboob.deprecated.browser.decorators import id2url from .pages import IndexPage, VideoPage, KidsVideoPage from .video import DailymotionVideo __all__ = ['DailymotionBrowser'] class DailymotionBrowser(Browser): DOMAIN = 'www.dailymotion.com' ENCODING = None PAGES = {r'http://[w\.]*dailymotion\.com/1': IndexPage, r'http://[w\.]*dailymotion\.com/[a-z\-]{2,5}/1': IndexPage, r'http://[w\.]*dailymotion\.com/[a-z\-]{2,5}/(\w+/)?search/.*': IndexPage, r'http://[w\.]*dailymotion\.com/video/(?P.+)': VideoPage, r'http://kids\.dailymotion\.com/(?P[^\/#]+)#(.*&)?video=(?P.+)': KidsVideoPage, } @id2url(DailymotionVideo.id2url) def get_video(self, url, video=None): # clear cookies. # this is required in some weird cases, namely *interactive* videoob usage # to avoid getting 403 errors when getting the video URL after a search. # # better control of this issue would be nice (especially if we support user login) self._ua_handlers['_cookies'].cookiejar.clear() # translate embed URLs url = url.replace('dailymotion.com/swf/', 'dailymotion.com/video/') self.location(url) return self.page.get_video(video) def home(self): self.location('/1') def search_videos(self, pattern, sortby): pattern = pattern.replace('/', '').encode('utf-8') if sortby is None: url = '/en/search/%s/1' % quote_plus(pattern) else: url = '/en/%s/search/%s/1' % (sortby, quote_plus(pattern)) self.location(url) assert self.is_on_page(IndexPage) return self.page.iter_videos() def latest_videos(self): self.home() assert self.is_on_page(IndexPage) return self.page.iter_videos() weboob-1.1/modules/dailymotion/favicon.png000066400000000000000000000020451265717027300207760ustar00rootroot00000000000000PNG  IHDR@@APLTE !!"#       ""$ % '"(#)#*$*%,&.(/)4-;3 ;:<4 =5 ?7 LKMLNMOE ONRH UJ USYMYN_[dWgbk]n`ohum{lqx st}~êɰ ʰ ˱ ϴ и"$$%$&&'''''''(bfbƊ3Lb%,gtRNS>,IDATXíՉRA$ r "xx EEv+=JR_:3Y0u9p,^KJEBvY*Nת8 (]Ib!k>**%tU*P-RǪV tZ4%T4 ȇʆu+Svp4t̛Dm6]*6ο_ GO96?QK6*JLy |$Z?*R"uY02קR LJ. Wy3 9@(P|~/ C, ȀU86;~s !C`0Np\pvrhcD>Z1pElO` ! :ςއVd5:FEwWA cϧټ&ojE#t ]-#ި!$3( g gy7 ֩20Pxްyv@vr~b>cšG~9̸"}l>frIENDB`weboob-1.1/modules/dailymotion/module.py000066400000000000000000000054411265717027300205050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound from weboob.tools.backend import Module from .browser import DailymotionBrowser from .video import DailymotionVideo __all__ = ['DailymotionModule'] class DailymotionModule(Module, CapVideo, CapCollection): NAME = 'dailymotion' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'Dailymotion video streaming website' LICENSE = 'AGPLv3+' BROWSER = DailymotionBrowser def get_video(self, _id): with self.browser: return self.browser.get_video(_id) SORTBY = ['relevance', 'rated', 'visited', None] def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): with self.browser: return self.browser.search_videos(pattern, self.SORTBY[sortby]) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields with self.browser: video = self.browser.get_video(video.id, video) if 'thumbnail' in fields and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest']) if collection.split_path == [u'latest']: for video in self.browser.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest']: collection.title = u'Latest Dailymotion videos' return raise CollectionNotFound(collection.split_path) OBJECTS = {DailymotionVideo: fill_video} weboob-1.1/modules/dailymotion/pages.py000066400000000000000000000206721265717027300203220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.json import json import datetime import re import urllib import urlparse import mechanize from weboob.capabilities import NotAvailable from weboob.capabilities.image import BaseImage from weboob.tools.html import html2text from weboob.deprecated.browser import Page, BrokenPageError from .video import DailymotionVideo class IndexPage(Page): def iter_videos(self): for div in self.parser.select(self.document.getroot(), 'div.sd_video_listitem'): smalldiv = self.parser.select(div, 'div.sd_video_preview', 1) _id = smalldiv.attrib.get('data-id', None) if _id is None: self.browser.logger.warning('Unable to find the ID of a video') continue video = DailymotionVideo(_id) video.title = unicode(self.parser.select(div, 'div a img', 1).attrib['title']).strip() video.author = unicode(self.parser.select(div, 'a.link-on-hvr', 1).text).strip() video.description = NotAvailable try: parts = self.parser.select(div, 'div.badge-duration', 1).text.split(':') except BrokenPageError: # it's probably a live, np. video.duration = NotAvailable else: if len(parts) == 1: seconds = parts[0] hours = minutes = 0 elif len(parts) == 2: minutes, seconds = parts hours = 0 elif len(parts) == 3: hours, minutes, seconds = parts else: raise BrokenPageError('Unable to parse duration %r' % self.parser.select(div, 'div.duration', 1).text) video.duration = datetime.timedelta(hours=int(hours), minutes=int(minutes), seconds=int(seconds)) url = unicode(self.parser.select(div, 'img.preview', 1).attrib['data-src']) # remove the useless anti-caching url = re.sub('\?\d+', '', url) video.thumbnail = BaseImage(url) video.thumbnail.url = video.thumbnail.id video.set_empty_fields(NotAvailable, ('url',)) yield video def get_rate(self, div): m = re.match('width: *(\d+)px', div.attrib['style']) if m: return int(m.group(1)) else: self.browser.logger.warning('Unable to parse rating: %s' % div.attrib['style']) return 0 class VideoPage(Page): def get_video(self, video=None): if video is None: video = DailymotionVideo(self.group_dict['id']) self.set_video_metadata(video) self.set_video_url(video) video.set_empty_fields(NotAvailable) # Dailymotion video url is protected by a redirection with cookie verification # so we need to use the "play_proxy" method using urllib2 proxy streaming to handle this video._play_proxy = True return video def set_video_metadata(self, video): head = self.parser.select(self.document.getroot(), 'head', 1) video.title = unicode(self.parser.select(head, 'meta[property="og:title"]', 1).get("content")).strip() video.author = unicode(self.parser.select(head, 'meta[name="author"]', 1).get("content")).strip() url = unicode(self.parser.select(head, 'meta[property="og:image"]', 1).get("content")).strip() # remove the useless anti-caching url = re.sub('\?\d+', '', url) video.thumbnail = BaseImage(url) video.thumbnail.url = video.thumbnail.id try: parts = self.parser.select(head, 'meta[property="video:duration"]', 1).get("content").strip().split(':') except BrokenPageError: # it's probably a live, np. video.duration = NotAvailable else: if len(parts) == 1: seconds = parts[0] hours = minutes = 0 elif len(parts) == 2: minutes, seconds = parts hours = 0 elif len(parts) == 3: hours, minutes, seconds = parts else: raise BrokenPageError('Unable to parse duration %r' % parts) video.duration = datetime.timedelta(hours=int(hours), minutes=int(minutes), seconds=int(seconds)) try: video.description = html2text(self.parser.select(head, 'meta[property="og:description"]', 1).get("content")).strip() or unicode() except BrokenPageError: video.description = u'' def set_video_url(self, video): embed_page = self.browser.readurl('http://www.dailymotion.com/embed/video/%s' % video.id) m = re.search('playerV5\s*=\s*dmp\.create\([^,]+?,\s*({.+?})\);', embed_page) if not m: raise BrokenPageError('Unable to find information about video') info = json.loads(m.group(1)) qualities = info.get('metadata').get('qualities') for key in ['2160', '1440', '1080', '720', '480', '380', '240']: if qualities.get(key): max_quality = key break else: raise BrokenPageError(u'Unable to extract video URL') video.url = unicode(qualities.get(max_quality)[0].get('url')) class KidsVideoPage(VideoPage): CONTROLLER_PAGE = 'http://kids.dailymotion.com/controller/Page_Kids_KidsUserHome?%s' def set_video_metadata(self, video): # The player html code with all the required information is loaded # after the main page using javascript and a special XmlHttpRequest # we emulate this behaviour from_request = self.group_dict['from'] query = urllib.urlencode({ 'from_request': from_request, 'request': '/video/%s?get_video=1' % video.id }) request = mechanize.Request(KidsVideoPage.CONTROLLER_PAGE % query) # This header is mandatory to have the correct answer from dailymotion request.add_header('X-Requested-With', 'XMLHttpRequest') player_html = self.browser.readurl(request) try: m = re.search('. from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo from random import choice class DailymotionTest(BackendTest): MODULE = 'dailymotion' # Not easy to find a kids video which will always be there # This might break in the future KIDS_VIDEO_TITLE = 'Telmo et Tula' def test_search(self): l = list(self.backend.search_videos('chirac')) self.assertTrue(len(l) > 0) v = choice(l) self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) self.backend.browser.openurl(v.url) def test_latest(self): l = list(self.backend.iter_resources([BaseVideo], [u'latest'])) assert len(l) v = choice(l) self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) def test_kids_video(self): l = list(self.backend.search_videos(DailymotionTest.KIDS_VIDEO_TITLE)) self.assertTrue(len(l) > 0) for elt in l[:10]: video_id = elt.id video = self.backend.get_video(video_id) self.assertIsNotNone(video.title) if DailymotionTest.KIDS_VIDEO_TITLE in video.title: self.assertTrue(video.url and video.url.startswith('http://'), 'URL for video "%s" not found: %s' % (video.id, video.url)) return self.fail("Can't find test video '%s' in kids.dailymotion.com video " "on dailymotion, maybe the test video should be changed." % DailymotionTest.KIDS_VIDEO_TITLE) weboob-1.1/modules/dailymotion/video.py000066400000000000000000000020151265717027300203200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import BaseVideo class DailymotionVideo(BaseVideo): def __init__(self, *args, **kwargs): BaseVideo.__init__(self, *args, **kwargs) self.ext = u'mp4' @classmethod def id2url(cls, _id): return 'http://www.dailymotion.com/video/%s' % _id weboob-1.1/modules/delubac/000077500000000000000000000000001265717027300157115ustar00rootroot00000000000000weboob-1.1/modules/delubac/__init__.py000066400000000000000000000014411265717027300200220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Noe Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import DelubacModule __all__ = ['DelubacModule'] weboob-1.1/modules/delubac/browser.py000066400000000000000000000044111265717027300177460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import time from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities.bank import AccountNotFound from weboob.capabilities.base import find_object from .pages import LoginPage, LoginSuccessPage, MenuPage, AccountsPage, HistoryPage __all__ = ['DelubacBrowser'] class DelubacBrowser(LoginBrowser): BASEURL = 'https://e.delubac.com' home = URL('/es@b/fr/esab.jsp') login = URL('/es@b/fr/codeident.jsp', LoginPage) login_success = URL('/es@b/servlet/internet0.ressourceWeb.servlet.Login', LoginSuccessPage) menu = URL('/es@b/fr/menuConnecte1.jsp\?c&deploye=false&pulseMenu=false&styleLien=false&dummyDate=(?P.*)', MenuPage) accounts = URL('/es@b/servlet/internet0.ressourceWeb.servlet.EsabServlet.*', AccountsPage) history = URL('/es@b/servlet/internet0.ressourceWeb.servlet.ListeDesMouvementsServlet.*', HistoryPage) def do_login(self): self.home.go() self.login.go() self.page.login(self.username, self.password) if self.login.is_here(): raise BrowserIncorrectPassword() @need_login def iter_accounts(self): self.menu.go(date=int(time.time()*1000)) self.location(self.page.accounts_url) return self.page.get_list() @need_login def get_account(self, _id): return find_object(self.iter_accounts(), id=_id, error=AccountNotFound) @need_login def iter_history(self, account): self.location(account._link) return self.page.get_transactions() weboob-1.1/modules/delubac/favicon.png000066400000000000000000000053531265717027300200520ustar00rootroot00000000000000PNG  IHDR@@% pHYs76vtIME )5_ IDAThZkTSW'7 Ix^3>7߿q-Ru'f͈]Aޮ՗!c=tgPa~"==:[:<̲um?Yx o>\kòXJ$4:-3ђ%_cA%N.NL{YqJqxzbʂlgM@74/&抅ƇE|`oOS'PT.4*~bKb1Ύޮw*&`siQƺ췠hhg/vVؼ/g/,:0p.Wm'MH\/axJLP A˛K`KCE}qJr\LnjBF@d9[gkP GO+i64ArE{%p_ R>O۩A`Q:apv3qdΞ.5T4T, w_[o; GjjH*] _'G$F(RQgO熊zb;Fu\l-Wf%RbbsMWgA&0; 9bX^8cptu0dqT5*M)؛LQ&7|xL7` [ưS_JAu_JAT#.~0Ti\0E_N픉 17?x!OFi,{zH[$Rr]cOW/W8(Kg:S^3Rݸppר5T_Ĝeo cMªsY@8Mß+.>oOJ,K/V6RioAƆeC-cRee[K"Jwi:u/\x8<`9R~4/M rgl]AШ50./ېbS s88Do2wt8nvlsÜ@`d6$j E_=02[b@h|~%x_ÇPKP_Xk ?<H393{l\=54Zl@;s̥3 ~WUq*+4>lրo2`waBK\''k@G-N4$;h.g>PP _0wL7JCT!Re r{OeEI=YjeYf n>nDfCc`{yEDTA7m  M0*v:^WVg,E@湛 *T$2p?bWO_"7!ܩ-y(1K2x0k3nXوۍFA g_ aš@l׍lݐ߾Id?뿶p]F!:MaEH9r,*8L|j]P ɓ IQ_γaY{*Mj_ S*0\!*D&==x88M>Τ뺱P3-M-p ryH #rt&-My 4~lG\D fW6RCܭs(U])3t= @DU/ b=yIߒN|tkjZoY~~PO4@:0v {BY)9c~jHw^㛙f䤆QO9qbP[VSCSuM9$zQSv,qZ'(YO߬. from weboob.capabilities.bank import CapBank from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import DelubacBrowser __all__ = ['DelubacModule'] class DelubacModule(Module, CapBank): NAME = 'delubac' DESCRIPTION = u'Banque Delubac & Cie' MAINTAINER = u'Noe Rubinstein' EMAIL = 'nru@budget-insight.com' VERSION = '1.1' BROWSER = DelubacBrowser CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe', regexp='^\d+$')) def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.iter_accounts() def get_account(self, _id): return self.browser.get_account(_id) def iter_history(self, account, coming=False): return self.browser.iter_history(account) weboob-1.1/modules/delubac/pages.py000066400000000000000000000230261265717027300173650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from io import BytesIO from weboob.capabilities.bank import Account from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ListElement, ItemElement, method from weboob.exceptions import ParseError from weboob.tools.captcha.virtkeyboard import GridVirtKeyboard from weboob.browser.filters.standard import CleanText, CleanDecimal, Field, Format, Date from weboob.browser.filters.html import Link from weboob.tools.capabilities.bank.transactions import FrenchTransaction class Transaction(FrenchTransaction): PATTERNS = [(re.compile(u'^CARTE DU'), FrenchTransaction.TYPE_CARD), (re.compile(u'^VIR (SEPA)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(u'^Vir (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(u'^VIREMENT DE (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(u'^CHQ (?P.*)'), FrenchTransaction.TYPE_CHECK), (re.compile(u'^PRLV SEPA (?P.*)'), FrenchTransaction.TYPE_ORDER), ] class DelubacVirtKeyboard(GridVirtKeyboard): symbols = {'0': ('ad0ae6278e58bf2300cb7e0b87729e4d', '33e6fecddeb02ad3756570b541320914', '9f47d540a8bf89056106bc2c06fdea2e', '176c63721c61da6cbae04ed95b36a343', '6af3ed27e718a93acc8923abebef4734'), '1': ('ba6ca06344687bd2337e2bfb39e2378a', 'cef70da6fb76b8bb90c025d4e62db7f6'), '2': ('c442cd1cee0c95d8423665983e9e45b7', '38aac4c0dcc1c40bfa0173bb2fc959f6', '8be33fe7de693d8d1404c0b51ce6f893', '85bf89cc03d7d772f7b0b4aa9a7897c6', '955423582ae4cde07b0831eee879c068', '19712acd76beedef3038b131ee9b5f19', '34b0276d52b8bdc2e68c98f1bac8fecc'), '3': ('f5ebe3bdfc645210c38f1b89bde6b732', '0ff42e4481af10901213636a654d56ab', '3b6b94bc9748a881fd0692f5a8c4a791', '38809719796e812285e8da365268336d', '31ee44b350e8a062fcde5c8c6e8e1dbf', '84012a1fe9c2809fb348d3dcd362d15a', '4e076b4b60852f8e8fb40ac751a8c7a5'), '4': ('6d194520cb4d7e5ba0c24fa6dad21285', '08e40532e7c4207239c543576a2fa7b1', '4f7267f5879ba5fdda61ff6ac7897d75', '7a5d5abb743d13a036a7d8582576b284', '59767e1a982ee4212d795acf1f3bda3d', '9f796703a309453d5f4c0f3baddf2f0d', '9d52b25d92866001c6035ea3abfc04ed', 'b6fe068a99e5b93af2348947ddeddf5c', '9a021f8eb7ab9091aeba512481de3301'), '5': ('b3d5990972b82abd9e8c049457794ab1', '4c761e7b65eed3baf899960e0ba0d131', '729a2baf278fe557ee54f532b8263a98', '634e8b3ec904f219b858990a739b8283', '55138402b60e3d3027e1d26b078b73f9', '7a03617f129806672ae5c4b478535b29', 'c4bb4958271d61d098bd239e403e9ecc'), '6': ('c69e8ad49ffa359ca7f77658c090e1dd', 'e0294f0af8037d544f5b4729931453f3', '359f46ac7dc0d8dee18831981c863a73', '6752eb433a0f72312f19b24f69ea6adb', '50e2c34749b3aa4010db73d108e241ae', '3fdc463cfea86a565151059d8d114123', '9e321e0d31a1e54510b51ae5c2e91749', 'fab5e1970f78c521a94d8aa52a88075a', 'b620c174da8d74d04139b0d334d064b5', 'd83eff07ba513c875dc42ec87a441989', '67b214138a7efe3f600adaea1d1cffbc', '014dc575b0a980b0037cf1e8f5ed9987', '0994aab1f56f9427d1f5dbba27eb3266', 'bda8a78783bddfbb8a3bc6b03ba1c449', '1ddb303b52769096582095e70ef481a4', '344642e1a97750328f058e1dcb4cd6e9'), '7': ('57b179554275be15562824284395c833', '687f5020c59bdde6edac72917cbbebc2', '6752eb433a0f72312f19b24f69ea6adb', 'ea6eec45008ddb61cd830bd690a3d55f'), '8': ('394752d62aea07c5c5f5650b3e404e88', 'dc72f59b61e18dd313e16d4ee0bb8207', '06297c98471f5a06a9c180dbb8b82305', '8349e6ae068167ee565721a34a4bcc9f', '1347687d61f0fb4c9c0601a9ff4c7d60', '5dd319ab0d0dd40730b90abdf2ad27c4', '70e543a626496f719f837e57a798c288', 'ab34d9ff8f1504e949e06d7c51049837', 'bafa9bc81270863eeaba9267412ce854', '27f6b4127a02026ce5bb42a7686a05de', '4ceccf7b8f24316465838c5f97bc06c8', 'bef000f56d1907697a6e0922b2a5184b', '55b2820aec3e9cb8af88e50068620a73', 'f6722d76cca62ebb150c1b79338c2325', 'c74c0c5231a656b95b407e995793b80a', '3398b5e93b96c90557406ca461a55da0', '80cd1440a3b2a4b8f3480ee25e3e4c5d', 'b6429ded63ab3e6d62fb9542dc76a42d'), '9': ('d040ced0ae3a55365fe46b498316d734', '0f518491d0a16f91bd6e4df1f9db47b2', '59a08f18d72d52eed250cc6a88aebd40', '0e474a38e1c330613e406bf738723f01', '4bfe94b095e8c4b391abf42c0a4a8dc6', '1810d4ce38929acaa8a788a35b9b5e5d', 'e19ea6338bcbbcaf3e40017bea21c770', '2f2b034747480bdc583335a43b5cdcb7', '15497fc6422cd626d4d3639dbb01aa35')} margin = 1 color = (0xff,0xf7,0xff) nrow = 4 ncol = 4 def __init__(self, browser, session, codes): f = BytesIO(browser.open('%s.jpg' % session).content) super(DelubacVirtKeyboard, self).__init__(range(16), self.ncol, self.nrow, f, self.color) self.check_symbols(self.symbols, browser.responses_dirname) self.codes = codes def check_color(self, pixel): for p in pixel: if p < 0xd0: return False return True def get_string_code(self, string): res = [] ndata = self.nrow * self.ncol for nbchar, c in enumerate(string): index = self.get_symbol_code(self.symbols[c]) res.append(self.codes[(nbchar * ndata) + index]) return ','.join(res) class LoginPage(HTMLPage): def login(self, username, password): for script in self.doc.xpath('//script'): m = re.search("session='([^']+)'", script.text or '') if m: session = m.group(1) m = re.search('codes = "([^"]+)"', script.text or '') if m: codes = m.group(1).split(',') vk = DelubacVirtKeyboard(self.browser, session, codes) form = self.get_form(name='codeident') form['identifiant'] = username form['motpasse'] = vk.get_string_code(password) form['CodSec'] = vk.get_string_code(password) form['modeClavier'] = '1' form['identifiantDlg'] = '' form.submit() class LoginSuccessPage(HTMLPage): logged = True class MenuPage(HTMLPage): logged = True def get_link(self, name): for script in self.doc.xpath('//script'): m = re.search(r"""\["%s",'([^']+)'""" % name, script.text or '', flags=re.MULTILINE) if m: return m.group(1) raise ParseError('Link %r not found' % name) @property def accounts_url(self): return self.get_link(u'Comptes') class AccountsPage(HTMLPage): logged = True is_here = u'//title[text() = "Solde de chacun de vos comptes"]' @method class get_list(ListElement): item_xpath = '//tr' class item(ItemElement): klass = Account def condition(self): if len(self.el.xpath('./td')) < 6: return False return True obj__title = CleanText('td[@id="idCompteIntitule"]') obj__nature = CleanText('td[@id="idCompteNature"]') obj_label = Format('%s %s', Field('_title'), Field('_nature')) obj_currency = FrenchTransaction.Currency('./td[@id="idCompteSoldeUM"]') obj_id = CleanText('td[@id="idCompteLibelle"]/a') obj_balance = CleanDecimal('td[@id="idCompteSolde"]', replace_dots=True) obj__link = Link('td[@id="idCompteLibelle"]/a') class HistoryPage(HTMLPage): logged = True is_here = u'//title[text() = "Liste des opérations sur un compte"]' @pagination @method class get_transactions(ListElement): item_xpath = '//tr' def next_page(self): for script in self.page.doc.xpath('//script'): m = re.search(r"""getCodePagination\('(?P\d+)','(?P\d+)','(?P[^']+)'""", script.text or '', flags=re.MULTILINE) if m: next_page = int(m.group('current_page')) + 1 max_page = int(m.group('max_page')) if next_page <= max_page: return m.group('link') + '&numeroPage=' + str(next_page) class item(ItemElement): klass = Transaction def condition(self): if len(self.el.xpath('./td')) < 6 or len(self.el.xpath('./td[@class="TitreTableau"]')) > 0: return False return True obj_raw = Transaction.Raw('.//td[@class="ColonneLibelle"]') obj_amount = CleanDecimal('.//td[4] | .//td[5]', replace_dots=True) obj_date = Date(CleanText('.//td[1]'), dayfirst=True) obj_vdate = Date(CleanText('.//td[3]'), dayfirst=True) weboob-1.1/modules/delubac/test.py000066400000000000000000000017531265717027300172500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Noe Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class DelubacTest(BackendTest): MODULE = 'delubac' def test_delubac(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/dhl/000077500000000000000000000000001265717027300150615ustar00rootroot00000000000000weboob-1.1/modules/dhl/__init__.py000066400000000000000000000014311265717027300171710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import DHLModule __all__ = ['DHLModule'] weboob-1.1/modules/dhl/browser.py000066400000000000000000000020671265717027300171230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import SearchPage class DHLBrowser(PagesBrowser): BASEURL = 'http://nolp.dhl.de' search_page = URL('/nextt-online-public/set_identcodes.do\?lang=en&idc=(?P.+)', SearchPage) def get_tracking_info(self, _id): return self.search_page.go(id=_id).get_info(_id) weboob-1.1/modules/dhl/favicon.png000066400000000000000000000006431265717027300172170ustar00rootroot00000000000000PNG  IHDR@@% pHYs  tIME! (tEXtCommentCreated with GIMPWIDAThرn@E7&D&UK 'f;rc˳zkV1뇟W);KtCkno^c+g[К/@g@䵼3`Nj"f 5 M=aۿׁ2ߥzX\Ţ[nhsw%n|ɜV1[`ҏebF V!IߝH~. from weboob.tools.backend import Module from weboob.capabilities.parcel import CapParcel from .browser import DHLBrowser __all__ = ['DHLModule'] class DHLModule(Module, CapParcel): NAME = 'dhl' DESCRIPTION = u'DHL website' MAINTAINER = u'Matthieu Weber' EMAIL = 'mweber+weboob@free.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = DHLBrowser def get_parcel_tracking(self, id): """ Get information abouut a parcel. :param id: ID of the parcel :type id: :class:`str` :rtype: :class:`Parcel` :raises: :class:`ParcelNotFound` """ return self.browser.get_tracking_info(id) weboob-1.1/modules/dhl/pages.py000066400000000000000000000071501265717027300165350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from dateutil.parser import parse as parse_date from weboob.browser.pages import HTMLPage from weboob.capabilities.parcel import Parcel, Event, ParcelNotFound # Based on http://www.parcelok.com/delivery-status-dhl.html STATUSES = { "The instruction data for this shipment have been provided by the sender to DHL " "electronically": Parcel.STATUS_PLANNED, "The shipment has been posted by the sender at the retail outlet": Parcel.STATUS_PLANNED, "The shipment has been processed in the destination parcel center": Parcel.STATUS_IN_TRANSIT, "The international shipment has been processed in the parcel center of origin": Parcel.STATUS_IN_TRANSIT, "The international shipment has been processed in the export parcel center": Parcel.STATUS_IN_TRANSIT, "The shipment will be transported to the destination country and, from there, handed over to " "the delivery organization.": Parcel.STATUS_IN_TRANSIT, "The shipment has arrived in the destination country": Parcel.STATUS_IN_TRANSIT, "The shipment has arrived at the parcel center.": Parcel.STATUS_IN_TRANSIT, "Shipment is prepared for customs clearance in country of destination": Parcel.STATUS_IN_TRANSIT, "The shipment is being prepared for delivery in the delivery depot": Parcel.STATUS_IN_TRANSIT, "Scheduled for delivery": Parcel.STATUS_IN_TRANSIT, "The shipment has been loaded onto the delivery vehicle": Parcel.STATUS_IN_TRANSIT, "Shipment has arrived at delivery location": Parcel.STATUS_IN_TRANSIT, "With delivery courier": Parcel.STATUS_IN_TRANSIT, "Delivery attempted; consignee premises closed": Parcel.STATUS_IN_TRANSIT, "The shipment has been damaged and is being returned to the parcel center for" "repackaging": Parcel.STATUS_IN_TRANSIT, "The shipment has been successfully delivered": Parcel.STATUS_ARRIVED, } class SearchPage(HTMLPage): def get_info(self, _id): result_id = self.doc.xpath('//th[@class="mm_sendungsnummer"]') if not result_id: raise ParcelNotFound("No such ID: %s" % _id) result_id = result_id[0].text if result_id != _id: raise ParcelNotFound("ID mismatch: expecting %s, got %s" % (_id, result_id)) p = Parcel(_id) events = self.doc.xpath('//div[@class="accordion-inner"]/table/tbody/tr') p.history = [self.build_event(i, tr) for i, tr in enumerate(events)] p.status, p.info = self.guess_status(p.history[-1]) return p def guess_status(self, most_recent): txt = most_recent.activity return STATUSES.get(txt, Parcel.STATUS_UNKNOWN), txt def build_event(self, index, tr): event = Event(index) event.date = parse_date(tr.xpath('./td[1]')[0].text.strip(), dayfirst=True, fuzzy=True) event.location = unicode(tr.xpath('./td[2]')[0].text.strip()) event.activity = unicode(tr.xpath('./td[3]')[0].text.strip()) return event weboob-1.1/modules/dhl/test.py000066400000000000000000000017361265717027300164210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.parcel import ParcelNotFound class DHLTest(BackendTest): MODULE = 'dhl' def test_dhl(self): self.assertRaises(ParcelNotFound, self.backend.get_parcel_tracking, "foo") weboob-1.1/modules/dlfp/000077500000000000000000000000001265717027300152375ustar00rootroot00000000000000weboob-1.1/modules/dlfp/__init__.py000066400000000000000000000014731265717027300173550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .browser import DLFP from .module import DLFPModule __all__ = ['DLFP', 'DLFPModule'] weboob-1.1/modules/dlfp/browser.py000066400000000000000000000217001265717027300172740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib import re import hashlib import lxml from weboob.deprecated.browser import Browser, BrowserHTTPNotFound, BrowserHTTPError, BrowserIncorrectPassword, BrokenPageError from weboob.capabilities.messages import CantSendMessage from .pages.index import IndexPage, LoginPage from .pages.news import ContentPage, NewCommentPage, NodePage, CommentPage, NewTagPage, RSSComment from .pages.board import BoardIndexPage from .pages.wiki import WikiEditPage from .tools import id2url, url2id # Browser class DLFP(Browser): DOMAIN = 'linuxfr.org' PROTOCOL = 'https' PAGES = {'https?://[^/]*linuxfr\.org/?': IndexPage, 'https?://[^/]*linuxfr\.org/compte/connexion': LoginPage, 'https?://[^/]*linuxfr\.org/news/[^\.]+': ContentPage, 'https?://[^/]*linuxfr\.org/wiki/(?!nouveau)[^/]+': ContentPage, 'https?://[^/]*linuxfr\.org/wiki': WikiEditPage, 'https?://[^/]*linuxfr\.org/wiki/nouveau': WikiEditPage, 'https?://[^/]*linuxfr\.org/wiki/[^\.]+/modifier': WikiEditPage, 'https?://[^/]*linuxfr\.org/suivi/[^\.]+': ContentPage, 'https?://[^/]*linuxfr\.org/sondages/[^\.]+': ContentPage, 'https?://[^/]*linuxfr\.org/users/[^\./]+/journaux/[^\.]+': ContentPage, 'https?://[^/]*linuxfr\.org/forums/[^\./]+/posts/[^\.]+': ContentPage, 'https?://[^/]*linuxfr\.org/nodes/(\d+)/comments/(\d+)': CommentPage, 'https?://[^/]*linuxfr\.org/nodes/(\d+)/comments/nouveau': NewCommentPage, 'https?://[^/]*linuxfr\.org/nodes/(\d+)/comments': NodePage, 'https?://[^/]*linuxfr\.org/nodes/(\d+)/tags/nouveau': NewTagPage, 'https?://[^/]*linuxfr\.org/board/index.xml': BoardIndexPage, 'https?://[^/]*linuxfr\.org/nodes/(\d+)/comments.atom': RSSComment, } last_board_msg_id = None def parse_id(self, _id): if re.match('^https?://.*linuxfr.org/nodes/\d+/comments/\d+$', _id): return _id, None url = id2url(_id) if url is None: if url2id(_id) is not None: url = _id _id = url2id(url) else: return None, None return url, _id def get_wiki_content(self, _id): url, _id = self.parse_id('W.%s' % _id) if url is None: return None try: self.location('%s/modifier' % url) except BrowserHTTPNotFound: return '' assert self.is_on_page(WikiEditPage) return self.page.get_body() def _go_on_wiki_edit_page(self, name): """ Go on the wiki page named 'name'. Return True if this is a new page, or False if the page already exist. Return None if it isn't a right wiki page name. """ url, _id = self.parse_id('W.%s' % name) if url is None: return None try: self.location('%s/modifier' % url) except BrowserHTTPNotFound: self.location('/wiki/nouveau') new = True else: new = False assert self.is_on_page(WikiEditPage) return new def set_wiki_content(self, name, content, message): new = self._go_on_wiki_edit_page(name) if new is None: return None if new: title = name.replace('-', ' ') else: title = None self.page.post_content(title, content, message) def get_wiki_preview(self, name, content): if self._go_on_wiki_edit_page(name) is None: return None self.page.post_preview(content) if self.is_on_page(WikiEditPage): return self.page.get_preview_html() elif self.is_on_page(ContentPage): return self.page.get_article().body def get_hash(self, url): self.location(url) if self.page.document.xpath('//entry'): myhash = hashlib.md5(lxml.etree.tostring(self.page.document)).hexdigest() return myhash else: return None def get_content(self, _id): url, _id = self.parse_id(_id) if url is None: return None self.location(url) self.page.url = self.absurl(url) if self.is_on_page(CommentPage): content = self.page.get_comment() elif self.is_on_page(ContentPage): m = re.match('.*#comment-(\d+)$', url) if m: content = self.page.get_comment(int(m.group(1))) else: content = self.page.get_article() else: raise BrokenPageError('Not on a content or comment page (%r)' % self.page) if _id is not None: content.id = _id return content def _is_comment_submit_form(self, form): return 'comment_new' in form.action def post_comment(self, thread, reply_id, title, message): url = id2url(thread) if url is None: raise CantSendMessage('%s is not a right ID' % thread) self.location(url) assert self.is_on_page(ContentPage) self.location(self.page.get_post_comment_url()) assert self.is_on_page(NewCommentPage) self.select_form(predicate=self._is_comment_submit_form) self.set_all_readonly(False) if title is not None: self['comment[title]'] = title.encode('utf-8') self['comment[wiki_body]'] = message.encode('utf-8') if int(reply_id) > 0: self['comment[parent_id]'] = str(reply_id) self['commit'] = 'Poster le commentaire' try: self.submit() except BrowserHTTPError as e: raise CantSendMessage('Unable to send message to %s.%s: %s' % (thread, reply_id, e)) if self.is_on_page(NodePage): errors = self.page.get_errors() if len(errors) > 0: raise CantSendMessage('Unable to send message: %s' % ', '.join(errors)) return None def login(self): if self.username is None: return # not usefull for the moment #self.location('/', no_login=True) data = {'account[login]': self.username, 'account[password]': self.password, 'account[remember_me]': 1, #'authenticity_token': self.page.get_login_token(), } self.location('/compte/connexion', urllib.urlencode(data), no_login=True) if not self.is_logged(): raise BrowserIncorrectPassword() self._token = self.page.document.xpath('//input[@name="authenticity_token"]') def is_logged(self): return (self.username is None or (self.page and self.page.is_logged())) def close_session(self): if self._token: self.openurl('/compte/deconnexion', urllib.urlencode({'authenticity_token': self._token[0].attrib['value']})) def plusse(self, url): return self.relevance(url, 'for') def moinse(self, url): return self.relevance(url, 'against') def relevance(self, url, what): comment = self.get_content(url) if comment is None: raise ValueError('The given URL isn\'t a comment.') if comment.relevance_token is None: return False res = self.readurl('%s%s' % (comment.relevance_url, what), urllib.urlencode({'authenticity_token': comment.relevance_token})) return res def iter_new_board_messages(self): self.location('/board/index.xml') assert self.is_on_page(BoardIndexPage) msgs = self.page.get_messages(self.last_board_msg_id) for msg in reversed(msgs): self.last_board_msg_id = msg.id yield msg def board_post(self, msg): request = self.request_class(self.absurl('/board/'), urllib.urlencode({'board[message]': msg}), {'Referer': self.absurl('/')}) self.readurl(request) def add_tag(self, _id, tag): url, _id = self.parse_id(_id) if url is None: return None self.location(url) assert self.is_on_page(ContentPage) self.location(self.page.get_tag_url()) assert self.is_on_page(NewTagPage) self.page.tag(tag) weboob-1.1/modules/dlfp/favicon.png000066400000000000000000000117641265717027300174030ustar00rootroot00000000000000PNG  IHDR@@% sRGB pHYs  tIME ,0aIDAThi]W}{fެ{I;5-EiPJ*TʇVHtIP@D Nxyom~{8&F)]{wYq~2*;]wޡC)%tloeiW@D@HBCoF)%5=ED!yK(Ap+gOT6}F w qJ9e c ʖJ-!76ŕ_^9VN|]@W2@3B2 eK𶏰[ֵ*S i(lF!,4 !7˷"w#@G2 MP9Pz H)>BnN$NW!$-$ CC[l^Xs0er JޒrS9p cw$UCۄit 8{h806K6@AWCX>tcwt}ox? lL}r@|GukI 0 ݾ_,J$RB2:]pSFi3ɣ?]/LKUJǦ+p7T-Eoh6![`3h΀1 *o߆O5ie]RY^[%y)H[BeS jso#2B[Qa93+Mhf&cUvNl&V]ؽ'|/).峾~rd?C>|[ķO7!K߁/~`B6>ޣ WNRcc{ta~85}^saZ}q\"#f#%|G٧JS^pG+Ώ{=cgcjw]P#\mw>nJ/u07o=T\󯟩.#K;eB%NjG۱F up{4{EDLkwU O KO&W3}e|vCyaOCeeV'aJ kH  Ʀqhvx#2H8?󕧞jL;6/_TulGlni/$L.W*iإr>kj*dT*UL|#Ϗf-i$H4+ޑwda~Y^H,g ?~{v;Lo]1Il E"dm:{e`/~;z{JzԹK=陹d93<|Vav{uEUhЃR-8yύw"Pa';hϯm8ٻt4Je"WF;s/L<]u0@v(|!T,7Nu@#IA.,.Mb0!1h678<A?^vkfz2D໎U!(p9K텞{_ƨp,bcmcU6=X{c3Fp@N]BLM5v-ݬι"S)o\1] {3h] ͹V-O7zw.=Z[|J_OWyx-XVwWAf(΍֮.wR2L(\׋ kfۘ^Sf8i @@JA8X]7 ]JzU؁S9c^ , #yćyExJ3?9r`﫯](umbx}8kb#e@H Rp=ǁ\0e.tw)0#H/^+n B,[ɖsrezZJv .\vCB>̳å򐢀:sZRKs3 Ł}{FED0[h,c*Gy:pFn '7w \&ԛO:;`lFNkYSa~٨xn(W4r Sזىzfuc.\u0 +݅t )A"(\Mc=@˅'EKmCZqTb"vck:RJs fR[1 X{BG:D"CdH8NCD5ͤd Ixm:;2ުܩ}@d1 ̏ ̊z$j ?V#SWS 5FrlޥɕJʨ!!ه!EJY--DD5gIcי$Bf6kVHP$cЙ%n]]s+LȔPU.!`-WZRW&\E-~($t y>&4C3 2S45IŲb眛8i+`hPHQl%;f@(CntYWa|zA"2R )( %HS ;7n(J7"vRRdU%p:>s$U[Ԉi(NR 1H@RN5bhiL Vܠ^G"Bȭ DGc)! f;` HR`2;Wʭ_iTڈh6!`jThsEz3D*"PB$P6C|&ԍtHf6ҙ*d46w @Ptzf޲6@ٳJ h**zxRfS.1J+f9፱/A;J e))RJ8iQC$ P PS@x$u0w-̌[ +b-XIENDB`weboob-1.1/modules/dlfp/module.py000066400000000000000000000241131265717027300170770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime, timedelta import time from weboob.tools.backend import Module, BackendConfig from weboob.deprecated.browser import BrowserForbidden from weboob.tools.newsfeed import Newsfeed from weboob.tools.value import Value, ValueBool, ValueBackendPassword from weboob.capabilities.messages import CapMessages, CapMessagesPost, Message, Thread, CantSendMessage from weboob.capabilities.content import CapContent, Content from .browser import DLFP from .tools import rssid, id2url __all__ = ['DLFPModule'] class DLFPModule(Module, CapMessages, CapMessagesPost, CapContent): NAME = 'dlfp' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = "Da Linux French Page news website" CONFIG = BackendConfig(Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password', default=''), ValueBool('get_news', label='Get newspapers', default=True), ValueBool('get_diaries', label='Get diaries', default=False), ValueBool('get_polls', label='Get polls', default=False), ValueBool('get_board', label='Get board', default=False), ValueBool('get_wiki', label='Get wiki', default=False), ValueBool('get_tracker', label='Get tracker', default=False)) STORAGE = {'seen': {}} BROWSER = DLFP FEEDS = {'get_news': "https://linuxfr.org/news.atom", 'get_diaries': "https://linuxfr.org/journaux.atom", 'get_polls': "https://linuxfr.org/sondages.atom", 'get_board': "https://linuxfr.org/forums.atom", 'get_wiki': "https://linuxfr.org/wiki.atom", 'get_tracker': "https://linuxfr.org/suivi.atom", } def create_default_browser(self): username = self.config['username'].get() if username: password = self.config['password'].get() else: password = None return self.create_browser(username, password) def deinit(self): # don't need to logout if the browser hasn't been used. if not self._browser: return with self.browser: self.browser.close_session() #### CapMessages ############################################## def iter_threads(self): whats = set() for param, url in self.FEEDS.iteritems(): if self.config[param].get(): whats.add(url) for what in whats: for article in Newsfeed(what, rssid).iter_entries(): if article.datetime and (datetime.now() - article.datetime) > timedelta(days=60): continue thread = Thread(article.id) thread.title = article.title thread._rsscomment = article.rsscomment if article.datetime: thread.date = article.datetime yield thread def get_thread(self, id, getseen=True): if not isinstance(id, Thread): thread = None else: thread = id id = thread.id if thread.date: self.storage.set('date', id, thread.date) self.storage.save() with self.browser: content = self.browser.get_content(id) if not content: return None if not thread: thread = Thread(content.id) flags = Message.IS_HTML if thread.id not in self.storage.get('seen', default={}): flags |= Message.IS_UNREAD thread.title = content.title if not thread.date: thread.date = content.date thread.root = Message(thread=thread, id='0', # root message title=content.title, sender=content.author or u'', receivers=None, date=thread.date, parent=None, content=content.body, signature='URL: %s' % self.browser.absurl(id2url(content.id)), children=[], flags=flags) for com in content.comments: self._insert_comment(com, thread.root, getseen) return thread def _insert_comment(self, com, parent, getseen=True): """" Insert 'com' comment and its children in the parent message. """ flags = Message.IS_HTML if com.id not in self.storage.get('seen', parent.thread.id, 'comments', default=[]): flags |= Message.IS_UNREAD if getseen or flags & Message.IS_UNREAD: com.parse() message = Message(thread=parent.thread, id=com.id, title=com.title, sender=com.author or u'', receivers=None, date=com.date, parent=parent, content=com.body, signature=com.signature + '
'.join(['Score: %d' % com.score, 'URL: %s' % com.url]), children=[], flags=flags) else: message = Message(thread=parent.thread, id=com.id, children=[], flags=flags) parent.children.append(message) for sub in com.comments: self._insert_comment(sub, message, getseen) def iter_unread_messages(self): for thread in self.iter_threads(): # Check if we have seen all comments of this thread. with self.browser: oldhash = self.storage.get('hash', thread.id, default="") newhash = self.browser.get_hash(thread._rsscomment) if oldhash != newhash: self.storage.set('hash', thread.id, newhash) self.storage.save() self.fill_thread(thread, 'root', getseen=False) for m in thread.iter_all_messages(): if m.flags & m.IS_UNREAD: yield m def set_message_read(self, message): self.storage.set('seen', message.thread.id, 'comments', self.storage.get('seen', message.thread.id, 'comments', default=[]) + [message.id]) self.storage.save() lastpurge = self.storage.get('lastpurge', default=0) # 86400 = one day if time.time() - lastpurge > 86400: self.storage.set('lastpurge', time.time()) self.storage.save() # we can't directly delete without a "RuntimeError: dictionary changed size during iteration" todelete = [] for id in self.storage.get('seen', default={}): date = self.storage.get('date', id, default=0) # if no date available, create a new one (compatibility with "old" storage) if date == 0: self.storage.set('date', id, datetime.now()) elif datetime.now() - date > timedelta(days=60): todelete.append(id) for id in todelete: self.storage.delete('hash', id) self.storage.delete('date', id) self.storage.delete('seen', id) self.storage.save() def fill_thread(self, thread, fields, getseen=True): return self.get_thread(thread, getseen) #### CapMessagesReply ######################################### def post_message(self, message): if not self.browser.username: raise BrowserForbidden() if not message.parent: raise CantSendMessage('Posting news and diaries on DLFP is not supported yet') assert message.thread with self.browser: return self.browser.post_comment(message.thread.id, message.parent.id, message.title, message.content) #### CapContent ############################################### def get_content(self, _id, revision=None): if isinstance(_id, basestring): content = Content(_id) else: content = _id _id = content.id if revision: raise NotImplementedError('Website does not provide access to older revisions sources.') with self.browser: data = self.browser.get_wiki_content(_id) if data is None: return None content.content = data return content def push_content(self, content, message=None, minor=False): if not self.browser.username: raise BrowserForbidden() with self.browser: return self.browser.set_wiki_content(content.id, content.content, message) def get_content_preview(self, content): with self.browser: return self.browser.get_wiki_preview(content.id, content.content) OBJECTS = {Thread: fill_thread} weboob-1.1/modules/dlfp/pages/000077500000000000000000000000001265717027300163365ustar00rootroot00000000000000weboob-1.1/modules/dlfp/pages/__init__.py000066400000000000000000000000001265717027300204350ustar00rootroot00000000000000weboob-1.1/modules/dlfp/pages/board.py000066400000000000000000000040731265717027300200030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from logging import warning from weboob.deprecated.browser import Page class Message(object): TIMESTAMP_REGEXP = re.compile(r'(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})') def __init__(self, id, timestamp, login, message, is_me): self.id = id self.timestamp = timestamp self.login = login self.message = message self.is_me = is_me self.norloge = timestamp m = self.TIMESTAMP_REGEXP.match(timestamp) if m: self.norloge = '%02d:%02d:%02d' % (int(m.group(4)), int(m.group(5)), int(m.group(6))) else: warning('Unable to parse timestamp "%s"' % timestamp) class BoardIndexPage(Page): def is_logged(self): return True def get_messages(self, last=None): msgs = [] for post in self.parser.select(self.document.getroot(), 'post'): m = Message(int(post.attrib['id']), post.attrib['time'], post.find('login').text, post.find('message').text, post.find('login').text.lower() == self.browser.username.lower()) if last is not None and last == m.id: break msgs.append(m) return msgs weboob-1.1/modules/dlfp/pages/index.py000066400000000000000000000025011265717027300200150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Page class DLFPPage(Page): def is_logged(self): for form in self.document.getiterator('form'): if form.attrib.get('id', None) == 'new_account_sidebar': return False return True class IndexPage(DLFPPage): def get_login_token(self): form = self.parser.select(self.document.getroot(), 'form#new_account_sidebar', 1) for i in form.find('div').getiterator('input'): if i.attrib['name'] == 'authenticity_token': return i.attrib['value'] class LoginPage(DLFPPage): pass weboob-1.1/modules/dlfp/pages/news.py000066400000000000000000000170071265717027300176710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime from weboob.deprecated.browser import BrokenPageError from weboob.tools.date import local2utc from ..tools import url2id from .index import DLFPPage class RSSComment(DLFPPage): def on_loaded(self): pass class Content(object): TAGGABLE = False def __init__(self, browser): self.browser = browser self.url = u'' self.id = u'' self.title = u'' self.author = u'' self.username = u'' self.body = u'' self.date = None self.score = 0 self.comments = [] self.relevance_url = None self.relevance_token = None def is_taggable(self): return False class Comment(Content): def __init__(self, article, div, reply_id): Content.__init__(self, article.browser) self.reply_id = reply_id self.signature = u'' self.preurl = article.url self.div = div self.id = div.attrib['id'].split('-')[1] subs = div.find('ul') if subs is not None: for sub in subs.findall('li'): comment = Comment(article, sub, self.id) self.comments.append(comment) def parse(self): self.url = '%s#%s' % (self.preurl, self.div.attrib['id']) self.title = unicode(self.browser.parser.select(self.div.find('h2'), 'a.title', 1).text) try: a = self.browser.parser.select(self.div.find('p'), 'a[rel=author]', 1) except BrokenPageError: self.author = 'Anonyme' self.username = None else: self.author = unicode(a.text) self.username = unicode(a.attrib['href'].split('/')[2]) self.date = datetime.strptime(self.browser.parser.select(self.div.find('p'), 'time', 1).attrib['datetime'].split('+')[0], '%Y-%m-%dT%H:%M:%S') self.date = local2utc(self.date) content = self.div.find('div') try: signature = self.browser.parser.select(content, 'p.signature', 1) except BrokenPageError: # No signature. pass else: content.remove(signature) self.signature = self.browser.parser.tostring(signature) self.body = self.browser.parser.tostring(content) self.score = int(self.browser.parser.select(self.div.find('p'), 'span.score', 1).text) forms = self.browser.parser.select(self.div.find('footer'), 'form.button_to') if len(forms) > 0: self.relevance_url = forms[0].attrib['action'].rstrip('for').rstrip('against') self.relevance_token = self.browser.parser.select(forms[0], 'input[name=authenticity_token]', 1).attrib['value'] def iter_all_comments(self): for comment in self.comments: yield comment for c in comment.iter_all_comments(): yield c def __repr__(self): return u"" % (self.id, self.author, self.title) class Article(Content): TAGGABLE = True def __init__(self, browser, url, tree): Content.__init__(self, browser) self.url = url self.id = url2id(self.url) if tree is None: return header = tree.find('header') self.title = u' — '.join([a.text for a in header.find('h1').xpath('.//a')]) try: a = self.browser.parser.select(header, 'a[rel=author]', 1) except BrokenPageError: self.author = 'Anonyme' self.username = None else: self.author = unicode(a.text) self.username = unicode(a.attrib['href'].split('/')[2]) self.body = self.browser.parser.tostring(self.browser.parser.select(tree, 'div.content', 1)) try: self.date = datetime.strptime(self.browser.parser.select(header, 'time', 1).attrib['datetime'].split('+')[0], '%Y-%m-%dT%H:%M:%S') self.date = local2utc(self.date) except BrokenPageError: pass for form in self.browser.parser.select(tree.find('footer'), 'form.button_to'): if form.attrib['action'].endswith('/for'): self.relevance_url = form.attrib['action'].rstrip('for').rstrip('against') self.relevance_token = self.browser.parser.select(form, 'input[name=authenticity_token]', 1).attrib['value'] self.score = int(self.browser.parser.select(tree, 'div.figures figure.score', 1).text) def append_comment(self, comment): self.comments.append(comment) def iter_all_comments(self): for comment in self.comments: yield comment for c in comment.iter_all_comments(): yield c class CommentPage(DLFPPage): def get_comment(self): article = Article(self.browser, self.url, None) return Comment(article, self.parser.select(self.document.getroot(), 'li.comment', 1), 0) class ContentPage(DLFPPage): def on_loaded(self): self.article = None def is_taggable(self): return True def get_comment(self, id): article = Article(self.browser, self.url, None) try: li = self.parser.select(self.document.getroot(), 'li#comment-%s' % id, 1) except BrokenPageError: return None else: return Comment(article, li, 0) def get_article(self): if not self.article: self.article = Article(self.browser, self.url, self.parser.select(self.document.getroot(), 'main#contents article', 1)) try: threads = self.parser.select(self.document.getroot(), 'ul.threads', 1) except BrokenPageError: pass # no comments else: for comment in threads.findall('li'): self.article.append_comment(Comment(self.article, comment, 0)) return self.article def get_post_comment_url(self): return self.parser.select(self.document.getroot(), 'p#send-comment', 1).find('a').attrib['href'] def get_tag_url(self): return self.parser.select(self.document.getroot(), 'div.tag_in_place', 1).find('a').attrib['href'] class NewCommentPage(DLFPPage): pass class NewTagPage(DLFPPage): def _is_tag_form(self, form): return form.action.endswith('/tags') def tag(self, tag): self.browser.select_form(predicate=self._is_tag_form) self.browser['tags'] = tag self.browser.submit() class NodePage(DLFPPage): def get_errors(self): try: div = self.parser.select(self.document.getroot(), 'div.errors', 1) except BrokenPageError: return [] l = [] for li in div.find('ul').findall('li'): l.append(li.text) return l weboob-1.1/modules/dlfp/pages/wiki.py000066400000000000000000000040511265717027300176530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import BrokenPageError from .index import DLFPPage class WikiEditPage(DLFPPage): def get_body(self): try: return self.parser.select(self.document.getroot(), 'textarea#wiki_page_wiki_body', 1).text except BrokenPageError: return '' def _is_wiki_form(self, form): return form.attrs.get('class', '') in ('new_wiki_page', 'edit_wiki_page') def post_content(self, title, body, message): self.browser.select_form(predicate=self._is_wiki_form) self.browser.set_all_readonly(False) if title is not None: self.browser['wiki_page[title]'] = title.encode('utf-8') self.browser['commit'] = 'Créer' else: self.browser['commit'] = 'Mettre à jour' self.browser['wiki_page[wiki_body]'] = body.encode('utf-8') if message is not None: self.browser['wiki_page[message]'] = message.encode('utf-8') self.browser.submit() def post_preview(self, body): self.browser.select_form(predicate=self._is_wiki_form) self.browser['wiki_page[wiki_body]'] = body self.browser.submit() def get_preview_html(self): body = self.parser.select(self.document.getroot(), 'article.wikipage div.content', 1) return self.parser.tostring(body) weboob-1.1/modules/dlfp/test.py000066400000000000000000000034021265717027300165670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime from weboob.tools.test import BackendTest from .browser import DLFP class DLFPTest(BackendTest): MODULE = 'dlfp' def __init__(self, *args, **kwargs): DLFP.DOMAIN = 'alpha.linuxfr.org' BackendTest.__init__(self, *args, **kwargs) def test_new_messages(self): feeds = {} for name, feed in self.backend.FEEDS.iteritems(): feeds[name] = feed.replace('//linuxfr.org', '//alpha.linuxfr.org') self.backend.FEEDS = feeds for message in self.backend.iter_unread_messages(): pass def test_get_content(self): self.backend.get_content(u"Ceci-est-un-test") def test_push_content(self): content = self.backend.get_content(u"Ceci-est-un-test") content.content = "test "+str(datetime.now()) self.backend.push_content(content, message="test weboob", minor=True) def test_content_preview(self): content = self.backend.get_content(u"Ceci-est-un-test") self.backend.get_content_preview(content) weboob-1.1/modules/dlfp/tools.py000066400000000000000000000043271265717027300167570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re RSSID_RE = re.compile('tag:.*:(\w+)/(\d+)') ID2URL_RE = re.compile('^(\w)(.*)\.([^ \.]+)$') REGEXPS = {'/users/%s/journaux/%s': 'D%s.%s', '/news/%s': 'N.%s', '/wiki/%s': 'W.%s', '/suivi/%s': 'T.%s', '/sondages/%s': 'P.%s', '/forums/%s/posts/%s': 'B%s.%s', } def f2re(f): return '.*' + f.replace('%s', '([^ /]+)') def rssid(entry): m = RSSID_RE.match(entry.id) if not m: return None ind = m.group(1).replace('Post', 'Board')[0] for url_re, id_re in REGEXPS.iteritems(): if id_re[0] != ind: continue if id_re.count('%s') == 2: mm = re.match(f2re(url_re), entry.link) if not mm: return return '%s%s.%s' % (ind, mm.group(1), m.group(2)) else: return '%s.%s' % (ind, m.group(2)) def id2url(id): m = ID2URL_RE.match(id) if not m: return None for url_re, id_re in REGEXPS.iteritems(): if id_re[0] != m.group(1): continue if id_re.count('%s') == 2: return url_re % (m.group(2), m.group(3)) else: return url_re % m.group(3) def url2id(url): for url_re, id_re in REGEXPS.iteritems(): m = re.match(f2re(url_re), url) if not m: continue return id_re % m.groups() def id2threadid(id): m = ID2URL_RE.match(id) if m: return m.group(3) weboob-1.1/modules/dpd/000077500000000000000000000000001265717027300150615ustar00rootroot00000000000000weboob-1.1/modules/dpd/__init__.py000066400000000000000000000014311265717027300171710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import DPDModule __all__ = ['DPDModule'] weboob-1.1/modules/dpd/browser.py000066400000000000000000000021031265717027300171120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import SearchPage class DPDBrowser(PagesBrowser): BASEURL = 'https://tracking.dpd.de/' search_page = URL('/cgi-bin/simpleTracking.cgi\?parcelNr=(?P.+)&locale=en_D2&type=1', SearchPage) def get_tracking_info(self, _id): return self.search_page.go(id=_id).get_info(_id) weboob-1.1/modules/dpd/favicon.png000066400000000000000000000007741265717027300172240ustar00rootroot00000000000000PNG  IHDR@@% pHYs  tIME"?@tEXtCommentCreated with GIMPWvIDATh F|C,pά&Yx#*4@G'k:M] naFxn7izk5z&@4$ce묱'9#B;Sr \ȏF{xB4Q5䁞k'2FҰGQ ib:,6`ZN;<\[ځW#~N~ dU\]\ 6ghO=78^h1(CQFΎ{68x% Nz *ipdICpzz{< r H{RgUIENDB`weboob-1.1/modules/dpd/module.py000066400000000000000000000026021265717027300167200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.parcel import CapParcel from .browser import DPDBrowser __all__ = ['DPDModule'] class DPDModule(Module, CapParcel): NAME = 'dpd' DESCRIPTION = u'DPD website' MAINTAINER = u'Matthieu Weber' EMAIL = 'mweber+weboob@free.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = DPDBrowser def get_parcel_tracking(self, id): """ Get information abouut a parcel. :param id: ID of the parcel :type id: :class:`str` :rtype: :class:`Parcel` :raises: :class:`ParcelNotFound` """ return self.browser.get_tracking_info(id) weboob-1.1/modules/dpd/pages.py000066400000000000000000000045461265717027300165430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from dateutil.parser import parse as parse_date from weboob.browser.pages import JsonPage from weboob.capabilities.parcel import Parcel, Event, ParcelNotFound STATUSES = { 1: Parcel.STATUS_PLANNED, 2: Parcel.STATUS_IN_TRANSIT, 3: Parcel.STATUS_IN_TRANSIT, 4: Parcel.STATUS_IN_TRANSIT, 5: Parcel.STATUS_ARRIVED, } class SearchPage(JsonPage): def build_doc(self, text): from weboob.tools.json import json return json.loads(text[1:-1]) def get_info(self, _id): result_id = self.doc.get("TrackingStatusJSON", {}).get("shipmentInfo", {}).get("parcelNumber", None) if not result_id: raise ParcelNotFound("No such ID: %s" % _id) if not _id.startswith(result_id): raise ParcelNotFound("ID mismatch: expecting %s, got %s" % (_id, result_id)) p = Parcel(_id) events = self.doc.get("TrackingStatusJSON", {}).get("statusInfos", []) p.history = [self.build_event(i, data) for i, data in enumerate(events)] p.status = self.guess_status( self.doc.get("TrackingStatusJSON", {}). get("shipmentInfo", {}). get("deliveryStatus")) p.info = p.history[-1].activity return p def guess_status(self, status_code): return STATUSES.get(status_code, Parcel.STATUS_UNKNOWN) def build_event(self, index, data): event = Event(index) date = "%s %s" % (data["date"], data["time"]) event.date = parse_date(date, dayfirst=False) event.location = unicode(data["city"]) event.activity = unicode(", ".join([_["label"] for _ in data["contents"]])) return event weboob-1.1/modules/dpd/test.py000066400000000000000000000017361265717027300164210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.parcel import ParcelNotFound class DPDTest(BackendTest): MODULE = 'dpd' def test_dpd(self): self.assertRaises(ParcelNotFound, self.backend.get_parcel_tracking, "foo") weboob-1.1/modules/dresdenwetter/000077500000000000000000000000001265717027300171715ustar00rootroot00000000000000weboob-1.1/modules/dresdenwetter/__init__.py000066400000000000000000000014731265717027300213070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import DresdenWetterModule __all__ = ['DresdenWetterModule'] weboob-1.1/modules/dresdenwetter/browser.py000066400000000000000000000021121265717027300212220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import StartPage __all__ = ['DresdenWetterBrowser'] class DresdenWetterBrowser(PagesBrowser): BASEURL = 'http://www.dresden-wetter.de' home = URL('/Current_Vantage_Pro.htm', StartPage) def get_sensors_list(self): return self.home.stay_or_go().get_sensors_list() weboob-1.1/modules/dresdenwetter/favicon.png000066400000000000000000000016721265717027300213320ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIMEtEXtCommentCreated with GIMPW"IDATx[K0GȞP!oHJ{T,{*.lpJ0ƎǞGv-1}#R{vCODQH O~x976=/MǵN8%yYA&%PxNn>?.Sp%@B7V,CĹ?gɞ*:jY &@dڥSO#P@prz\ΡO9\<L}kӜ@ 5Ҹ0 Q-KU~kVXPJ5H[zߟqze܀b$ZdL$A]orr-WVY$ ZW 'aq[$HOYY`q8y_ +PK1ӯ`pʹ#[ɧtד({mZ''eq`qWʯɂKWyAu Xr E\:]:znD`ւxyf/㽺҂Z㿺+6Aw/Xz (Ɩ7oTp. from .browser import DresdenWetterBrowser from weboob.capabilities.gauge import CapGauge, GaugeSensor, Gauge,\ SensorNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module __all__ = ['DresdenWetterModule'] class DresdenWetterModule(Module, CapGauge): NAME = 'dresdenwetter' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u"Private wetter station Dresden" BROWSER = DresdenWetterBrowser def iter_gauges(self, pattern=None): if pattern is None or pattern.lower() in u"dresden"\ or pattern.lower() in "weather": gauge = Gauge("wetter") gauge.name = u"Private Wetterstation Dresden" gauge.city = u"Dresden" gauge.object = u"Weather" gauge.sensors = list(self.browser.get_sensors_list()) yield gauge def _get_sensor_by_id(self, id): for gauge in self.iter_gauges(): for sensor in gauge.sensors: if id == sensor.id: return sensor raise SensorNotFound() def iter_sensors(self, gauge, pattern=None): if not isinstance(gauge, Gauge): gauge = find_object(self.iter_gauges(), id=gauge, error=SensorNotFound) if pattern is None: for sensor in gauge.sensors: yield sensor else: lowpattern = pattern.lower() for sensor in gauge.sensors: if lowpattern in sensor.name.lower(): yield sensor # Not in the website def iter_gauge_history(self, sensor): raise NotImplementedError() def get_last_measure(self, sensor): if not isinstance(sensor, GaugeSensor): sensor = self._get_sensor_by_id(sensor) return sensor.lastvalue weboob-1.1/modules/dresdenwetter/pages.py000066400000000000000000000045001265717027300206410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, Regexp, Field, Filter, debug from weboob.capabilities.gauge import GaugeMeasure, GaugeSensor from weboob.capabilities.base import NotAvailable class Split(Filter): def __init__(self, selector, mode): super(Split, self).__init__(selector) self.mode = mode @debug() def filter(self, txt): if u"Temperatur" in txt: value = txt.split(': ')[1].split(u'°')[0] unit = u'°C' else: value = txt.split(':')[-1].split()[0] unit = txt.split(':')[-1].split()[1] if unit == u"W/m": unit = u"W/m²" try: value = float(value) except ValueError: value = NotAvailable return [value, unit][self.mode] class StartPage(HTMLPage): @method class get_sensors_list(ListElement): item_xpath = '//p[@align="center"]' class item(ItemElement): klass = GaugeSensor obj_name = Regexp(CleanText('.'), '(.*?) {0,}: .*', "\\1") obj_id = CleanText(Regexp(Field('name'), '(.*)', "dd-\\1"), " .():") obj_gaugeid = u"wetter" obj_forecast = NotAvailable obj_unit = Split(CleanText('.'), 1) def obj_lastvalue(self): lastvalue = GaugeMeasure() lastvalue.level = Split(CleanText('.'), 0)(self) lastvalue.alarm = NotAvailable return lastvalue weboob-1.1/modules/dresdenwetter/test.py000066400000000000000000000045361265717027300205320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class DresdenWetterTest(BackendTest): MODULE = 'dresdenwetter' def test_gauges_sensors(self): """ test if the gauge listing works. Only one gauge on the website, but we can test sensors after that """ l = list(self.backend.iter_gauges()) self.assertTrue(len(l) == 1, msg="Gauge not found") self.assertTrue(len(l[0].sensors) > 5, msg="Not enough sensors") def test_sensors_value(self): temperature = self.backend.get_last_measure("dd-Temperatur2m").level self.assertTrue(temperature > -50., msg="To cold") self.assertTrue(temperature < 50., msg="Temperature to high") self.assertTrue(self.backend.get_last_measure(u"dd-Wind10minØ").level >= 0) self.assertTrue(self.backend.get_last_measure("dd-RelLuftdruck").level > 800.) self.assertTrue(self.backend.get_last_measure("dd-RelLuftfeuchtigkeit").level >= 0.) self.assertTrue(self.backend.get_last_measure("dd-Niederschlagseit001Uhr").level >= 0.) self.assertTrue(self.backend.get_last_measure("dd-Globalstrahlung").level >= 0.) def test_temperature(self): """ test the first sensor return by module" """ temperature = list(self.backend.iter_sensors("wetter", "Temperatur")) assert temperature[0].name == u"Temperatur 2m" assert temperature[0].unit == u"°C" def test_globalstrahlung(self): """ Test the last sensor return by module" """ sensor = list(self.backend.iter_sensors("wetter", "Globalstrahlung")) assert sensor[0].unit == u"W/m²" weboob-1.1/modules/eatmanga/000077500000000000000000000000001265717027300160675ustar00rootroot00000000000000weboob-1.1/modules/eatmanga/__init__.py000066400000000000000000000014351265717027300202030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import EatmangaModule __all__ = ['EatmangaModule'] weboob-1.1/modules/eatmanga/favicon.png000066400000000000000000000174221265717027300202300ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs B4tIME$UеiTXtCommentCreated with GIMPd.eiIDATx{ieq^Urufޛ I$JlY ;( 1d38Al #?āرHdk,7qyozsNwWU~77CR iq9v_WUWʯ|/#ԅ7d}No,C" ̩jk6TcOVVm Aeom鷖~ԸlVNGdhAEUTD$X͍W͟y)8)+:DѺSj*w9'S'c:_BP bt:jon^_-!* "Xgdt`C]{հgw绋 k+˃x;W:`Ѩ4o̻\)5 _0>݃V3xo\s`-@sT\ګtf:tnZ|M<Bt|vsv1X\ ?mvai2-ӏUT!;`TŨ*|*BWk~q_xG`yGSZ*@I7-?L*0 }kn^zx(ZIU#ZEa;hgz `l V3;X*# u3-۽l-;Q|PP̻{ OKKK30' "%._~kg.#u=몪HH*¤BDW_~@8-V!5ZEAXW *Z't\3"$v{[ۯ8&έ u>.|ٛx2 (2(Ng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?NFn 0 duDN/|2)"#.BjFpUEP!7nf5KO)PnI%IJ@L 16l0 ; 8roO^t)ec'㽣{9oe|0YmC@%"8_̍_UUd^GMmBq3L21LzK20Q 4dժVݙAS1K'*:QTM:fv{=_F[$sk2{3Nq@.\t5u~q* " 9!i %ٌN*h85a(!Nk-V(T%j!saVIt(*qo8zI8r{(%"M;Wd' &iwlpQU`I⬬B,"v;o7cfDRpӌ9R=G;w.c}ڨJ"i%:xNF979qr4sMdlY3p>sdZ/ÉEP;26r 2K2M*ǘPa#Y29­U1Ntu3k a h^ 0Ww@25E+q\4;8ޙ{ݳ"-f&tjS+ *+m٩sl#:VQg (Zа-5NY-!UdD8foWt,BbSo`ttyswR`;vy7#JSd,|Nʧh!EO"* (0* X&Qj@u*!4drs:S$?žKH/=#Gh )4Q,vݬ߫lH6h|_.,<~ C)<i Wk-jRn&u886GV.f`mSERhv'M YLLX %c(!STaZ쏶{u \r/{db#e&`ekN*.qG0$,p7px"M~ͣIΖ-P4ȴ|tH5!i0PAfgX99#|Ώ@˛seCi3ϲwCi498À`0*Z!$ERQ$ vV#*T{ 7ˌA }{.nD"IPU怕4BՀ*QY*$:Ng͍pO^o>Zﳾ =uw&R 486FC&1 4 چ,5hLCIbo]R_ߤ;?o^ЂLECACV5S- Dֲ&q^]&o6o74g_ og@,(J*Ivo#NMBHHElm]6.x_ϦgҟuKl!t u{C1D]yC-Uga+ oIENDB`weboob-1.1/modules/eatmanga/module.py000066400000000000000000000025671265717027300177400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderModule, DisplayPage __all__ = ['EatmangaModule'] class EatmangaModule(GenericComicReaderModule): NAME = 'eatmanga' DESCRIPTION = 'EatManga manga reading website' DOMAIN = 'www.eatmanga.com' BROWSER_PARAMS = dict( img_src_xpath="//img[@class='eatmanga_bigimage']/@src", page_list_xpath="(//select[@id='pages'])[1]/option/@value") ID_REGEXP = r'[^/]+/[^/]+' URL_REGEXP = r'.+eatmanga.com/(?:index.php/)?Manga-Scan/(%s).+' % ID_REGEXP ID_TO_URL = 'http://www.eatmanga.com/index.php/Manga-Scan/%s' PAGES = {URL_REGEXP: DisplayPage} weboob-1.1/modules/eatmanga/test.py000066400000000000000000000017401265717027300174220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.capabilities.gallery.genericcomicreadertest import GenericComicReaderTest class EatmangaTest(GenericComicReaderTest): MODULE = 'eatmanga' def test_download(self): return self._test_download('Glass-Mask/Glass-Mask-Vol-031') weboob-1.1/modules/ebonics/000077500000000000000000000000001265717027300157345ustar00rootroot00000000000000weboob-1.1/modules/ebonics/__init__.py000066400000000000000000000014331265717027300200460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import EbonicsModule __all__ = ['EbonicsModule'] weboob-1.1/modules/ebonics/favicon.png000066400000000000000000000145001265717027300200670ustar00rootroot00000000000000PNG  IHDR@@iqbKGD___4ƍ pHYs  tIME  &CtEXtCommentCreated with GIMPWIDATx͛{eYU?k0 %8`DIDT0E$*c$$!FI"&)IYQ1!Vd"R@AyȠC$#3 3 L?~{9gV8i;MT}{z}.U^ٜ 'T@Hy |_Y)v)EDp. JKuasp#h<98D6[Lbx'Zܜ[B*pcc܏䩒q,V rwrWo[5jh#\.~VkKk-TړUO»މ Gp\PO4."',ƛ}>:,x1gou/]\W$CRCu'xšW>~gfo01p[ -۩Rƾg>Y/r>{>@C(J5VTO%|&S-a8oj㛟XYi*/Bc%/c灵="?o2u D(y@YY\[%(;޳Awi- e`ͺ;& }˹ kV2JxŭʛйlO `?BJhԩ!6koId]}߳îDsk|ӷ [) bb3E DA/R2m݁CAqr9WNT̐TOrj1MKR|K@J(b*PEpw# &8D>[U(A҂OgbZ"aUrWv: Qq(aMA*YAr&2yфBm!a;>z3jg AIyC,k3q0M;7jFFS`0VLQbKDXOLc({~&-.b)PK6-*FuCO|b qpȔ ZJFpN@[VeðS$Jĉ2f <<97BlYږ\F ڀ0^Ɔ`+kW3^q/u&h"eXҊ1nlAK #"tbgMB<#T ׉Q'Ak 0BFڠ1?DrY;#GKbD'`8tl&]p/DQi)e5^{ D $:qfy)! H MOo4-L8[ )&(iP)%c*{H'8BXƝ8/hGHHB "zxXO0a4&hB'وUָf,S=2]kRIdIj&}61ٳMSoPIlAtd+R hN%邺~f d  Zىo=;3Nu04!0;`.n< G{eLH4Xi7'P ,Sq\ E`2PN2mh3kZSb f#I# bM8l9֏/(L# 1TZpYX2MKD$Ub!)SpxX/WePfv*e,m6, e`` BL<R2qF{r]ւu5T0"FBFK] 2VP7Q"DfI-`> Хa qB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vv0 'KUm[?uꔿ}c~ww'=okf!$֑ƵWGq$ΫO_4RuaiTwu{??ɉ'R{Nz衋cv]0 *}oö1RkEU9{,vGx_LbӒf62ǎww_UJ@r gŠTEm>{ߧLjTBIENDB`weboob-1.1/modules/ebonics/module.py000066400000000000000000000037661265717027300176070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from weboob.capabilities.translate import CapTranslate, Translation, TranslationFail, LanguageNotSupported from weboob.tools.backend import Module from weboob.deprecated.browser import StandardBrowser __all__ = ['EbonicsModule'] class EbonicsModule(Module, CapTranslate): NAME = 'ebonics' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'English to Ebonics translation service' BROWSER = StandardBrowser def translate(self, lan_from, lan_to, text): if lan_from != 'English' or lan_to != 'Nigger!': raise LanguageNotSupported() with self.browser: data = {'English': text.encode('utf-8')} doc = self.browser.location('http://joel.net/EBONICS/Translator', urllib.urlencode(data)) try: text = doc.getroot().cssselect('div.translateform div.bubble1 div.bubblemid')[0].text except IndexError: raise TranslationFail() if text is None: raise TranslationFail() translation = Translation(0) translation.lang_src = unicode(lan_from) translation.lang_dst = unicode(lan_to) translation.text = unicode(text).strip() return translation weboob-1.1/modules/ebonics/test.py000066400000000000000000000016441265717027300172720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class EbonicsTest(BackendTest): MODULE = 'ebonics' def test_translate(self): self.backend.translate('English', 'Nigger!', 'I like penis.') weboob-1.1/modules/edf/000077500000000000000000000000001265717027300150505ustar00rootroot00000000000000weboob-1.1/modules/edf/__init__.py000066400000000000000000000014351265717027300171640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Christophe Gouiran # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import EdfModule __all__ = ['EdfModule'] weboob-1.1/modules/edf/browser.py000066400000000000000000000101261265717027300171050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Christophe Gouiran # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.capabilities.bill import Detail from decimal import Decimal from .pages import LoginPage, FirstRedirectionPage, SecondRedirectionPage, OtherPage, AccountPage, BillsPage, LastPaymentsPage, LastPaymentsPage2 __all__ = ['EdfBrowser'] class EdfBrowser(Browser): PROTOCOL = 'https' DOMAIN = 'monagencepart.edf.fr' ENCODING = None #DEBUG_HTTP = True #DEBUG_MECHANIZE = True PAGES = {'.*page_authentification': LoginPage, '.*serviceRedirectionAel.*': FirstRedirectionPage, '.*Routage\?service=.*': SecondRedirectionPage, '.*routage/Routage.*': SecondRedirectionPage, '.*page_synthese_client': AccountPage, '.*autres-pages-.*': OtherPage, '.*page_mes_factures.*': BillsPage, '.*portlet_mon_paiement_1.*': LastPaymentsPage, '.*portlet_echeancier_2.*': LastPaymentsPage2 } loginp = '/ASPFront/appmanager/ASPFront/front?_nfpb=true&_pageLabel=page_authentification' accountp = '/ASPFront/appmanager/ASPFront/front?_nfls=false&_nfpb=true&_pageLabel=private/page_synthese_client' billsp = '/ASPFront/appmanager/ASPFront/front?_nfls=false&_nfpb=true&_pageLabel=private/page_mes_factures&portletInstance2=portlet_suivi_consommation_2' lastpaymentsp = '/ASPFront/appmanager/ASPFront/front?_nfls=false&_nfpb=true&_pageLabel=private/page_mon_paiement&portletInstance=portlet_mon_paiement_1' is_logging = False def home(self): if not self.is_logged(): self.login() def is_logged(self): logged = self.page and self.page.is_logged() or self.is_logging self.logger.debug('logged: %s' % (logged)) return logged def login(self): # Do we really need to login? if self.is_logged(): self.logger.debug('Already logged in') return self.is_logging = True self.location(self.loginp) self.page.login(self.username, self.password) self.is_logging = False if not self.is_logged(): raise BrowserIncorrectPassword() def iter_subscription_list(self): if not self.is_on_page(AccountPage): self.location(self.accountp) return self.page.iter_subscription_list() def get_subscription(self, id): assert isinstance(id, basestring) for sub in self.iter_subscription_list(): if id == sub._id: return sub return None def iter_history(self, sub): if not sub._id.isdigit(): return [] if not self.is_on_page(LastPaymentsPage): self.location(self.lastpaymentsp) return self.page.iter_payments(sub) def iter_details(self, sub): det = Detail() det.id = sub.id det.label = sub.label det.infos = '' det.price = Decimal('0.0') yield det def iter_bills(self, sub): if not sub._id.isdigit(): return [] if not self.is_on_page(BillsPage): self.location(self.billsp) return self.page.iter_bills(sub) def get_bill(self, id): assert isinstance(id, basestring) subs = self.iter_subscription_list() for sub in subs: for b in self.iter_bills(sub): if id == b.id: return b weboob-1.1/modules/edf/favicon.png000066400000000000000000000042111265717027300172010ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME0IDATxk]Uo>LfA &C;Z5Ш$XL+DSC$H  JiIma H \ tfe^PZvڙN|N&kZ߻ 6mǴp4ݱL0 4ǴEGP_yyGr6F|P@>D/;GDq'K"XX&a A(ko;q lU(%=/ th&þR~# BXI3'jdMv7V݁5gd8?]V|׋]οc9xaJ2RcaB<%E+Ց*`AU/+ 1E^T5S!fsح0J =([ϑKX>ٕV;_㶬#HgVeڨ'61QuxXdMA|]|44qܭ;߽\[R΀d+9yΝ cʎ*z؜r}E&3U/^|B]"k:q pP F& Fƚ̸}Xԥ =L;-"dبrM^P ՔJUV2 {U9uR`%Y S:y+6iGõv:f}X?ʀN+B 5;/&d[`MrWZsFQՁi!Gu6.UB 7ˈ PdոgOճpvZK9)D+ 5j$Zs¦V[.[N|=[b1d M&O.? 4L۴M۴Q`܅IENDB`weboob-1.1/modules/edf/module.py000066400000000000000000000063621265717027300167160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Christophe Gouiran # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bill import CapBill, SubscriptionNotFound, BillNotFound, Subscription, Bill from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import EdfBrowser __all__ = ['EdfModule'] class EdfModule(Module, CapBill): NAME = 'edf' DESCRIPTION = u'Edf website: French power provider' MAINTAINER = u'Christophe Gouiran' EMAIL = 'bechris13250@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' BROWSER = EdfBrowser CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Password', masked=True) ) BROWSER = EdfBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): return self.browser.iter_subscription_list() def get_subscription(self, _id): with self.browser: subscription = self.browser.get_subscription(_id) if not subscription: raise SubscriptionNotFound() else: return subscription def iter_bills_history(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) with self.browser: return self.browser.iter_history(subscription) def get_details(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) with self.browser: return self.browser.iter_details(subscription) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) with self.browser: return self.browser.iter_bills(subscription) def get_bill(self, id): with self.browser: bill = self.browser.get_bill(id) if not bill: raise BillNotFound() else: return bill def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) with self.browser: return self.browser.readurl(bill._url) weboob-1.1/modules/edf/pages.py000066400000000000000000000146271265717027300165330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Christophe Gouiran # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime import re import urllib from decimal import Decimal from weboob.deprecated.browser import Page from weboob.capabilities.bill import Subscription, Detail, Bill from weboob.tools.capabilities.bank.transactions import FrenchTransaction base_url = "http://particuliers.edf.com/" class EdfBasePage(Page): def is_logged(self): return (u'Me déconnecter' in self.document.xpath('//a/text()')) \ or (self.document.xpath('//table[contains(@summary, "Informations sur mon")]')) class LoginPage(EdfBasePage): def login(self, login, password): self.browser.select_form("identification") self.browser["login"] = str(login) self.browser["pswd"] = str(password) self.browser.submit() class HomePage(EdfBasePage): def on_loaded(self): pass class FirstRedirectionPage(EdfBasePage): def on_loaded(self): self.browser.select_form("form1") self.browser.submit() class SecondRedirectionPage(EdfBasePage): def on_loaded(self): self.browser.select_form("redirectForm") self.browser.submit() class OtherPage(EdfBasePage): def on_loaded(self): self.browser.open(base_url) class AccountPage(EdfBasePage): def iter_subscription_list(self): boxHeader = self.document.xpath('//div[@class="boxHeader"]')[0] subscriber = self.parser.tocleanstring(boxHeader.xpath('.//p')[0]) contract = self.parser.tocleanstring(boxHeader.xpath('.//p[@class="folderNumber"]')[0]) if not re.search('^Contrat n\xb0\s*', contract): return contract = re.sub('Contrat n\xb0\s*', '', contract) number = re.sub('[^\d]', '', contract) sub = Subscription(number) sub._id = number sub.label = subscriber sub.subscriber = subscriber yield sub class BillsPage(EdfBasePage): def iter_bills(self, sub): #pdb.set_trace() years = [None] + self.document.xpath('//ul[@class="years"]/li/a') for year in years: #pdb.set_trace() if year is not None and year.attrib['href']: self.browser.location(year.attrib['href']) tables = self.browser.page.document.xpath('//table[contains(@summary, "factures")]') for table in tables: for tr in table.xpath('.//tr'): list_tds = tr.xpath('.//td') if len(list_tds) == 0: continue url = re.sub('[\r\n\t]', '', list_tds[0].xpath('.//a')[0].attrib['href']) date_search = re.search('dateFactureQE=(\d+/\d+/\d+)', url) if not date_search: continue date = datetime.strptime(date_search.group(1), "%d/%m/%Y").date() amount = self.parser.tocleanstring(list_tds[2]) if amount is None: continue bill = Bill() bill.id = sub._id + "." + date.strftime("%Y%m%d") bill.price = Decimal(FrenchTransaction.clean_amount(amount)) bill.currency = bill.get_currency(amount) bill.date = date bill.label = self.parser.tocleanstring(list_tds[0]) bill.format = u'pdf' bill._url = url yield bill def get_bill(self, bill): self.location(bill._url) class LastPaymentsPage(EdfBasePage): def on_loaded(self): # Here we simulate ajax request to following URL: # https://monagencepart.edf.fr/ASPFront/appmanager/ASPFront/front/portlet_echeancier_2?_nfpb=true&_portlet.contentOnly=true&_portlet.instanceLabel=portlet_echeancier_2&_portlet.contentMode=FRAGMENT&_portlet.async=true&_portlet.pageLabel=page_mon_paiement&_portlet.lafUniqueId=aspDefinitionLabel&_portlet.portalUrl=%2FASPFront%2Fappmanager%2FASPFront%2Ffront&_portlet.portalId=ASPFront%09front&_portlet.contentType=text%2Fhtml%3B+charset%3DUTF-8&_portlet.asyncMode=compat_9_2&_portlet.title=CalendrierpaiementController&_nfsp=true params = { '_nfpb': 'true', '_portlet.async': 'true', '_portlet.portalId': 'ASPFront\tfront', '_portlet.contentOnly': 'true', '_portlet.title': 'CalendrierpaiementController', '_portlet.pageLabel': 'page_mon_paiement', '_portlet.asyncMode': 'compat_9_2', '_portlet.lafUniqueId': 'aspDefinitionLabel', '_portlet.contentMode': 'FRAGMENT', '_portlet.instanceLabel': 'portlet_echeancier_2', '_portlet.contentType': 'text/html; charset=UTF-8', '_portlet.portalUrl': '/ASPFront/appmanager/ASPFront/front', '_nfsp': 'true' } self.browser.location('/ASPFront/appmanager/ASPFront/front/portlet_echeancier_2?%s' % urllib.urlencode(params)) class LastPaymentsPage2(EdfBasePage): def iter_payments(self, sub): table = self.browser.page.document.xpath('//table[contains(@summary, "Informations sur mon")]')[0] for tr in table.xpath('.//tr'): list_tds = tr.xpath('.//td') if len(list_tds) == 0: continue date = datetime.strptime(self.parser.tocleanstring(list_tds[0]), "%d/%m/%Y").date() amount = self.parser.tocleanstring(list_tds[1]) if amount is None: continue det = Detail() det.id = sub._id + "." + date.strftime("%Y%m%d") det.price = Decimal(re.sub('[^\d,-]+', '', amount).replace(',', '.')) det.datetime = date det.label = unicode(self.parser.tocleanstring(list_tds[2])) yield det weboob-1.1/modules/edf/test.py000066400000000000000000000021201265717027300163740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Christophe Gouiran # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class EdfTest(BackendTest): MODULE = 'edf' def test_edf(self): for subscription in self.backend.iter_subscription(): list(self.backend.iter_bills_history(subscription.id)) for bill in self.backend.iter_bills(subscription.id): self.backend.download_bill(bill.id) weboob-1.1/modules/ehentai/000077500000000000000000000000001265717027300157275ustar00rootroot00000000000000weboob-1.1/modules/ehentai/__init__.py000066400000000000000000000014401265717027300200370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import EHentaiModule __all__ = ['EHentaiModule'] weboob-1.1/modules/ehentai/browser.py000066400000000000000000000070271265717027300177720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from urllib import urlencode from .pages import IndexPage, GalleryPage, ImagePage, HomePage, LoginPage from .gallery import EHentaiImage __all__ = ['EHentaiBrowser'] class EHentaiBrowser(Browser): ENCODING = None PAGES = { r'http://[^/]+/': IndexPage, r'http://[^/]+/\?.*': IndexPage, r'http://[^/]+/g/.+': GalleryPage, r'http://[^/]+/s/.*': ImagePage, r'http://[^/]+/home\.php': HomePage, r'http://e-hentai\.org/bounce_login\.php': LoginPage, } def __init__(self, domain, username, password, *args, **kwargs): self.DOMAIN = domain self.logged = False Browser.__init__(self, parser=('lxmlsoup',), *args, **kwargs) if password: self.login(username, password) def _gallery_url(self, gallery): return 'http://%s/g/%s/' % (self.DOMAIN, gallery.id) def _gallery_page(self, gallery, n): return gallery.url + ('?p='+str(n)) def search_galleries(self, pattern): self.location(self.buildurl('/', f_search=pattern.encode('utf-8'))) assert self.is_on_page(IndexPage) return self.page.iter_galleries() def latest_gallery(self): self.location('/') assert self.is_on_page(IndexPage) return self.page.iter_galleries() def iter_gallery_images(self, gallery): self.location(gallery.url) assert self.is_on_page(GalleryPage) for n in self.page._page_numbers(): self.location(self._gallery_page(gallery, n)) assert self.is_on_page(GalleryPage) for img in self.page.image_pages(): yield EHentaiImage(img) def get_image_url(self, image): self.location(image.id) assert self.is_on_page(ImagePage) return self.page.get_url() def gallery_exists(self, gallery): gallery.url = self._gallery_url(gallery) self.location(gallery.url) assert self.is_on_page(GalleryPage) return self.page.gallery_exists(gallery) def fill_gallery(self, gallery, fields): gallery.url = self._gallery_url(gallery) self.location(gallery.url) assert self.is_on_page(GalleryPage) self.page.fill_gallery(gallery) def login(self, username, password): assert isinstance(username, basestring) assert isinstance(password, basestring) data = {'ipb_login_username': username, 'ipb_login_password': password} self.location('http://e-hentai.org/bounce_login.php', urlencode(data), no_login=True) assert self.is_on_page(LoginPage) if not self.page.is_logged(): raise BrowserIncorrectPassword() # necessary in order to reach the fjords self.home() weboob-1.1/modules/ehentai/favicon.png000066400000000000000000000016251265717027300200660ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME,!IȀtEXtCommentCreated with GIMPWIDATxMEߎ1FM#QEP0b.hD EPB=x3ы.AK,n!$ E\ F-Ԡqm:μ? M{]MիWUAAAA0nL)<+߶fy'[y}ށIhAB֥t =HP4;q`_K4>ƣWeu&jB!۔^ɶ+(j5A0 sك}$wmQV{ɋ)^# mvܚ.8S8SZIL4T78_F-H6Olc(EXAgw'VciwO_S :ŀiͣ0|qSrvڭ *{w.Ϙ;^i¡%twC oZ^`c^K_لuV \fG@QVg06|e!Fg/P{ C)Ni$:!R.~9|wF};-:X<>qpRn0Ā8 cM;d/'N6?;%]TONִs-^6]5ߵo^\#[~Skx=O1~8\u'}jv<AAAcߊIENDB`weboob-1.1/modules/ehentai/gallery.py000066400000000000000000000021131265717027300177350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.gallery import BaseGallery, BaseImage __all_ = ['EHentaiGallery', 'EHentaiImage'] class EHentaiGallery(BaseGallery): def __init__(self, *args, **kwargs): BaseGallery.__init__(self, *args, **kwargs) class EHentaiImage(BaseImage): def __init__(self, *args, **kwargs): BaseImage.__init__(self, *args, **kwargs) weboob-1.1/modules/ehentai/module.py000066400000000000000000000100241265717027300175630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.capabilities.gallery import CapGallery, BaseGallery from weboob.capabilities.collection import CapCollection, CollectionNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.misc import ratelimit from weboob.tools.value import Value, ValueBackendPassword from .browser import EHentaiBrowser from .gallery import EHentaiGallery, EHentaiImage __all__ = ['EHentaiModule'] class EHentaiModule(Module, CapGallery, CapCollection): NAME = 'ehentai' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' VERSION = '1.1' DESCRIPTION = 'E-Hentai galleries' LICENSE = 'AGPLv3+' BROWSER = EHentaiBrowser CONFIG = BackendConfig( Value('domain', label='Domain', default='g.e-hentai.org'), Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password')) def create_default_browser(self): username = self.config['username'].get() if username: password = self.config['password'].get() else: password = None return self.create_browser(self.config['domain'].get(), username, password) def search_galleries(self, pattern, sortby=None): with self.browser: return self.browser.search_galleries(pattern) def iter_gallery_images(self, gallery): self.fillobj(gallery, ('url',)) with self.browser: return self.browser.iter_gallery_images(gallery) ID_REGEXP = r'/?\d+/[\dabcdef]+/?' URL_REGEXP = r'.+/g/(%s)' % ID_REGEXP def get_gallery(self, _id): match = re.match(r'^%s$' % self.URL_REGEXP, _id) if match: _id = match.group(1) else: match = re.match(r'^%s$' % self.ID_REGEXP, _id) if match: _id = match.group(0) else: return None gallery = EHentaiGallery(_id) with self.browser: if self.browser.gallery_exists(gallery): return gallery else: return None def fill_gallery(self, gallery, fields): if not gallery.__iscomplete__(): with self.browser: self.browser.fill_gallery(gallery, fields) def fill_image(self, image, fields): with self.browser: image.url = self.browser.get_image_url(image) if 'data' in fields: ratelimit("ehentai_get", 2) image.data = self.browser.readurl(image.url) def iter_resources(self, objs, split_path): if BaseGallery in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest_nsfw']) if collection.split_path == [u'latest_nsfw']: for gallery in self.browser.latest_gallery(): yield gallery def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseGallery in objs and collection.split_path == [u'latest_nsfw']: collection.title = u'Latest E-Hentai galleries (NSFW)' return raise CollectionNotFound(collection.split_path) OBJECTS = { EHentaiGallery: fill_gallery, EHentaiImage: fill_image} weboob-1.1/modules/ehentai/pages.py000066400000000000000000000065071265717027300174100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Page from weboob.tools.capabilities.thumbnail import Thumbnail from datetime import datetime import re from .gallery import EHentaiGallery class LoginPage(Page): def is_logged(self): success_p = self.document.xpath( '//p[text() = "Login Successful. You will be returned momentarily."]') if len(success_p): return True else: return False class HomePage(Page): pass class IndexPage(Page): def iter_galleries(self): lines = self.document.xpath('//table[@class="itg"]//tr[@class="gtr0" or @class="gtr1"]') for line in lines: a = line.xpath('.//div[@class="it3"]/a')[-1] url = a.attrib["href"] title = a.text.strip() yield EHentaiGallery(re.search('(?<=/g/)\d+/[\dabcdef]+', url).group(0), title=title) class GalleryPage(Page): def image_pages(self): return self.document.xpath('//div[@class="gdtm"]//a/attribute::href') def _page_numbers(self): return [n for n in self.document.xpath("(//table[@class='ptt'])[1]//td/text()") if re.match(r"\d+", n)] def gallery_exists(self, gallery): if self.document.xpath("//h1"): return True else: return False def fill_gallery(self, gallery): gallery.title = self.document.xpath("//h1[@id='gn']/text()")[0] cardinality_string = self.document.xpath("//div[@id='gdd']//tr[td[@class='gdt1']/text()='Length:']/td[@class='gdt2']/text()")[0] gallery.cardinality = int(re.match(r"\d+", cardinality_string).group(0)) date_string = self.document.xpath("//div[@id='gdd']//tr[td[@class='gdt1']/text()='Posted:']/td[@class='gdt2']/text()")[0] gallery.date = datetime.strptime(date_string, "%Y-%m-%d %H:%M") rating_string = self.document.xpath("//td[@id='rating_label']/text()")[0] rating_match = re.search(r"\d+\.\d+", rating_string) if rating_match is None: gallery.rating = None else: gallery.rating = float(rating_match.group(0)) gallery.rating_max = 5 try: thumbnail_url = self.document.xpath("//div[@class='gdtm']/a/img/attribute::src")[0] except IndexError: thumbnail_style = self.document.xpath("//div[@class='gdtm']/div/attribute::style")[0] thumbnail_url = re.search(r"background:[^;]+url\((.+?)\)", thumbnail_style).group(1) gallery.thumbnail = Thumbnail(thumbnail_url) class ImagePage(Page): def get_url(self): return self.document.xpath('//div[@class="sni"]/a/img/attribute::src')[0] weboob-1.1/modules/ehentai/test.py000066400000000000000000000031531265717027300172620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.gallery import BaseGallery class EHentaiTest(BackendTest): MODULE = 'ehentai' def test_search(self): l = list(self.backend.search_galleries('lol')) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for gallery "%s" not found: %s' % (v.id, v.url)) self.backend.browser.openurl(v.url) img = self.backend.iter_gallery_images(v).next() self.backend.fillobj(img, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for first image in gallery "%s" not found: %s' % (v.id, img.url)) self.backend.browser.openurl(img.url) def test_latest(self): l = list(self.backend.iter_resources([BaseGallery], [u'latest_nsfw'])) assert len(l) > 0 weboob-1.1/modules/entreparticuliers/000077500000000000000000000000001265717027300200565ustar00rootroot00000000000000weboob-1.1/modules/entreparticuliers/__init__.py000066400000000000000000000014601265717027300221700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import EntreparticuliersModule __all__ = ['EntreparticuliersModule'] weboob-1.1/modules/entreparticuliers/browser.py000066400000000000000000000116451265717027300221220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.json import json from weboob.capabilities.housing import Query, TypeNotSupported from weboob.browser import PagesBrowser, URL from .pages import CitiesPage, SearchPage, HousingPage class EntreparticuliersBrowser(PagesBrowser): BASEURL = 'http://www.entreparticuliers.com' cities = URL('/HTTPHandlers/LocalisationsAutocompleteHandler.ashx\?q=(?P.*)', CitiesPage) search = URL('/Default.aspx/CreateSearchParams') form_item = URL('/Default.aspx/GetElementsMoteur') search_result = URL('/annonces-immobilieres/vente/resultats-de-recherche-ergo', SearchPage) housing = URL('/(?P<_id>.*).html', HousingPage) def search_city(self, pattern): return self.cities.open(pattern=pattern).iter_cities() TYPES = {Query.TYPE_RENT: "1", Query.TYPE_SALE: "4" } RET = {Query.TYPE_RENT: {Query.HOUSE_TYPES.HOUSE: '2', Query.HOUSE_TYPES.APART: '1', Query.HOUSE_TYPES.LAND: '', Query.HOUSE_TYPES.PARKING: '4', Query.HOUSE_TYPES.OTHER: '6'}, Query.TYPE_SALE: {Query.HOUSE_TYPES.HOUSE: '2', Query.HOUSE_TYPES.APART: '1', Query.HOUSE_TYPES.LAND: '5', Query.HOUSE_TYPES.PARKING: '6', Query.HOUSE_TYPES.OTHER: '9'} } def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types): if type not in self.TYPES: raise TypeNotSupported referer = "http://www.entreparticuliers.com/annonces-immobilieres/vente/resultats-de-recherche-ergo" self.session.headers.update({"X-Requested-With": "XMLHttpRequest", "Referer": referer, "Content-Type": "application/json; charset=utf-8", "Accept": "application/json, text/javascript, */*; q=0.01"}) result = self.form_item.open(data="{'rubrique': '%s'}" % self.TYPES.get(type)) biens = json.loads(json.loads(result.content)['d']) for house_type in house_types: id_type = self.RET[type].get(house_type, '1') data = {} data['rubrique'] = self.TYPES.get(type) data['ach_id'] = None data['FromMoteur'] = "true" for bien in biens: if bien['Idchoix'] == int(id_type): data['lstSSTbien'] = bien['SsTypebien'] data['lstTbien'] = bien['TypeBien'] data['Caracteristique'] = bien['Idchoix'] data['OrigineAlerte'] = "SaveSearchMoteurHome" data['pays'] = "fra" data['prix_min'] = cost_min if cost_min and cost_min > 0 else None data['prix_max'] = cost_max if cost_max and cost_max > 0 else None data['lstThemes'] = "" min_rooms = nb_rooms if nb_rooms else None if not min_rooms: data['lstNbPieces'] = 0 else: data['lstNbPieces'] = ','.join('%s' % n for n in range(min_rooms, 6)) data['lstNbChambres'] = None data['surface_min'] = area_min if area_min else None # var modes = { "all": -1, "ville": 5, "region": 2, "departement": 4, "pays": 1, "regionUsuelle": 3 }; data['localisationType'] = 5 data['reference'] = '' data['rayon'] = 0 data['localisation_id_rayon'] = None data['lstLocalisationId'] = ','.join(cities) data['photos'] = 0 data['colocation'] = '' data['meuble'] = '' data['pageNumber'] = 1 data['order_by'] = 1 data['sort_order'] = 1 data['top'] = 25 data['SaveSearch'] = "false" data['EmailUser'] = "" data['GSMUser'] = "" self.search.go(data="{'p_SearchParams':'%s', 'forcealerte':'0'}" % json.dumps(data)) for item in self.search_result.go().iter_housings(): yield item def get_housing(self, _id, obj=None): return self.housing.go(_id=_id).get_housing(obj=obj) weboob-1.1/modules/entreparticuliers/module.py000066400000000000000000000042331265717027300217170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.housing import CapHousing, Housing, HousingPhoto from .browser import EntreparticuliersBrowser __all__ = ['EntreparticuliersModule'] class EntreparticuliersModule(Module, CapHousing): NAME = 'entreparticuliers' DESCRIPTION = u'entreparticuliers.com website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = EntreparticuliersBrowser def search_city(self, pattern): return self.browser.search_city(pattern) def search_housings(self, query): cities = [c.id for c in query.cities if c.backend == self.name] if len(cities) == 0: return list([]) return self.browser.search_housings(query.type, cities, query.nb_rooms, query.area_min, query.area_max, query.cost_min, query.cost_max, query.house_types) def get_housing(self, _id): return self.browser.get_housing(_id) def fill_housing(self, housing, fields): return self.browser.get_housing(housing.id, housing) def fill_photo(self, photo, fields): if 'data' in fields and photo.url and not photo.data: photo.data = self.browser.open(photo.url).content return photo OBJECTS = {Housing: fill_housing, HousingPhoto: fill_photo} weboob-1.1/modules/entreparticuliers/pages.py000066400000000000000000000107301265717027300215300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal from datetime import datetime import re from weboob.browser.pages import JsonPage, HTMLPage from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.browser.filters.json import Dict from weboob.browser.filters.html import CleanHTML from weboob.browser.filters.standard import CleanText, CleanDecimal, Regexp, Env, BrowserURL from weboob.capabilities.housing import Housing, HousingPhoto, City class CitiesPage(JsonPage): @method class iter_cities(DictElement): class item(ItemElement): klass = City def condition(self): return Dict('id', default=None)(self) and\ Dict('localisationType')(self) == u'ville' obj_id = Dict('id') obj_name = Dict('libelle') class SearchPage(HTMLPage): @method class iter_housings(ListElement): item_xpath = '//li[@class="annonce"]' class item(ItemElement): klass = Housing def condition(self): return CleanText('./div/span[@class="infos"]/a[@class="titre"]/@href')(self) obj_id = Regexp(CleanText('./div/span[@class="infos"]/a[@class="titre"]/@href'), '/(.*).html') obj_title = CleanText('./div/span[@class="infos"]/a[@class="titre"]') obj_cost = CleanDecimal(Regexp(CleanText('./div/span[@class="infos"]/span[@id="spanprix"]/text()'), '(.*) [%s%s%s].*' % (u'€', u'$', u'£'), default=''), replace_dots=(',', '.'), default=Decimal(0)) obj_currency = Regexp(CleanText('./div/span[@class="infos"]/span[@id="spanprix"]'), '.*([%s%s%s]).*' % (u'€', u'$', u'£'), default=u'€') obj_text = CleanText('./div/span[@class="infos"]/span[@id="spandescription"]/text()') obj_date = datetime.now class HousingPage(HTMLPage): @method class get_housing(ItemElement): klass = Housing obj_id = Env('_id') obj_title = CleanText('//main/section/div/h1') def obj_cost(self): for detail in self.el.xpath('//span[@class="i small"]|//span[@class="i prix"]'): m = re.search('(.*) [%s%s%s].*' % (u'€', u'$', u'£'), CleanText('.')(detail)) if m: return Decimal(m.group(1).replace(' ', '')) obj_currency = Regexp(CleanText('//span[@class="i small"]'), '.*([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') obj_text = CleanHTML('//article[@class="bloc description"]/p') obj_location = CleanText('//span[@class="i ville"]') def obj_area(self): for detail in self.el.xpath('//span[@class="i"]'): m = re.search('.*\/(.*) m.*', CleanText('.')(detail)) if m: return Decimal(m.group(1).replace(' ', '')) obj_url = BrowserURL('housing', _id=Env('_id')) obj_phone = CleanText('//input[@id="hftel"]/@value') obj_date = datetime.now def obj_details(self): details = {} for detail in self.el.xpath('//span[has-class("i")]'): item = detail.text.split(':') if len(item) == 2: details[item[0]] = item[1] return details def obj_photos(self): photos = [] for img in self.el.xpath('//ul[@id="ulPhotos"]/li/img/@src'): url = u'http://www.entreparticuliers.com/%s' % img photos.append(HousingPhoto(url)) return photos weboob-1.1/modules/entreparticuliers/test.py000066400000000000000000000027111265717027300214100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import itertools from weboob.tools.test import BackendTest from weboob.capabilities.housing import Query class EntreparticuliersTest(BackendTest): MODULE = 'entreparticuliers' def test_entreparticuliers(self): query = Query() query.cities = [] for city in self.backend.search_city('lille'): city.backend = self.backend.name query.cities.append(city) query.type = Query.TYPE_SALE query.house_types = [Query.HOUSE_TYPES.HOUSE] results = list(itertools.islice(self.backend.search_housings(query), 0, 20)) self.assertTrue(len(results) > 0) obj = self.backend.fillobj(results[0]) self.assertTrue(obj.area is not None, 'Area for "%s"' % (obj.id)) weboob-1.1/modules/europarl/000077500000000000000000000000001265717027300161435ustar00rootroot00000000000000weboob-1.1/modules/europarl/__init__.py000066400000000000000000000001011265717027300202440ustar00rootroot00000000000000from .module import EuroparlModule __all__ = ['EuroparlModule'] weboob-1.1/modules/europarl/browser.py000066400000000000000000000042071265717027300202030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser from weboob.deprecated.browser.decorators import id2url #from .pages.index import IndexPage from .pages import VideoPage from .video import EuroparlVideo __all__ = ['EuroparlBrowser'] class EuroparlBrowser(Browser): DOMAIN = 'europarl.europa.eu' ENCODING = None PAGES = {r'http://[w\.]*europarl\.europa\.eu/ep-live/(?P\w+)/committees/video\?.*event=(?P[^&]+).*': VideoPage, r'http://[w\.]*europarl\.europa\.eu/ep-live/(?P\w+)/other-events/video\?.*event=(?P[^&]+).*': VideoPage #TODO:plenaries # r'http://[w\.]*europarl\.europa\.eu/ep-live/(?P\w+)/plenary/video\?.*date=(?P[^&]+).*': VideoPage # r'http://[w\.]*europarl\.europa\.eu/ep-live/(?P\w+)/plenary/video\?.*debate=(?P[^&]+).*': VideoPage } @id2url(EuroparlVideo.id2url) def get_video(self, url, video=None): self.location(url) return self.page.get_video(video) # def search_videos(self, pattern, sortby): # return None # self.location(self.buildurl('http://europarltv.europa.eu/en/search%s' % sortby, query=pattern.encode('utf-8'))) # assert self.is_on_page(IndexPage) # return self.page.iter_videos() # def latest_videos(self): # self.home() # assert self.is_on_page(IndexPage) # return self.page.iter_videos() weboob-1.1/modules/europarl/favicon.png000066400000000000000000000010161265717027300202740ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME 0RLtEXtCommentCreated with GIMPWvIDATx EۆjblOKNP(\\輮x,S jԽ ={-!?+[u= s7p$¿i DOhg ([Y&p9tXo#pڧ9?+ -byuѓOO":] JW#T7q3$I0ޑW) vwcvHg\<,ە"#oF2P$<"$Gk; x.0/F0z0oO= jtZs^a.FFu~#ZRklny 7Q@K-14D bZv_IENDB`weboob-1.1/modules/europarl/favicon_europarl.xcf000066400000000000000000000044441265717027300222110ustar00rootroot00000000000000gimp xcf file@@BBm gimp-commentCreated with GIMPgimp-image-grid(style solid) (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000)) (bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000)) (xspacing 10.000000) (yspacing 10.000000) (spacing-unit inches) (xoffset 0.000000) (yoffset 0.000000) (offset-unit inches) gamma0.45454999804496765t@@ favicon.png     @@@@77=77077 777%77777$777"777 777"777777"77777777777777<7$777!777"77 77!77777 7:7:7777N77=77<7/777,77 7-7 7+77,77777+7:7:777777=7777$777"77#77 777777777777777777777777777#7777%777%777%777777777.7:7:7777777=77077 777%77777$777"777 777"777777"77777777777777<7$777!777"77 77!77777 7:7:7777N77=77<7/777,77 7-7 7+77,77777+7:7:777777=7777$777"77#77 777777777777777777777777777#7777%777%777%777777777.7:7:777777=707 77%777$777"777 777"7777"77777777<7$77!77"77 77!777 7:7:77N7=7<7/77,7 7-7 7+77,777+7:7:777=77$77"77#77 777777777777777777#777%777%777%77777.7:7:77@@Masque de sélection @@ @@ weboob-1.1/modules/europarl/module.py000066400000000000000000000055301265717027300200050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import CapVideo, BaseVideo from weboob.tools.backend import Module from weboob.capabilities.collection import CapCollection, CollectionNotFound from .browser import EuroparlBrowser from .video import EuroparlVideo __all__ = ['EuroparlModule'] class EuroparlModule(Module, CapVideo, CapCollection): NAME = 'europarl' MAINTAINER = u'François Revol' EMAIL = 'revol@free.fr' VERSION = '1.1' DESCRIPTION = 'Europarl parliamentary video streaming website' LICENSE = 'AGPLv3+' BROWSER = EuroparlBrowser def get_video(self, _id): with self.browser: return self.browser.get_video(_id) SORTBY = ['relevance', 'rating', 'views', 'time'] # def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): # with self.browser: # return self.browser.search_videos(pattern, self.SORTBY[sortby]) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields with self.browser: video = self.browser.get_video(EuroparlVideo.id2url(video.id), video) if 'thumbnail' in fields and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest']) if collection.split_path == [u'latest']: for video in self.browser.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest']: collection.title = u'Latest Europarl videos' return raise CollectionNotFound(collection.split_path) OBJECTS = {EuroparlVideo: fill_video} weboob-1.1/modules/europarl/pages.py000066400000000000000000000104131265717027300176130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.mech import ClientForm ControlNotFoundError = ClientForm.ControlNotFoundError from weboob.deprecated.browser import Page import re import datetime from weboob.capabilities.base import NotAvailable from weboob.deprecated.browser import BrokenPageError from .video import EuroparlVideo class VideoPage(Page): def get_video(self, video=None): if video is None: video = EuroparlVideo(self.group_dict['id']) video.title = unicode(self.get_title()) video.url = unicode(self.get_url()) self.set_details(video) video.set_empty_fields(NotAvailable) return video def get_url(self): # search for # TODO: plenaries can be downloaded as mp4... obj = self.parser.select(self.document.getroot(), 'input#codeUrl', 1) if obj is None: return None return obj.attrib['value'] def get_title(self): obj = self.parser.select(self.document.getroot(), 'h1#player_subjectTitle') if len(obj) < 1: obj = self.parser.select(self.document.getroot(), 'title') if len(obj) < 1: return None title = obj[0].text.strip() obj = self.parser.select(self.document.getroot(), 'span.ep_subtitle') if len(obj) < 1: return title for span in self.parser.select(obj[0], 'span.ep_acronym, span.ep_theme'): if span.text_content(): title += ' ' + span.text_content().strip() return title def set_details(self, v): v.author = u'European Parliament' obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1) if obj is not None: value = obj.attrib['content'] m = re.match('(\d\d)-(\d\d)-(\d\d\d\d)\s*(\d\d):(\d\d)', value) if not m: raise BrokenPageError('Unable to parse datetime: %r' % value) day = m.group(1) month = m.group(2) year = m.group(3) hour = m.group(4) minute = m.group(5) v.date = datetime.datetime(year=int(year), month=int(month), day=int(day), hour=int(hour), minute=int(minute)) obj = self.parser.select(self.document.getroot(), 'span.ep_subtitle', 1) if obj is not None: span = self.parser.select(obj, 'span.ep_date', 1) value = span.text m = re.match('(\d\d):(\d\d)\s*\/\s*(\d\d):(\d\d)\s*-\s*(\d\d)-(\d\d)-(\d\d\d\d)', value) if not m: raise BrokenPageError('Unable to parse datetime: %r' % value) bhour = m.group(1) bminute = m.group(2) ehour = m.group(3) eminute = m.group(4) day = m.group(5) month = m.group(6) year = m.group(7) start = datetime.datetime(year=int(year), month=int(month), day=int(day), hour=int(bhour), minute=int(bminute)) end = datetime.datetime(year=int(year), month=int(month), day=int(day), hour=int(ehour), minute=int(eminute)) v.duration = end - start weboob-1.1/modules/europarl/test.py000066400000000000000000000031011265717027300174670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest #from weboob.capabilities.video import BaseVideo class EuroparlTest(BackendTest): MODULE = 'europarl' # def test_search(self): # l = list(self.backend.search_videos('neelie kroes')) # self.assertTrue(len(l) > 0) # v = l[0] # self.backend.fillobj(v, ('url',)) # self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) # self.backend.browser.openurl(v.url) # def test_latest(self): # l = list(self.backend.iter_resources([BaseVideo], [u'latest'])) # self.assertTrue(len(l) > 0) # v = l[0] # self.backend.fillobj(v, ('url',)) # self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) weboob-1.1/modules/europarl/video.py000066400000000000000000000032451265717027300176270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import BaseVideo import re class EuroparlVideo(BaseVideo): def __init__(self, *args, **kwargs): BaseVideo.__init__(self, *args, **kwargs) self.ext = u'wmv' @classmethod def id2url(cls, _id): m = re.match('.*-COMMITTEE-.*', _id) if m: return u'http://www.europarl.europa.eu/ep-live/en/committees/video?event=%s&format=wmv' % _id m = re.match('.*-SPECIAL-.*', _id) if m: return u'http://www.europarl.europa.eu/ep-live/en/other-events/video?event=%s&format=wmv' % _id # XXX: not yet supported m = re.match('\d\d-\d\d-\d\d\d\d', _id) if m: return u'http://www.europarl.europa.eu/ep-live/en/plenary/video?date=%s' % _id # XXX: not yet supported m = re.match('\d+', _id) if m: return u'http://www.europarl.europa.eu/ep-live/en/plenary/video?debate=%s' % _id return None weboob-1.1/modules/explorimmo/000077500000000000000000000000001265717027300165055ustar00rootroot00000000000000weboob-1.1/modules/explorimmo/__init__.py000066400000000000000000000014421265717027300206170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ExplorimmoModule __all__ = ['ExplorimmoModule'] weboob-1.1/modules/explorimmo/browser.py000066400000000000000000000057711265717027300205540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from weboob.browser import PagesBrowser, URL from weboob.capabilities.housing import Query, TypeNotSupported from .pages import CitiesPage, SearchPage, HousingPage, HousingPage2, PhonePage class ExplorimmoBrowser(PagesBrowser): BASEURL = 'http://www.explorimmo.com/' cities = URL('rest/locations\?q=(?P.*)', CitiesPage) search = URL('resultat/annonces.html\?(?P.*)', SearchPage) housing_html = URL('annonce-(?P<_id>.*).html', HousingPage) phone = URL('rest/classifieds/(?P<_id>.*)/phone', PhonePage) housing = URL('rest/classifieds/(?P<_id>.*)', 'rest/classifieds/\?(?P.*)', HousingPage2) TYPES = {Query.TYPE_RENT: 'location', Query.TYPE_SALE: 'vente'} RET = {Query.HOUSE_TYPES.HOUSE: 'Maison', Query.HOUSE_TYPES.APART: 'Appartement', Query.HOUSE_TYPES.LAND: 'Terrain', Query.HOUSE_TYPES.PARKING: 'Parking', Query.HOUSE_TYPES.OTHER: 'Divers'} def get_cities(self, pattern): return self.cities.open(city=pattern).get_cities() def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types): if type not in self.TYPES: raise TypeNotSupported() ret = [] for house_type in house_types: if house_type in self.RET: ret.append(self.RET.get(house_type)) data = {'location': ','.join(cities), 'areaMin': area_min or '', 'areaMax': area_max or '', 'priceMin': cost_min or '', 'priceMax': cost_max or '', 'transaction': self.TYPES.get(type, 'location'), 'recherche': '', 'mode': '', 'proximity': '0', 'roomMin': nb_rooms or '', 'page': '1' } query = '%s%s%s' % (urllib.urlencode(data), '&type=', '&type='.join(ret)) return self.search.go(query=query).iter_housings() def get_housing(self, _id, housing=None): return self.housing.go(_id=_id).get_housing(obj=housing) def get_phone(self, _id): return self.phone.go(_id=_id).get_phone() def get_total_page(self, js_datas): return self.housing.open(js_datas=js_datas).get_total_page() weboob-1.1/modules/explorimmo/favicon.png000066400000000000000000000044231265717027300206430ustar00rootroot00000000000000PNG  IHDR@@iqsRGBgAMA a pHYs+tEXtAuthorxrq tEXtCreationTime2014:01:24 11:19:28r!tEXtCreation Time2014:01:24 11:19:28xz;IDATx^ZiM__=d̑"#O $Ŕ/$ A^f Q"12뷲v{;]sZ{sSfCnEx9PR U\pڸqի}j֬镄 &m̘1tԩ[ԯ_/yds۷oO݋j*Yfي/^<~ئ|R4hdڴit~~>ґj 6HK@˖-IдiS)IEǥMw7o:CP~-Anݬ CjՒի'sAAA ˗/PM[.=zUIg}6A޿o|qXH +4q-C/N1|޾}kׯ_.%`ƌ`Zn#FHϟ[Eԩc;C`n }ڜ8qر#2ӭ͍7 9w9x)dɴjJ< Ov߰u0Ϟ=y:/Q8zUel@ 0ݻw]>5f͚5`Ͱa2F@c=JEȕ`@Y rJW.Q ?fܹ{eg̦ƱsMB^62Y&Tgg[plF:N8$h\G(!+V@]e x9b_lĕ ;>59~ByU53[l 8;ܲ:6x]U)mhҷQ02pb-o>B Vfg8D^ @,.xg0p7]|M 4Wty9?\W^qVi"bpVj`W'= }=Z#WЖG)Tu.);v%eѢEO /lZXW/ !aէv?,8^c}ա{$'EtI:qnx(:jm3S/):ٽ{7۷K]uwf&IB{ z z|_^n 6zl?.uE B_>|x6zSZQ\#.:;Aӻ>(et `'QdyÇON͛7iĉ;UADq_dm 2viǏ6 LP`Qd`>/Z@jOw`!)8IX!-Bʕ2N*+D% o/:@.~2ĂJW;xPxу]  [æNwe%BztZlhvZV%LI+Bz<0`^X0vu(kyc UBdz} r"+BpQ"q =À.su=O[2k]/{+3 cǎ%Xdzh…iwf@qf_+ 4> nj璆,7ޭ\&F9`oK%XOSIENDB`weboob-1.1/modules/explorimmo/module.py000066400000000000000000000047371265717027300203570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.housing import CapHousing, Housing, HousingPhoto from .browser import ExplorimmoBrowser __all__ = ['ExplorimmoModule'] class ExplorimmoModule(Module, CapHousing): NAME = 'explorimmo' DESCRIPTION = u'explorimmo website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = ExplorimmoBrowser def get_housing(self, housing): if isinstance(housing, Housing): id = housing.id else: id = housing housing = None housing = self.browser.get_housing(id, housing) housing.phone = self.browser.get_phone(id) return housing def search_city(self, pattern): return self.browser.get_cities(pattern) def search_housings(self, query): cities = ['%s' % c.id for c in query.cities if c.backend == self.name] if len(cities) == 0: return list() return self.browser.search_housings(query.type, cities, query.nb_rooms, query.area_min, query.area_max, query.cost_min, query.cost_max, query.house_types) def fill_housing(self, housing, fields): self.browser.get_housing(housing.id, housing) if 'phone' in fields: housing.phone = self.browser.get_phone(housing.id) return housing def fill_photo(self, photo, fields): if 'data' in fields and photo.url and not photo.data: photo.data = self.browser.open(photo.url).content return photo OBJECTS = {Housing: fill_housing, HousingPhoto: fill_photo, } weboob-1.1/modules/explorimmo/pages.py000066400000000000000000000161521265717027300201630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from decimal import Decimal from datetime import datetime from weboob.browser.filters.json import Dict from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.browser.pages import JsonPage, HTMLPage, pagination from weboob.browser.filters.standard import CleanText, CleanDecimal, Regexp, Env, BrowserURL, Filter, Format from weboob.browser.filters.html import CleanHTML, XPath from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.capabilities.housing import Housing, HousingPhoto, City class CitiesPage(JsonPage): @method class get_cities(DictElement): item_xpath = '0/locations' class item(ItemElement): klass = City obj_id = Dict('label') obj_name = Dict('label') class SearchPage(HTMLPage): @pagination @method class iter_housings(ListElement): item_xpath = '//div[starts-with(@id, "bloc-vue-")]' def next_page(self): js_datas = CleanText('//div[@id="js-data"]/@data-rest-search-request')(self) total_page = self.page.browser.get_total_page(js_datas.split('?')[-1]) m = re.match(".*page=(\d?)(?:&.*)?", self.page.url) if m: current_page = int(m.group(1)) next_page = current_page + 1 if next_page <= total_page: return self.page.url.replace('page=%d' % current_page, 'page=%d' % next_page) class item(ItemElement): klass = Housing obj_id = CleanText('./@data-classified-id') obj_title = CleanText('./div/h2[@itemprop="name"]/a') obj_location = CleanText('./div/h2[@itemprop="name"]/span[class="item-localisation"]') obj_cost = CleanDecimal('./div/div/span[@class="price-label"]') obj_currency = Regexp(CleanText('./div/div/span[@class="price-label"]'), '.*([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') obj_text = CleanText('./div/div/div[@itemprop="description"]') obj_area = CleanDecimal(Regexp(CleanText('./div/h2[@itemprop="name"]/a'), '(.*?)(\d*) m2(.*?)', '\\2', default=None), default=NotAvailable) def obj_phone(self): phone = CleanText('./div/div/ul/li/span[@class="js-clickphone"]', replace=[(u'Téléphoner : ', u'')], default=NotAvailable)(self) if '...' in phone: return NotLoaded return phone def obj_photos(self): url = CleanText('./div/div/a/img[@itemprop="image"]/@src')(self) return [HousingPhoto(url)] class TypeDecimal(Filter): def filter(self, el): return Decimal(el) class FromTimestamp(Filter): def filter(self, el): return datetime.fromtimestamp(el / 1000.0) class PhonePage(JsonPage): def get_phone(self): return self.doc.get('phoneNumber') class HousingPage2(JsonPage): @method class get_housing(ItemElement): klass = Housing obj_id = Env('_id') obj_title = Dict('characteristics/titleWithTransaction') obj_location = Format('%s %s %s', Dict('location/address'), Dict('location/postalCode'), Dict('location/cityLabel')) obj_cost = TypeDecimal(Dict('characteristics/price')) obj_currency = u'€' obj_text = CleanHTML(Dict('characteristics/description')) obj_url = BrowserURL('housing_html', _id=Env('_id')) obj_area = TypeDecimal(Dict('characteristics/area')) obj_date = FromTimestamp(Dict('characteristics/date')) def obj_photos(self): photos = [] for img in Dict('characteristics/images')(self): m = re.search('http://thbr\.figarocms\.net.*(http://.*)', img.get('xl')) if m: photos.append(HousingPhoto(m.group(1))) else: photos.append(HousingPhoto(img.get('xl'))) return photos def obj_details(self): details = {} details['fees'] = Dict('characteristics/fees')(self) details['bedrooms'] = Dict('characteristics/bedroomCount')(self) details['energy'] = Dict('characteristics/energyConsumptionCategory')(self) rooms = Dict('characteristics/roomCount')(self) if len(rooms): details['rooms'] = rooms[0] details['available'] = Dict('characteristics/available', default=NotAvailable)(self) return details def get_total_page(self): return self.doc.get('pagination').get('total') if 'pagination' in self.doc else 0 class HousingPage(HTMLPage): @method class get_housing(ItemElement): klass = Housing obj_id = Env('_id') obj_title = CleanText('//h1[@itemprop="name"]') obj_location = CleanText('//span[@class="informations-localisation"]') obj_cost = CleanDecimal('//span[@itemprop="price"]') obj_currency = Regexp(CleanText('//span[@itemprop="price"]'), '.*([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') obj_text = CleanHTML('//div[@itemprop="description"]') obj_url = BrowserURL('housing', _id=Env('_id')) obj_area = CleanDecimal(Regexp(CleanText('//h1[@itemprop="name"]'), '(.*?)(\d*) m2(.*?)', '\\2'), default=NotAvailable) def obj_photos(self): photos = [] for img in XPath('//a[@class="thumbnail-link"]/img[@itemprop="image"]')(self): url = Regexp(CleanText('./@src'), 'http://thbr\.figarocms\.net.*(http://.*)')(img) photos.append(HousingPhoto(url)) return photos def obj_details(self): details = dict() for item in XPath('//div[@class="features clearfix"]/ul/li')(self): key = CleanText('./span[@class="name"]')(item) value = CleanText('./span[@class="value"]')(item) if value and key: details[key] = value key = CleanText('//div[@class="title-dpe clearfix"]')(self) value = CleanText('//div[@class="energy-consumption"]')(self) if value and key: details[key] = value return details weboob-1.1/modules/explorimmo/test.py000066400000000000000000000025601265717027300200410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import itertools from weboob.capabilities.housing import Query from weboob.tools.test import BackendTest class ExplorimmoTest(BackendTest): MODULE = 'explorimmo' def test_explorimmo(self): query = Query() query.area_min = 20 query.cost_max = 900 query.type = Query.TYPE_RENT query.cities = [] for city in self.backend.search_city('paris'): city.backend = self.backend.name query.cities.append(city) results = list(itertools.islice(self.backend.search_housings(query), 0, 20)) self.assertTrue(len(results) > 0) self.backend.fillobj(results[0], 'phone') weboob-1.1/modules/feedly/000077500000000000000000000000001265717027300155625ustar00rootroot00000000000000weboob-1.1/modules/feedly/__init__.py000066400000000000000000000014321265717027300176730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import FeedlyModule __all__ = ['FeedlyModule'] weboob-1.1/modules/feedly/browser.py000066400000000000000000000101431265717027300176160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.json import json from weboob.capabilities.base import UserError from weboob.capabilities.collection import Collection from weboob.browser import LoginBrowser, URL, need_login from .pages import EssentialsPage, TokenPage, ContentsPage, PreferencesPage, MarkerPage __all__ = ['FeedlyBrowser'] class FeedlyBrowser(LoginBrowser): BASEURL = 'https://www.feedly.com/' essentials = URL('https://s3.feedly.com/essentials/essentials_fr.json', EssentialsPage) token = URL('v3/auth/token', TokenPage) contents = URL('v3/streams/contents', ContentsPage) preferences = URL('v3/preferences', PreferencesPage) marker = URL('v3/markers', MarkerPage) def __init__(self, username, password, login_browser, *args, **kwargs): super(FeedlyBrowser, self).__init__(username, password, *args, **kwargs) self.user_id = None self.login_browser = login_browser def do_login(self): if self.login_browser: if self.login_browser.code is None or self.user_id is None: self.login_browser.do_login() params = {'code': self.login_browser.code, 'client_id': 'feedly', 'client_secret': '0XP4XQ07VVMDWBKUHTJM4WUQ', 'redirect_uri': 'http://dev.feedly.com/feedly.html', 'grant_type': 'authorization_code'} token, self.user_id = self.token.go(data=params).get_token() self.session.headers['X-Feedly-Access-Token'] = token else: raise UserError(r'You need to fill your username and password to access this page') @need_login def iter_threads(self): params = {'streamId': 'user/%s/category/global.all' % self.user_id, 'unreadOnly': 'true', 'ranked': 'newest', 'count': '100'} return self.contents.go(params=params).get_articles() @need_login def get_unread_feed(self, url): params = {'streamId': url, 'backfill': 'true', 'boostMustRead': 'true', 'unreadOnly': 'true'} return self.contents.go(params=params).get_articles() def get_categories(self): if self.username is not None and self.password is not None: return self.get_logged_categories() return self.essentials.go().get_categories() @need_login def get_logged_categories(self): user_categories = list(self.preferences.go().get_categories()) user_categories.append(Collection([u'global.saved'], u'Saved')) return user_categories def get_feeds(self, category): if self.username is not None and self.password is not None: return self.get_logged_feeds(category) return self.essentials.go().get_feeds(category) @need_login def get_logged_feeds(self, category): if category == 'global.saved': type = 'tag' else: type = 'category' url = 'user/%s/%s/%s' % (self.user_id, type, category) return self.get_unread_feed(url) def get_feed_url(self, category, feed): return self.essentials.go().get_feed_url(category, feed) @need_login def set_message_read(self, _id): datas = {'action': 'markAsRead', 'type': 'entries', 'entryIds': [_id]} self.marker.open(data=json.dumps(datas)) weboob-1.1/modules/feedly/favicon.png000066400000000000000000000034041265717027300177160ustar00rootroot00000000000000PNG  IHDR@@PLTEij㥽姱鬴桪ʖߖ蚜ߒÎܘɑًۡІًԌۍފ׈ۋ܊ߌp|qАwm│upuzwxvmvq`ϊ`v`s`vZX_sVd\tSVZ`Y\YUT^HL  " [UZTTNHIEH "+(8Nbfox~׎뚖ݑٞ&KtRNS "#$%(*./0235889 \>~ LY'l$ϖ07$Hyv$r-,>D gM8,pՔp9u@i]sq_R;r9Wve  IQLzl` _(;^JoRȃJ:5`Gw)8?/B<{r}m6x)jhT7OQb4`A= x30& M!njH#.ƆcQlwA݀l6@XH"Lx1=Z OY'D0VP1#Л.J|Pt1!?Y$c߰$uz͖X<ZcmfwE&>YwgkwQӕfwIw$+fkx-: : wlJ-)nɤ+^ |Lzˬh̉l5i!-Y@fgoU$gYTzٹ $`2NϘw7LýGzSݤ~StmsՐ  W|fa\raOwl+b& 'eqpی6aLx{~Gk]x*L|\;H|e$k o9IENDB`weboob-1.1/modules/feedly/google.py000066400000000000000000000043721265717027300174160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from urlparse import urlparse, parse_qs from weboob.browser import LoginBrowser, URL from weboob.browser.pages import HTMLPage, LoggedPage from weboob.exceptions import BrowserIncorrectPassword class GoogleLoginPage(LoggedPage, HTMLPage): def login(self, login, passwd): form = self.get_form('//form[@id="gaia_loginform"]', submit='//input[@id="signIn"]') form['Email'] = login form['Passwd'] = passwd form.submit() class GoogleBrowser(LoginBrowser): BASEURL = 'https://accounts.google.com/' code = None google_login = URL('https://accounts.google.com/(?P.+)', 'AccountLoginInfo', GoogleLoginPage) def __init__(self, username, password, redirect_uri, *args, **kwargs): super(GoogleBrowser, self).__init__(username, password, *args, **kwargs) self.redirect_uri = redirect_uri def do_login(self): params = {'response_type': 'code', 'client_id': '534890559860-r6gn7e3agcpiriehe63dkeus0tpl5i4i.apps.googleusercontent.com', 'redirect_uri': self.redirect_uri} queryString = "&".join([key+'='+value for key, value in params.items()]) self.google_login.go(auth='o/oauth2/auth', params=queryString).login(self.username, self.password) if self.google_login.is_here(): self.page.login(self.username, self.password) try: self.code = parse_qs(urlparse(self.url).query).get('code')[0] except: raise BrowserIncorrectPassword() weboob-1.1/modules/feedly/module.py000066400000000000000000000102171265717027300174220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.collection import CapCollection from weboob.capabilities.messages import CapMessages, Message, Thread from weboob.tools.value import Value, ValueBackendPassword from .browser import FeedlyBrowser from .google import GoogleBrowser __all__ = ['FeedlyModule'] class FeedlyModule(Module, CapMessages, CapCollection): NAME = 'feedly' DESCRIPTION = u'handle the popular RSS reading service Feedly' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' STORAGE = {'seen': []} CONFIG = BackendConfig(Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password', default='')) BROWSER = FeedlyBrowser def iter_resources(self, objs, split_path): collection = self.get_collection(objs, split_path) if collection.path_level == 0: return self.browser.get_categories() if collection.path_level == 1: return self.browser.get_feeds(split_path[0]) if collection.path_level == 2: url = self.browser.get_feed_url(split_path[0], split_path[1]) threads = [] for article in self.browser.get_unread_feed(url): thread = self.get_thread(article.id, article) threads.append(thread) return threads def validate_collection(self, objs, collection): if collection.path_level in [0, 1, 2]: return def get_thread(self, id, entry=None): if isinstance(id, Thread): thread = id id = thread.id else: thread = Thread(id) if entry is None: url = id.split('#')[0] for article in self.browser.get_unread_feed(url): if article.id == id: entry = article if entry is None: return None if thread.id not in self.storage.get('seen', default=[]): entry.flags = Message.IS_UNREAD entry.thread = thread thread.title = entry.title thread.root = entry return thread def iter_unread_messages(self): for thread in self.iter_threads(): for m in thread.iter_all_messages(): if m.flags & m.IS_UNREAD: yield m def iter_threads(self): for article in self.browser.iter_threads(): yield self.get_thread(article.id, article) def set_message_read(self, message): self.browser.set_message_read(message.thread.id.split('#')[-1]) self.storage.get('seen', default=[]).append(message.thread.id) self.storage.save() def fill_thread(self, thread, fields): return self.get_thread(thread) def create_default_browser(self): username = self.config['username'].get() if username: password = self.config['password'].get() login_browser = GoogleBrowser(username, password, 'https://feedly.com/v3/auth/callback&scope=profile+email&state=Amm-1gV7ImkiOiJmZWVkbHkiLCJycCI6IndlbGNvbWUiLCJyIjoiaHR0cDovL2ZlZWRseS5jb20vZmVlZGx5Lmh0bWwiLCJwIjoiR29vZ2xlUGx1cyIsImMiOiJmZWVkbHkuZGVza3RvcCAyOC4wLjk1NSJ9') else: password = None login_browser = None return self.create_browser(username, password, login_browser) OBJECTS = {Thread: fill_thread} weboob-1.1/modules/feedly/pages.py000066400000000000000000000066121265717027300172400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime from weboob.capabilities.messages import Message from weboob.capabilities.collection import Collection from weboob.browser.pages import JsonPage, LoggedPage from weboob.browser.elements import ItemElement, DictElement, method from weboob.browser.filters.standard import CleanText, Format from weboob.browser.filters.json import Dict from weboob.browser.filters.html import CleanHTML class ContentsPage(LoggedPage, JsonPage): @method class get_articles(DictElement): item_xpath = 'items' class item(ItemElement): klass = Message obj_id = Format(u'%s#%s', CleanText(Dict('origin/streamId')), CleanText(Dict('id'))) obj_sender = CleanText(Dict('author', default=u'')) obj_title = Format(u'%s - %s', CleanText(Dict('origin/title', default=u'')), CleanText(Dict('title', default=u''))) def obj_date(self): return datetime.fromtimestamp(Dict('published')(self.el) / 1e3) def obj_content(self): if 'content' in self.el.keys(): return Format(u'%s%s\r\n', CleanHTML(Dict('content/content')), CleanText(Dict('origin/htmlUrl')))(self.el) elif 'summary' in self.el.keys(): return Format(u'%s%s\r\n', CleanHTML(Dict('summary/content')), CleanText(Dict('origin/htmlUrl')))(self.el) else: return '' class TokenPage(JsonPage): def get_token(self): return self.doc['access_token'], self.doc['id'] class EssentialsPage(JsonPage): def get_categories(self): for category in self.doc: name = u'%s' % category.get('label') yield Collection([name], name) def get_feeds(self, label): for category in self.doc: if category.get('label') == label: feeds = category.get('subscriptions') for feed in feeds: yield Collection([label, feed.get('title')]) def get_feed_url(self, _category, _feed): for category in self.doc: if category.get('label') == _category: feeds = category.get('subscriptions') for feed in feeds: if feed.get('title') == _feed: return feed.get('id') class PreferencesPage(LoggedPage, JsonPage): def get_categories(self): for category, value in self.doc.items(): if value in [u"shown", u"hidden"]: yield Collection([u'%s' % category], u'%s' % category.replace('global.', '')) class MarkerPage(LoggedPage): pass weboob-1.1/modules/feedly/test.py000066400000000000000000000026201265717027300171130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest, SkipTest class FeedlyTest(BackendTest): MODULE = 'feedly' def test_login(self): if self.backend.browser.username: l1 = list(self.backend.iter_threads()) assert len(l1) thread = self.backend.get_thread(l1[0].id) assert len(thread.root.content) else: raise SkipTest("User credentials not defined") def test_feedly(self): self.backend.browser.username = None l1 = list(self.backend.iter_resources(None, ['Technologie', 'Korben'])) assert len(l1) thread = self.backend.get_thread(l1[0].id) assert len(thread.root.content) weboob-1.1/modules/fortuneo/000077500000000000000000000000001265717027300161535ustar00rootroot00000000000000weboob-1.1/modules/fortuneo/__init__.py000066400000000000000000000014671265717027300202740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gilles-Alexandre Quenot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import FortuneoModule __all__ = ['FortuneoModule'] # vim:ts=4:sw=4 weboob-1.1/modules/fortuneo/browser.py000066400000000000000000000117431265717027300202160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gilles-Alexandre Quenot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages.login import LoginPage from .pages.accounts_list import GlobalAccountsList, AccountsList, AccountHistoryPage, CardHistoryPage, \ InvestmentHistoryPage, PeaHistoryPage __all__ = ['Fortuneo'] class Fortuneo(Browser): DOMAIN_LOGIN = 'www.fortuneo.fr' DOMAIN = 'www.fortuneo.fr' PROTOCOL = 'https' CERTHASH = ['4ff0301115f80f18c4e81a136ca28829b46d416d404174945b1ae48abd0634e2'] ENCODING = None # refer to the HTML encoding PAGES = { '.*identification\.jsp.*': LoginPage, '.*prive/default\.jsp.*': AccountsList, '.*/prive/mes-comptes/synthese-mes-comptes\.jsp': AccountsList, '.*/prive/mes-comptes/synthese-globale/synthese-mes-comptes\.jsp': GlobalAccountsList, '.*/prive/mes-comptes/livret/consulter-situation/consulter-solde\.jsp.*': AccountHistoryPage, '.*/prive/mes-comptes/compte-courant/consulter-situation/consulter-solde\.jsp.*': AccountHistoryPage, '.*/prive/mes-comptes/compte-courant/carte-bancaire/encours-debit-differe\.jsp.*': CardHistoryPage, '.*/prive/mes-comptes/compte-titres-.*': PeaHistoryPage, '.*/prive/mes-comptes/assurance-vie.*': InvestmentHistoryPage, '.*/prive/mes-comptes/pea.*': PeaHistoryPage, '.*/prive/mes-comptes/compte-especes.*': AccountHistoryPage, } def __init__(self, *args, **kwargs): Browser.__init__(self, *args, **kwargs) def home(self): """main page (login)""" self.login() def is_logged(self): """Return True if we are logged on website""" return self.page is not None and not self.is_on_page(LoginPage) def login(self): """Login to the website. This function is called when is_logged() returns False and the password attribute is not None.""" assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(LoginPage): self.location('https://' + self.DOMAIN_LOGIN + '/fr/identification.jsp', no_login=True) self.page.login(self.username, self.password) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() m = re.match('https://(.*?fr)', self.page.url) if m: self.DOMAIN_LOGIN = m.group(1) self.location('https://' + self.DOMAIN_LOGIN + '/fr/prive/mes-comptes/synthese-mes-comptes.jsp') if self.is_on_page(AccountsList) and self.page.need_reload(): self.location('/ReloadContext?action=1&') elif self.is_on_page(AccountsList) and self.page.need_sms(): raise BrowserIncorrectPassword('Authentification with sms is not supported') def get_investments(self, account): self.location('https://' + self.DOMAIN_LOGIN + account._link_id) return self.page.get_investments() def get_history(self, account): self.location('https://' + self.DOMAIN_LOGIN + account._link_id) if self.page.select_period(): return self.page.get_operations(account) return iter([]) def get_coming(self, account): for cb_link in account._card_links: self.location('https://' + self.DOMAIN_LOGIN + cb_link) for tr in self.page.get_operations(account): yield tr def get_accounts_list(self): """accounts list""" if not self.is_on_page(AccountsList): self.location('https://' + self.DOMAIN_LOGIN + '/fr/prive/mes-comptes/synthese-mes-comptes.jsp') return self.page.get_list() def get_account(self, id): """Get an account from its ID""" assert isinstance(id, basestring) for a in list(self.get_accounts_list()): if a.id == id: return a return None # vim:ts=4:sw=4 weboob-1.1/modules/fortuneo/favicon.png000066400000000000000000000036171265717027300203150ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME .)jsD/tEXtCommentCreated with GIMPWIDATxkLSgZ)¡AE[o V`ls`f`Mݖ}pYL4.Qc,̰6cpNQf8墴@ ZZPZFyO/}=}~s?EoOS.QQQQQQQO>1v7lV~#> h!RT* -zX N4TvVkBPɐWХd̰iwGa;`;Хwft\L-Q]7Jlu'pR?|Ɍ U"i! FC UfNO`T)F6e؉WPxl(`30h4湞ѥrpt.~ sF/<K?`y>:^K?vz~݊FtDt휑!jmCv Ȯιhc +9wɞ02y2[a}|^PbZ9bZ9M$fCO Y#B8ܬz|]j2h58Zx*)ht2N Ixoo;"0qy}QIۭF\Bt}{+.9%xldJ&9uۇY & $G 5z ",.~fzh]0è;i-7DD+@^YFX@L 'Ms6O}W0<^>16y}+AayerNQXvnȌ/\L ܨ@_*SKCKmJ"W(nS5 \H@ kvxpP J Y+ibbZRBXϪfJ 1".nzoW dRpئFJ1V @!)C̞H|@˥^Tv}Cs$yyo{17+:̷L- ZS-P.fX 95~dhBI),Q-Җ'zq{{22)* 6|v> @M`Z 9 [+`/nP>$6Tz I(:m"SXgMs![ ! 3=Ƚfev[dۭ(!!!/jptUOn^ӗ%V;۳4Pp;L*28rD(st]xYWcn|y"rJg@J.&88Vrm;ЌwY1ꭊLcD".񭵽h`am{@S- :7rP(/Fm8o1&,q (ٿyeDݳ\)ko^TAaþX./Kċ,^eJƖcZO ]Bw"6NS$:DY3}B5wI:$=|*QitX3z]"A[۳9SHxs ;TuRCL-Lm~ɰof7fݮ) ϿQYT\<9q((((((((V!&IENDB`weboob-1.1/modules/fortuneo/module.py000066400000000000000000000043351265717027300200170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gilles-Alexandre Quenot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Fortuneo __all__ = ['FortuneoModule'] class FortuneoModule(Module, CapBank): NAME = 'fortuneo' MAINTAINER = u'Gilles-Alexandre Quenot' EMAIL = 'gilles.quenot@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Fortuneo' CONFIG = BackendConfig( ValueBackendPassword('login', label='Identifiant', masked=False, required=True), ValueBackendPassword('password', label='Mot de passe', required=True)) BROWSER = Fortuneo def create_default_browser(self): return self.create_browser( self.config['login'].get(), self.config['password'].get() ) def iter_accounts(self): """Iter accounts""" return self.browser.get_accounts_list() def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): """Iter history of transactions on a specific account""" return self.browser.get_history(account) def iter_coming(self, account): return self.browser.get_coming(account) def iter_investment(self, account): return self.browser.get_investments(account) # vim:ts=4:sw=4 weboob-1.1/modules/fortuneo/pages/000077500000000000000000000000001265717027300172525ustar00rootroot00000000000000weboob-1.1/modules/fortuneo/pages/__init__.py000066400000000000000000000000001265717027300213510ustar00rootroot00000000000000weboob-1.1/modules/fortuneo/pages/accounts_list.py000066400000000000000000000317071265717027300225060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gilles-Alexandre Quenot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from lxml.html import etree from decimal import Decimal import re from time import sleep from datetime import date from dateutil.relativedelta import relativedelta from mechanize import FormNotFoundError from weboob.browser.filters.standard import CleanText from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account, Investment from weboob.deprecated.browser import Page, BrowserIncorrectPassword from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.json import json class Transaction(FrenchTransaction): PATTERNS = [(re.compile(u'^(?PCHEQUE)(?P.*)'), FrenchTransaction.TYPE_CHECK), (re.compile('^(?PFACTURE CARTE) DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*?)( CA?R?T?E? ?\d*X*\d*)?$'), FrenchTransaction.TYPE_CARD), (re.compile('^(?PCARTE)( DU)? (?P
\d{2})/(?P\d{2}) (?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile('^(?P(PRELEVEMENT|TELEREGLEMENT|TIP|PRLV)) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?PECHEANCEPRET)(?P.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile('^(?PRET(RAIT)? DAB) (?P
\d{2})/(?P\d{2})/(?P\d{2})( (?P\d+)H(?P\d+))? (?P.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?PVIR(EMEN)?T? ((RECU|FAVEUR) TIERS|SEPA RECU)?)( /FRM)?(?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?PREMBOURST)(?P.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?PCOMMISSIONS)(?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P(?PREMUNERATION).*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?PREMISE CHEQUES)(?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] class PeaHistoryPage(Page): COL_LABEL = 0 COL_UNITVALUE = 1 COL_QUANTITY = 3 COL_UNITPRICE = 4 COL_VALUATION = 5 COL_PERF = 6 COL_WEIGHT = 7 def get_investments(self): for line in self.document.xpath('//table[@id="t_intraday"]/tbody/tr'): if line.find_class('categorie') or line.find_class('detail') or line.find_class('detail02'): continue cols = line.findall('td') inv = Investment() inv.label = self.parser.tocleanstring(cols[self.COL_LABEL]) link = cols[self.COL_LABEL].xpath('./a[contains(@href, "cdReferentiel")]')[0] inv.id = unicode(re.search('cdReferentiel=(.*)', link.attrib['href']).group(1)) inv.code = re.match('^[A-Z]+[0-9]+(.*)$', inv.id).group(1) inv.quantity = self.parse_decimal(cols[self.COL_QUANTITY]) inv.unitprice = self.parse_decimal(cols[self.COL_UNITPRICE]) inv.unitvalue = self.parse_decimal(cols[self.COL_UNITVALUE]) inv.valuation = self.parse_decimal(cols[self.COL_VALUATION]) diff = cols[self.COL_PERF].text.strip() if diff == "-": inv.diff = NotAvailable else: inv.diff = Decimal(Transaction.clean_amount(diff)) yield inv def parse_decimal(self, string): value = Transaction.clean_amount(self.parser.tocleanstring(string)) if value == '-': return NotAvailable return Decimal(value) def select_period(self): return True def get_operations(self, account): return iter([]) class InvestmentHistoryPage(Page): COL_LABEL = 0 COL_QUANTITY = 1 COL_UNITVALUE = 2 COL_DATE = 3 COL_VALUATION = 4 COL_WEIGHT = 5 COL_UNITPRICE = 6 COL_PERF = 7 COL_PERF_PERCENT = 8 def get_investments(self): for line in self.document.xpath('//table[@id="tableau_support"]/tbody/tr'): cols = line.findall('td') inv = Investment() inv.id = unicode(re.search('cdReferentiel=(.*)', cols[self.COL_LABEL].find('a').attrib['href']).group(1)) inv.code = re.match('^[A-Z]+[0-9]+(.*)$', inv.id).group(1) inv.label = self.parser.tocleanstring(cols[self.COL_LABEL]) inv.quantity = self.parse_decimal(cols[self.COL_QUANTITY]) inv.unitprice = self.parse_decimal(cols[self.COL_UNITPRICE]) inv.unitvalue = self.parse_decimal(cols[self.COL_UNITVALUE]) inv.valuation = self.parse_decimal(cols[self.COL_VALUATION]) inv.diff = self.parse_decimal(cols[self.COL_PERF]) yield inv def parse_decimal(self, string): value = self.parser.tocleanstring(string) if value == '-': return NotAvailable return Decimal(Transaction.clean_amount(value)) def select_period(self): self.browser.location(self.url.replace('portefeuille-assurance-vie.jsp', 'operations/assurance-vie-operations.jsp')) try: self.browser.select_form(name='OperationsForm') except FormNotFoundError: return False self.browser.set_all_readonly(False) self.browser['dateDebut'] = (date.today() - relativedelta(years=1)).strftime('%d/%m/%Y') self.browser['nbrEltsParPage'] = '100' self.browser.submit() return True def get_operations(self, account): for tr in self.document.xpath('//table[@id="tableau_histo_opes"]/tbody/tr'): tds = tr.findall('td') t = Transaction() t.parse(date=self.parser.tocleanstring(tds[1]), raw=self.parser.tocleanstring(tds[2])) t.set_amount(self.parser.tocleanstring(tds[-1])) yield t class AccountHistoryPage(Page): def get_investments(self): return iter([]) def select_period(self): self.browser.select_form(name='ConsultationHistoriqueOperationsForm') self.browser.set_all_readonly(False) self.browser['dateRechercheDebut'] = (date.today() - relativedelta(years=1)).strftime('%d/%m/%Y') self.browser['nbrEltsParPage'] = '100' self.browser.submit() return True def get_operations(self, account): """history, see http://docs.weboob.org/api/capabilities/bank.html?highlight=transaction#weboob.capabilities.bank.Transaction""" # TODO need to rewrite that with FrenchTransaction class http://tinyurl.com/6lq4r9t tables = self.document.findall(".//*[@id='tabHistoriqueOperations']/tbody/tr") if len(tables) == 0: return for i in range(len(tables)): operation = Transaction() operation.type = 0 operation.category = NotAvailable date_oper = tables[i].xpath("./td[2]/text()")[0] date_val = tables[i].xpath("./td[3]/text()")[0] label = tables[i].xpath("./td[4]/text()")[0] label = re.sub(r'[ \xa0]+', ' ', label).strip() amount = tables[i].xpath("./td[5]/text() | ./td[6]/text()") operation.parse(date=date_oper, raw=label, vdate=date_val) if amount[1] == u'\xa0': amount = amount[0] else: amount = amount[1] operation.set_amount(amount) yield operation class CardHistoryPage(Page): def get_investments(self): return iter([]) def select_period(self): return True def get_operations(self, account): for op in self.document.xpath('//table[@id="tableauEncours"]/tbody/tr'): rdate = self.parser.tocleanstring(op.xpath('./td[1]')[0]) date = self.parser.tocleanstring(op.xpath('./td[2]')[0]) raw = self.parser.tocleanstring(op.xpath('./td[3]')[0]) credit = self.parser.tocleanstring(op.xpath('./td[4]')[0]) debit = self.parser.tocleanstring(op.xpath('./td[5]')[0]) tr = Transaction() tr.parse(date=date, raw=raw) tr.rdate = tr.parse_date(rdate) tr.type = tr.TYPE_CARD tr.set_amount(credit, debit) yield tr class AccountsList(Page): def on_loaded(self): warn = self.document.xpath('//div[@id="message_renouvellement_mot_passe"] | \ //span[contains(text(), "Votre identifiant change")] | \ //span[contains(text(), "Nouveau mot de passe")]') if len(warn) > 0: raise BrowserIncorrectPassword(warn[0].text) self.load_async(0) def load_async(self, time): # load content of loading divs. lst = self.document.xpath('//input[@type="hidden" and starts-with(@id, "asynch")]') if len(lst) > 0: params = {} for i, input in enumerate(lst): params['key%s' % i] = input.attrib['name'] params['div%s' % i] = input.attrib['value'] params['time'] = time r = self.browser.openurl(self.browser.buildurl('/AsynchAjax', **params)) data = json.load(r) for i, d in enumerate(data['data']): div = self.document.xpath('//div[@id="%s"]' % d['key'])[0] html = d['flux'] div.clear() div.attrib['id'] = d['key'] # needed because clear removes also all attributes div.insert(0, etree.fromstring(html, parser=etree.HTMLParser())) if 'time' in data: sleep(float(data['time'])/1000.0) return self.load_async(time) def need_reload(self): form = self.document.xpath('//form[@name="InformationsPersonnellesForm"]') return len(form) > 0 def need_sms(self): return len(self.document.xpath('//div[@id="aidesecuforte"]')) ACCOUNT_TYPES = {'mes-comptes/compte-courant/consulter-situation': Account.TYPE_CHECKING, 'mes-comptes/compte-courant/carte-bancaire': Account.TYPE_CARD, 'mes-comptes/assurance-vie': Account.TYPE_LIFE_INSURANCE, 'mes-comptes/livret': Account.TYPE_SAVINGS, 'mes-comptes/pea': Account.TYPE_MARKET, 'mes-comptes/compte-titres': Account.TYPE_MARKET, } def get_list(self): account = None for cpt in self.document.xpath('//a[@class="synthese_id_compte" or @class="synthese_carte_differe"]'): url_to_parse = cpt.xpath('@href')[0].replace("\n", "") # link # account._link_id = lien vers historique d'un compte (courant ou livret) if '/mes-comptes/livret/' in url_to_parse: compte_id_re = re.compile(r'.*\?(.*)$') link_id = '/fr/prive/mes-comptes/livret/consulter-situation/consulter-solde.jsp?%s' % \ (compte_id_re.search(url_to_parse).groups()[0]) else: link_id = url_to_parse number = cpt.xpath('./span[@class="synthese_numero_compte"]') if len(number) == 0: account._card_links.append(link_id) continue account = Account() account.id = self.parser.tocleanstring(number[0]).replace(u'N°', '') try: balance = self.parser.tocleanstring(cpt.xpath('./span[contains(@class, "synthese_solde")]')[0]) except IndexError: continue account.balance = Decimal(Transaction.clean_amount(balance)) account.currency = account.get_currency(balance) account._link_id = link_id account._card_links = [] account.label = (' '.join([CleanText.clean(part) for part in cpt.xpath('./text()')])).strip(' - ').strip() for pattern, type in self.ACCOUNT_TYPES.iteritems(): if pattern in account._link_id: account.type = type yield account class GlobalAccountsList(Page): pass weboob-1.1/modules/fortuneo/pages/login.py000066400000000000000000000024661265717027300207440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gilles-Alexandre Quenot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . #from logging import error from weboob.deprecated.browser import Page, BrowserUnavailable class LoginPage(Page): def login(self, login, passwd): msgb = self.document.xpath(".//*[@id='message_client']/text()") msga = ''.join(msgb) msg = msga.strip("\n") if "maintenance" in msg: raise BrowserUnavailable(msg) self.browser.select_form(name="acces_identification") self.browser['login'] = login.encode('utf-8') self.browser['passwd'] = passwd.encode('utf-8') self.browser.submit(nologin=True) # vim:ts=4:sw=4 weboob-1.1/modules/fortuneo/test.py000066400000000000000000000020101265717027300174750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Gilles-Alexandre Quenot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class FortuneoTest(BackendTest): MODULE = 'fortuneo' def test_fortuneo(self): l = list(self.backend.iter_accounts()) self.assertTrue(len(l) > 0) a = l[0] list(self.backend.iter_history(a)) # vim:ts=4:sw=4 weboob-1.1/modules/fourchan/000077500000000000000000000000001265717027300161175ustar00rootroot00000000000000weboob-1.1/modules/fourchan/__init__.py000066400000000000000000000001531265717027300202270ustar00rootroot00000000000000from .module import FourChanModule from .browser import FourChan __all__ = ['FourChanModule', 'FourChan'] weboob-1.1/modules/fourchan/browser.py000066400000000000000000000025501265717027300201560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser from .pages.board import BoardPage class FourChan(Browser): DOMAIN = 'boards.4chan.org' PAGES = { 'http://boards.4chan.org/\w+/': BoardPage, 'http://boards.4chan.org/\w+/res/\d+': BoardPage, } def is_logged(self): return True def get_threads(self, board): self.location('http://boards.4chan.org/%s/' % board) return self.page.articles def get_thread(self, board, id): self.location('http://boards.4chan.org/%s/res/%d' % (board, long(id))) assert len(self.page.articles) == 1 return self.page.articles[0] weboob-1.1/modules/fourchan/favicon.png000066400000000000000000000106641265717027300202610ustar00rootroot00000000000000PNG  IHDR@@iqsRGB pHYs  tIME 3)FIDATx[iU~mwttN IhQ"3PcLC*T1UԀ82Ha R(#LXDIL ӡww͏,KMU]>{87,2yPb8F[A1x H_Y\VTUUuF|_uʬRz:~$Kү92tَsd[C?ޫʅ{F" `[WxjL:gu(mBO 1T>ta>O=zEĐ]V-M[a R7PzȺ5wr֥@Qf_ŏO#_Y)xΆ#-tEh(UY=#72_uԟsvId60P55*3o;wu<4dzG!N@芺⏛" ue,NFh^0h9"i 'IݔԬoIsCN1! b(_mio`mƘAGޖun]|Fx5*;u]f݌s6xeI ZYiBqXXKi܄rc`I~Š5V*LJȝ#ĐxDdc[i(d<(C}4H zMXuʼh UI x ¢~,i¬V@]Z}<etFtܘ#{F>zHDM@ NɋZFb(\dM] q6su,mt]'C) E(_N;gzLoQ/;]P@$!Ԙ(yX䯇qIVΪoY NF4K2Pq~:0q&.b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uUVpYP5@ t h) d5q mgz`>gsk)8_:(>iσ5j6Ö́pdu0AC'pz\ΊwA,2F. from weboob.capabilities.messages import CapMessages, Message, Thread from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value from .browser import FourChan __all__ = ['FourChanModule'] class FourChanModule(Module, CapMessages): NAME = 'fourchan' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = '4chan image board' CONFIG = BackendConfig(Value('boards', label='Boards to fetch')) STORAGE = {'boards': {}} BROWSER = FourChan def _splitid(self, id): return id.split('.', 1) def get_thread(self, id): thread = None if isinstance(id, Thread): thread = id id = thread.id if '.' not in id: self.logger.warning('Malformated ID (%s)' % id) return board, thread_id = self._splitid(id) with self.browser: _thread = self.browser.get_thread(board, thread_id) flags = 0 if _thread.id not in self.storage.get('boards', board, default={}): flags |= Message.IS_UNREAD if not thread: thread = Thread(id) thread.title = _thread.filename thread.root = Message(thread=thread, id=0, # root message title=_thread.filename, sender=_thread.author, receivers=None, date=_thread.datetime, parent=None, content=_thread.text, signature=None, children=[], flags=flags|Message.IS_HTML) for comment in _thread.comments: flags = 0 if comment.id not in self.storage.get('boards', board, _thread.id, default=[]): flags |= Message.IS_UNREAD m = Message(thread=thread, id=comment.id, title=_thread.filename, sender=comment.author, receivers=None, date=comment.datetime, parent=thread.root, content=comment.text, signature=None, children=None, flags=flags|Message.IS_HTML) thread.root.children.append(m) return thread def iter_threads(self): for board in self.config['boards'].get().split(' '): with self.browser: threads = self.browser.get_threads(board) for thread in threads: t = Thread('%s.%s' % (board, thread.id)) t.title = thread.filename yield t def iter_unread_messages(self): for thread in self.iter_threads(): self.fill_thread(thread, 'root') for m in thread.iter_all_messages(): if m.flags & Message.IS_UNREAD: yield m def set_message_read(self, message): board, thread_id = self._splitid(message.thread.id) self.storage.set('boards', board, thread_id, self.storage.get('boards', board, thread_id, default=[]) + [message.id]) self.storage.save() def fill_thread(self, thread, fields): return self.get_thread(thread) OBJECTS = {Thread: fill_thread} weboob-1.1/modules/fourchan/pages/000077500000000000000000000000001265717027300172165ustar00rootroot00000000000000weboob-1.1/modules/fourchan/pages/__init__.py000066400000000000000000000000001265717027300213150ustar00rootroot00000000000000weboob-1.1/modules/fourchan/pages/board.py000066400000000000000000000061751265717027300206700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from datetime import datetime from weboob.deprecated.browser import Page class Message(object): def __init__(self, browser, board, id, filename=u'', url=u''): self.id = id self.browser = browser self.board = board self.filename = filename self.datetime = datetime.now() self.url = url self.author = u'' self.text = u'' self.comments = [] def add_comment(self, div): comment = Message(self.browser, self.board, int(div.attrib.get('id', ''))) comment.author = div.cssselect('span.commentpostername')[0].text comment.text = self.browser.parser.tostring(div.find('blockquote')) self.comments.append(comment) def __repr__(self): return '' % (self.id, self.filename, self.url, len(self.comments)) class BoardPage(Page): URL_REGEXP = re.compile('http://boards.4chan.org/(\w+)/') def on_loaded(self): self.articles = [] m = self.URL_REGEXP.match(self.url) if m: self.board = m.group(1) else: self.logger.warning('Unable to find board') self.board = 'unknown' forms = self.document.getroot().cssselect('form') form = None for f in forms: if f.attrib.get('name', '') == 'delform': form = f break if form is None: self.logger.warning('No delform :(') article = None for div in form.getchildren(): if div.tag == 'span' and div.attrib.get('class', '') == 'filesize': url = div.find('a').get('href', '') filename = 'unknown.jpg' span = div.find('span') if span is not None: filename = span.text article = Message(self.browser, self.board, 0, filename, url) self.articles.append(article) if article is None: continue if div.tag == 'input' and div.attrib.get('type', 'checkbox') and div.attrib.get('value', 'delete'): article.id = int(div.attrib.get('name', '0')) if div.tag == 'blockquote': article.text = self.parser.tostring(div) if div.tag == 'table': tags = div.cssselect('td.reply') if tags: article.add_comment(tags[0]) weboob-1.1/modules/fourchan/test.py000066400000000000000000000025371265717027300174570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from logging import debug from weboob.tools.test import BackendTest class FourChanTest(BackendTest): MODULE = 'fourchan' def test_new_messages(self): tot = 0 for thread in self.backend.iter_threads(): thread = self.backend.fillobj(thread, 'root') count = 0 for m in thread.iter_all_messages(): count += 1 debug('Count: %s' % count) tot += count debug('Total messages: %s' % tot) count = 0 for message in self.backend.iter_unread_messages(): count += 1 debug('Unread messages: %s' % count) weboob-1.1/modules/francetelevisions/000077500000000000000000000000001265717027300200355ustar00rootroot00000000000000weboob-1.1/modules/francetelevisions/__init__.py000066400000000000000000000000731265717027300221460ustar00rootroot00000000000000from .module import PluzzModule __all__ = ['PluzzModule'] weboob-1.1/modules/francetelevisions/browser.py000066400000000000000000000060031265717027300220710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import IndexPage, VideoPage, Programs, VideoListPage, LatestPage, FrancetvinfoPage __all__ = ['PluzzBrowser'] class PluzzBrowser(PagesBrowser): ENCODING = 'utf-8' BASEURL = 'http://pluzz.francetv.fr' PROGRAMS = None francetvinfo = URL(r'http://www.francetvinfo.fr/(?P.*)', FrancetvinfoPage) latest = URL(r'http://pluzz.webservices.francetelevisions.fr/pluzz/liste/type/replay', LatestPage) programs_page = URL(r'http://pluzz.webservices.francetelevisions.fr/pluzz/programme', Programs) index_page = URL(r'recherche\?recherche=(?P.*)', IndexPage) video_page = URL(r'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/\?idDiffusion=(?P.*)&catalogue=Pluzz', VideoPage) videos_list_page = URL(r'(?Pvideos/.*)', VideoListPage) def get_video_id_from_francetvinfo(self, url): return self.francetvinfo.go(url=url).get_video_id_from_francetvinfo() def get_video_from_url(self, url): video = self.videos_list_page.go(program=url).get_last_video() if video: return self.get_video(video.id, video) def search_videos(self, pattern): if not self.PROGRAMS: self.PROGRAMS = list(self.get_program_list()) videos = [] for program in self.PROGRAMS: if pattern.upper() in program._title.upper(): video = self.videos_list_page.go(program=program.id).get_last_video() if video: videos.append(video) videos += list(self.page.iter_videos()) return videos if len(videos) > 0 else self.index_page.go(pattern=pattern).iter_videos() def get_program_list(self): return list(self.programs_page.go().iter_programs()) @video_page.id2url def get_video(self, url, video=None): self.location(url) video = self.page.get_video(obj=video) if not video: return for item in self.read_url(video.url): video.url = u'%s' % item return video def read_url(self, url): r = self.open(url, stream=True) buf = r.iter_lines() return buf def latest_videos(self): return self.latest.go().iter_videos() weboob-1.1/modules/francetelevisions/favicon.png000066400000000000000000000026151265717027300221740ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME :'?tEXtCommentCreated with GIMPWIDATx=LGఝDrPΆ(Q\@&EH YNL" q.(d)"m8"A)M$ H e,H&nۜ9/ R.;{Ozڛ737yޛ]8C)N`Z`I@f $,g9\jF h>NMN]4cϵ8-_ ,5r/9𞣁u%6/O t 9eZPn60|m{TmlҀ[hDCc0ŬTWƺ/FoR:~ xÙaoF!rcWDZ[%+gtk?f"Q n #qR)/׮yqX^+W~.8wfgCOƦCO` .:3"ٿGFDD._Y\R)vG켅;wdi% Ғٳ"{dpHcudRd|8"x.۷E,+[hP9~&ЪV  A/Ar xy8RN󸔰 F U`j{$~ m#GJ aNؘ+o m1Z ڀ[##;ܼYwPP\:q‹],3ٲ)Gz40\R~Oaj*[vtp)XYQ=fNPb?[vuU$ɕD2Ok7H44+74-bn d012MLeb5@#[޲D\cޞQLݻ{zżt,f4?ssBJjWbe:oAO}e[h`{&03ō?(}^q P5Dsc>/=r߲' vTJ&I%r`۞''mTWL.f tb%pqOxnx>ٗJnLy6 Kh(. from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound from weboob.tools.backend import Module from .browser import PluzzBrowser import re __all__ = ['PluzzModule'] class PluzzModule(Module, CapVideo, CapCollection): NAME = 'francetelevisions' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'France Télévisions video website' LICENSE = 'AGPLv3+' BROWSER = PluzzBrowser def get_video(self, _id): m = re.match('http://pluzz.francetv.fr/(videos/.*)', _id) if m: return self.browser.get_video_from_url(m.group(1)) m2 = re.match('http://www.francetvinfo.fr/(.*)', _id) if m2: _id = self.browser.get_video_id_from_francetvinfo(m2.group(1)) if not _id: return return self.browser.get_video(_id) def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): return self.browser.search_videos(pattern) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields video = self.browser.get_video(video.id, video) if 'thumbnail' in fields and video.thumbnail: video.thumbnail.data = self.browser.open(video.thumbnail.url).content return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest']) if collection.split_path == [u'latest']: for video in self.browser.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest']: collection.title = u'Latest France Télévisions videos' return raise CollectionNotFound(collection.split_path) OBJECTS = {BaseVideo: fill_video} weboob-1.1/modules/francetelevisions/pages.py000066400000000000000000000134111265717027300215060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.image import BaseImage from weboob.capabilities.video import BaseVideo from weboob.capabilities.base import BaseObject from datetime import timedelta from weboob.browser.pages import HTMLPage, JsonPage from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.browser.filters.standard import Filter, CleanText, Regexp, Format, DateTime, Env, Duration from weboob.browser.filters.html import Link, Attr from weboob.browser.filters.json import Dict class DurationPluzz(Filter): def filter(self, el): duration = Regexp(CleanText('.'), r'.+\|(.+)')(el[0]) if duration[-1:] == "'": t = [0, int(duration[:-1])] else: t = map(int, duration.split(':')) return timedelta(hours=t[0], minutes=t[1]) class FrancetvinfoPage(HTMLPage): def get_video_id_from_francetvinfo(self): return Regexp(CleanText('//a[@id="catchup"]/@href'), 'http://info.francetelevisions.fr/\?id-video=(.*)@Info-web', default=None)(self.doc) class VideoListPage(HTMLPage): @method class get_last_video(ItemElement): klass = BaseVideo obj_id = CleanText('//div[@id="diffusion-info"]/@data-diffusion') obj_title = CleanText('//div[@id="diffusion-info"]/h1/div[@id="diffusion-titre"]') obj_date = DateTime(Regexp(CleanText('//div[@id="diffusion-info"]/h1|//div[@id="diffusion-info"]/div/div/*[1]', replace=[(u'à', u''), (u' ', u' ')]), '.+(\d{2}-\d{2}-\d{2}.+\d{1,2}h\d{1,2}).+'), dayfirst=True) @method class iter_videos(ListElement): item_xpath = '//div[@id="player-memeProgramme"]/a' class item(ItemElement): klass = BaseVideo def condition(self): return CleanText('div[@class="autre-emission-c3"]')(self) == "En replay" obj_id = Regexp(Link('.'), '^/videos/.+,(.+).html$') obj_title = CleanText('//meta[@name="programme_titre"]/@content') obj_date = DateTime(Regexp(CleanText('./div[@class="autre-emission-c2"]|./div[@class="autre-emission-c4"]', replace=[(u'à', u''), (u' ', u' ')]), '(\d{2}-\d{2}.+\d{1,2}:\d{1,2})'), dayfirst=True) class IndexPage(HTMLPage): @method class iter_videos(ListElement): item_xpath = '//div[@class="panel-resultat panel-separateur"]' class item(ItemElement): klass = BaseVideo obj_title = Format('%s du %s', CleanText('div/div[@class="resultat-titre-diff"]/a'), Regexp(CleanText('div/div[@class="resultat-soustitre-diff"]'), '.+(\d{2}-\d{2}-\d{2}).+')) obj_id = Regexp(Link('div/div[@class="resultat-titre-diff"]/a'), '^/videos/.+,(.+).html$') obj_date = DateTime(Regexp(CleanText('div/div[@class="resultat-soustitre-diff"]', replace=[(u'à', u''), (u' ', u' ')]), '.+(\d{2}-\d{2}-\d{2}.+\d{1,2}h\d{1,2}).+')) obj_duration = DurationPluzz('div/div[3]') def obj_thumbnail(self): url = Attr('a/img[@class="resultat-vignette"]', 'data-src')(self) thumbnail = BaseImage(url) thumbnail.url = thumbnail.id return thumbnail class VideoPage(JsonPage): @method class get_video(ItemElement): klass = BaseVideo def validate(self, obj): return obj.url def parse(self, el): for video in el['videos']: if video['format'] != 'm3u8-download': continue self.env['url'] = video['url'] obj_id = Env('id') obj_title = Format(u'%s - %s', Dict['titre'], Dict['sous_titre']) obj_url = Env('url') obj_date = Dict['diffusion']['date_debut'] & DateTime obj_duration = Dict['duree'] & Duration obj_description = Dict['synopsis'] obj_ext = u'm3u8' def obj_thumbnail(self): url = Format('http://www.francetv.fr%s', Dict['image'])(self) thumbnail = BaseImage(url) thumbnail.url = thumbnail.id return thumbnail class Programs(JsonPage): @method class iter_programs(DictElement): item_xpath = 'reponse/programme' class item(ItemElement): klass = BaseObject obj_id = CleanText(Dict('url')) obj__title = CleanText(Dict('titre_programme')) class LatestPage(JsonPage): @method class iter_videos(DictElement): item_xpath = 'reponse/emissions' class Item(ItemElement): klass = BaseVideo obj_id = Dict('id_diffusion') obj_title = Dict('titre_programme') obj_date = DateTime(Dict('date_diffusion')) weboob-1.1/modules/francetelevisions/test.py000066400000000000000000000032261265717027300213710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import BaseVideo from weboob.tools.test import BackendTest class PluzzTest(BackendTest): MODULE = 'francetelevisions' def test_search(self): # If the test fails, it might be good news! l = list(self.backend.search_videos("pblv")) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url, 'URL for video "%s" not found: %s' % (v.id, v.url)) def test_video_from_url(self): v = self.backend.get_video('http://pluzz.francetv.fr/videos/plus_belle_la_vie.html') self.assertTrue(v.url, 'URL for video "%s" not found: %s' % (v.id, v.url)) def test_latest(self): l = list(self.backend.iter_resources([BaseVideo], [u'latest'])) assert len(l) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id)) weboob-1.1/modules/freegeoip/000077500000000000000000000000001265717027300162575ustar00rootroot00000000000000weboob-1.1/modules/freegeoip/__init__.py000066400000000000000000000001031265717027300203620ustar00rootroot00000000000000from .module import FreegeoipModule __all__ = ['FreegeoipModule'] weboob-1.1/modules/freegeoip/favicon.png000066400000000000000000000024461265717027300204200ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME: qIDATx]L[eƟcOӞNэh|tcAF>D"7KL.YQ4K ov7&͘lթsESGW>iǠZrS*O6}Λ>+Vr   \,:+x<\AD;`;>(֎ ?эqa<JfP~p<yjw[0ԢYh:k&Q Dc!m.nrj ^LNmw~-ii 67wĢR 0 }6kfd7H@Y^0SFWr K s0[AK3 @:cs'A%B@g:υ’a7y_^q4,\G6*ܺ;Ea0y. C8t؃ yÉ]ssq4gm+'j[ޠ}S[fM'VTpzbk.A/K^wvp:2ab؊[c`.2Qx~_P,W^JG5`AUp2^U֎9#zѳ:1 ˺uLLU䄗3lR8R8柎nje}4ANxJm~x͹^913[{g3vRdZ6 fg|%(k;J^s0^JT&/ɋX G]rK+GFј]e)98쳩j 5hZ-P[;v / }3:Gq  8?'.^J5iR`Y -,ߘuA_PwD cw'ʔ8|q{m:0Ο5<ُ; 44 J%iC m n  (FIUIENDB`weboob-1.1/modules/freegeoip/module.py000066400000000000000000000035441265717027300201240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.geolocip import CapGeolocIp, IpLocation from weboob.tools.backend import Module from weboob.browser.browsers import Browser from weboob.tools.json import json __all__ = ['FreegeoipModule'] class FreegeoipModule(Module, CapGeolocIp): NAME = 'freegeoip' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'public API to search the geolocation of IP addresses' BROWSER = Browser def get_location(self, ipaddr): res = self.browser.location('https://freegeoip.net/json/%s' % ipaddr.encode('utf-8')) jres = json.loads(res.text) iploc = IpLocation(ipaddr) iploc.city = u'%s'%jres['city'] iploc.region = u'%s'%jres['region_name'] iploc.zipcode = u'%s'%jres['zip_code'] iploc.country = u'%s'%jres['country_name'] if jres['latitude'] != '': iploc.lt = float(jres['latitude']) else: iploc.lt = 0.0 if jres['longitude'] != '': iploc.lg = float(jres['longitude']) else: iploc.lg = 0.0 return iploc weboob-1.1/modules/freegeoip/test.py000066400000000000000000000016261265717027300176150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class FreegeoipTest(BackendTest): MODULE = 'freegeoip' def test_freegeoip(self): self.backend.get_location('88.198.11.130') weboob-1.1/modules/freemobile/000077500000000000000000000000001265717027300164235ustar00rootroot00000000000000weboob-1.1/modules/freemobile/__init__.py000066400000000000000000000014471265717027300205420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import FreeMobileModule __all__ = ['FreeMobileModule'] weboob-1.1/modules/freemobile/browser.py000066400000000000000000000046011265717027300204610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import HomePage, LoginPage, HistoryPage, DetailsPage __all__ = ['Freemobile'] class Freemobile(LoginBrowser): BASEURL = 'https://mobile.free.fr/moncompte/' homepage = URL('index.php\?page=home', HomePage) detailspage = URL('index.php\?page=suiviconso', DetailsPage) loginpage = URL('index.php', LoginPage) historypage = URL('ajax.php\?page=consotel_current_month', HistoryPage) def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.username.isdigit() self.loginpage.stay_or_go().login(self.username, self.password) self.homepage.go() if self.loginpage.is_here(): raise BrowserIncorrectPassword() @need_login def get_subscription_list(self): subscriptions = self.homepage.stay_or_go().get_list() self.detailspage.go() for subscription in subscriptions: subscription._virtual = self.page.load_virtual(subscription.id) subscription.renewdate = self.page.get_renew_date(subscription) yield subscription def get_history(self, subscription): self.historypage.go(data={'login': subscription._login}) return sorted([x for x in self.page.get_calls()], key=lambda self: self.datetime, reverse=True) def get_details(self, subscription): return self.detailspage.stay_or_go().get_details(subscription) def iter_bills(self, subscription): return self.detailspage.stay_or_go().date_bills(subid=subscription.id) weboob-1.1/modules/freemobile/favicon.png000066400000000000000000000027011265717027300205560ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs B(xtIME Em^tEXtCommentCreated with GIMPWIDATx[lTUU jI+h0AK& -T5bB"F5`L4M1(ER-&*RXPE/ѠTxX/\Wf̙)̜u֙9k]g """"""""""TD ;@%p=𐂿z=lrFD@,w2=?)mԛ!PC_ GjKt@X<:^ U԰F*U /USuӁ<^}@ X\p.;},gW<*[m+a.bBi q_ ~roYp1p2 xΔ.^ŀkE}xmeGo"Qh8L[ 6{aD~6z:p5LJ>HCVY;**8 pHq$[ 9ne~0?~MU1`k1~*13`3@R>a1~+p p_@4lc!A^Ӂ-xy `ZXLUS\n?BP 3I)&<.+f`2p/Qp4>rIDnߙm 3yEwYf{7ŀU]#ƻ@#<a&wC"Lv h;F9Gd|ߔ:Ra 9<{{x wUVgxd@2L fɊ;4=.V= ]eV1zN#, TfK#;wPS`(0Ww1Կ1]Z|.4kܒ;@XBl 䍃cG7fJ%w0-P:6oS G֦,_@)*kl>հK;;SJ#6r\WaN%.0!vVJuB))n[_#kQ!&̏KF#Ogi?&$`g<_S@/ |OK^)Ȝ,Ƅ. from weboob.capabilities.bill import CapBill, Subscription, Bill, SubscriptionNotFound, BillNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Freemobile __all__ = ['FreeMobileModule'] class FreeMobileModule(Module, CapBill): NAME = 'freemobile' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'Free Mobile website' CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False, regexp='^(\d{8}|)$'), ValueBackendPassword('password', label='Password') ) BROWSER = Freemobile def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): return self.browser.get_subscription_list() def get_subscription(self, _id): return find_object(self.iter_subscription(), id=_id, error=SubscriptionNotFound) def iter_bills_history(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.get_history(subscription) def get_bill(self, _id): subid = _id.split('.')[0] subscription = self.get_subscription(subid) return find_object(self.iter_bills(subscription), id=_id, error=BillNotFound) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_bills(subscription) def get_details(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.get_details(subscription) def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) return self.browser.open(bill._url).content weboob-1.1/modules/freemobile/pages/000077500000000000000000000000001265717027300175225ustar00rootroot00000000000000weboob-1.1/modules/freemobile/pages/__init__.py000066400000000000000000000016131265717027300216340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .homepage import HomePage from .history import HistoryPage, DetailsPage from .login import LoginPage __all__ = ['LoginPage', 'HomePage', 'HistoryPage', 'DetailsPage'] weboob-1.1/modules/freemobile/pages/history.py000066400000000000000000000140231265717027300215750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import calendar from datetime import datetime from decimal import Decimal from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import Date, CleanText, Filter,\ CleanDecimal, Regexp, Field, DateTime, Format, Env from weboob.browser.filters.html import Attr from weboob.capabilities.bill import Detail, Bill class FormatDate(Filter): def filter(self, txt): return datetime.strptime(txt, "%Y%m%d").date() class BadUTF8Page(HTMLPage): ENCODING = 'UTF-8' class DetailsPage(LoggedPage, BadUTF8Page): def load_virtual(self, phonenumber): for div in self.doc.xpath('//div[@class="infosLigne pointer"]'): if CleanText('.')(div).split("-")[-1].strip() == phonenumber: return Attr('.', 'onclick')(div).split('(')[1][1] def on_load(self): self.details = {} for div in self.doc.xpath('//div[@class="infosConso"]'): num = div.attrib['id'].split('_')[1][0] self.details[num] = [] # National parsing divnat = div.xpath('div[@class="national"]')[0] self._parse_div(divnat, "National : %s | International : %s", num, False) # International parsing divint = div.xpath('div[@class="international hide"]')[0] if divint.xpath('div[@class="detail"]'): self._parse_div(divint, u"Appels émis : %s | Appels reçus : %s", num, True) def _parse_div(self, divglobal, string, num, inter=False): divs = divglobal.xpath('div[@class="detail"]') # Two pieces of information in one div... div = divs.pop(0) voice = self._parse_voice(div, string, num, inter) self.details[num].append(voice) self._iter_divs(divs, num, inter) def _iter_divs(self, divs, num, inter=False): for div in divs: detail = Detail() detail.label = CleanText('div[@class="titre"]/p')(div) detail.id = "-" + detail.label.split(' ')[1].lower() if inter: detail.label = detail.label + u" (international)" detail.id = detail.id + "-inter" detail.infos = CleanText('div[@class="conso"]/p')(div) detail.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0), replace_dots=True)(div) self.details[num].append(detail) def _parse_voice(self, div, string, num, inter=False): voicediv = div.xpath('div[@class="conso"]')[0] voice = Detail() voice.id = "-voice" voice.label = CleanText('div[@class="titre"]/p')(div) if inter: voice.label = voice.label + " (international)" voice.id = voice.id + "-inter" voice.price = CleanDecimal('div[@class="horsForfait"]/p/span', default=Decimal(0), replace_dots=True)(div) voice1 = CleanText('.//span[@class="actif"][1]')(voicediv) voice2 = CleanText('.//span[@class="actif"][2]')(voicediv) voice.infos = unicode(string) % (voice1, voice2) return voice # XXX def get_details(self, subscription): for detail in self.details[subscription._virtual]: detail.id = subscription.id + detail.id yield detail @method class date_bills(ListElement): item_xpath = '//div[@class="factLigne hide "]' class item(ItemElement): klass = Bill def condition(self): num = Attr('.', 'data-fact_ligne', default='')(self) return self.env['subid'] == num obj__url = Attr('.//div[@class="pdf"]/a', 'href') obj__localid = Regexp(Field('_url'), '&l=(\d*)&id', u'\\1') obj_label = Regexp(Field('_url'), '&date=(\d*)', u'\\1') obj_id = Format('%s.%s', Env('subid'), Field('label')) obj_date = FormatDate(Field('label')) obj_format = u"pdf" obj_price = CleanDecimal('div[@class="montant"]', default=Decimal(0), replace_dots=False) def get_renew_date(self, subscription): div = self.doc.xpath('//div[@login="%s"]' % subscription._login)[0] mydate = Date(CleanText('.//div[@class="resumeConso"]/span[@class="actif"][1]'), dayfirst=True)(div) if mydate.month == 12: mydate = mydate.replace(month=1) mydate = mydate.replace(year=mydate.year + 1) else: try: mydate = mydate.replace(month=mydate.month + 1) except ValueError: lastday = calendar.monthrange(mydate.year, mydate.month + 1)[1] mydate = mydate.replace(month=mydate.month + 1, day=lastday) return mydate class HistoryPage(LoggedPage, BadUTF8Page): @method class get_calls(ListElement): item_xpath = '//tr' class item(ItemElement): klass = Detail def condition(self): txt = self.el.xpath('td[1]')[0].text return (txt is not None) and (txt != "Date") obj_id = None obj_datetime = DateTime(CleanText('td[1]', symbols=u'à'), dayfirst=True) obj_label = Format(u'%s %s %s', CleanText('td[2]'), CleanText('td[3]'), CleanText('td[4]')) obj_price = CleanDecimal('td[5]', default=Decimal(0), replace_dots=True) weboob-1.1/modules/freemobile/pages/homepage.py000066400000000000000000000033651265717027300216700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .history import BadUTF8Page from weboob.capabilities.bill import Subscription from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, Field, Format, Filter from weboob.browser.filters.html import Attr class GetID(Filter): def filter(self, txt): return txt.split('=')[-1] class HomePage(BadUTF8Page): def is_here(self): if len(self.doc.xpath('//form[@id="form_connect"]')) > 0: return False return True @method class get_list(ListElement): item_xpath = '//div[@class="abonne"]' class item(ItemElement): klass = Subscription obj_subscriber = CleanText('div[@class="idAbonne pointer"]/p[1]', symbols='-', children=False) obj_id = CleanText('div[@class="idAbonne pointer"]/p/span') obj__login = GetID(Attr('.//div[@class="acceuil_btn"]/a', 'href')) obj_label = Format(u'%s - %s', Field('id'), CleanText('.//div[@class="forfaitChoisi"]')) weboob-1.1/modules/freemobile/pages/login.py000066400000000000000000000112131265717027300212020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import time from StringIO import StringIO from PIL import Image from weboob.browser.pages import HTMLPage class FreeKeyboard(object): symbols = {'0': '001111111111110011111111111111111111111111111110000000000011110000000000011111111111111111011111111111111001111111111110', '1': '001110000000000001110000000000001110000000000011111111111111111111111111111111111111111111000000000000000000000000000000', '2': '011110000001111011110000111111111000001111111110000011110011110000111100011111111111000011011111110000011001111000000011', '3': '011100000011110111100000011111111000110000111110000110000011110001110000011111111111111111011111111111110001110001111100', '4': '000000011111000000001111111000000111110011000011110000011000111111111111111111111111111111111111111111111000000000011000', '5': '111111110011110111111110011111111001110000111111001100000011111001100000011111001111111111111001111111111010000111111110', '6': '001111111111110011111111111111111111111111111110001100000011110001100000011111001111111111111101111111111011100111111110', '7': '111000000000000111000000000000111000000011111111000011111111111011111111111111111111000000111111000000000111100000000000', '8': '001110001111110011111111111111111111111111111110000110000011110000110000011111111111111111011111111111111001111001111110', '9': '001111111000110011111111100111111111111100111110000001100011110000001100011111111111111111011111111111111001111111111110' } def __init__(self, basepage): self.basepage = basepage self.fingerprints = [] for htmlimg in self.basepage.doc.xpath('//img[@class="ident_chiffre_img pointer"]'): url = htmlimg.attrib.get("src") imgfile = StringIO(basepage.browser.open(url).content) img = Image.open(imgfile) matrix = img.load() s = "" # The digit is only displayed in the center of image for x in range(15, 23): for y in range(12, 27): (r, g, b) = matrix[x, y] # If the pixel is "red" enough if g + b < 450: s += "1" else: s += "0" self.fingerprints.append(s) def get_symbol_code(self, digit): fingerprint = self.symbols[digit] for i, string in enumerate(self.fingerprints): if string == fingerprint: return i # Image contains some noise, and the match is not always perfect # (this is why we can't use md5 hashs) # But if we can't find the perfect one, we can take the best one best = 0 result = None for i, string in enumerate(self.fingerprints): match = 0 for j, bit in enumerate(string): if bit == fingerprint[j]: match += 1 if match > best: best = match result = i self.basepage.browser.logger.debug(self.fingerprints[result] + " match " + digit) return result def get_string_code(self, string): code = '' for c in string: codesymbol = self.get_symbol_code(c) code += str(codesymbol) return code def get_small(self, string): for c in string: time.sleep(0.5) url = 'https://mobile.free.fr/moncompte/chiffre.php?pos=' + c + '&small=1' self.basepage.browser.open(url) class LoginPage(HTMLPage): def login(self, login, password): vk = FreeKeyboard(self) code = vk.get_string_code(login) vk.get_small(code) # If img are not downloaded, the server do not accept the login form = self.get_form(xpath='//form[@id="form_connect"]') form['login_abo'] = code form['pwd_abo'] = password form.submit() weboob-1.1/modules/freemobile/test.py000066400000000000000000000033521265717027300177570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class FreeMobileTest(BackendTest): MODULE = 'freemobile' def test_details(self): for subscription in self.backend.iter_subscription(): details = list(self.backend.get_details(subscription)) self.assertTrue(len(details) > 4, msg="Not enough details") def test_history(self): for subscription in self.backend.iter_subscription(): self.assertTrue(len(list(self.backend.iter_bills_history(subscription))) > 0) def test_downloadbills(self): """ Iter all bills and try to download it. """ for subscription in self.backend.iter_subscription(): for bill in self.backend.iter_bills(subscription.id): self.backend.download_bill(bill.id) def test_list(self): """ Test listing of subscriptions. """ subscriptions = list(self.backend.iter_subscription()) self.assertTrue(len(subscriptions) > 0, msg="Account listing failed") weboob-1.1/modules/funmooc/000077500000000000000000000000001265717027300157605ustar00rootroot00000000000000weboob-1.1/modules/funmooc/__init__.py000066400000000000000000000014341265717027300200730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import FunmoocModule __all__ = ['FunmoocModule'] weboob-1.1/modules/funmooc/browser.py000066400000000000000000000063051265717027300200210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from .pages import PageLogin, PageDashboard, PageChapter, PageSection from .video import MoocVideo import re class FunmoocBrowser(LoginBrowser): BASEURL = 'https://www.france-universite-numerique-mooc.fr' login = URL('/accounts/login', PageLogin) dashboard = URL('/dashboard', PageDashboard) course = URL('/courses/(?P[^/]+/[^/]+/[^/]+)/courseware/?$', '/courses/(?P[^/]+/[^/]+/[^/]+)/info/?$', PageChapter) chapter = URL('/courses/(?P[^/]+/[^/]+/[^/]+)/courseware' '/(?P[0-9a-f]+)/$', PageChapter) section = URL('/courses/(?P[^/]+/[^/]+/[^/]+)/courseware/' '(?P[0-9a-f]+)/(?P
[0-9a-f]+)/$', PageSection) file = URL(r'https://fun\.libcast\.com/resource/(?P[^/]+)/' r'flavor/video/fun-(?P\w+)\.mp4') def __init__(self, username, password, quality='hd', *args, **kwargs): super(FunmoocBrowser, self).__init__(username, password, *args, **kwargs) self.quality = quality def do_login(self): self.login.stay_or_go() csrf = self.session.cookies.get('csrftoken') self.page.login(self.username, self.password, csrf) def get_video(self, _id): if re.search('[^a-zA-Z0-9_-]', _id): match = self.file.match(_id) if not match: return None _id = match.group('id') v = MoocVideo(_id) v.url = self.file.build(id=_id, quality=self.quality) v.ext = 'mp4' v.title = _id return v @need_login def iter_videos(self, course, chapter, section): course = course.replace('-', '/') assert self.section.stay_or_go(course=course, chapter=chapter, section=section) return self.page.iter_videos() @need_login def iter_sections(self, courseid, chapter): course = courseid.replace('-', '/') assert self.chapter.stay_or_go(course=course, chapter=chapter) for coll in self.page.iter_sections(): if coll.split_path[:2] == [courseid, chapter]: yield coll @need_login def iter_chapters(self, courseid): course = courseid.replace('-', '/') assert self.course.stay_or_go(course=course) return self.page.iter_chapters() @need_login def iter_courses(self): assert self.dashboard.stay_or_go() return self.page.iter_courses() weboob-1.1/modules/funmooc/favicon.png000066400000000000000000000040431265717027300201140ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME KutEXtCommentCreated with GIMPWIDATxlTE?Gz@-G9R@~A rP9&hA$-vH-(#䐻3**bOP-Q+-Pls-Ǽ*d2f3;|Y 2A fg"`$pXix0t)92 Ҁ@_  @59p( DfuϺ&H/Uܭ[Sr~`w0 J\STZ?mK2|'~-3tl@J,A^A  Ӛ SO'lEJ4á߿'XZ< HR.@%P9U1j, lv:< c*Vϙ`fmNž6*xU7?6uf#e%yHz躷}@ݸ8`3@rą8AݸOY]ɯ8f$ڍUkgR9g4t~2x>Zt[2QN|LƒU|:V]bDa,1Q] dhiP)vQsBRsT ʹ :ɤpUΟJ[Ih:wL=鮂E=esB}rJש,Ih|. }T`xY}F?"􊗺ӆGLkUXߧ *)د5--R mëpƀ \B&%,wn]W5rɌ$^Mj}n0`4D*3 Hb?NLo55u?ugs3TaR.+_ֆ>1)L.ޚC=NI8*|\g p "yt5P3hJVM@ݢ7totmfـ؄<`2<7#jYvs77ayW7#vm8C^DP< q8<{À0FKxLxZ7Y뢴 1.~aDFpǞfǝF 4\_N#^@L,E?Fp x֭1KUͩ z~Ҍpb59vju5? ԩJc , "h#zqdX;1|hc.IENDB`weboob-1.1/modules/funmooc/module.py000066400000000000000000000064141265717027300176240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from weboob.capabilities.collection import CapCollection from weboob.capabilities.video import CapVideo, BaseVideo from .browser import FunmoocBrowser __all__ = ['FunmoocModule'] class FunmoocModule(Module, CapVideo, CapCollection): NAME = 'funmooc' DESCRIPTION = u'France-Université-Numérique MOOC website' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(Value('email', label='Email', default=''), ValueBackendPassword('password', label='Password', default=''), Value('quality', label='Quality', default='hd', choices=['hd', 'sd', 'ld'])) BROWSER = FunmoocBrowser def create_default_browser(self): return self.create_browser(self.config['email'].get(), self.config['password'].get(), quality=self.config['quality'].get()) def get_video(self, _id): return self.browser.get_video(_id) def iter_resources(self, objs, split_path): if len(split_path) == 0: return self.browser.iter_courses() elif len(split_path) == 1: return self.browser.iter_chapters(*split_path) elif len(split_path) == 2: return self.browser.iter_sections(*split_path) elif len(split_path) == 3: return self.browser.iter_videos(*split_path) def _matches(self, title, pattern): title = title.lower() words = pattern.lower().split() return all(word in title for word in words) def search_videos(self, pattern, sortby=0, nsfw=False): queue = [[]] while len(queue): path = queue.pop() for item in self.iter_resources(BaseVideo, path): if isinstance(item, BaseVideo): if self._matches(item.title, pattern): yield item else: # collection newpath = item.split_path if self._matches(item.title, pattern): self.logger.debug('%s matches, returning content', item.title) for item in self.iter_resources_flat(BaseVideo, newpath): yield item return queue.append(newpath) weboob-1.1/modules/funmooc/pages.py000066400000000000000000000071161265717027300174360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.elements import method, ListElement, ItemElement from weboob.capabilities.collection import Collection import re class PageLogin(HTMLPage): def login(self, email, password, csrf): data = {'email': email, 'password': password, 'remember': 'true'} headers = {'X-CSRFToken': csrf} form = self.get_form(xpath='//form[contains(@class,"login-form")]') req = self.browser.build_request(form.url, data=data, headers=headers) self.browser.open(req) class PageDashboard(HTMLPage, LoggedPage): def iter_courses(self): for c in self.doc.xpath('//article[@class="course"]'): title = c.xpath('.//h3[@class="course-title"]/a')[0].text.strip() link = c.xpath('.//a[contains(@class,"enter-course")]')[0] url = self.browser.absurl(link.get('href')) match = self.browser.course.match(url) courseid = match.group('course').replace('/', '-') yield Collection([courseid], title) class PageChapter(LoggedPage, HTMLPage): @method class iter_chapters(ListElement): item_xpath = '//div[@class="chapter"]' class item(ItemElement): klass = Collection def obj_title(self): return self.xpath('.//a')[0].text.strip() def obj_split_path(self): # parse first section link url = self.xpath('.//li//a')[0].get('href') url = self.page.browser.absurl(url) match = self.page.browser.section.match(url) courseid = self.env['course'].replace('/', '-') chapter = match.group('chapter') return [courseid, chapter] def obj_id(self): return '-'.join(self.obj_split_path()) @method class iter_sections(ListElement): item_xpath = '//div[@class="chapter"]//li' class item(ItemElement): klass = Collection def obj_title(self): return self.xpath('.//p')[0].text.strip() def obj_split_path(self): url = self.xpath('.//a')[0].get('href') url = self.page.browser.absurl(url) match = self.page.browser.section.match(url) courseid = self.env['course'].replace('/', '-') chapter = match.group('chapter') section = match.group('section') return [courseid, chapter, section] def obj_id(self): return '-'.join(self.obj_split_path()) class PageSection(LoggedPage, HTMLPage): def iter_videos(self): urls = re.findall(r'[^\s;]+fun-hd\.mp4', self.text) for n, url in enumerate(set(urls)): match = self.browser.file.match(url) _id = match.group('id') yield self.browser.get_video(_id) weboob-1.1/modules/funmooc/video.py000066400000000000000000000016461265717027300174470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import BaseVideo class MoocVideo(BaseVideo): @classmethod def id2url(cls, _id): return 'https://fun.libcast.com/resource/%s/flavor/video/fun-hd.mp4' % _id weboob-1.1/modules/ganassurances/000077500000000000000000000000001265717027300171475ustar00rootroot00000000000000weboob-1.1/modules/ganassurances/__init__.py000066400000000000000000000014461265717027300212650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import GanAssurancesModule __all__ = ['GanAssurancesModule'] weboob-1.1/modules/ganassurances/browser.py000066400000000000000000000055761265717027300212210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import ssl from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, AccountsPage, TransactionsPage __all__ = ['GanAssurances'] class GanAssurances(LoginBrowser): login = URL('/wps/portal/login.*', '/wps/portal/inscription.*', LoginPage) accounts = URL('/wps/myportal/TableauDeBord', AccountsPage) transactions = URL('/wps/myportal/!ut.*', TransactionsPage) def __init__(self, website, *args, **kwargs): self.BASEURL = 'https://%s' % website super(GanAssurances, self).__init__(*args, **kwargs) def prepare_request(self, req): """ Gan Assurances does not support SSL anymore. """ preq = super(GanAssurances, self).prepare_request(req) conn = self.session.adapters['https://'].get_connection(preq.url) conn.ssl_version = ssl.PROTOCOL_TLSv1 return preq def do_login(self): """ Attempt to log in. Note: this method does nothing if we are already logged in. """ assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.login.stay_or_go() self.page.login(self.username, self.password) if self.login.is_here(): raise BrowserIncorrectPassword() @need_login def get_accounts_list(self): self.accounts.stay_or_go() return self.page.get_list() def get_history(self, account): accounts = self.get_accounts_list() for a in accounts: if a.id == account.id: self.location(a._link) assert self.transactions.is_here() return self.page.get_history() return iter([]) def get_coming(self, account): accounts = self.get_accounts_list() for a in accounts: if a.id == account.id: self.location(a._link) assert self.transactions.is_here() self.location(self.page.get_coming_link()) assert self.transactions.is_here() return self.page.get_history() return iter([]) weboob-1.1/modules/ganassurances/favicon.png000066400000000000000000000064001265717027300213020ustar00rootroot00000000000000PNG  IHDR@@iqbKGD{{TS pHYs  tIME  ,$tEXtCommentCreated with GIMPW hIDATxݛmTUFvi^eTfZ2h\t#3] BV$YƄFc@8/tĦJwmh꾜쇮[{gNrR:ys5H FG? ?Mp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=c?+ܐIENDB`weboob-1.1/modules/ganassurances/module.py000066400000000000000000000047111265717027300210110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import ValueBackendPassword, Value from .browser import GanAssurances __all__ = ['GanAssurancesModule'] class GanAssurancesModule(Module, CapBank): NAME = 'ganassurances' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Groupama' LICENSE = 'AGPLv3+' website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ 'espaceclient.groupama.fr': u'Groupama Banque', 'espaceclient.ganassurances.fr': u'Gan Assurances', }.iteritems(), key=lambda k_v: (k_v[1], k_v[0]))]) CONFIG = BackendConfig(Value('website', label='Banque', choices=website_choices, default='espaceclient.ganassurances.fr'), ValueBackendPassword('login', label=u'Numéro client', masked=False), ValueBackendPassword('password', label=u"Code d'accès")) BROWSER = GanAssurances def create_default_browser(self): return self.create_browser(self.config['website'].get(), self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): return self.browser.get_history(account) def iter_coming(self, account): return self.browser.get_coming(account) weboob-1.1/modules/ganassurances/pages.py000066400000000000000000000104161265717027300206220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal import re from weboob.browser.pages import HTMLPage from weboob.browser.elements import method from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction class LoginPage(HTMLPage): def login(self, login, passwd): form = self.get_form(name='loginForm') form['LoginPortletFormID'] = login form['LoginPortletFormPassword1'] = passwd form.submit() class AccountsPage(HTMLPage): logged = True ACCOUNT_TYPES = {u'Solde des comptes bancaires - Groupama Banque': Account.TYPE_CHECKING, u'Epargne bancaire constituée - Groupama Banque': Account.TYPE_SAVINGS, } def get_list(self): account_type = Account.TYPE_UNKNOWN accounts = [] for tr in self.doc.xpath('//div[@class="finance"]/form/table[@class="ecli"]/tr'): if tr.attrib.get('class', '') == 'entete': account_type = self.ACCOUNT_TYPES.get(tr.find('th').text.strip(), Account.TYPE_UNKNOWN) continue tds = tr.findall('td') balance = tds[-1].text.strip() if balance == '': continue account = Account() account.label = u' '.join([txt.strip() for txt in tds[0].itertext()]) account.label = re.sub(u'[ \xa0\u2022\r\n\t]+', u' ', account.label).strip() account.id = re.findall('(\d+)', account.label)[0] account.balance = Decimal(FrenchTransaction.clean_amount(balance)) account.currency = account.get_currency(balance) account.type = account_type m = re.search(r"javascript:submitForm\(([\w_]+),'([^']+)'\);", tds[0].find('a').attrib['onclick']) if not m: self.logger.warning('Unable to find link for %r' % account.label) account._link = None else: account._link = m.group(2) accounts.append(account) return accounts class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^Facture (?P
\d{2})/(?P\d{2})-(?P.*) carte .*'), FrenchTransaction.TYPE_CARD), (re.compile(u'^(Prlv( de)?|Ech(éance|\.)) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(Vir|VIR)( de)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(u'^CHEQUE.*? (N° \w+)?$'), FrenchTransaction.TYPE_CHECK), (re.compile('^Cotis(ation)? (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile('(?PInt .*)'), FrenchTransaction.TYPE_BANK), ] class TransactionsPage(HTMLPage): logged = True @method class get_history(Transaction.TransactionsElement): head_xpath = '//table[@id="releve_operation"]//tr/th' item_xpath = '//table[@id="releve_operation"]//tr' col_date = [u'Date opé', 'Date', u'Date d\'opé'] col_vdate = [u'Date valeur'] class item(Transaction.TransactionElement): def condition(self): return len(self.el.xpath('./td')) > 3 def get_coming_link(self): a = self.doc.getroot().cssselect('div#sous_nav ul li a.bt_sans_off')[0] return re.sub('[ \t\r\n]+', '', a.attrib['href']) weboob-1.1/modules/ganassurances/test.py000066400000000000000000000017631265717027300205070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class GanAssurancesTest(BackendTest): MODULE = 'ganassurances' def test_banquepop(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/gazelle/000077500000000000000000000000001265717027300157355ustar00rootroot00000000000000weboob-1.1/modules/gazelle/__init__.py000066400000000000000000000000771265717027300200520ustar00rootroot00000000000000from .module import GazelleModule __all__ = ['GazelleModule'] weboob-1.1/modules/gazelle/browser.py000066400000000000000000000050631265717027300177760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages.index import IndexPage, LoginPage from .pages.torrents import TorrentsPage __all__ = ['GazelleBrowser'] class GazelleBrowser(Browser): PAGES = {'https?://[^/]+/?(index.php)?': IndexPage, 'https?://[^/]+/login.php.*': LoginPage, 'https?://[^/]+/torrents.php.*': TorrentsPage, } def __init__(self, protocol, domain, *args, **kwargs): self.DOMAIN = domain self.PROTOCOL = protocol Browser.__init__(self, *args, **kwargs) def login(self): if not self.is_on_page(LoginPage): self.location('/login.php', no_login=True) self.page.login(self.username, self.password) # If we are not logged, the on_loaded event on LoginPage has probably # raised the exception, but to be sure, check here to prevent an # unfinite loop if we can't find the error message. if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() def is_logged(self): if not self.page or self.is_on_page(LoginPage): return False if self.is_on_page(IndexPage): return self.page.is_logged() return True def home(self): return self.location('%s://%s/' % (self.PROTOCOL, self.DOMAIN)) def iter_torrents(self, pattern): self.location(self.buildurl('/torrents.php', searchstr=pattern.encode('utf-8'))) assert self.is_on_page(TorrentsPage) return self.page.iter_torrents() def get_torrent(self, fullid): if '.' not in fullid: return None id, torrentid = fullid.split('.', 1) self.location(self.buildurl('/torrents.php', id=id, torrentid=torrentid)) assert self.is_on_page(TorrentsPage) return self.page.get_torrent(fullid) weboob-1.1/modules/gazelle/favicon.png000066400000000000000000000025051265717027300200720ustar00rootroot00000000000000PNG  IHDR@@iqsRGB pHYs  tIME 75 GtIDATxMh\UIblc|ZiH.Zt16B-ӍG҂ q!LR_Up@.tCf_үOb@X+ qyahe9OZ$d;|F1D&@G׉Pd4@ѭObvV'tӤ< 7pm <dz@hNlUѰM]%@[{1‰ʗ .'aRݏھ@Aꕐ! p}E(Jv\B'|KM)J1ַBKdͅ ,:߳~n$|C 8h~kp2 pHވasz#=-N'jݝYQJQN^D&wMm2`x,z衇儿^7AIENDB`weboob-1.1/modules/gazelle/module.py000066400000000000000000000041511265717027300175750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.torrent import CapTorrent from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import GazelleBrowser __all__ = ['GazelleModule'] class GazelleModule(Module, CapTorrent): NAME = 'gazelle' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'Gazelle-based BitTorrent trackers' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('domain', label='Domain (example "ssl.what.cd")'), Value('protocol', label='Protocol to use', choices=('http', 'https')), Value('username', label='Username'), ValueBackendPassword('password', label='Password')) BROWSER = GazelleBrowser def create_default_browser(self): return self.create_browser(self.config['protocol'].get(), self.config['domain'].get(), self.config['username'].get(), self.config['password'].get()) def get_torrent(self, id): return self.browser.get_torrent(id) def get_torrent_file(self, id): torrent = self.browser.get_torrent(id) if not torrent: return None return self.browser.openurl(torrent.url.encode('utf-8')).read() def iter_torrents(self, pattern): return self.browser.iter_torrents(pattern) weboob-1.1/modules/gazelle/pages/000077500000000000000000000000001265717027300170345ustar00rootroot00000000000000weboob-1.1/modules/gazelle/pages/__init__.py000066400000000000000000000000001265717027300211330ustar00rootroot00000000000000weboob-1.1/modules/gazelle/pages/base.py000066400000000000000000000021231265717027300203160ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import BrowserUnavailable, Page as _BasePage class BasePage(_BasePage): def on_loaded(self): errors = [] for div in self.parser.select(self.document.getroot(), 'div.poetry'): errors.append(self.parser.tocleanstring(div)) if len(errors) > 0: raise BrowserUnavailable(', '.join(errors)) weboob-1.1/modules/gazelle/pages/index.py000066400000000000000000000030561265717027300205210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import BrowserIncorrectPassword, BrowserBanned from .base import BasePage class IndexPage(BasePage): def is_logged(self): return 'id' in self.document.find('body').attrib class LoginPage(BasePage): def on_loaded(self): BasePage.on_loaded(self) warns = self.parser.select(self.document.getroot(), '.warning') for warn in warns: text = self.parser.tocleanstring(warn) if text.startswith('Your '): raise BrowserIncorrectPassword(text) if text.startswith('You are banned'): raise BrowserBanned(text) def login(self, login, password): self.browser.select_form(nr=0) self.browser['username'] = login self.browser['password'] = password self.browser.submit(no_login=True) weboob-1.1/modules/gazelle/pages/torrents.py000066400000000000000000000204321265717027300212670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import urlparse from logging import warning, debug from urlparse import parse_qs from weboob.tools.misc import get_bytes_size from weboob.tools.html import html2text from weboob.capabilities.torrent import Torrent from weboob.capabilities.base import NotLoaded from .base import BasePage class TorrentsPage(BasePage): TORRENTID_REGEXP = re.compile('torrents\.php\?action=download&id=(\d+)') def format_url(self, url): return '%s://%s/%s' % (self.browser.PROTOCOL, self.browser.DOMAIN, url) def iter_torrents(self): table = self.document.getroot().cssselect('table.torrent_table') if not table: table = self.document.getroot().cssselect('table#browse_torrent_table') if table: table = table[0] current_group = None for tr in table.findall('tr'): if tr.attrib.get('class', '') == 'colhead': # ignore continue if tr.attrib.get('class', '') == 'group': tds = tr.findall('td') current_group = u'' div = tds[-6] if div.getchildren()[0].tag == 'div': div = div.getchildren()[0] for a in div.findall('a'): if not a.text: continue if current_group: current_group += ' - ' current_group += a.text elif tr.attrib.get('class', '').startswith('group_torrent') or \ tr.attrib.get('class', '').startswith('torrent'): tds = tr.findall('td') title = current_group if len(tds) == 7: # Under a group i = 0 elif len(tds) in (8, 9): # An alone torrent i = len(tds) - 1 while i >= 0 and tds[i].find('a') is None: i -= 1 else: # Useless title continue if title: title += u' (%s)' % tds[i].find('a').text else: title = ' - '.join([a.text for a in tds[i].findall('a')]) url = urlparse.urlparse(tds[i].find('a').attrib['href']) params = parse_qs(url.query) if 'torrentid' in params: id = '%s.%s' % (params['id'][0], params['torrentid'][0]) else: url = tds[i].find('span').find('a').attrib['href'] m = self.TORRENTID_REGEXP.match(url) if not m: continue id = '%s.%s' % (params['id'][0], m.group(1)) try: size, unit = tds[i + 3].text.split() except ValueError: size, unit = tds[i + 2].text.split() size = get_bytes_size(float(size.replace(',', '')), unit) seeders = int(tds[-2].text) leechers = int(tds[-1].text) torrent = Torrent(id, title) torrent.url = self.format_url(url) torrent.size = size torrent.seeders = seeders torrent.leechers = leechers yield torrent else: debug('unknown attrib: %s' % tr.attrib) def get_torrent(self, id): table = self.browser.parser.select(self.document.getroot(), 'div.thin', 1) h2 = table.xpath('.//h2') if len(h2) > 0: title = u''.join([txt.strip() for txt in h2[0].itertext()]) else: title = self.browser.parser.select(table, 'div.title_text', 1).text torrent = Torrent(id, title) if '.' in id: torrentid = id.split('.', 1)[1] else: torrentid = id table = self.browser.parser.select(self.document.getroot(), 'table.torrent_table') if len(table) == 0: table = self.browser.parser.select(self.document.getroot(), 'div.main_column', 1) is_table = False else: table = table[0] is_table = True for tr in table.findall('tr' if is_table else 'div'): if is_table and 'group_torrent' in tr.attrib.get('class', ''): tds = tr.findall('td') if not len(tds) == 5: continue url = tds[0].find('span').find('a').attrib['href'] m = self.TORRENTID_REGEXP.match(url) if not m: warning('ID not found') continue if m.group(1) != torrentid: continue torrent.url = self.format_url(url) size, unit = tds[1].text.split() torrent.size = get_bytes_size(float(size.replace(',', '')), unit) torrent.seeders = int(tds[3].text) torrent.leechers = int(tds[4].text) break elif not is_table and tr.attrib.get('class', '').startswith('torrent_widget') \ and tr.attrib.get('class', '').endswith('pad'): url = tr.cssselect('a[title=Download]')[0].attrib['href'] m = self.TORRENTID_REGEXP.match(url) if not m: warning('ID not found') continue if m.group(1) != torrentid: continue torrent.url = self.format_url(url) size, unit = tr.cssselect('div.details_title strong')[-1].text.strip('()').split() torrent.size = get_bytes_size(float(size.replace(',', '')), unit) torrent.seeders = int(tr.cssselect('img[title=Seeders]')[0].tail) torrent.leechers = int(tr.cssselect('img[title=Leechers]')[0].tail) break if not torrent.url: warning('Torrent %s not found in list' % torrentid) return None div = self.parser.select(self.document.getroot(), 'div.main_column', 1) for box in div.cssselect('div.box'): title = None body = None title_t = box.cssselect('div.head') if len(title_t) > 0: title_t = title_t[0] if title_t.find('strong') is not None: title_t = title_t.find('strong') if title_t.text is not None: title = title_t.text.strip() body_t = box.cssselect('div.body,div.desc') if body_t: body = html2text(self.parser.tostring(body_t[-1])).strip() if title and body: if torrent.description is NotLoaded: torrent.description = u'' torrent.description += u'%s\n\n%s\n' % (title, body) divs = self.document.getroot().cssselect('div#files_%s,div#filelist_%s,tr#torrent_%s td' % (torrentid, torrentid, torrentid)) if divs: torrent.files = [] for div in divs: table = div.find('table') if table is None: continue for tr in table: if tr.attrib.get('class', None) != 'colhead_dark': torrent.files.append(tr.find('td').text) return torrent weboob-1.1/modules/gazelle/test.py000066400000000000000000000017351265717027300172740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class GazelleTest(BackendTest): MODULE = 'gazelle' def test_torrent(self): l = list(self.backend.iter_torrents('sex')) if len(l) > 0: self.backend.get_torrent_file(l[0].id) weboob-1.1/modules/gdcvault/000077500000000000000000000000001265717027300161235ustar00rootroot00000000000000weboob-1.1/modules/gdcvault/__init__.py000066400000000000000000000001011265717027300202240ustar00rootroot00000000000000from .module import GDCVaultModule __all__ = ['GDCVaultModule'] weboob-1.1/modules/gdcvault/browser.py000066400000000000000000000117131265717027300201630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from weboob.deprecated.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\ BrowserBanned from weboob.deprecated.browser.decorators import id2url #from .pages.index import IndexPage from .pages import VideoPage, IndexPage, SearchPage from .video import GDCVaultVideo #HACK from urllib2 import HTTPError import re from weboob.capabilities.base import NotAvailable __all__ = ['GDCVaultBrowser'] class GDCVaultBrowser(Browser): DOMAIN = 'gdcvault.com' ENCODING = 'utf-8' PAGES = {r'http://[w\.]*gdcvault.com/play/(?P[\d]+)/?.*': VideoPage, r'http://[w\.]*gdcvault.com/search\.php.*': (SearchPage, "json"), r'http://[w\.]*gdcvault.com/.*': IndexPage, } def is_logged(self): if self.password is None: return True if not self.page: return False obj = self.parser.select(self.page.document.getroot(), 'h3[id=welcome_user_name]', 1) if obj is None: return False return obj.attrib.get('class','') != "hidden" def login(self): if self.password is None: return params = {'remember_me': 0, 'email': self.username, 'password': self.password, } data = self.readurl('http://gdcvault.com/api/login.php', urllib.urlencode(params)) # some data returned as JSON, not sure yet if it's useful if data is None: self.openurl('/logout', '') raise BrowserBanned('Too many open sessions?') self.location('/', no_login=True) if not self.is_logged(): raise BrowserIncorrectPassword() def close_session(self): if self.password is None or not self.is_logged(): return self.openurl('/logout', '') @id2url(GDCVaultVideo.id2url) def get_video(self, url, video=None): requires_account = False redir_url = None # FIXME: this is quite ugly # but is required to handle cases like 1013422@gdcvault self.set_handle_redirect(False) try: self.open_novisit(url) #headers = req.info() except HTTPError as e: if e.getcode() == 302 and hasattr(e, 'hdrs'): if e.hdrs['Location'] in ['/', '/login']: requires_account = True else: # 1015865 redirects to a file with an eacute in the name redir_url = unicode(e.hdrs['Location'], encoding='utf-8') self.set_handle_redirect(True) if requires_account: raise BrowserUnavailable('Requires account') if redir_url: if video is None: m = re.match('http://[w\.]*gdcvault.com/play/(?P[\d]+)/?.*', url) if m: video = GDCVaultVideo(int(m.group(1))) else: raise BrowserUnavailable('Cannot find ID on page with redirection') video.url = redir_url video.set_empty_fields(NotAvailable) # best effort for now return video self.location(url) # redirects to /login means the video is not public if not self.is_on_page(VideoPage): raise BrowserUnavailable('Requires account') return self.page.get_video(video) def search_videos(self, pattern, sortby): post_data = {"firstfocus" : "", "category" : "free", "keyword" : pattern.encode('utf-8'), "conference_id" : "", } post_data = urllib.urlencode(post_data) # probably not required self.addheaders = [('Referer', 'http://gdcvault.com/'), ("Content-Type" , 'application/x-www-form-urlencoded') ] # is_logged assumes html page self.location('http://gdcvault.com/search.php', data=post_data, no_login=True) assert self.is_on_page(SearchPage) return self.page.iter_videos() def latest_videos(self): #self.home() self.location('/free') assert self.is_on_page(IndexPage) return self.page.iter_videos() weboob-1.1/modules/gdcvault/favicon.png000066400000000000000000000066321265717027300202650ustar00rootroot00000000000000PNG  IHDR@@iqbKGDg} pHYs  tIME 50] 0tEXtCommentCreated with GIMPW IDATxɏ\uwzjv7 KQ,@6""+ 0dU,?M @ h# eɲ,S)jDT{N'W0`9s>PۤR h34VC΂OBș2k(j'i]oVv~V2$$|1%4ݩgpʥ}6+M$HcK95,rR,Ĕ9V|GԚ|1N0ĸlj~qZ)Zʂ>ϭὭ}^TpJbStuʌ :d蠱JsO#Xg "$0\(GKh!, .ƅ]ڤ޽JZJgY[,,:ӫLC񄐰J/x)tl6 o|1 ̠t,١j$HIYYkv5\ݯB +K\[]v B[XjaGc!f<( Vyje1sD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QsdfbVq"O:KtQfQP:ˠ0Zs ($#S#!<ཇ=D "д>NgZn4IK>FoSnyjmO7]Sy 0`9s0`9_Ke ޫ7IENDB`weboob-1.1/modules/gdcvault/favicon.xcf000066400000000000000000000116401265717027300202540ustar00rootroot00000000000000gimp xcf file@@BBm gimp-commentCreated with GIMPgimp-image-grid(style solid) (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000)) (bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000)) (xspacing 10.000000) (yspacing 10.000000) (spacing-unit inches) (xoffset 0.000000) (yoffset 0.000000) (offset-unit inches) gamma0.45454999804496765@@ favicon.png     @@@@ghg6ghiknstxvpkhhpv{{|}z}~|unggijlmkliggӼ}qlzxjilsŜmgg伅tк|lptgghqp迄|㮛wp՟vhgglmggn{onsԘzpmmyԍuompxvohgg}oggnālgpГrjhm{jgghiihggxggՅlhpΒsggoٖsjggmރggykgoΓrggoԒsjgghtԉkgg܀kgnϑqggl٘ukgglyʏoggpwgglՐqggjliggm|ǘ{rwmggi֏oggtё|qnptqkggn}ͯogg׏oggjzФzggm{qgg~׍nggm~л~jggkuƹniggsāmggivŴwjgghnxulggku{rjgghnzwmgghknpolkihg gjigghjklmlljgghiig9gmz}skhjljjg gioutnhg gv־mlt~xmg gmogggg|ҍnmsg gnzhggkjggՐsqxg gjngghyjlswz|ytnggmtxrjgginllh֓|skg gvwggmrmζujj{sggnpj֖mggnӃlk~quˏrnggwxjזpggi~uuـmw~rۃig}zkז~ꚃwng gs{lvɆr؇kj}kדsu܍mg gm۟ܖvrևq׉nlkُooؑng gw‡r~ބnڋprnۋlmؒphg gnߩ|q~kz~݈p݉mmܙwmjg gҎsm򯋏ygt򿕠׊rۈkk民ujg gqljwsgkҊtԆig|̳mg gjԏphglwsgglըӽrо}kgq˷lg glqw{wqgghloqkgghhgghnqtpry{rlusjgjq}sig+ghihjklljgghklkkhggǥ񦧩ڮħطղ뭥޳۵½ƶծȰ溮ܳ侪˱緩⽪볥취⽪轪淥괨佪ܦ༨஥彫ɱ槱¯è漨侰⨥鼨Ƚͭ۫缩װ񦬸ռܳ® : !ڴ ƪ弪櫥 Ⱕʥ濬 ᄅ逸翳 ʮӯનԹ謥 ɪ洧߼ ʲǬ粨Գ궥ö ̫ڶӰ෬縨򳧷迭껩 ̨縫躩𴧷꽪轩 ܷͯ뷩麪꺨龩 ˩˱Կ򲧲𾯴귩븦 ˳㻫ι滬귥н ˪ղ幬絥ҳ 弩ѫ˹سٱӴ  橬,A!       0weboob-1.1/modules/gdcvault/module.py000066400000000000000000000070721265717027300177700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import CapVideo, BaseVideo from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.collection import CapCollection, CollectionNotFound from weboob.tools.value import Value, ValueBackendPassword from .browser import GDCVaultBrowser from .video import GDCVaultVideo __all__ = ['GDCVaultModule'] class GDCVaultModule(Module, CapVideo, CapCollection): NAME = 'gdcvault' MAINTAINER = u'François Revol' EMAIL = 'revol@free.fr' VERSION = '1.1' DESCRIPTION = 'Game Developers Conferences Vault video streaming website' LICENSE = 'AGPLv3+' BROWSER = GDCVaultBrowser CONFIG = BackendConfig(Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password', default='')) def create_default_browser(self): username = self.config['username'].get() if len(username) > 0: password = self.config['password'].get() else: password = None return self.create_browser(username, password) def deinit(self): # don't need to logout if the browser hasn't been used. if not self._browser: return with self.browser: self.browser.close_session() def get_video(self, _id): with self.browser: return self.browser.get_video(_id) SORTBY = ['relevance', 'rating', 'views', 'time'] def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): with self.browser: return self.browser.search_videos(pattern, self.SORTBY[sortby]) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields with self.browser: video = self.browser.get_video(GDCVaultVideo.id2url(video.id), video) if 'thumbnail' in fields and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest']) if collection.split_path == [u'latest']: for video in self.browser.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest']: collection.title = u'Latest GDCVault videos' return raise CollectionNotFound(collection.split_path) OBJECTS = {GDCVaultVideo: fill_video} weboob-1.1/modules/gdcvault/pages.py000066400000000000000000000337651265717027300176120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Page import urllib import re import datetime from dateutil.parser import parse as parse_dt from weboob.capabilities.base import NotAvailable from weboob.capabilities.image import BaseImage from weboob.deprecated.browser import BrokenPageError #HACK from urllib2 import HTTPError from .video import GDCVaultVideo #import lxml.etree # TODO: check title on 1439 class IndexPage(Page): def iter_videos(self): for a in self.parser.select(self.document.getroot(), 'section.conference ul.media_items li.featured a.session_item'): href = a.attrib.get('href', '') # print href m = re.match('/play/(\d+)/.*', href) if not m: continue # print m.group(1) video = GDCVaultVideo(m.group(1)) # get title try: video.title = unicode(self.parser.select(a, 'div.conference_info p strong', 1).text) except IndexError: video.title = NotAvailable # get description try: video.description = unicode(self.parser.select(a, 'div.conference_info p', 1).text) except IndexError: video.description = NotAvailable # get thumbnail img = self.parser.select(a, 'div.featured_image img', 1) if img is not None: video.thumbnail = BaseImage(img.attrib['src']) video.thumbnail.url = video.thumbnail.id else: video.thumbnail = NotAvailable #m = re.match('id-(\d+)', a.attrib.get('class', '')) #if not m: # continue # FIXME yield video # the search page class uses a JSON parser, # since it's what search.php returns when POSTed (from Ajax) class SearchPage(Page): def iter_videos(self): if self.document is None or self.document['data'] is None: raise BrokenPageError('Unable to find JSON data') for data in self.document['data']: video = GDCVaultVideo.get_video_from_json(data) # TODO: split type 4 videos into id and id#slides if video is None: continue yield video class VideoPage(Page): def get_video(self, video=None): # check for slides id variant want_slides = False m = re.match('.*#slides', self.url) if m: want_slides = True # not sure it's safe self.group_dict['id'] += '#slides' if video is None: video = GDCVaultVideo(self.group_dict['id']) # the config file has it too, but in CDATA and only for type 4 obj = self.parser.select(self.document.getroot(), 'title') title = None if len(obj) > 0: try: title = unicode(obj[0].text) except UnicodeDecodeError as e: title = None if title is None: obj = self.parser.select(self.document.getroot(), 'meta[name=title]') if len(obj) > 0: if 'content' in obj[0].attrib: try: # FIXME: 1013483 has buggus title (latin1) # for now we just pass it as-is title = obj[0].attrib['content'] except UnicodeDecodeError as e: # XXX: this doesn't even works!? title = obj[0].attrib['content'].decode('iso-5589-15') if title is not None: title = title.strip() m = re.match('GDC Vault\s+-\s+(.*)', title) if m: title = m.group(1) video.title = title #TODO: POST back the title to /search.php and filter == id to get # cleaner (JSON) data... (though it'd be much slower) # try to find an iframe (type 3 and 4) obj = self.parser.select(self.document.getroot(), 'iframe') if len(obj) == 0: # type 1 or 2 (swf+js) # find which script element contains the swf args for script in self.parser.select(self.document.getroot(), 'script'): m = re.match(".*new SWFObject.*addVariable\('type', '(.*)'\).*", unicode(script.text), re.DOTALL) if m: video.ext = m.group(1) m = re.match(".*new SWFObject.*addVariable\(\"file\", encodeURIComponent\(\"(.*)\"\)\).*", unicode(script.text), re.DOTALL) if m: video.url = "http://gdcvault.com%s" % (m.group(1)) # TODO: for non-free (like 769), # must be logged to use /mediaProxy.php # FIXME: doesn't seem to work yet, we get 2 bytes as html # 769 should give: # http://twvideo01.ubm-us.net/o1/gdcradio-net/2007/gdc/GDC07-4889.mp3 # HACK: we use mechanize directly here for now... FIXME #print "asking for redirect on '%s'" % (video.url) #self.browser.addheaders += [['Referer', 'http://gdcvault.com/play/%s' % self.group_dict['id']]] #print self.browser.addheaders self.browser.set_handle_redirect(False) try: self.browser.open_novisit(video.url) # headers = req.info() # if headers.get('Content-Type', '') == 'text/html' and headers.get('Content-Length', '') == '2': # print 'BUG' #print req.code except HTTPError as e: #print e.getcode() if e.getcode() == 302 and hasattr(e, 'hdrs'): #print e.hdrs['Location'] video.url = unicode(e.hdrs['Location']) self.browser.set_handle_redirect(True) video.set_empty_fields(NotAvailable) return video #XXX: raise error? return None obj = obj[0] if obj is None: return None # type 3 or 4 (iframe) # get the config file for the rest iframe_url = obj.attrib['src'] # 1015020 has a boggus url m = re.match('http:/event(.+)', iframe_url) if m: iframe_url = 'http://event' + m.group(1) # print iframe_url # 1013798 has player169.html # 1012186 has player16x9.html # some other have /somethingplayer.html... # 1441 has a space in the xml filename, which we must not strip m = re.match('(http:.*/)[^/]*player[0-9a-z]*\.html\?.*xmlURL=([^&]+\.xml).*\&token=([^& ]+)', iframe_url) if not m: m = re.match('/play/mediaProxy\.php\?sid=(\d+)', iframe_url) if m is None: return None # TODO: must be logged to use /mediaProxy.php # type 3 (pdf slides) video.ext = u'pdf' video.url = "http://gdcvault.com%s" % (unicode(iframe_url)) # HACK: we use mechanize directly here for now... FIXME # print "asking for redirect on '%s'" % (video.url) self.browser.set_handle_redirect(False) try: self.browser.open_novisit(video.url) except HTTPError as e: if e.getcode() == 302 and hasattr(e, 'hdrs'): video.url = unicode(e.hdrs['Location']) self.browser.set_handle_redirect(True) video.set_empty_fields(NotAvailable) return video # type 4 (dual screen video) # token doesn't actually seem required # 1441 has a space in the xml filename xml_filename = urllib.quote(m.group(2)) config_url = m.group(1) + xml_filename + '?token=' + m.group(3) # self.browser.addheaders += [['Referer', 'http://gdcvault.com/play/%s' % self.group_dict['id']]] # print self.browser.addheaders # TODO: fix for 1015021 & others (forbidden) #config = self.browser.openurl(config_url).read() config = self.browser.get_document(self.browser.openurl(config_url)) obj = self.parser.select(config.getroot(), 'akamaihost', 1) host = obj.text if host is None: raise BrokenPageError('Missing tag in xml config file') if host == "smil": # the rtmp URL is described in a smil file, # with several available bitrates obj = self.parser.select(config.getroot(), 'speakervideo', 1) smil = self.browser.get_document(self.browser.openurl(obj.text)) obj = self.parser.select(smil.getroot(), 'meta', 1) # TODO: error checking base = obj.attrib.get('base', '') best_bitrate = 0 path = None obj = self.parser.select(smil.getroot(), 'video') # choose the best bitrate for o in obj: rate = int(o.attrib.get('system-bitrate', 0)) if rate > best_bitrate: path = o.attrib.get('src', '') video.url = unicode(base + '/' + path) else: # not smil, the rtmp url is directly here as host + path # for id 1373 host is missing '/ondemand' # only add it when only a domain is specified without path m = re.match('^[^\/]+$', host) if m: host += "/ondemand" videos = {} obj = self.parser.select(config.getroot(), 'speakervideo', 1) if obj.text is not None: videos['speaker'] = 'rtmp://' + host + '/' + urllib.quote(obj.text) obj = self.parser.select(config.getroot(), 'slidevideo', 1) if obj.text is not None: videos['slides'] = 'rtmp://' + host + '/' + urllib.quote(obj.text) # print videos # XXX if 'speaker' in videos: video.url = unicode(videos['speaker']) elif 'slides' in videos: # 1016627 only has slides, so fallback to them video.url = unicode(videos['slides']) if want_slides: if 'slides' in videos: video.url = unicode(videos['slides']) # if video.url is none: raise ? XXX obj = self.parser.select(config.getroot(), 'date', 1) if obj.text is not None: # 1016634 has "Invalid Date" try: video.date = parse_dt(obj.text) except ValueError as e: video.date = NotAvailable obj = self.parser.select(config.getroot(), 'duration', 1) m = re.match('(\d\d):(\d\d):(\d\d)', obj.text) if m: video.duration = datetime.timedelta(hours = int(m.group(1)), minutes = int(m.group(2)), seconds = int(m.group(3))) obj = self.parser.select(config.getroot(), 'speaker', 1) #print obj.text_content() #self.set_details(video) video.set_empty_fields(NotAvailable) return video obj = self.parser.select(self.document.getroot(), 'title') if len(obj) < 1: return None title = obj[0].text.strip() m = re.match('GDC Vault\s+-\s+(.*)', title) if m: title = m.group(1) def set_details(self, v): obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1) if obj is not None: value = obj.attrib['content'] m = re.match('(\d\d)-(\d\d)-(\d\d\d\d)\s*(\d\d):(\d\d)', value) if not m: raise BrokenPageError('Unable to parse datetime: %r' % value) day = m.group(1) month = m.group(2) year = m.group(3) hour = m.group(4) minute = m.group(5) v.date = datetime.datetime(year=int(year), month=int(month), day=int(day), hour=int(hour), minute=int(minute)) obj = self.parser.select(self.document.getroot(), 'span.ep_subtitle', 1) if obj is not None: span = self.parser.select(obj, 'span.ep_date', 1) value = span.text m = re.match('(\d\d):(\d\d)\s*\/\s*(\d\d):(\d\d)\s*-\s*(\d\d)-(\d\d)-(\d\d\d\d)', value) if not m: raise BrokenPageError('Unable to parse datetime: %r' % value) bhour = m.group(1) bminute = m.group(2) ehour = m.group(3) eminute = m.group(4) day = m.group(5) month = m.group(6) year = m.group(7) start = datetime.datetime(year=int(year), month=int(month), day=int(day), hour=int(bhour), minute=int(bminute)) end = datetime.datetime(year=int(year), month=int(month), day=int(day), hour=int(ehour), minute=int(eminute)) v.duration = end - start weboob-1.1/modules/gdcvault/test.py000066400000000000000000000030721265717027300174560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest #from weboob.capabilities.video import BaseVideo class GDCVaultTest(BackendTest): MODULE = 'gdcvault' # def test_search(self): # l = list(self.backend.search_videos('linux')) # self.assertTrue(len(l) > 0) # v = l[0] # self.backend.fillobj(v, ('url',)) # self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) # self.backend.browser.openurl(v.url) # def test_latest(self): # l = list(self.backend.iter_resources([BaseVideo], [u'latest'])) # self.assertTrue(len(l) > 0) # v = l[0] # self.backend.fillobj(v, ('url',)) # self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) weboob-1.1/modules/gdcvault/video.py000066400000000000000000000062031265717027300176040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.image import BaseImage from weboob.capabilities.video import BaseVideo from weboob.capabilities.base import NotAvailable import re from dateutil.parser import parse as parse_dt class GDCVaultVideo(BaseVideo): def __init__(self, *args, **kwargs): BaseVideo.__init__(self, *args, **kwargs) # not always flv... self.ext = NotAvailable @classmethod def id2url(cls, _id): # attempt to enlarge the id namespace to differentiate # videos from the same page m = re.match('\d+#speaker', _id) if m: return u'http://www.gdcvault.com/play/%s#speaker' % _id m = re.match('\d+#slides', _id) if m: return u'http://www.gdcvault.com/play/%s#slides' % _id return u'http://www.gdcvault.com/play/%s' % _id @classmethod def get_video_from_json(self, data): # session_id is unique per talk # vault_media_id is unique per page # (but can refer to 2 video files for dual screen) # solr_id is "${vault_media_id}.${conference_id}.${session_id}.$vault_media_type_id{}" # XXX: do we filter them or let people know about them? #if 'anchor' in data: # if data['anchor']['href'] == '#': # # file will not be accessible (not free and not logged in) # return None if 'vault_media_id' not in data: return None media_id = int(data['vault_media_id']) video = GDCVaultVideo(media_id) # 1013679 has \n in title... video.title = unicode(data.get('session_name', '').replace('\n', '')) # TODO: strip out

,
and other html... # XXX: 1013422 has all 3 and != if 'overview' in data: video.description = unicode(data['overview']) elif 'spell' in data: video.description = unicode(data['spell']) else: video.description = unicode(data.get('description', '')) if 'image' in data: video.thumbnail = BaseImage(data['image']) video.thumbnail.url = video.thumbnail.id if 'speakers_name' in data: video.author = unicode(", ".join(data['speakers_name'])) if 'start_date' in data: video.date = parse_dt(data['start_date']) if 'score' in data: video.rating = data['score'] video.set_empty_fields(NotAvailable) return video weboob-1.1/modules/gdfsuez/000077500000000000000000000000001265717027300157615ustar00rootroot00000000000000weboob-1.1/modules/gdfsuez/__init__.py000066400000000000000000000000771265717027300200760ustar00rootroot00000000000000from .module import GdfSuezModule __all__ = ['GdfSuezModule'] weboob-1.1/modules/gdfsuez/browser.py000066400000000000000000000072141265717027300200220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Mathieu Jourdan # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import StringIO from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, HomePage, AccountPage, TimeoutPage, HistoryPage, PdfPage __all__ = ['GdfSuez'] class GdfSuez(Browser): PROTOCOL = 'https' DOMAIN = 'www.gdfsuez-dolcevita.fr' PAGES = {'.*portail/clients.*?_nfpb=true&_pageLabel=page_identification': LoginPage, '.*portail/clients.*?_nfpb=true&_pageLabel=page_accueil_compte_en_ligne': HomePage, '.*p/visualiser_mes_contrats.*?_nfpb=true': AccountPage, '.*p/page_historique_de_mes_factures': HistoryPage, '.*clients.*?_nfpb=true&_nfls=false&_pageLabel=page_erreur_timeout_session': TimeoutPage } loginp = '/portailClients/appmanager/portail/clients' homep = '/portailClients/appmanager/portail/clients?_nfpb=true&_pageLabel=page_accueil_compte_en_ligne' accountp = '/portailClients/client/p/visualiser_mes_contrats?_nfpb=true' historyp = '/portailClients/client/p/page_historique_de_mes_factures' def __init__(self, *args, **kwargs): Browser.__init__(self, *args, **kwargs) def home(self): self.location(self.homep) def is_logged(self): if self.is_on_page(LoginPage) or self.is_on_page(TimeoutPage): return False return True def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) #assert isemail(self.username) if not self.is_on_page(LoginPage): self.location(self.loginp) self.page.login(self.username, self.password) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() def get_subscription_list(self): if not self.is_on_page(AccountPage): self.location(self.accountp) return self.page.get_subscription_list() def get_subscription(self, id): assert isinstance(id, basestring) for sub in self.get_subscription_list(): if sub.id == id: return sub def get_history(self, subscription): if not self.is_on_page(HistoryPage): self.location(self.historyp) return self.page.get_history() def get_details(self, subscription): bills = self.iter_bills() id = bills[0].id if not self.is_on_page(HistoryPage): self.location(self.historyp) url = 'https://www.gdfsuez-dolcevita.fr/' + self.get_bill(id)._url response = self.openurl(url) pdf = PdfPage(StringIO.StringIO(response.read())) for detail in pdf.get_details(subscription.label): yield detail def iter_bills(self): if not self.is_on_page(HistoryPage): self.location(self.historyp) return self.page.get_bills() def get_bill(self, id): assert isinstance(id, basestring) for b in self.iter_bills(): if b.id == id: return b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-1.1/modules/gdfsuez/module.py000066400000000000000000000066661265717027300176360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Mathieu Jourdan # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bill import CapBill, SubscriptionNotFound,\ BillNotFound, Subscription, Bill from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import GdfSuez __all__ = ['GdfSuezModule'] class GdfSuezModule(Module, CapBill): NAME = 'gdfsuez' MAINTAINER = u'Mathieu Jourdan' EMAIL = 'mathieu.jourdan@gresille.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'GDF-Suez French energy provider' CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID (e-mail)', masked=False), ValueBackendPassword('password', label='Password', masked=True) ) BROWSER = GdfSuez def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): for subscription in self.browser.get_subscription_list(): yield subscription def get_subscription(self, _id): if not _id.isdigit(): raise SubscriptionNotFound() with self.browser: subscription = self.browser.get_subscription(_id) if not subscription: raise SubscriptionNotFound() else: return subscription def iter_bills_history(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) with self.browser: for history in self.browser.get_history(subscription): yield history def get_details(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) with self.browser: for detail in self.browser.get_details(subscription): yield detail def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) with self.browser: for bill in self.browser.iter_bills(): yield bill def get_bill(self, id): with self.browser: bill = self.browser.get_bill(id) if not bill: raise BillNotFound() else: return bill def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) with self.browser: return self.browser.readurl(bill._url) weboob-1.1/modules/gdfsuez/pages/000077500000000000000000000000001265717027300170605ustar00rootroot00000000000000weboob-1.1/modules/gdfsuez/pages/__init__.py000066400000000000000000000016471265717027300212010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Mathieu Jourdan # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .history import HistoryPage, PdfPage from .homepage import LoginPage, HomePage, AccountPage, TimeoutPage __all__ = ['LoginPage', 'HomePage', 'AccountPage', 'HistoryPage', 'PdfPage', 'TimeoutPage'] weboob-1.1/modules/gdfsuez/pages/history.py000066400000000000000000000217141265717027300211400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Mathieu Jourdan # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import os import subprocess import tempfile import shutil from datetime import date from decimal import Decimal from weboob.deprecated.browser import Page from weboob.capabilities.base import NotAvailable from weboob.capabilities.bill import Detail, Bill class HistoryPage(Page): def on_loaded(self): self.details = [] self.bills = [] # Latest bill div = self.document.xpath('//div[@class="consulter_dernierefacture"]')[0] bdate = div.xpath('p[@class="date"]/span[@class="textetertiaire"]')[0].text bprice = div.xpath('p[@class="montant"]/span[@class="textetertiaire"]')[0].text link = div.xpath('a[@id="display_popin"]')[0].attrib['href'] mydate = date(*reversed([int(x) for x in bdate.split("/")])) price = Decimal(bprice.strip(u' € TTC').replace(',', '.')) self.bills.append(self._create_bill(mydate, price, link)) # Previous bills table = self.document.xpath('//table[@class="afficher_factures"]')[0] for tr in table[0].xpath('//tbody/tr'): cells = tr.xpath('td') bdate = unicode(cells[0].text.strip()) mydate = date(*reversed([int(x) for x in bdate.split("/")])) bprice = unicode(cells[1].text) price = Decimal(bprice.strip(u' €').replace(',', '.')) link = cells[3].xpath('a')[0].attrib['href'] self.bills.append(self._create_bill(mydate, price, link)) def _create_bill(self, date, price, link): bill = Bill() bill.id = date.__str__().replace('-', '') bill.date = date bill._price = price bill._url = link bill.format = u'pdf' bill.label = unicode(price) return bill def get_details(self): return self.details def get_bills(self): return self.bills class PdfPage(): def __init__(self, file): self.pdf = file def _parse_pdf(self): pdffile = tempfile.NamedTemporaryFile(bufsize=100000, mode='w', suffix='.pdf') temptxt = pdffile.name.replace('.pdf', '.txt') cmd = "ebook-convert" stdout = open("/dev/null", "w") shutil.copyfileobj(self.pdf, pdffile) pdffile.flush() subprocess.call([cmd, pdffile.name, temptxt], stdout=stdout) pdffile.close() txtfile = open(temptxt, 'r') txt = txtfile.read() txtfile.close() os.remove(temptxt) return txt def _parse_page(self, page): # Regexp footnote = re.compile(r'\([0-9]\) ') # (f) ht = re.compile('HT par mois') base = re.compile('la base de') enddate = re.compile('\d\d\/\d\d\/\d\d') # YY/MM/DD endwithdigit = re.compile('\d+$') # blah blah 42 textwithcoma = re.compile('([a-z]|\d{4})\,') # blah 2012, blah blah # Parsing details = [] for title in ['Abonnement', 'Consommation', 'Contributions et taxes liées à l\'énergie']: section = page.split(title, 1)[1].split('Total ')[0] # When a line holds '(0)', a newline is missing. section = re.sub(footnote, '\n', section) lines = section.split('\n') lines = [x for x in lines if len(x) > 0] # Remove empty lines detail = None for line in lines: if re.match('[A-Za-z]', line[0]): # Things we want to merge with the one just before if 'facturées' in line: # Long lines are sometimes split, so we try to join them # That is the case for: # 'Déduction du montant des consommations # estimées facturées du 00/00/00 au 00/00/00' detail.label = detail.label + u' ' + unicode(line, encoding='utf-8') # Things for which we want a new detail else: # Entering here, we will instantiate a new detail. # We hadn't so before because of fragmented lines. if detail is not None and detail.label is not NotAvailable: # We have a new element, return the other one details.append(detail) detail = Detail() detail.price = Decimal(0) # If the coma is not a decimal separator, then # this is is probably a loooong sentence. # When it comes to jokes, keep it short and sweet. line = re.split(textwithcoma, line)[0] # Things we want for sure if re.findall(enddate, line): # When a line has been badly split after a date, # We want the label to end after the date, and maybe # the second part to be the info mydate = re.search(enddate, line).group(0) mylist = line.rpartition(mydate) label = mylist[0] + mylist[1] detail.label = unicode(label, encoding='utf-8') elif re.findall(endwithdigit, line): # What is this stupid number at the end of the line? # Line should have been split before the number detail.label = unicode(re.split(endwithdigit, line)[0], encoding='utf-8') # Things we don't want for sure elif ')' in line and '(' not in line: # First part of the parenthesis should have been drop before # Avoid to create a new empty detail detail.label = NotAvailable elif re.match(base, line): # This string should come always after a date, # usually, it will match one of the cases above. # Sometimes, it appears on a new line we don't need. detail.label = NotAvailable elif re.match(ht, line): # '00,00 € HT par mois' may have been split after HT # We don't need of the second line detail.label = NotAvailable # Things we probably want to keep else: # Well, maybe our line is correct, after all. # Not much to do. detail.label = unicode(line, encoding='utf-8') detail.infos = NotAvailable elif ' %' in line: if isinstance(detail, Detail): # Sometimes the vat is not on a new line: # '00,00 00,0 %' instead of '00,0 %' vat = line.split()[line.count(' ')-1].replace(',', '.') detail.infos = unicode('TVA: ' + vat) elif ' €' in line: price = line.replace(',', '.') if isinstance(detail, Detail): detail.price = Decimal(price.strip(' €')) elif re.match(enddate, line): # Line holding dates may have been mixed up label = detail.label.split(' au ')[0] + u' au ' + unicode(line, encoding='utf-8') detail.label = label if detail.label is not NotAvailable: # Do not append empty details to the list # It seemed easier to create details anyway than dealing # with None objects details.append(detail) return details def get_details(self, label): txt = self._parse_pdf() page = None if label == u'Gaz naturel': page = txt.split('GAZ NATUREL')[1].split('TOTAL GAZ NATUREL TTC')[0] elif label == u'Electricité': page = txt.split('ELECTRICITE')[1].split('TOTAL ELECTRICITE TTC')[0] else: pass return self._parse_page(page) weboob-1.1/modules/gdfsuez/pages/homepage.py000066400000000000000000000047141265717027300212250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Mathieu Jourdan # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import date from weboob.deprecated.browser import Page from weboob.capabilities.bill import Subscription class LoginPage(Page): def login(self, login, password): self.browser.select_form('symConnexionForm') self.browser["portlet_login_plein_page_3{pageFlow.mForm.login}"] = unicode(login) self.browser["portlet_login_plein_page_3{pageFlow.mForm.password}"] = unicode(password) self.browser.submit() class HomePage(Page): def on_loaded(self): pass class AccountPage(Page): def get_subscription_list(self): table = self.document.xpath('//table[@id="ensemble_contrat_N0"]')[0] if len(table) > 0: # some clients may have subscriptions to gas and electricity, # but they receive a single bill # to avoid "boobill details" and "boobill bills" returning the same # table twice, we could return only one subscription for both. # We do not, and "boobill details" will take care of parsing only the # relevant section in the bill files. for line in table[0].xpath('//tbody/tr'): cells = line.xpath('td') snumber = cells[2].attrib['id'].replace('Contrat_', '') slabel = cells[0].xpath('a')[0].text.replace('offre', '').strip() d = unicode(cells[3].xpath('strong')[0].text.strip()) sdate = date(*reversed([int(x) for x in d.split("/")])) sub = Subscription(snumber) sub._id = snumber sub.label = slabel sub.subscriber = unicode(cells[1]) sub.renewdate = sdate yield sub class TimeoutPage(Page): def on_loaded(self): pass weboob-1.1/modules/gdfsuez/test.py000066400000000000000000000022151265717027300173120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Mathieu Jourdan # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . # This is a clone of freemobile/test.py for the gdfsuez module from weboob.tools.test import BackendTest class GdfSuezTest(BackendTest): MODULE = 'gdfsuez' def test_gdfsuez(self): for subscription in self.backend.iter_subscription(): list(self.backend.iter_history(subscription.id)) for bill in self.backend.iter_bills(subscription.id): self.backend.download_bill(bill.id) weboob-1.1/modules/geolocip/000077500000000000000000000000001265717027300161135ustar00rootroot00000000000000weboob-1.1/modules/geolocip/__init__.py000066400000000000000000000001011265717027300202140ustar00rootroot00000000000000from .module import GeolocIpModule __all__ = ['GeolocIpModule'] weboob-1.1/modules/geolocip/favicon.png000066400000000000000000000074121265717027300202520ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME  65\CIDATx[}y3;{c[@#0v(PLi * IZi5mP"DU#*&p0'@m\q;;_cgsgu|O#kvgs"sqC_)2JJq.֞miƼ~Uk= lZ+/44[Ve,1\L)- uRPZC)c̄oZq!h`WjRRzp a-5R)RBk c RB fW'or JV[S(7uoPmMZD:z,%1F)EBǬN;Z cҋ.ܽ;RE0R Z%0LjjA }Z uQ)bB~-,|+sŸŰց1B m)ɣk#5A)y=1RJ+c+vw?] k{RU#"!D,e[@Z ڒF h%c!.<σcyiR޷kf=0JAGQxc,%1 UZt_1!ǀ` P1z9\ׅ8aBDAp熛o@Cp.DH)Ɓ(/B\[` GD0  H!` )0s(Bͣ従 =ϥ̇#< 8¼[CԽPmK8LMV´"a> 80|2+}wG>vy ofEEH Q!5BVBr|cO#Qp] a* =:5V000m]ZGW_[3$Zm_=V)(:rp,DtnI (TBXM~фCLfiq7a`oZVZ<"DQ,xau4+=[`>Xs5?j/_;lΌXoV> O־R " uBeEPԟ]Wa8t)¡.q{-oI ZBcL;I:)%Sf]s_:߃Z8)C=ϻy7Iuc.IR zP?{̹GݶL$ ,qY˱;rW  aMi&X١{;c̢pI T SUǂ৛_bF}b2I l11Jymy]]^2,=<ďݍsD~BN]J;奵ZBWvsY5R\1ZkO2uqpj@9vrSgǻlwbYk_Mk.>JVmշ!Bx!FB@&#I06ޝZ#V*( ZAdG|cCQr8' AGބe~d/H82y0k`G$.sq6ϢBs.VsϹ1 C Fg^?߾@+zǶnu74[AtGd )Z h3*HLb>cp!mLL~&twU 1ǙZAn=:9:ѽa&8Fzߎ:nORzkEB8GFIX 1>{aJ3Zظd&@& yqhdfL5 |B8s_(8ic ,$ߑMU ݸt}ׅJ҄(  "# j1 ?qk-hFH<84ow&ٌw=Zk.>-x\c,[i/MiɬRGGGOe %2EFC;^{n^9fժ!o/qNXaFAbD?}[we籔F@9x @#`^h6{/7np@k} r6fi:gC?80]&x<;0\euRJaxhl6:6w2 o{ccD "4&& R6_~1$gKOIENDB`weboob-1.1/modules/geolocip/module.py000066400000000000000000000046471265717027300177650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.geolocip import CapGeolocIp, IpLocation from weboob.tools.backend import Module from weboob.deprecated.browser import Browser, BrowserUnavailable __all__ = ['GeolocIpModule'] class GeolocIpModule(Module, CapGeolocIp): NAME = 'geolocip' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u"GeolocIP IP addresses geolocation service" BROWSER = Browser def get_location(self, ipaddr): with self.browser: content = self.browser.readurl('http://www.geolocip.com/?s[ip]=%s&commit=locate+IP!' % str(ipaddr)) if content is None: raise BrowserUnavailable() tab = {} last_line = '' line = '' for line in content.split('\n'): if len(line.split('

')) > 1: key = last_line.split('
')[1].split('
')[0][0:-2] value = line.split('
')[1].split('
')[0] tab[key] = value last_line = line iploc = IpLocation(ipaddr) iploc.city = u'%s'%tab['City'] iploc.region = u'%s'%tab['Region'] iploc.zipcode = u'%s'%tab['Postal code'] iploc.country = u'%s'%tab['Country name'] if tab['Latitude'] != '': iploc.lt = float(tab['Latitude']) else: iploc.lt = 0.0 if tab['Longitude'] != '': iploc.lg = float(tab['Longitude']) else: iploc.lg = 0.0 #iploc.host = 'NA' #iploc.tld = 'NA' #iploc.isp = 'NA' return iploc weboob-1.1/modules/geolocip/test.py000066400000000000000000000016301265717027300174440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class GeolocIPTest(BackendTest): MODULE = 'geolocip' def test_geolocip(self): self.backend.get_location('88.198.11.130') weboob-1.1/modules/github/000077500000000000000000000000001265717027300155745ustar00rootroot00000000000000weboob-1.1/modules/github/__init__.py000066400000000000000000000014321265717027300177050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import GithubModule __all__ = ['GithubModule'] weboob-1.1/modules/github/browser.py000066400000000000000000000172051265717027300176360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser from weboob.tools.json import json as json_module from base64 import b64encode import datetime import re import os from urllib import quote_plus __all__ = ['GithubBrowser'] class GithubBrowser(Browser): PROTOCOL = 'https' DOMAIN = 'api.github.com' ENCODING = 'utf-8' def __init__(self, *a, **kw): kw['parser'] = 'json' Browser.__init__(self, *a, **kw) self.fewer_requests = not bool(self.username) def home(self): pass def get_project(self, project_id): json = self.do_get('https://api.github.com/repos/%s' % project_id) return {'name': json['name'], 'id': project_id} def get_issue(self, project_id, issue_number): json = self.do_get('https://api.github.com/repos/%s/issues/%s' % (project_id, issue_number)) return self._make_issue(project_id, issue_number, json) def iter_project_issues(self, project_id): base_url = 'https://api.github.com/repos/%s/issues' % project_id for json in self._paginated(base_url): for jissue in json: issue_number = jissue['number'] yield self._make_issue(project_id, issue_number, jissue) if len(json) < 100: break def iter_issues(self, query): qsparts = ['repo:%s' % query.project] if query.assignee: qsparts.append('assignee:%s' % query.assignee) if query.author: qsparts.append('author:%s' % query.author) if query.status: qsparts.append('state:%s' % query.status) if query.title: qsparts.append('%s in:title' % query.title) qs = quote_plus(' '.join(qsparts)) base_url = 'https://api.github.com/search/issues?q=%s' % qs for json in self._paginated(base_url): for jissue in json['items']: issue_number = jissue['number'] yield self._make_issue(query.project, issue_number, jissue) if not len(json['items']): break def post_issue(self, issue): base_data = self._issue_post_body(issue) url = 'https://api.github.com/repos/%s/issues' % issue.project.id json = self.do_post(url, base_data) issue_number = json['id'] return self._make_issue(issue.project.id, issue_number, json) def edit_issue(self, issue, issue_number): base_data = self._issue_post_body(issue) url = 'https://api.github.com/repos/%s/issues/%s' % (issue.project.id, issue_number) self.do_patch(url, base_data) return issue def _issue_post_body(self, issue): data = {'title': issue.title, 'body': issue.body} if issue.assignee: data['assignee'] = issue.assignee.id if issue.version: data['milestone'] = issue.version.id if issue.status: data['state'] = issue.status.name # TODO improve if more statuses are implemented return json_module.dumps(data) def post_comment(self, issue_id, comment): project_id, issue_number = issue_id.rsplit('/', 1) url = 'https://api.github.com/repos/%s/issues/%s/comments' % (project_id, issue_number) data = json_module.dumps({'body': comment}) self.do_post(url, data) # helpers def _make_issue(self, project_id, issue_number, json): d = {'number': issue_number, 'title': json['title'], 'body': json['body'], 'creation': parse_date(json['created_at']), 'updated': parse_date(json['updated_at']), 'author': json['user']['login'], 'status': json['state']} if json['assignee']: d['assignee'] = json['assignee']['login'] else: d['assignee'] = None if json['milestone']: d['version'] = json['milestone'] else: d['version'] = None d['has_comments'] = (json['comments'] > 0) d['attachments'] = list(self._extract_attachments(d['body'])) # TODO fetch other updates? return d def iter_milestones(self, project_id): for jmilestone in self.do_get('https://api.github.com/repos/%s/milestones' % project_id): yield {'id': jmilestone['number'], 'name': jmilestone['title']} def iter_comments(self, project_id, issue_number): json = self.do_get('https://api.github.com/repos/%s/issues/%s/comments' % (project_id, issue_number)) for jcomment in json: d = {'id': jcomment['id'], 'message': jcomment['body'], 'author': jcomment['user']['login'], 'date': parse_date(jcomment['created_at'])} d['attachments'] = list(self._extract_attachments(d['message'])) yield d def _extract_attachments(self, message): for attach_url in re.findall(r'https://f.cloud.github.com/assets/[\w/.-]+', message): d = {'url': attach_url, 'filename': os.path.basename(attach_url)} yield d def _paginated(self, url, start_at=1): while True: if '?' in url: page_url = '%s&per_page=100&page=%s' % (url, start_at) else: page_url = '%s?per_page=100&page=%s' % (url, start_at) yield self.do_get(page_url) start_at += 1 def get_user(self, _id): json = self.do_get('https://api.github.com/users/%s' % _id) if 'name' in json: name = json['name'] else: name = _id # wasted one request... return {'id': _id, 'name': name} def iter_members(self, project_id): for json in self._paginated('https://api.github.com/repos/%s/assignees' % project_id): for jmember in json: yield {'id': jmember['login'], 'name': jmember['login']} if len(json) < 100: break def do_get(self, url): headers = self.auth_headers() headers.update({'Accept': 'application/vnd.github.preview'}) req = self.request_class(url, None, headers=headers) return self.get_document(self.openurl(req)) def do_post(self, url, data): headers = self.auth_headers() headers.update({'Accept': 'application/vnd.github.preview'}) req = self.request_class(url, data, headers=headers) return self.get_document(self.openurl(req)) def do_patch(self, url, data): class PatchRequest(self.request_class): def get_method(self): return 'PATCH' headers = self.auth_headers() headers.update({'Accept': 'application/vnd.github.preview'}) req = PatchRequest(url, data, headers=headers) return self.get_document(self.openurl(req)) def auth_headers(self): if self.username: return {'Authorization': 'Basic %s' % b64encode('%s:%s' % (self.username, self.password))} else: return {} # TODO use a cache for objects and/or pages? # TODO use an api-key? def parse_date(s): if s.endswith('Z'): s = s[:-1] return datetime.datetime.strptime(s, '%Y-%m-%dT%H:%M:%S') weboob-1.1/modules/github/favicon.png000066400000000000000000000056371265717027300177420ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME1tEXtCommentCreated with GIMPW IDATxY]U>sGRE(PE!Q,F4 q$1<фD$jbL4 &&*)Rӝˇ_bsNoe';tk_ kBG!~  L ` 8 8R$4]gփ)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!~ "vQtAIENDB`weboob-1.1/modules/github/module.py000066400000000000000000000135341265717027300174410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from weboob.capabilities.bugtracker import CapBugTracker, Issue, Project, User, Version, Status, Update, Attachment from .browser import GithubBrowser __all__ = ['GithubModule'] STATUSES = {'open': Status('open', u'Open', Status.VALUE_NEW), 'closed': Status('closed', u'closed', Status.VALUE_RESOLVED)} # TODO tentatively parse github "labels"? class GithubModule(Module, CapBugTracker): NAME = 'github' DESCRIPTION = u'GitHub issues tracking' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password', default='')) BROWSER = GithubBrowser def create_default_browser(self): username = self.config['username'].get() if username: password = self.config['password'].get() else: password = None return self.create_browser(username, password) def get_project(self, _id): d = self.browser.get_project(_id) project = Project(_id, d['name']) project.members = list(self._iter_members(project.id)) project.statuses = list(STATUSES.values()) project.categories = [] project.versions = list(self._iter_versions(project.id)) return project def get_issue(self, _id): project_id, issue_number = self._extract_issue_id(_id) project = self.get_project(project_id) d = self.browser.get_issue(project_id, issue_number) issue = self._make_issue(d, project) if d['has_comments']: self._fetch_comments(issue) return issue def iter_issues(self, query): if ((query.assignee, query.author, query.status, query.title) == (None, None, None, None)): it = self.browser.iter_project_issues(query.project) else: it = self.browser.iter_issues(query) project = self.get_project(query.project) for d in it: issue = self._make_issue(d, project) yield issue def create_issue(self, project_id): issue = Issue(0) issue.project = self.get_project(project_id) return issue def post_issue(self, issue): assert not issue.attachments if issue.id and issue.id != '0': _, issue_number = self._extract_issue_id(issue.id) self.browser.edit_issue(issue, issue_number) else: self.browser.post_issue(issue) def update_issue(self, issue_id, update): assert not update.attachments self.browser.post_comment(issue_id, update.message) # iter_projects, remove_issue are impossible def _iter_members(self, project_id): for d in self.browser.iter_members(project_id): yield User(d['id'], d['name']) def _iter_versions(self, project_id): for d in self.browser.iter_milestones(project_id): yield Version(d['id'], d['name']) def _make_issue(self, d, project): _id = self._build_issue_id(project.id, d['number']) issue = Issue(_id) issue.project = project issue.title = d['title'] issue.body = d['body'] issue.creation = d['creation'] issue.updated = d['updated'] issue.author = project.find_user(d['author'], None) if not issue.author: # may duplicate users issue.author = User(d['author'], d['author']) issue.status = STATUSES[d['status']] if d['assignee']: issue.assignee = project.find_user(d['assignee'], None) else: issue.assignee = None if d['version']: issue.version = project.find_version(d['version'], None) else: issue.version = None issue.category = None issue.attachments = [self._make_attachment(dattach) for dattach in d['attachments']] return issue def _fetch_comments(self, issue): project_id, issue_number = self._extract_issue_id(issue.id) if not issue.history: issue.history = [] issue.history += [self._make_comment(dcomment, issue.project) for dcomment in self.browser.iter_comments(project_id, issue_number)] def _make_attachment(self, d): a = Attachment(d['url']) a.url = d['url'] a.filename = d['filename'] return a def _make_comment(self, d, project): u = Update(d['id']) u.message = d['message'] u.author = project.find_user(d['author'], None) if not u.author: # may duplicate users u.author = User(d['author'], d['author']) u.date = d['date'] u.changes = [] u.attachments = [self._make_attachment(dattach) for dattach in d['attachments']] return u @staticmethod def _extract_issue_id(_id): return _id.rsplit('/', 1) @staticmethod def _build_issue_id(project_id, issue_number): return '%s/%s' % (project_id, issue_number) weboob-1.1/modules/github/test.py000066400000000000000000000030071265717027300171250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.bugtracker import Query class GithubTest(BackendTest): MODULE = 'github' def test_project(self): project = self.backend.get_project('github/hubot') assert project assert project.name assert project.members def test_issue(self): issue = self.backend.get_issue('github/hubot/1') assert issue assert issue.title assert issue.body assert issue.creation assert issue.history def test_search(self): query = Query() query.project = u'github/hubot' query.status = u'closed' query.title = u'fix' issues = self.backend.iter_issues(query) issue = issues.next() assert issue.status.name == 'closed' weboob-1.1/modules/gls/000077500000000000000000000000001265717027300150775ustar00rootroot00000000000000weboob-1.1/modules/gls/__init__.py000066400000000000000000000014311265717027300172070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import GLSModule __all__ = ['GLSModule'] weboob-1.1/modules/gls/browser.py000066400000000000000000000024011265717027300171310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from weboob.browser.exceptions import HTTPNotFound from weboob.capabilities.parcel import ParcelNotFound from .pages import SearchPage class GLSBrowser(PagesBrowser): BASEURL = 'https://gls-group.eu' search_page = URL('/app/service/open/rest/EU/en/rstt001\?match=(?P.+)', SearchPage) def get_tracking_info(self, _id): try: return self.search_page.go(id=_id).get_info(_id) except HTTPNotFound: raise ParcelNotFound("No such ID: %s" % _id) weboob-1.1/modules/gls/favicon.png000066400000000000000000000006501265717027300172330ustar00rootroot00000000000000PNG  IHDR@@% pHYs  tIME882bvtEXtCommentCreated with GIMPW"IDATh0 D[QPUn!LIw˶̼h|_ynm ZqR9$/@:#>doX z-Bz>?%%2 Hif0E+t4F֥sG_Yl Bڲ? @҃@cS]wF]% l*QbJwY"9Hjc4"<*f\!*#cN{Ȭ7tsg%IENDB`weboob-1.1/modules/gls/module.py000066400000000000000000000026021265717027300167360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.parcel import CapParcel from .browser import GLSBrowser __all__ = ['GLSModule'] class GLSModule(Module, CapParcel): NAME = 'gls' DESCRIPTION = u'GLS website' MAINTAINER = u'Matthieu Weber' EMAIL = 'mweber+weboob@free.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = GLSBrowser def get_parcel_tracking(self, id): """ Get information abouut a parcel. :param id: ID of the parcel :type id: :class:`str` :rtype: :class:`Parcel` :raises: :class:`ParcelNotFound` """ return self.browser.get_tracking_info(id) weboob-1.1/modules/gls/pages.py000066400000000000000000000034771265717027300165630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from dateutil.parser import parse as parse_date from weboob.browser.pages import JsonPage from weboob.capabilities.parcel import Parcel, Event STATUSES = { "DELIVEREDPS": Parcel.STATUS_ARRIVED, "DELIVERED": Parcel.STATUS_ARRIVED, } class SearchPage(JsonPage): def get_info(self, _id): p = Parcel(_id) events = self.doc["tuStatus"][0]["history"] p.history = [self.build_event(i, tr) for i, tr in enumerate(events)] p.status = self.guess_status(self.doc["tuStatus"][0]["progressBar"]["statusInfo"]) p.info = self.doc["tuStatus"][0]["progressBar"]["statusText"] return p def guess_status(self, code): return STATUSES.get(code, Parcel.STATUS_UNKNOWN) def build_event(self, index, data): event = Event(index) date = "%s %s" % (data["date"], data["time"]) event.date = parse_date(date, dayfirst=False) event.location = ", ".join( [unicode(data["address"][field]) for field in ["city", "countryName"] if data["address"][field]]) event.activity = unicode(data["evtDscr"]) return event weboob-1.1/modules/gls/test.py000066400000000000000000000017361265717027300164370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.capabilities.parcel import ParcelNotFound class GLSTest(BackendTest): MODULE = 'gls' def test_gls(self): self.assertRaises(ParcelNotFound, self.backend.get_parcel_tracking, "foo") weboob-1.1/modules/googletranslate/000077500000000000000000000000001265717027300175045ustar00rootroot00000000000000weboob-1.1/modules/googletranslate/__init__.py000066400000000000000000000015111265717027300216130ustar00rootroot00000000000000"GoogleTranslateModule init" # -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import GoogleTranslateModule __all__ = ['GoogleTranslateModule'] weboob-1.1/modules/googletranslate/browser.py000066400000000000000000000033541265717027300215460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from weboob.deprecated.browser import Browser from .pages import TranslatePage __all__ = ['GoogleTranslateBrowser'] class GoogleTranslateBrowser(Browser): DOMAIN = 'translate.google.com' ENCODING = 'UTF-8' USER_AGENT = Browser.USER_AGENTS['desktop_firefox'] PAGES = { 'https?://translate\.google\.com': TranslatePage } def __init__(self, *args, **kwargs): Browser.__init__(self, *args, **kwargs) def translate(self, source, to, text): """ translate 'text' from 'source' language to 'to' language """ d = { 'sl': source.encode('utf-8'), 'tl': to.encode('utf-8'), 'js': 'n', 'prev': '_t', 'hl': 'en', 'ie': 'UTF-8', 'layout': '2', 'eotf': '1', 'text': text.encode('utf-8'), } self.location('https://'+self.DOMAIN, urllib.urlencode(d)) translation = self.page.get_translation() return translation weboob-1.1/modules/googletranslate/favicon.png000066400000000000000000000175221265717027300216460ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDf` pHYs  tIME(1mIDATx{wﯪtOټZ*ȀDȟ1`l 1ZK€{6 2"a![#K(vV]l3ө16H={}N鮮&8`zN ND`fD_LrzBd4LKvXHD |i !I.5!0}Zu'3ܲ"RY<6lnz:>e {{t`?1Et̿>A^ `ÛOyu*1B2&FLnjh6O􃂰W.Xr& (,0&0(wX`"؆$\ܝXD0kQU8[_v;vO.pC$ڣ*T4It%788A/Y,M=xT16| 7a+RQZ @gn"K'bv/Yp(]yLG/LZx'm%Mfpo rTyV#<ߺT26+tpkkᎺښܥVOa{v]$ W}J,{ hZsدU$jn>.Wq^Q7N|餷D˨z|3CW9cn{m6y|-ɓo9m#,Jq;"dyZ>wiʚi}s63S]3Hu1TygLMa& L 2$x|yܡecLjk~z>s-KQ\PG V^R64`}83ZFO-є `"eLڪ ?>|lft7ނ{/QpyTZ7X>ⱏ* ?9~)KV㬪P `bSx Q@fl!8+VV?gfK啮?Z1u8׺V-EEP:;Ujg_k־|GCʎ̨(\[67WdWߣA ߼@E`)H  \j}c*' Ͻ{8@ka@&82EmʪyISl;mw~ׁq;v|2v>dC*bWsPP"{`95zY.8-u@pHq{# Z2q[ڄUpBr`T@v{_sG-s..<28C))GC*\?!;Z$u 4oIJJO\y54iMX-ڀo'NHj]o9C0!A#Y >}ݯ1tܡ_OxDH'mDD8f8w:0{lZ7߬])!70v$C RXP%:}Ë!L|)9熗37켏=⫋v_w[EԄ#z|Vq2 DȈoy>UQJc6C6x|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300213400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . "backend for http://translate.google.com" from weboob.capabilities.translate import CapTranslate, Translation, TranslationFail, LanguageNotSupported from weboob.tools.backend import Module from .browser import GoogleTranslateBrowser __all__ = ['GoogleTranslateModule'] class GoogleTranslateModule(Module, CapTranslate): MAINTAINER = u'Lucien Loiseau' EMAIL = 'loiseau.lucien@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' NAME = 'googletranslate' DESCRIPTION = u'Google translation web service' BROWSER = GoogleTranslateBrowser GOOGLELANGUAGE = { 'Arabic':'ar', 'Afrikaans':'af', 'Albanian':'sq', 'Armenian':'hy', 'Azerbaijani':'az', 'Basque':'eu', 'Belarusian':'be', 'Bengali':'bn', 'Bulgarian':'bg', 'Catalan':'ca', 'Chinese':'zh-CN', 'Croatian':'hr', 'Czech':'cs', 'Danish':'da', 'Dutch':'nl', 'English':'en', 'Esperanto':'eo', 'Estonian':'et', 'Filipino':'tl', 'Finnish':'fi', 'French':'fr', 'Galician':'gl', 'Georgian':'ka', 'German':'de', 'Greek':'el', 'Gujarati':'gu', 'Haitian':'ht', 'Hebrew':'iw', 'Hindi':'hi', 'Hungaric':'hu', 'Icelandic':'is', 'Indonesian':'id', 'Irish':'ga', 'Italian':'it', 'Japanese':'ja', 'Kannada':'kn', 'Korean':'ko', 'Latin':'la', 'Latvian':'lv', 'Lithuanian':'lt', 'Macedonian':'mk', 'Malay':'ms', 'Maltese':'mt', 'Norwegian':'no', 'Persian':'fa', 'Polish':'pl', 'Portuguese':'pt', 'Romanian':'ro', 'Russian':'ru', 'Serbian':'sr', 'Slovak':'sk', 'Slovenian':'sl', 'Spanish':'es', 'Swahili':'sw', 'Swedish':'sv', 'Tamil':'ta', 'Telugu':'te', 'Thai':'th', 'Turkish':'tr', 'Ukrainian':'uk', 'Urdu':'ur', 'Vietnamese':'vi', 'Welsh':'cy', 'Yiddish':'yi', } def translate(self, lan_from, lan_to, text): if lan_from not in self.GOOGLELANGUAGE.keys(): raise LanguageNotSupported() if lan_to not in self.GOOGLELANGUAGE.keys(): raise LanguageNotSupported() translation = Translation(0) translation.lang_src = unicode(self.GOOGLELANGUAGE[lan_from]) translation.lang_dst = unicode(self.GOOGLELANGUAGE[lan_to]) translation.text = self.browser.translate(self.GOOGLELANGUAGE[lan_from], self.GOOGLELANGUAGE[lan_to], text) if translation.text is None: raise TranslationFail() return translation weboob-1.1/modules/googletranslate/pages.py000066400000000000000000000020301265717027300211500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Page class TranslatePage(Page): def get_translation(self): boxes = self.parser.select(self.document.getroot(), 'span#result_box', 1).findall('span') if len(boxes) == 0: return None return u''.join([unicode(box.text) for box in boxes]) weboob-1.1/modules/googletranslate/test.py000066400000000000000000000017721265717027300210440ustar00rootroot00000000000000# -*- CODing: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class GoogleTranslateTest(BackendTest): MODULE = 'googletranslate' def test_translate(self): tr = self.backend.translate('French', 'English', 'je mange du chocolat') self.assertTrue(tr.text == u'I eat chocolate') weboob-1.1/modules/groupamaes/000077500000000000000000000000001265717027300164555ustar00rootroot00000000000000weboob-1.1/modules/groupamaes/__init__.py000066400000000000000000000014421265717027300205670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import GroupamaesModule __all__ = ['GroupamaesModule'] weboob-1.1/modules/groupamaes/browser.py000066400000000000000000000045771265717027300205270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from weboob.tools.date import LinearDateGuesser from .pages import LoginPage, LoginErrorPage, AvoirPage, OperationsTraiteesPage, OperationsFuturesPage __all__ = ['GroupamaesBrowser'] class GroupamaesBrowser(LoginBrowser): BASEURL = 'https://www.gestion-epargne-salariale.fr' login = URL('/groupama-es/fr/index.html', LoginPage) login_error = URL('/groupama-es/fr/identification/default.cgi', LoginErrorPage) avoir = URL('/groupama-es/fr/espace/devbavoirs.aspx\?mode=net&menu=cpte(?P.*)', AvoirPage) operations_traitees = URL('/groupama-es/fr/espace/ListeOperations.asp\?TypeOperation_=T', OperationsTraiteesPage) operations_futures = URL('/groupama-es/fr/espace/ListeOperations.asp\?TypeOperation_=E', OperationsFuturesPage) def do_login(self): self.login.stay_or_go() self.page.login(self.username, self.password) if not self.page.logged or self.login_error.is_here(): raise BrowserIncorrectPassword() @need_login def get_accounts_list(self): return self.avoir.stay_or_go(page='&page=situglob').iter_accounts() @need_login def get_history(self): transactions = list(self.operations_traitees.go().get_history(date_guesser=LinearDateGuesser())) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return transactions @need_login def get_coming(self): transactions = list(self.operations_futures.go().get_list(date_guesser=LinearDateGuesser())) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return transactions weboob-1.1/modules/groupamaes/favicon.png000066400000000000000000000221721265717027300206140ustar00rootroot00000000000000PNG  IHDR@@iqsRGBgAMA a pHYs  $IDATx^{w|UU%@hHCBBzrSnnMO ""}TD(MQf0eF}}<> {ؿrkdtpL\X9z{ :䚌{6\Y|,u~d;'÷7WSB5j.DV9wr-޷.O΁{2:fsj}ܹ]n㶟\T&vpυj>GG'\n^Ϗ bd| kpMBT5 ]*'[U&z2˞$tLD/G2z;г*=+8Sɖ`{yOY66fl,}~j}k2ԍP-bD:~ S4Z:HB7{"Q1։-q(v%<asŠ6 6DXPPDW9r۞0Bϒ5\dyQ}xM8Eɍ8!_N# >+Sѹx"p!*1LmI©X55MM3i 4#9:; ff[Xl:J!Ǥ3UQBe31 9%늙y\'au iHE.^&PJ?x34z HB!bx8]X}k>Y(*kE߲DSѱ4]'+x7N|-mR)xb7q4 \uno>50_AU6y*\1N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300203260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from weboob.capabilities.base import find_object from .browser import GroupamaesBrowser __all__ = ['GroupamaesModule'] class GroupamaesModule(Module, CapBank): NAME = 'groupamaes' DESCRIPTION = u"Groupama Épargne Salariale" MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = GroupamaesBrowser CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', regexp='\d{8}', masked=False), ValueBackendPassword('password', label='Mot de passe')) def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def iter_coming(self, account): return self.browser.get_coming() def iter_history(self, account): return self.browser.get_history() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) weboob-1.1/modules/groupamaes/pages.py000066400000000000000000000071611265717027300201330ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.elements import TableElement, ItemElement, method from weboob.browser.filters.standard import CleanText, CleanDecimal, TableCell, Date, Env from weboob.capabilities.bank import Account, Transaction class LoginPage(HTMLPage): def login(self, login, passwd): form = self.get_form(nr=0) form['_cm_user'] = login form['_cm_pwd'] = passwd form.submit() class LoginErrorPage(HTMLPage): pass class AvoirPage(LoggedPage, HTMLPage): @method class iter_accounts(TableElement): item_xpath = u'//table[@summary="Liste des échéances"]/tbody/tr' head_xpath = u'//table[@summary="Liste des échéances"]/thead/tr/th/text()' col_name = u'Plan' col_value = u'Evaluation en' class item(ItemElement): klass = Account obj_id = CleanText(TableCell('name')) obj_label = CleanText(TableCell('name')) obj_balance = CleanDecimal(TableCell('value'), replace_dots=True) obj_currency = CleanText(u'//table[@summary="Liste des échéances"]/thead/tr/th/small/text()') obj_type = Account.TYPE_UNKNOWN class OperationsFuturesPage(LoggedPage, HTMLPage): @method class get_list(TableElement): head_xpath = u'//table[@summary="Liste des opérations en attente"]/thead/tr/th/text()' item_xpath = u'//table[@summary="Liste des opérations en attente"]/tbody/tr' col_date = u'Date' col_operation = u'Opération' col_etat = u'Etat' col_montant = u'Montant net en' col_action = u'Action' class item(ItemElement): klass = Transaction def condition(self): return u'Aucune opération en attente' not in CleanText(TableCell('date'))(self) obj_date = Date(CleanText(TableCell('date')), Env('date_guesser')) obj_type = Transaction.TYPE_UNKNOWN obj_label = CleanText(TableCell('operation')) obj_amount = CleanDecimal(TableCell('montant'), replace_dots=True) class OperationsTraiteesPage(LoggedPage, HTMLPage): @method class get_history(TableElement): head_xpath = u'//table[@summary="Liste des opérations en attente"]/thead/tr/th/text()' item_xpath = u'//table[@summary="Liste des opérations en attente"]/tbody/tr' col_date = u'Date' col_operation = u'Opération' col_montant = u'Montant net en' class item(ItemElement): klass = Transaction def condition(self): return u'Aucune opération' not in CleanText(TableCell('date'))(self) obj_date = Date(CleanText(TableCell('date')), Env('date_guesser')) obj_type = Transaction.TYPE_UNKNOWN obj_label = CleanText(TableCell('operation')) obj_amount = CleanDecimal(TableCell('montant'), replace_dots=True) weboob-1.1/modules/groupamaes/test.py000066400000000000000000000020721265717027300200070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class GroupamaesTest(BackendTest): MODULE = 'groupamaes' def test_groupamaes(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] self.assertTrue(self.backend.get_account(l[0].id) is not None) list(self.backend.iter_history(a)) weboob-1.1/modules/guerrillamail/000077500000000000000000000000001265717027300171435ustar00rootroot00000000000000weboob-1.1/modules/guerrillamail/__init__.py000066400000000000000000000014501265717027300212540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import GuerrillamailModule __all__ = ['GuerrillamailModule'] weboob-1.1/modules/guerrillamail/browser.py000066400000000000000000000052071265717027300212040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Browser from weboob.tools.date import datetime from weboob.deprecated.browser.parsers.jsonparser import json from urllib import urlencode #from .pages import Page1, Page2 __all__ = ['GuerrillamailBrowser'] class GuerrillamailBrowser(Browser): PROTOCOL = 'https' DOMAIN = 'www.guerrillamail.com' ENCODING = 'utf-8' def __init__(self, *args, **kw): kw['parser'] = 'raw' Browser.__init__(self, *args, **kw) def _get_unicode(self, url, *a): return self.get_document(self.openurl(url, *a)).decode(self.ENCODING, 'replace') def _get_json(self, url, *a): j = json.loads(self._get_unicode(url, *a)) return j def get_mails(self, boxid): params = {'email_user': boxid, 'lang': 'en', 'domain': 'guerrillamail.com'} d = self._get_json('https://www.guerrillamail.com/ajax.php?f=set_email_user', urlencode(params)) d = self._get_json('https://www.guerrillamail.com/ajax.php?f=get_email_list&offset=0&domain=guerrillamail.com') for m in d['list']: info = {} info['id'] = m['mail_id'] info['from'] = m['mail_from'] # info['to'] = m['mail_recipient'] info['to'] = '%s@guerrillamail.com' % boxid info['subject'] = m['mail_subject'] info['datetime'] = datetime.fromtimestamp(int(m['mail_timestamp'])) info['read'] = bool(int(m['mail_read'])) yield info def get_mail_content(self, mailid): d = self._get_json('https://www.guerrillamail.com/ajax.php?f=fetch_email&email_id=mr_%s&domain=guerrillamail.com' % mailid) return d['mail_body'] def send_mail(self, from_, to, subject, body): params = {'from': from_, 'to': to, 'subject': subject, 'body': body, 'attach': '', 'domain': 'guerrillamail.com'} self._get_json('https://www.guerrillamail.com/ajax.php?f=send_email', urlencode(params)) weboob-1.1/modules/guerrillamail/favicon.png000066400000000000000000000020711265717027300212760ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME %($tEXtCommentCreated with GIMPWIDATxkA_*"BAezj^RY֫H^kA` R"%-Z"Р(lfgΛ/%NH&JlT6oŘ_/yPߒ܀H!Q\MٞಡӦEI(dbt-[M ٭ #CP{A[*î GTyىm-F~s=vvOj0@Ƽ j4.ܘvC0e4 .}@ #14=:!m ƟAXKu0*0:Ab$Z];|Dd}LiJ37)PEd^ި`ji. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.messages import CapMessages, CapMessagesPost, Thread, Message from weboob.tools.value import Value from .browser import GuerrillamailBrowser __all__ = ['GuerrillamailModule'] class GuerrillamailModule(Module, CapMessages, CapMessagesPost): NAME = 'guerrillamail' DESCRIPTION = u'GuerrillaMail temp mailbox' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = GuerrillamailBrowser CONFIG = BackendConfig(Value('inbox', label='Inbox', default='')) def iter_threads(self): inbox = self.config['inbox'].get() if not inbox: raise NotImplementedError() else: return [self.get_thread(inbox)] def get_thread(self, _id): t = Thread(_id) t.title = 'Mail for %s' % _id t.flags = t.IS_DISCUSSION first = True for d in self.browser.get_mails(_id): m = self.make_message(d, t) if not m.content: m.content = self.browser.get_mail_content(m.id) if first: first = False t.root = m else: m.parent = t.root m.parent.children.append(m) return t def post_message(self, m): raise NotImplementedError() for receiver in m.receivers: self.browser.send_mail(m.sender, receiver, m.title, m.content) def make_message(self, d, thread): m = Message(thread, d['id']) m.children = [] m.sender = d['from'] m.flags = 0 if not d.get('read', True): m.flags = m.IS_UNREAD m.title = d['subject'] m.date = d['datetime'] m.receivers = [d['to']] return m weboob-1.1/modules/guerrillamail/test.py000066400000000000000000000023101265717027300204700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from uuid import uuid4 class GuerrillamailTest(BackendTest): MODULE = 'guerrillamail' def test_guerrillamail(self): box = uuid4() thread = self.backend.get_thread(box) self.assertTrue(thread) message = thread.root self.assertTrue(message) self.assertTrue(message.sender) self.assertTrue(message.title) self.assertTrue(message.date) self.assertTrue(message.receivers) weboob-1.1/modules/happn/000077500000000000000000000000001265717027300154205ustar00rootroot00000000000000weboob-1.1/modules/happn/__init__.py000066400000000000000000000014361265717027300175350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import HappnModule __all__ = ['HappnModule'] weboob-1.1/modules/happn/browser.py000066400000000000000000000130071265717027300174560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.browser.browsers import DomainBrowser from weboob.browser.profiles import IPhone from weboob.browser.pages import HTMLPage from weboob.browser.filters.standard import CleanText from weboob.exceptions import BrowserIncorrectPassword, ParseError from weboob.tools.json import json __all__ = ['HappnBrowser', 'FacebookBrowser'] class FacebookBrowser(DomainBrowser): BASEURL = 'https://graph.facebook.com' CLIENT_ID = "247294518656661" PROFILE = IPhone('Happn/3.0.2') access_token = None info = None def login(self, username, password): self.location('https://www.facebook.com/dialog/oauth?client_id=%s&redirect_uri=fbconnect://success&scope=email,user_birthday,user_friends,public_profile,user_photos,user_likes&response_type=token' % self.CLIENT_ID) page = HTMLPage(self, self.response) form = page.get_form('//form[@id="login_form"]') form['email'] = username form['pass'] = password form.submit(allow_redirects=False) if 'Location' not in self.response.headers: raise BrowserIncorrectPassword() self.location(self.response.headers['Location']) page = HTMLPage(self, self.response) if len(page.doc.xpath('//td/div[has-class("s")]')) > 0: raise BrowserIncorrectPassword(CleanText('//td/div[has-class("s")]')(page.doc)) form = page.get_form(nr=0, submit='//input[@value="OK"]') form.submit() m = re.search('access_token=([^&]+)&', self.response.text) if m: self.access_token = m.group(1) else: raise ParseError('Unable to find access_token') self.info = self.request('/me') def request(self, url, *args, **kwargs): url += '?access_token=' + self.access_token r = self.location(self.absurl(url, base=True), *args, **kwargs) return json.loads(r.content) class HappnBrowser(DomainBrowser): BASEURL = 'https://api.happn.fr/' PROFILE = IPhone('Happn/18.3.1') ALLOW_REFERRER = False recs = [] def __init__(self, facebook, *args, **kwargs): super(HappnBrowser, self).__init__(*args, **kwargs) self.facebook = facebook self.session.headers['User-Agent'] = 'Happn/18.3.1 AndroidSDK/11' r = self.request('/connect/oauth/token', data={ 'client_id': 'FUE-idSEP-f7AqCyuMcPr2K-1iCIU_YlvK-M-im3c', 'client_secret': 'brGoHSwZsPjJ-lBk0HqEXVtb3UFu-y5l_JcOjD-Ekv', 'grant_type': 'assertion', 'assertion_type': 'facebook_access_token', 'assertion': facebook.access_token, 'scope': 'mobile_app', }) self.session.headers['Authorization'] = 'OAuth="%s"' % r['access_token'] self.my_id = r['user_id'] self.refresh_token = r['refresh_token'] me = self.request('/api/users/me') self.my_name = me['data']['name'] def request(self, *args, **kwargs): r = self.location(*args, **kwargs) return r.json() def get_contact(self, contact_id): return self.request('/api/users/%s?fields=birth_date,first_name,last_name,display_name,login,credits,referal,matching_preferences,notification_settings,unread_conversations,about,is_accepted,age,job,workplace,school,modification_date,profiles.mode(0).width(1000).height(1000).fields(url,width,height,mode),last_meet_position,my_relation,is_charmed,distance,gender' % contact_id)['data'] def get_threads(self): return self.request('/api/users/me/conversations')['data'] def get_thread(self, id): r = self.request('/api/users/%s/conversations/%s?fields=id,messages.limit(100).fields(id,message,creation_date,sender.fields(id)),participants.fields(user.fields(birth_date,first_name,last_name,display_name,credits,referal,matching_preferences,notification_settings,unread_conversations,about,is_accepted,age,job,workplace,school,modification_date,profiles.mode(0).width(1000).height(1000).fields(url,width,height,mode),last_meet_position,my_relation,is_charmed,distance,gender))' % (self.my_id, id))['data'] return r def post_message(self, thread_id, content): self.request('/api/conversations/%s/messages/' % thread_id, data={'message': content}) def find_users(self): return self.request('/api/users/me/notifications?types=468&fields=id,is_pushed,lon,actions,creation_date,is_notified,lat,modification_date,notification_type,nb_times,notifier.fields(id,job,is_accepted,workplace,my_relation,distance,gender,my_conversation,is_charmed,nb_photos,last_name,first_name,age),notified.fields(is_accepted,is_charmed)')['data'] def accept(self, id): self.request('/api/users/me/accepted/%s' % id, method='POST') def set_position(self, lat, lng): self.request('/api/users/me/position', data={'latitude': lat, 'longitude': lng, 'altitude': 0.0}) weboob-1.1/modules/happn/favicon.png000066400000000000000000000070211265717027300175530ustar00rootroot00000000000000PNG  IHDR@@% pHYs  tIME(L؋tEXtCommentCreated with GIMPW IDAThZ[l] lMDDM QJIi!1H"!}hEMQVm(AHH `9}93k/H`=397l $'1__C#M-f D==Qv)oUxXw?6s )oGք^X1D0,\)Jd'`l%`DDDlHafy1bŢ`${gԁrr3;O&9>Q+C/@$13膞dNL Xb2ڵ11VLFEXl]wͩW[6T=WXJ1gF:hkfƆa3o=&({jyF}-E~pPByxo\ּ#1qm˚".FaL*bQye JU)~f]g,sщHftbj zBFRhwڠ0+;fPjAwWo`$s쥣/tWYذ.'J^, K*e|+/JvZjO<\W: ȖJdAScGƴSxG]ֵ]On.y(=x쐕??N%5]x"me c[; &$O,ў9y񁑌K&l~>uipt\3SG[:#KYHMrͩ" ={i~zGO}s(=NOZT[(XH"/T%ɰa@16ڣ/G M83]ta& /JԍKsN’vaV={fn#,fBFV"wg,ybB ֕=sk?/ETѵ֔-}мHfIcK'}`dԍk hu.AD8# 9bNg!zg7@crv*+beɒnj`{X܀^'%Y(/ nƧ;v D-%_y$5|~+rӹT$V5\eHRB2q왯-ܠloP?lozh^X?k(hJV?+QVʳ_W^k^^P3?jW-N.jO[eR&$Sg)M?mR;x2I<4KºPNfw8p|\ehcӔ5mC$,΀ZB[a/n;X;4lfdHiNf`>L$6*gm)&,=`\8܃\1[!\}>Ě<4?/rݡ`g|%;QD7a&r3<Ĝ\`&&.B_X1D5 uYh->>@+7Pd}aLe".T *T˿R ȗT Qhʔ|}aˇd /B-1IENDB`weboob-1.1/modules/happn/module.py000066400000000000000000000300351265717027300172600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from dateutil.parser import parse as parse_date from dateutil.relativedelta import relativedelta from dateutil.tz import tzlocal from random import randint from weboob.capabilities.base import NotAvailable from weboob.capabilities.messages import CapMessages, CapMessagesPost, Thread, Message from weboob.capabilities.dating import CapDating, Optimization from weboob.capabilities.contact import CapContact, Contact, ProfileNode from weboob.exceptions import BrowserHTTPError from weboob.tools.backend import Module, BackendConfig from weboob.tools.date import local2utc from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.ordereddict import OrderedDict from weboob.tools.log import getLogger from .browser import HappnBrowser, FacebookBrowser __all__ = ['HappnModule'] class ProfilesWalker(Optimization): def __init__(self, sched, storage, browser): super(ProfilesWalker, self).__init__() self._sched = sched self._storage = storage self._browser = browser self._logger = getLogger('walker', browser.logger) self._last_position_update = None self._view_cron = None def start(self): self._view_cron = self._sched.schedule(1, self.view_profile) return True def stop(self): self._sched.cancel(self._view_cron) self._view_cron = None return True def set_config(self, params): pass def is_running(self): return self._view_cron is not None INTERVALS = [(48896403, 2303976), (48820992, 2414698)] def view_profile(self): try: n = 0 for user in self._browser.find_users(): if user['notifier']['my_relation'] > 0: continue self._browser.accept(user['notifier']['id']) self._logger.info('Liked %s %s (%s at %s): https://www.facebook.com/profile.php?id=%s&fref=ufi&pnref=story', user['notifier']['first_name'], user['notifier']['last_name'], user['notifier']['job'], user['notifier']['workplace'], user['notifier']['fb_id']) n += 1 if n > 10: break if n == 0 and (self._last_position_update is None or self._last_position_update + datetime.timedelta(minutes=20) < datetime.datetime.now()): self._logger.info('No more new profiles, updating position...') lat = randint(self.INTERVALS[1][0], self.INTERVALS[0][0])/1000000.0 lng = randint(self.INTERVALS[0][1], self.INTERVALS[1][1])/1000000.0 try: self._browser.set_position(lat, lng) except BrowserHTTPError: self._logger.warning('Unable to update position for now, it will be retried later.') self._logger.warning('NB: don\'t be afraid, happn only allows to update position every 20 minutes.') else: self._logger.info('You are now here: https://www.google.com/maps/place//@%s,%s,17z', lat, lng) self._last_position_update = datetime.datetime.now() for thread in self._browser.get_threads(): other_name = '' for user in thread['participants']: if user['user']['id'] != self._browser.my_id: other_name = user['user']['display_name'] if len(thread['messages']) == 0 and parse_date(thread['creation_date']) < (datetime.datetime.now(tzlocal()) - relativedelta(hours=1)): self._browser.post_message(thread['id'], u'Coucou %s :)' % other_name) self._logger.info(u'Welcome message sent to %s' % other_name) finally: if self._view_cron is not None: self._view_cron = self._sched.schedule(60, self.view_profile) class HappnContact(Contact): def set_profile(self, *args): section = self.profile for arg in args[:-2]: try: s = section[arg] except KeyError: s = section[arg] = ProfileNode(arg, arg.capitalize().replace('_', ' '), OrderedDict(), flags=ProfileNode.SECTION) section = s.value key = args[-2] value = args[-1] section[key] = ProfileNode(key, key.capitalize().replace('_', ' '), value) def __init__(self, info): status = Contact.STATUS_OFFLINE last_seen = parse_date(info['modification_date']) if last_seen >= datetime.datetime.now(tzlocal()) - datetime.timedelta(minutes=30): status = Contact.STATUS_ONLINE super(HappnContact, self).__init__(info['id'], info['display_name'], status) self.summary = info['about'] for photo in info['profiles']: self.set_photo(photo['id'], url=photo['url']) self.status_msg = u'Last seen at %s' % last_seen.strftime('%Y-%m-%d %H:%M:%S') self.url = NotAvailable self.profile = OrderedDict() self.set_profile('info', 'id', info['id']) self.set_profile('info', 'full_name', ' '.join([info['first_name'] or '', info['last_name'] or '']).strip()) if info['fb_id'] is not None: self.set_profile('info', 'facebook', 'https://www.facebook.com/profile.php?id=%s&fref=ufi&pnref=story' % info['fb_id']) if info['twitter_id'] is not None: self.set_profile('info', 'twitter', info['twitter_id']) self.set_profile('stats', 'accepted', info['is_accepted']) self.set_profile('stats', 'charmed', info['is_charmed']) self.set_profile('stats', 'unread_conversations', info['unread_conversations']) self.set_profile('stats', 'credits', info['credits']) if info['last_meet_position'] is not None: self.set_profile('geoloc', 'last_meet', 'https://www.google.com/maps/place//@%s,%s,17z' % (info['last_meet_position']['lat'], info['last_meet_position']['lon'])) if info['distance'] is not None: self.set_profile('geoloc', 'distance', '%.2f km' % (info['distance']/1000.0)) self.set_profile('details', 'gender', info['gender']) self.set_profile('details', 'age', '%s yo' % info['age']) self.set_profile('details', 'birthday', info['birth_date']) self.set_profile('details', 'job', info['job']) self.set_profile('details', 'company', info['workplace']) self.set_profile('details', 'school', info['school']) if info['matching_preferences'] is not None: self.set_profile('settings', 'age_min', '%s yo' % info['matching_preferences']['age_min']) self.set_profile('settings', 'age_max', '%s yo' % info['matching_preferences']['age_max']) self.set_profile('settings', 'distance', '%s m' % info['matching_preferences']['distance']) self.set_profile('settings', 'female', info['matching_preferences']['female']) self.set_profile('settings', 'male', info['matching_preferences']['male']) class HappnModule(Module, CapMessages, CapMessagesPost, CapDating, CapContact): NAME = 'happn' DESCRIPTION = u'Happn dating mobile application' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(Value('username', label='Facebook email'), ValueBackendPassword('password', label='Facebook password')) BROWSER = HappnBrowser STORAGE = {'contacts': {}, } def create_default_browser(self): facebook = FacebookBrowser() facebook.login(self.config['username'].get(), self.config['password'].get()) return self.create_browser(facebook) # ---- CapDating methods ----------------------- def init_optimizations(self): self.add_optimization('PROFILE_WALKER', ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)) # ---- CapMessages methods --------------------- def fill_thread(self, thread, fields): return self.get_thread(thread) def iter_threads(self): for thread in self.browser.get_threads(): t = Thread(thread['id']) t.flags = Thread.IS_DISCUSSION for user in thread['participants']: if user['user']['id'] != self.browser.my_id: t.title = u'Discussion with %s' % user['user']['display_name'] t.date = local2utc(parse_date(thread['modification_date'])) yield t def get_thread(self, thread): if not isinstance(thread, Thread): thread = Thread(thread) thread.flags = Thread.IS_DISCUSSION info = self.browser.get_thread(thread.id) for user in info['participants']: if user['user']['id'] == self.browser.my_id: me = HappnContact(user['user']) else: other = HappnContact(user['user']) thread.title = u'Discussion with %s' % other.name contact = self.storage.get('contacts', thread.id, default={'lastmsg': 0}) child = None for msg in info['messages']: flags = 0 if int(contact['lastmsg']) < int(msg['id']): flags = Message.IS_UNREAD if msg['sender']['id'] == me.id: sender = me receiver = other else: sender = other receiver = me msg = Message(thread=thread, id=msg['id'], title=thread.title, sender=sender.name, receivers=[receiver.name], date=local2utc(parse_date(msg['creation_date'])), content=msg['message'], children=[], parent=None, signature=sender.get_text(), flags=flags) if child: msg.children.append(child) child.parent = msg child = msg thread.root = child return thread def iter_unread_messages(self): for thread in self.iter_threads(): thread = self.get_thread(thread) for message in thread.iter_all_messages(): if message.flags & message.IS_UNREAD: yield message def set_message_read(self, message): contact = self.storage.get('contacts', message.thread.id, default={'lastmsg': 0}) if int(contact['lastmsg']) < int(message.id): contact['lastmsg'] = int(message.id) self.storage.set('contacts', message.thread.id, contact) self.storage.save() # ---- CapMessagesPost methods --------------------- def post_message(self, message): self.browser.post_message(message.thread.id, message.content) # ---- CapContact methods --------------------- def get_contact(self, contact_id): if isinstance(contact_id, Contact): contact_id = contact_id.id info = self.browser.get_contact(contact_id) return HappnContact(info) OBJECTS = {Thread: fill_thread, } weboob-1.1/modules/happn/test.py000066400000000000000000000016431265717027300167550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class HappnTest(BackendTest): MODULE = 'happn' def test_happn(self): for m in self.backend.iter_unread_messages(): pass weboob-1.1/modules/hds/000077500000000000000000000000001265717027300150705ustar00rootroot00000000000000weboob-1.1/modules/hds/__init__.py000066400000000000000000000000671265717027300172040ustar00rootroot00000000000000from .module import HDSModule __all__ = ['HDSModule'] weboob-1.1/modules/hds/browser.py000066400000000000000000000033711265717027300171310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import ValidationPage, HomePage, HistoryPage, StoryPage, AuthorPage # Browser class HDSBrowser(PagesBrowser): BASEURL = 'http://histoires-de-sexe.net' validation_page = URL('^/$', ValidationPage) home = URL(r'/menu.php', HomePage) history = URL(r'/sexe/histoires-par-date.php\?p=(?P\d+)', HistoryPage) story = URL(r'/sexe.php\?histoire=(?P.+)', StoryPage) author = URL(r'/fiche.php\?auteur=(?P.+)', AuthorPage) def iter_stories(self): n = 1 self.history.go(pagenum=n) while self.page.get_numerous() == n: for story in self.page.iter_stories(): yield story n += 1 self.history.go(pagenum=n) def get_story(self, id): self.story.go(id=id) assert self.story.is_here() return self.page.get_story() def get_author(self, name): self.author.go(name=name) assert self.author.is_here() return self.page.get_author() weboob-1.1/modules/hds/favicon.png000066400000000000000000000024671265717027300172340ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDfp pHYs  tIME4OtEXtCommentCreated with GIMPWIDATx[lUEPЦE[+RUT"xw f*16UTh b' jiC,%*}ьJB4!>h/!*XBP"UPp|pd2g=͚:3=fC$D"H$D"H$Gbs5ܨ?'5o@B`-X\4ORb Va/'@ 0h>%N˝vkΓ6ɪ8 |%3T9i3-0*ퟑs<8zN[w Qڀt;a%[LWt>kpByYxvMڳGb촘,fL+qqŶ5~ '*4.`>AL7sq3y֝ݔ1G S0ٗnuHg(tB/^uuI^GV3Y^̓еy4$Y+Gto0Ν Wɳ(nܨ~ԄXSR.L%Y[V榝 g`ןkӞRqV{Y8gzy pgW|x tvlc1 8h1BjEE4rM_}qϞ$w~bNt!/%,NThI_~ "]]_`1s3}~"b$.|#n -ww^}cKo *ʄ6P=%*BeЃ %l{3ouFT/;Fv .9{ϒc|F#1 q >qSm)bz6X( L> Iux3D"H$D"H$Dg *ǻIENDB`weboob-1.1/modules/hds/module.py000066400000000000000000000061351265717027300167340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.messages import CapMessages, Message, Thread from .browser import HDSBrowser __all__ = ['HDSModule'] class HDSModule(Module, CapMessages): NAME = 'hds' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u"Histoires de Sexe French erotic novels" STORAGE = {'seen': []} BROWSER = HDSBrowser #### CapMessages ############################################## def iter_threads(self): for story in self.browser.iter_stories(): thread = Thread(story.id) thread.title = story.title thread.date = story.date yield thread GENDERS = ['', 'boy', 'girl', 'transexual'] def get_thread(self, id): if isinstance(id, Thread): thread = id id = thread.id else: thread = None story = self.browser.get_story(id) if not story: return None if not thread: thread = Thread(story.id) flags = 0 if thread.id not in self.storage.get('seen', default=[]): flags |= Message.IS_UNREAD thread.title = story.title thread.date = story.date thread.root = Message(thread=thread, id=0, title=story.title, sender=story.author.name, receivers=None, date=thread.date, parent=None, content=story.body, children=[], signature=u'Written by a %s in category %s' % (self.GENDERS[story.author.sex], story.category), flags=flags) return thread def iter_unread_messages(self): for thread in self.iter_threads(): if thread.id in self.storage.get('seen', default=[]): continue self.fill_thread(thread, 'root') yield thread.root def set_message_read(self, message): self.storage.set('seen', self.storage.get('seen', default=[]) + [message.thread.id]) self.storage.save() def fill_thread(self, thread, fields): return self.get_thread(thread) OBJECTS = {Thread: fill_thread} weboob-1.1/modules/hds/pages.py000066400000000000000000000107161265717027300165460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.pages import HTMLPage from weboob.browser.elements import method, ListElement, ItemElement from weboob.browser.filters.standard import CleanText, Regexp, Date, Env, Filter from weboob.browser.filters.html import XPath, Link class ValidationPage(HTMLPage): pass class HomePage(HTMLPage): pass class Author(object): (UNKNOWN, MALE, FEMALE, TRANSEXUAL) = xrange(4) def __init__(self, name=None): self.name = name self.sex = self.UNKNOWN self.description = None class Sex2Enum(Filter): def filter(self, text): if text == 'homme': return Author.MALE if text == 'femme': return Author.FEMALE return Author.TRANSEXUAL class Story(object): def __init__(self, id=None): self.id = id self.title = u'' self.date = None self.category = None self.author = None self.body = None class HistoryPage(HTMLPage): ENCODING = 'iso-8859-1' def get_numerous(self): return int(CleanText('//div[@align="justify"]/table[1]//td[has-class("t0")]/font/u/strong[1]')(self.doc)) @method class iter_stories(ListElement): item_xpath = '//div[@align="justify"]/span[has-class("t4")]' class item(ItemElement): klass = Story def parse(self, el): self.env['header'] = el.getprevious().xpath('.//span')[0] self.env['body'] = el.getnext().xpath('.//a') obj_id = XPath(Env('body')) & Link & Regexp(pattern=r'.*histoire=(\d+)') obj_title = CleanText('.') obj_date = XPath(Env('header')) & CleanText & Regexp(pattern=r'le (\d+)-(\d+)-(\d+)', template=r'\3-\2-\1') & Date obj_category = XPath(Env('header')) & CleanText & Regexp(pattern=u'Catégorie :\s*(.*)\s*Auteur') def obj_author(self): return Author(self.env['header'].xpath('.//a/text()')[0]) class StoryPage(HTMLPage): ENCODING = 'iso-8859-1' @method class get_story(ItemElement): klass = Story obj_id = Env('id') obj_title = CleanText('//h1') obj_date = CleanText('//span[has-class("t4")]') & Regexp(pattern=r'le (\d+)-(\d+)-(\d+)', template=r'\3-\2-\1') & Date obj_category = CleanText('//a[starts-with(@href, "histoires-cat")]') def obj_body(self): div = self.el.xpath('//div[@align="justify"]')[0] body = '' for para in div.findall('br'): if para.text is not None: body += para.text.strip() body += '\n' if para.tail is not None: body += para.tail.strip() return body.replace(u'\x92', "'").strip() class obj_author(ItemElement): klass = Author obj_name = CleanText('//a[starts-with(@href, "fiche.php")][2]') obj_sex = CleanText('//td[has-class("t0")]') & Regexp(pattern=r"Auteur (\w+)") & Author.Sex2Enum class AuthorPage(HTMLPage): @method class get_author(ItemElement): klass = Author obj_name = CleanText('//span[has-class("t3")]') obj_sex = CleanText('//td[has-class("t0")]') & Regexp(pattern=r"Auteur (\w+)") & Author.Sex2Enum def obj_description(self): description = u'' for para in self.el.xpath('//td[has-class("t0")]')[0].getchildren(): if para.tag not in ('b', 'br'): continue if para.text is not None: description += '\n\n%s' % para.text.strip() if para.tail is not None: description += '\n%s' % para.tail.strip() return description.replace(u'\x92', "'").strip() weboob-1.1/modules/hds/test.py000066400000000000000000000017321265717027300164240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest from weboob.tools.misc import limit class HDSTest(BackendTest): MODULE = 'hds' def test_new_messages(self): for message in limit(self.backend.iter_unread_messages(), 10): pass weboob-1.1/modules/hsbc/000077500000000000000000000000001265717027300152315ustar00rootroot00000000000000weboob-1.1/modules/hsbc/__init__.py000066400000000000000000000000711265717027300173400ustar00rootroot00000000000000from .module import HSBCModule __all__ = ['HSBCModule'] weboob-1.1/modules/hsbc/browser.py000066400000000000000000000106711265717027300172730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import ssl from datetime import timedelta, date from weboob.tools.date import LinearDateGuesser from weboob.exceptions import BrowserIncorrectPassword from weboob.browser import LoginBrowser, URL, need_login from .pages import AccountsPage, CBOperationPage, CPTOperationPage, LoginPage, AppGonePage __all__ = ['HSBC'] class HSBC(LoginBrowser): BASEURL = 'https://client.hsbc.fr' app_gone = False connection = URL(r'https://www.hsbc.fr/1/2/hsbc-france/particuliers/connexion', LoginPage) login = URL(r'https://www.hsbc.fr/1/*', LoginPage) cptPage = URL(r'/cgi-bin/emcgi.*\&Cpt=.*', r'/cgi-bin/emcgi.*\&Epa=.*', r'/cgi-bin/emcgi.*\&CPT_IdPrestation.*', r'/cgi-bin/emcgi.*\&Ass_IdPrestation.*', CPTOperationPage) cbPage = URL(r'/cgi-bin/emcgi.*\&Cb=.*', r'/cgi-bin/emcgi.*\&CB_IdPrestation.*', CBOperationPage) appGone = URL(r'/.*_absente.html', r'/pm_absent_inter.html', AppGonePage) accounts = URL(r'/cgi-bin/emcgi', AccountsPage) def __init__(self, username, password, secret, *args, **kwargs): self.accounts_list = dict() self.secret = secret LoginBrowser.__init__(self, username, password, *args, **kwargs) def load_state(self, state): return def prepare_request(self, req): preq = super(HSBC, self).prepare_request(req) conn = self.session.adapters['https://'].get_connection(preq.url) conn.ssl_version = ssl.PROTOCOL_TLSv1 return preq def do_login(self): self.connection.go() self.page.login(self.username) no_secure_key_link = self.page.get_no_secure_key() if not no_secure_key_link: raise BrowserIncorrectPassword() self.location(no_secure_key_link) self.page.login_w_secure(self.password, self.secret) for _ in range(2): if self.login.is_here(): self.page.useless_form() home_url = self.page.get_frame() if not home_url or not self.page.logged: raise BrowserIncorrectPassword() self.location(home_url) @need_login def get_accounts_list(self): self.update_accounts_list() for i,a in self.accounts_list.items(): yield a @need_login def update_accounts_list(self): for a in list(self.accounts.stay_or_go().iter_accounts()): try: self.accounts_list[a.id]._link_id = a._link_id except KeyError: self.accounts_list[a.id] = a @need_login def get_history(self, account, coming=False): if account._link_id is None: return if account._link_id.startswith('javascript') or '&Crd=' in account._link_id: raise NotImplementedError() self.location(self.accounts_list[account.id]._link_id) #If we relogin on hsbc, all link have change if self.app_gone: self.app_gone = False self.update_accounts_list() self.location(self.accounts_list[account.id]._link_id) if self.page is None: return if self.cbPage.is_here(): guesser = LinearDateGuesser(date_max_bump=timedelta(45)) return [tr for tr in self.page.get_history(date_guesser=guesser) if (coming and tr.date > date.today()) or (not coming and tr.date <= date.today())] elif not coming: return self._get_history() else: raise NotImplementedError() def _get_history(self): for tr in self.page.get_history(): yield tr weboob-1.1/modules/hsbc/favicon.png000066400000000000000000000040721265717027300173670ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGDVKV pHYs  tIME%}=`+tEXtCommentCreated with GIMPWIDATxݛmlTe7mjɮMXjH4~Un"Y%&!!h1Dw_  ta] DLYJKK[СNyw;'땟_tjqlcZN'f͜OFC-[$եKb#^Bf<@tl,X(B`*I(~5JЧs-3!1PUD`j67MoLَCH!!/<z/(۾]X/P,(`ZH4) ގ YBS<ޏuٴ10l>8lxFF,#iݥ(t>w@ڦhFgQ]]FE  ?JFx`Q+xᙹ:AYFS3/ @"V{̾>uW4>No ML $ׇ¶jӧ ࡇȯ\V`"HDHՊ#6Jtd L9B~M b>YUWc_a"}}-Y&p ιy 3ƃ`q۪U~j9"CC~/\d(jNEcxZ[~nVDU a۝Ɲ&hp~ 28,IRΑ,IK*֭7c"Y`LʼudLL&QT]e+9b뭭P a4$+A7r@PѪ9/Ozkk(e9cS)cĪ$n{{+UUKgiK dӴ6x!GFG?`|՛!v|/> 6'O|[~xb<{kr:x@;:u?tr[i`#С. "B8믿Rb0}@PD8*DOD4w~tUUFi Y,S VbFo5u~]_暌seB]ީ͜???W[bgz<.]OB{9v|&8{vJCCFH&5-L~*W7ot{M4YҸ|.LK|Xwu#59%.7l(35?9]듢&}Z5=&JcRlp,;<uv*ر O?}d]Kϩ(S͕3tՁ_ֶv\>#p!":6xᅒ+/߲̑Om g9r8쭭'iܐM@<5xLJm2V7 TO<ȵwyCƴB0 p~C ?n6FN.*C==?\"57gbN~,KL;gN\lx62vmyIbl׮GD+gxowX Gc IENDB`weboob-1.1/modules/hsbc/module.py000066400000000000000000000042431265717027300170730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import HSBC __all__ = ['HSBCModule'] class HSBCModule(Module, CapBank): NAME = 'hsbc' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'HSBC France' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe'), Value( 'secret', label=u'Réponse secrète')) BROWSER = HSBC def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get(), self.config['secret'].get()) def iter_accounts(self): for account in self.browser.get_accounts_list(): yield account def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): for tr in self.browser.get_history(account): yield tr def iter_coming(self, account): for tr in self.browser.get_history(account, coming=True): yield tr weboob-1.1/modules/hsbc/pages.py000066400000000000000000000172031265717027300167050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.exceptions import BrowserIncorrectPassword from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.pages import HTMLPage, LoggedPage, pagination from weboob.browser.filters.standard import Filter, Env, CleanText, CleanDecimal, Field, DateGuesser, TableCell, Regexp from weboob.browser.filters.html import Link class Transaction(FrenchTransaction): PATTERNS = [(re.compile(r'^VIR(EMENT)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(r'^PRLV (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile(r'^CB (?P.*)\s+(?P
\d+)/(?P\d+)\s*(?P.*)'), FrenchTransaction.TYPE_CARD), (re.compile(r'^DAB (?P
\d{2})/(?P\d{2}) ((?P\d{2})H(?P\d{2}) )?(?P.*?)( CB N°.*)?$'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(r'^CHEQUE$'), FrenchTransaction.TYPE_CHECK), (re.compile(r'^COTIS\.? (?P.*)'), FrenchTransaction.TYPE_BANK), (re.compile(r'^REMISE (?P.*)'), FrenchTransaction.TYPE_DEPOSIT), ] class AccountsPage(LoggedPage, HTMLPage): def get_frame(self): try: a = self.doc.xpath(u'//frame["@name=FrameWork"]')[0] except IndexError: return None else: return a.attrib['src'] @method class iter_accounts(ListElement): item_xpath = '//tr' flush_at_end = True class item(ItemElement): klass = Account def condition(self): return len(self.el.xpath('./td')) > 2 class Label(Filter): def filter(self, text): return text.lstrip(' 0123456789').title() class Type(Filter): def filter(self, label): if 'invest' in label.lower(): return Account.TYPE_MARKET return Account.TYPE_UNKNOWN obj_label = Label(CleanText('./td[1]/a')) obj_coming = Env('coming') obj_currency = FrenchTransaction.Currency('./td[3]') obj__link_id = Link('./td[1]/a') obj_type = Type(Field('label')) obj_coming = NotAvailable @property def obj_balance(self): if self.el.xpath('./parent::*/tr/th') and self.el.xpath('./parent::*/tr/th')[0].text == 'Credits': balance = CleanDecimal(replace_dots=True).filter(self.el.xpath('./td[3]')) if balance < 0: return balance else: return -balance return CleanDecimal(replace_dots=True).filter(self.el.xpath('./td[3]')) @property def obj_id(self): # Investment account and main account can have the same id # so we had account type in case of Investment to prevent conflict if Field('type')(self) == Account.TYPE_MARKET: return CleanText(replace=[('.', ''), (' ', '')]).filter(self.el.xpath('./td[2]')) + ".INVEST" return CleanText(replace=[('.', ''), (' ', '')]).filter(self.el.xpath('./td[2]')) class Pagination(object): def next_page(self): links = self.page.doc.xpath('//a[@class="fleche"]') if len(links) == 0: return current_page_found = False for link in links: l = link.attrib.get('href') if current_page_found and "#op" not in l: # Adding CB_IdPrestation so browser2 use CBOperationPage return l + "&CB_IdPrestation" elif "#op" in l: current_page_found = True return class CBOperationPage(LoggedPage, HTMLPage): @pagination @method class get_history(Pagination, Transaction.TransactionsElement): head_xpath = '//table//tr/th' item_xpath = '//table//tr' class item(Transaction.TransactionElement): condition = lambda self: len(self.el.xpath('./td')) >= 4 obj_rdate = Transaction.Date(TableCell('date')) def obj_date(self): return DateGuesser(Regexp(CleanText(self.page.doc.xpath('//table/tr[2]/td[1]')), r'(\d{2}/\d{2})'), Env("date_guesser"))(self) class CPTOperationPage(LoggedPage, HTMLPage): def get_history(self): for script in self.doc.xpath('//script'): if script.text is None or script.text.find('\nCL(0') < 0: continue for m in re.finditer(r"CL\((\d+),'(.+)','(.+)','(.+)','([\d -\.,]+)',('([\d -\.,]+)',)?'\d+','\d+','[\w\s]+'\);", script.text, flags=re.MULTILINE): op = Transaction() op.parse(date=m.group(3), raw=re.sub(u'[ ]+', u' ', m.group(4).replace(u'\n', u' '))) op.set_amount(m.group(5)) op._coming = (re.match(r'\d+/\d+/\d+', m.group(2)) is None) yield op class AppGonePage(HTMLPage): def on_load(self): self.browser.app_gone = True self.logger.info('Application has gone. Relogging...') self.browser.do_logout() self.browser.do_login() class LoginPage(HTMLPage): @property def logged(self): if self.doc.xpath(u'//p[contains(text(), "You are now being redirected to your Personal Internet Banking.")]'): return True return False def on_load(self): for message in self.doc.getroot().cssselect('div.csPanelErrors'): raise BrowserIncorrectPassword(CleanText('.')(message)) def login(self, login): form = self.get_form(nr=2) form['userid'] = login form.submit() def get_no_secure_key(self): try: a = self.doc.xpath(u'//a[contains(text(), "Without HSBC Secure Key")]')[0] except IndexError: return None else: return a.attrib['href'] def login_w_secure(self, password, secret): form = self.get_form(nr=0) form['memorableAnswer'] = secret inputs = self.doc.xpath(u'//input[starts-with(@id, "keyrcc_password_first")]') split_pass = u'' if len(password) != len(inputs): # HSBC only use 6 first and last two from the password password = password[:6] + password[-2:] for i, inpu in enumerate(inputs): # The good field are 1,2,3 and the bad one are 11,12,21,23,24,31 and so one if int(inpu.attrib['id'].split('first')[1]) < 10: split_pass += password[i] form['password'] = split_pass form.submit() def useless_form(self): form = self.get_form(nr=0) form.submit() weboob-1.1/modules/hsbc/test.py000066400000000000000000000017341265717027300165670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class HSBCTest(BackendTest): MODULE = 'hsbc' def test_hsbc(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) weboob-1.1/modules/hybride/000077500000000000000000000000001265717027300157405ustar00rootroot00000000000000weboob-1.1/modules/hybride/__init__.py000066400000000000000000000014341265717027300200530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import HybrideModule __all__ = ['HybrideModule'] weboob-1.1/modules/hybride/browser.py000066400000000000000000000030651265717027300200010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .pages import ProgramPage, EventPage from weboob.browser import PagesBrowser, URL from weboob.browser.profiles import Firefox __all__ = ['HybrideBrowser'] class HybrideBrowser(PagesBrowser): PROFILE = Firefox() BASEURL = 'http://www.lhybride.org/' program_page = URL('programmation/a-venir.html', ProgramPage) event_page = URL('programmation/item/(?P<_id>.*)', EventPage) def list_events(self, date_from, date_to=None, city=None, categories=None): return self.program_page.go().list_events(date_from=date_from, date_to=date_to, city=city, categories=categories) def get_event(self, _id, event=None): return self.event_page.go(_id=_id).get_event(obj=event) weboob-1.1/modules/hybride/calendar.py000066400000000000000000000022421265717027300200630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS, CATEGORIES class HybrideCalendarEvent(BaseCalendarEvent): def __init__(self): BaseCalendarEvent.__init__(self) self.city = u'Lille' self.location = u'18 rue Gosselet' self.sequence = 1 self.transp = TRANSP.TRANSPARENT self.status = STATUS.CONFIRMED self.category = CATEGORIES.CINE self.timezone = u'Europe/Paris' weboob-1.1/modules/hybride/favicon.png000066400000000000000000000013021265717027300200670ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIMEOIDATx۱A/nQZXوh'( Z6z" ?xՉV wX`Qz%,ȰFf=dw'ďE)EU K̔;_h'Ap(KyuM[2 :{([<z.Dg-E@R;4hfIb~-P*X2Iϒf,R8:`A9a ?1 H20ퟕtf&3{bfl\o@B I:o- Ѯ]TSo+|n]ަ|T)k%뉉A.W5CTȀ lO$Pc&;%lKjI-iFcI3Y I.ǁŐTJZ P8}j9J.`v?<^EN@,5Jͨ(?ߠ=Y~.0ofl(0znvGfXI 6IGքNHRTG~_>IENDB`weboob-1.1/modules/hybride/module.py000066400000000000000000000035501265717027300176020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.backend import Module from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES from .browser import HybrideBrowser from .calendar import HybrideCalendarEvent __all__ = ['HybrideModule'] class HybrideModule(Module, CapCalendarEvent): NAME = 'hybride' DESCRIPTION = u'hybride website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' ASSOCIATED_CATEGORIES = [CATEGORIES.CINE] BROWSER = HybrideBrowser def search_events(self, query): if self.has_matching_categories(query): return self.browser.list_events(query.start_date, query.end_date, query.city, query.categories) def list_events(self, date_from, date_to=None): return self.browser.list_events(date_from, date_to) def get_event(self, _id): return self.browser.get_event(_id) def fill_obj(self, event, fields): return self.browser.get_event(event.id, event) OBJECTS = {HybrideCalendarEvent: fill_obj} weboob-1.1/modules/hybride/pages.py000066400000000000000000000062351265717027300174170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .calendar import HybrideCalendarEvent import weboob.tools.date as date_util from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import Filter, CleanText, Env, Format, BrowserURL, Regexp, Decode from weboob.browser.filters.html import CleanHTML from weboob.browser.filters.html import Link class Date(Filter): def filter(self, text): return date_util.parse_french_date(text) class ProgramPage(HTMLPage): @method class list_events(ListElement): item_xpath = '//div[@class="itemContainer itemContainerLast"]' class item(ItemElement): klass = HybrideCalendarEvent def validate(self, obj): return self.check_date(obj) and self.check_city(obj) and self.check_category(obj) def check_date(self, obj): if self.env['date_from'] and obj.start_date >= self.env['date_from']: if not self.env['date_to']: return True elif obj.end_date and obj.end_date <= self.env['date_to']: return True elif self.env['date_to'] >= obj.start_date: return True return False def check_city(self, obj): return (not self.env['city'] or self.env['city'].upper() == obj.city.upper()) def check_category(self, obj): return (not self.env['categories'] or obj.category in self.env['categories']) obj_id = Regexp(Link('div/div[@class="catItemHeader"]/h3[@class="catItemTitle"]/a'), '/programmation/item/(\d*?)-.*.html') obj_start_date = Date(CleanText('div/div[@class="catItemHeader"]/span[@class="catItemDateCreated"]')) obj_summary = CleanText('div/div[@class="catItemHeader"]/h3[@class="catItemTitle"]/a') class EventPage(HTMLPage): @method class get_event(ItemElement): klass = HybrideCalendarEvent obj_id = Decode(Env('_id')) obj_start_date = Date(CleanText('//span[@class="itemDateCreated"]')) obj_summary = CleanText('//h2[@class="itemTitle"]') obj_description = Format('%s\n%s', CleanHTML('//div[@class="itemIntroText"]'), CleanHTML('//div[@class="itemFullText"]')) obj_url = BrowserURL('event_page', _id=Env('_id')) weboob-1.1/modules/hybride/test.py000066400000000000000000000024421265717027300172730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime from weboob.tools.test import BackendTest, SkipTest class HybrideTest(BackendTest): MODULE = 'hybride' def test_hybride_list(self): if datetime.now() > datetime(datetime.now().year, 6, 30) and\ datetime.now() < datetime(datetime.now().year, 9, 15): raise SkipTest("Fermeture estivale") l = list(self.backend.list_events(datetime.now())) assert len(l) event = self.backend.get_event(l[0].id) self.assertTrue(event.url, 'URL for event "%s" not found: %s' % (event.id, event.url)) weboob-1.1/modules/ideel/000077500000000000000000000000001265717027300153745ustar00rootroot00000000000000weboob-1.1/modules/ideel/__init__.py000066400000000000000000000014361265717027300175110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import IdeelModule __all__ = ['IdeelModule'] weboob-1.1/modules/ideel/browser.py000066400000000000000000000127241265717027300174370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.browser import LoginBrowser, URL, need_login from weboob.browser.pages import HTMLPage from weboob.capabilities.base import Currency from weboob.capabilities.shop import Order, Item, Payment, OrderNotFound from weboob.exceptions import BrowserIncorrectPassword import re from decimal import Decimal from datetime import datetime from itertools import takewhile, count __all__ = ['Ideel'] class IdeelPage(HTMLPage): @property def logged(self): return bool(self.doc.xpath('//a[@href="/logout"]')) class LoginPage(IdeelPage): def login(self, username, password): form = self.get_form(xpath='//form[@id="iform"]') form['login'] = username form['password'] = password form.submit() class HistoryPage(IdeelPage): def exists(self): return bool(self.doc.xpath('//table[@id="order_history"]')) def iter_orders(self): return (tr.xpath('td[1]/a/text()')[0][1:] for tr in self.doc.xpath('//table[@id="order_history"]/tbody/tr')) class OrderPage(IdeelPage): def exists(self): return bool(self.order_number()) def order(self): order = Order(id=self.order_number()) order.date = self.order_date() order.tax = self.tax() order.shipping = self.shipping() order.discount = self.discount() order.total = self.total() return order def items(self): for tr in self.doc.xpath('//table[contains(@class,"items_table")]' '//tr[td[@class="items_desc"]]'): label = tr.xpath('*//div[@class="item_desc"]//span/text()')[0] url = tr.xpath('*//div[@class="item_img"]//@src')[0] onclk = tr.xpath('*//div[@class="item_img"]//@onclick') if onclk: url=re.match(r'window.open\(\'([^\']*)\'.*', onclk[0]).group(1) if url.startswith('/'): url = self.browser.BASEURL + url price = tr.xpath('td[@class="items_price"]/span/text()')[0] qty = tr.xpath('td[@class="items_qty"]//span/text()')[0] price = AmTr.decimal_amount(price) * Decimal(qty) item = Item() item.label = unicode(label) item.url = unicode(url) item.price = price yield item def payments(self): # There's no payment information on Ideel, so we'll make one up. p = Payment() p.date = self.order_date() p.method = u'DEFAULT PAYMENT' p.amount = self.total() yield p def order_number(self): return next(iter(self.doc.xpath( u'//b[text()="Order Number:"]/../strong/text()')), None) def order_date(self): txt = self.doc.xpath('//div[@id="purchase-notice"]/text()')[0] date = re.match(r'.* (\w+ \d+, \d+)$', txt).group(1) return datetime.strptime(date, '%b %d, %Y') def tax(self): return AmTr.decimal_amount(self.doc.xpath( '//span[@id="taxes"]/text()')[0]) def shipping(self): return AmTr.decimal_amount(self.doc.xpath( '//span[@id="shipping_fee"]/text()')[0]) def discount(self): TAGS = ['coupon_discount_amount', 'promo_discount_amount', 'total_rewards', 'applied_credit'] return -sum(AmTr.decimal_amount(x[1:][:-1]) for tag in TAGS for x in self.doc.xpath('//span[@id="%s"]/text()' % tag)) def total(self): return AmTr.decimal_amount(self.doc.xpath( '//span[@id="total"]/text()')[0]) class Ideel(LoginBrowser): BASEURL = 'http://www.ideel.com' login = URL(r'https://www.ideel.com/login$', LoginPage) history = URL(r'/my_account/orders\?page=(?P\d+)$', HistoryPage) order = URL(r'/my_account/orders/(?P\d+)$', OrderPage) unknown = URL(r'/.*$', IdeelPage) def get_currency(self): # Ideel uses only U.S. dollars. return Currency.get_currency(u'$') @need_login def get_order(self, id_): if self.order.go(order=id_).exists(): return self.page.order() raise OrderNotFound() @need_login def iter_orders(self): exists = HistoryPage.exists hists = takewhile(exists, (self.history.go(page=i) for i in count(1))) return (self.get_order(x) for h in hists for x in h.iter_orders()) @need_login def iter_payments(self, order): return self.order.stay_or_go(order=order.id).payments() @need_login def iter_items(self, order): return self.order.stay_or_go(order=order.id).items() def do_login(self): self.login.stay_or_go().login(self.username, self.password) if not self.page.logged: raise BrowserIncorrectPassword() weboob-1.1/modules/ideel/favicon.png000066400000000000000000000050131265717027300175260ustar00rootroot00000000000000PNG  IHDR@@PegAMA a cHRMz&u0`:pQ<bKGD1tIME ^ IDATx{pTE=W`+E*Q4l`Er!]1U0"(YY/V]DG0 J@@$$$̷f LtVWu>_sH_4iN#"FD 8Np&4"8MiDpӈ4 }4 )E^>i7HR$bwUkU. ;J$Ӵmw@EMoJY#K(Mo9rp C< 󑬫rTDixפ҇ <{j.hZT'A.KuC9jDU0Q)#4q"kqUA0I=ziB9cLn i>cK7;vc%Yg6C8عnb|8<_8iN.,-ۃo} iV I 1r!jC`,_ǘfH:sP)­ T8gĕ3^Dcn^2Gүw811@:i̟-[&[vC0oiG0Z D5PWD`hNTUuIZ%LJ4iwJ+/(1\Oʬr%Ҭ)3^bBׅhx>rKO\!=#KkGJ?^jS6wR'5Ho%@%U0iq x>dpC]P \&3\'m 9/Y;}< /~aV%e @+ߞ{? ΀ CO!m4n1lb­;(L .@*U3FImvKʤ/RvK U] Is6JRѵRQ[ w KI|h䍂鳖퇥҃}ʽ~J=sCU-XӋwHqK$i蘛/*M IYRRn:IZ9l,}<pX|1i?m-+ )-a LN2Ɯũ?o4\c2As@֍G2 `SZzĘ@P ٛ ? ~kLo\󍹾Z ??_%<F;k7̓v IjS3!~7OS{mUB{pu9$mۓn h?l:#`}z%tY|f EU <^^x b y~(B!})L7K2v"-[a1tZMU,K@Ns˔Ԯ``(t#T} AIȘ /'iW#q7 `T+ׇ̊ W3᪖IÉ0!a=ץBv ':~r1ͦTx_"u&*XNVLjބ$<@rh \t9kgO͚|(z6LO$o7g˭r3\`e\ߎ*oCYe~cAv"o:YYAF$kҌ^

b>BLvTѳ0t_gp0kLHIL -q_BMZ ID(ԷJJIFz,%|eY&efdY`0)vTaROzz\\.yһ 㥞=CC\']T[۩ƲoQx)'{@ڲV&]*=(LJMJΓ<oNAK%>,}|j46M(Ue~znM4rR)#QJZ u/oR}SJ,~rW++U "b)͜!?G-ŧJ]wKl^T~(+~5(n z&K7H˥Ҩ7KnevJ LRKnR2)>K=Hx4˾WK ERMq#x=x)Z/ jxp&\3 >^.mΔ +o+u'muIwJCUwP{t@Rye3mDtӈ4iN#"FD 8Np&4"8MiDp7*@%tEXtdate:create2015-02-23T19:11:18-06:00'%tEXtdate:modify2015-02-23T19:11:18-06:00L/IENDB`weboob-1.1/modules/ideel/module.py000066400000000000000000000035261265717027300172410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.shop import CapShop from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Ideel __all__ = ['IdeelModule'] class IdeelModule(Module, CapShop): NAME = 'ideel' MAINTAINER = u'Oleg Plakhotniuk' EMAIL = 'olegus8@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Ideel' CONFIG = BackendConfig( ValueBackendPassword('username', label='User name', masked=False), ValueBackendPassword('password', label='Password')) BROWSER = Ideel def create_default_browser(self): return self.create_browser(self.config['username'].get(), self.config['password'].get()) def get_currency(self): return self.browser.get_currency() def get_order(self, id_): return self.browser.get_order(id_) def iter_orders(self): return self.browser.iter_orders() def iter_payments(self, order): return self.browser.iter_payments(order) def iter_items(self, order): return self.browser.iter_items(order) weboob-1.1/modules/ideel/test.py000066400000000000000000000021441265717027300167260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class IdeelTest(BackendTest): MODULE = 'ideel' def test_history(self): """ Test that at least one item was ordered in the whole history. """ b = self.backend items = (i for o in b.iter_orders() for i in b.iter_items(o)) item = next(items, None) self.assertNotEqual(item, None) weboob-1.1/modules/ilmatieteenlaitos/000077500000000000000000000000001265717027300200265ustar00rootroot00000000000000weboob-1.1/modules/ilmatieteenlaitos/__init__.py000066400000000000000000000014571265717027300221460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import IlmatieteenlaitosModule __all__ = ['IlmatieteenlaitosModule'] weboob-1.1/modules/ilmatieteenlaitos/browser.py000066400000000000000000000035671265717027300220760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.browsers import PagesBrowser from weboob.browser.url import URL from .pages import WeatherPage, SearchCitiesPage __all__ = ['IlmatieteenlaitosBrowser'] class IlmatieteenlaitosBrowser(PagesBrowser): BASEURL = 'http://ilmatieteenlaitos.fi' cities = URL('/etusivu\?p_p_id=locationmenuportlet_WAR_fmiwwwweatherportlets&p_p_lifecycle=2&p_p_state=normal&' 'p_p_mode=view&p_p_cacheability=cacheLevelFull&term=(?P.*)', SearchCitiesPage) weather_query = URL('/paikallissaa\?p_p_id=locationmenuportlet_WAR_fmiwwwweatherportlets&p_p_lifecycle=1&' 'p_p_state=normal&p_p_mode=view&_locationmenuportlet_WAR_fmiwwwweatherportlets_action=' 'changelocation') weather = URL('/saa/(?P.*)', WeatherPage) def iter_city_search(self, pattern): return self.cities.go(pattern=pattern).iter_cities() def iter_forecast(self, city): return self.weather_query.go(data={"place": city.name, "forecast": "short"}).iter_forecast() def get_current(self, city): return self.weather_query.go(data={"place": city.name, "forecast": "short"}).get_current() weboob-1.1/modules/ilmatieteenlaitos/favicon.png000066400000000000000000000042451265717027300221660ustar00rootroot00000000000000PNG  IHDR@@% pHYs  tIME,stEXtCommentCreated with GIMPWIDAThZlSpLb0 {u"b`/$+ Y7nlUDH i5 J4)m YԩTdk)[a0B4f5L֗ 4Nj~/6Zs}s>IXF>rAsN  d2Rh4FTJ$,df@bT%07$IfJ]ZHRK5kdeezCCCN/ ƘL͖V__G===333IArt_7ů_53ȟٳgu:S. &s|´޲o7f'Zc̃ׯK---/^`4y<^2"088V#Hz?q;|vw:ʸNߞ֐`xccrCP,sUVV]fޏ'#KG尖R##vZp^bTTT0"pĉ:7>Gts"ޑ]Y鐭*r_hoo?x`;kkkk]]`;C)n2 3BW*SB`×.]uuutfU7yt عp~BEEݻwC|T K ^D_O(c}zm`pΡVm+}4 G6ӧTVV.M jj~2!3&'\F/is( ZK0LHdwTWm'̄޵DL&S5000hr;pB28& b?^ a 83@`?2rzѣ uݥqlBYK:v.L!$7l~k]Z@sɻ$uL,߻w:?΀niA~P 577|'O%s#1ƬVkz1ϑ˳Zcccl6ȱȔٳ' ԩS&}9!d';, lv4ZRFW< Z Vk4e|>)#kȬiZ>r;3Lb f#voi5J Y!p Rh,_nˌ^R)BXrb=>B?rm>DlL g>MOdlR @șf>!e2T*@N^`*QoLhf pF&Vg8N,*0d@l I$#_2LD"as8^Ue3ؐeu9 zPSS `<;c. ȫ7rO3g`B^?츪38~Df>Bp.DU}'?=RLfe@ggg 0:E sks;&$eܛ7K&.P3 yZ.ߺu+F`bf3W~> 7Ti=kպFfySaahv\3qp*Zc4gh5D"T[sƉZh\.7 -,lx<O}s͵mˈ.%;p8JX bpڭٴ >\˂MX,Z}rpRR`0޾l%ZСCW4y XYyeodFTUUcǎ54,2J@M!gH&-'<%gQlH䌝L8 E(q}ɭf㛘~G=U ;+Ҟ[* %>`pJ5w0jfovN;;;)\.7 Kز_~k8 __wcО0+IENDB`weboob-1.1/modules/ilmatieteenlaitos/module.py000066400000000000000000000032411265717027300216650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.weather import CapWeather, CityNotFound from weboob.tools.backend import Module from weboob.capabilities.base import find_object from .browser import IlmatieteenlaitosBrowser __all__ = ['IlmatieteenlaitosModule'] class IlmatieteenlaitosModule(Module, CapWeather): NAME = 'ilmatieteenlaitos' MAINTAINER = u'Matthieu Weber' EMAIL = 'mweber+weboob@free.fr' VERSION = '1.1' DESCRIPTION = 'Get forecasts from the Ilmatieteenlaitos.fi website' LICENSE = 'AGPLv3+' BROWSER = IlmatieteenlaitosBrowser def get_current(self, city_id): return self.browser.get_current(self.get_city(city_id)) def iter_forecast(self, city_id): return self.browser.iter_forecast(self.get_city(city_id)) def iter_city_search(self, pattern): return self.browser.iter_city_search(pattern) def get_city(self, _id): return find_object(self.iter_city_search(_id), id=_id, error=CityNotFound) weboob-1.1/modules/ilmatieteenlaitos/pages.py000066400000000000000000000130041265717027300214750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import date from itertools import imap, ifilter from weboob.browser.pages import JsonPage, HTMLPage from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.capabilities.weather import Forecast, Current, City, Temperature from weboob.browser.filters.json import Dict from weboob.browser.filters.standard import Filter, CleanText, CleanDecimal, Regexp, Format, Date class Id(Filter): def filter(self, txt): return txt.split(", ")[0] class SearchCitiesPage(JsonPage): @method class iter_cities(DictElement): item_xpath = '.' ignore_duplicate = True class item(ItemElement): klass = City obj_id = Id(Dict('id')) obj_name = Dict('value') class WeatherPage(HTMLPage): @method class iter_forecast(ListElement): item_xpath = ('//div[contains(@class, "mid") and contains(@class, "local-weather-forecast")]//' 'tr[@class="meteogram-dates"]/td') class item(ItemElement): klass = Forecast obj_id = CleanText('.//span/@title') def obj_date(self): months = [u'tammikuuta', u'helmikuuta', u'maaliskuuta', u'huhtikuuta', u'toukokuuta', u'kesäkuuta', u'heinäkuuta', u'elokuuta', u'syyskuuta', u'lokakuuta', u'marraskuuta', u'joulukuuta'] d = CleanText('.//span/@title')(self).split() return date(int(d[2]), months.index(d[1])+1, int(d[0].strip("."))) def temperatures(self): offset = int(CleanText('string(sum(./preceding-sibling::td/@colspan))')(self)) length = int(CleanText('@colspan')(self)) temps = CleanText('../../../tbody/tr[@class="meteogram-temperatures"]/td[position() > %d ' 'and position() <= %d]/span' % (offset, offset+length))(self) return [float(_.strip(u'\xb0')) for _ in temps.split()] def obj_low(self): return Temperature(min(self.temperatures()), u'C') def obj_high(self): return Temperature(max(self.temperatures()), u'C') def obj_text(self): offset = int(CleanText('string(sum(./preceding-sibling::td/@colspan))')(self)) length = int(CleanText('@colspan')(self)) hour_test = ('../../tr[@class="meteogram-times"]/td[position() > %d and position() <= %d ' 'and .//text() = "%%s"]' % (offset, offset+length)) hour_offset = 'string(count(%s/preceding-sibling::td)+1)' % (hour_test) values = [ '../../../tbody/tr[@class="meteogram-weather-symbols"]/td[position() = %d]/div/@title', '../../../tbody/tr[@class="meteogram-apparent-temperatures"]/td[position() = %d]/div/@title', '../../../tbody/tr[@class="meteogram-wind-symbols"]/td[position() = %d]/div/@title', '../../../tbody/tr[@class="meteogram-probabilities-of-precipitation"]/td[position() = %d]' + '/div/@title', '../../../tbody/tr[@class="meteogram-hourly-precipitation-values"]/td[position() = %d]/span/@title', ] def descriptive_text_for_hour(hour): hour_exists = CleanText(hour_test % hour)(self) == hour if hour_exists: offset = int(CleanText(hour_offset % hour)(self)) def info_for_value(value): return CleanText(value % offset)(self).replace(u'edeltävän tunnin ', u'') return ("klo %s: " % hour) + ", ".join(ifilter(bool, imap(info_for_value, values))) return u'\n' + u'\n'.join(ifilter(bool, imap(descriptive_text_for_hour, ["02", "14"]))) @method class get_current(ItemElement): klass = Current obj_id = date.today() obj_date = Date(Regexp(CleanText('//table[@class="observation-text"]//span[@class="time-stamp"]'), r'^(\d+\.\d+.\d+)')) obj_text = Format(u'%s, %s, %s', CleanText(u'(//table[@class="observation-text"])//tr[2]/td[2]'), CleanText(u'(//table[@class="observation-text"])//tr[5]/td[1]'), CleanText(u'(//table[@class="observation-text"])//tr[4]/td[2]')) def obj_temp(self): path = u'//table[@class="observation-text"]//span[@class="parameter-name" and text() = "Lämpötila"]' + \ u'/../span[@class="parameter-value"]' temp = CleanDecimal(Regexp(CleanText(path), r'^([^ \xa0]+)'), replace_dots=True)(self) unit = Regexp(CleanText(path), r'\xb0(\w)')(self) return Temperature(float(temp), unit) weboob-1.1/modules/ilmatieteenlaitos/test.py000066400000000000000000000023341265717027300213610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class IlmatieteenlaitosTest(BackendTest): MODULE = 'ilmatieteenlaitos' def test_ilmatieteenlaitos(self): l = list(self.backend.iter_city_search('helsinki')) self.assertTrue(len(l) > 0) city = l[0] current = self.backend.get_current(city.id) self.assertTrue(current.temp.value > -50 and current.temp.value < 50) forecasts = list(self.backend.iter_forecast(city.id)) self.assertTrue(len(forecasts) > 0) weboob-1.1/modules/imdb/000077500000000000000000000000001265717027300152255ustar00rootroot00000000000000weboob-1.1/modules/imdb/__init__.py000066400000000000000000000014251265717027300173400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ImdbModule __all__ = ['ImdbModule'] weboob-1.1/modules/imdb/browser.py000066400000000000000000000204431265717027300172650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from HTMLParser import HTMLParser from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.capabilities.cinema import Movie, Person from weboob.tools.json import json from .pages import PersonPage, MovieCrewPage, BiographyPage, ReleasePage from datetime import datetime __all__ = ['ImdbBrowser'] class ImdbBrowser(Browser): DOMAIN = 'www.imdb.com' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.imdb.com/title/tt[0-9]*/fullcredits.*': MovieCrewPage, 'http://www.imdb.com/title/tt[0-9]*/releaseinfo.*': ReleasePage, 'http://www.imdb.com/name/nm[0-9]*/*': PersonPage, 'http://www.imdb.com/name/nm[0-9]*/bio.*': BiographyPage, } def iter_movies(self, pattern): res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=%s' % pattern.encode('utf-8')) jres = json.loads(res) htmlparser = HTMLParser() for cat in ['title_popular', 'title_exact', 'title_approx']: if cat in jres: for m in jres[cat]: tdesc = unicode(m['title_description']) if '' in tdesc: short_description = u'%s %s' % (tdesc.split('<')[ 0].strip(', '), tdesc.split('>')[1].split('<')[0]) else: short_description = tdesc.strip(', ') movie = Movie(m['id'], htmlparser.unescape(m['title'])) movie.other_titles = NotLoaded movie.release_date = NotLoaded movie.duration = NotLoaded movie.short_description = htmlparser.unescape(short_description) movie.pitch = NotLoaded movie.country = NotLoaded movie.note = NotLoaded movie.roles = NotLoaded movie.all_release_dates = NotLoaded movie.thumbnail_url = NotLoaded yield movie def iter_persons(self, pattern): res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=%s' % pattern.encode('utf-8')) jres = json.loads(res) htmlparser = HTMLParser() for cat in ['name_popular', 'name_exact', 'name_approx']: if cat in jres: for p in jres[cat]: person = Person(p['id'], htmlparser.unescape(unicode(p['name']))) person.real_name = NotLoaded person.birth_place = NotLoaded person.birth_date = NotLoaded person.death_date = NotLoaded person.gender = NotLoaded person.nationality = NotLoaded person.short_biography = NotLoaded person.short_description = htmlparser.unescape(p['description']) person.roles = NotLoaded person.thumbnail_url = NotLoaded yield person def get_movie(self, id): res = self.readurl('http://www.omdbapi.com/?i=%s&plot=full' % id) if res is not None: jres = json.loads(res) else: return None htmlparser = HTMLParser() title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'Title' not in jres: return title = htmlparser.unescape(unicode(jres['Title'].strip())) if 'Poster' in jres: thumbnail_url = unicode(jres['Poster']) if 'Director' in jres: short_description = unicode(jres['Director']) if 'Genre' in jres: for g in jres['Genre'].split(', '): genres.append(g) if 'Runtime' in jres: m = re.search('(\d+?) min', jres['Runtime']) if m: duration = int(m.group(1)) if 'Released' in jres: released_string = str(jres['Released']) if released_string == 'N/A': release_date = NotAvailable else: months = { 'Jan':'01', 'Feb':'02', 'Mar':'03', 'Apr':'04', 'May':'05', 'Jun':'06', 'Jul':'07', 'Aug':'08', 'Sep':'09', 'Oct':'10', 'Nov':'11', 'Dec':'12', } for st in months: released_string = released_string.replace(st,months[st]) release_date = datetime.strptime(released_string, '%d %m %Y') if 'Country' in jres: country = u'' for c in jres['Country'].split(', '): country += '%s, ' % c country = country[:-2] if 'Plot' in jres: pitch = unicode(jres['Plot']) if 'imdbRating' in jres and 'imdbVotes' in jres: note = u'%s/10 (%s votes)' % (jres['imdbRating'], jres['imdbVotes']) for r in ['Actors', 'Director', 'Writer']: if '%s' % r in jres.keys(): roles['%s' % r] = [('N/A',e) for e in jres['%s' % r].split(', ')] movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie def get_person(self, id): try: self.location('http://www.imdb.com/name/%s' % id) except BrowserHTTPNotFound: return assert self.is_on_page(PersonPage) return self.page.get_person(id) def get_person_biography(self, id): self.location('http://www.imdb.com/name/%s/bio' % id) assert self.is_on_page(BiographyPage) return self.page.get_biography() def iter_movie_persons(self, movie_id, role): self.location('http://www.imdb.com/title/%s/fullcredits' % movie_id) assert self.is_on_page(MovieCrewPage) for p in self.page.iter_persons(role): yield p def iter_person_movies(self, person_id, role): self.location('http://www.imdb.com/name/%s' % person_id) assert self.is_on_page(PersonPage) return self.page.iter_movies(role) def iter_person_movies_ids(self, person_id): self.location('http://www.imdb.com/name/%s' % person_id) assert self.is_on_page(PersonPage) for movie in self.page.iter_movies_ids(): yield movie def iter_movie_persons_ids(self, movie_id): self.location('http://www.imdb.com/title/%s/fullcredits' % movie_id) assert self.is_on_page(MovieCrewPage) for person in self.page.iter_persons_ids(): yield person def get_movie_releases(self, id, country): self.location('http://www.imdb.com/title/%s/releaseinfo' % id) assert self.is_on_page(ReleasePage) return self.page.get_movie_releases(country) weboob-1.1/modules/imdb/favicon.png000066400000000000000000000031361265717027300173630ustar00rootroot00000000000000PNG  IHDR@@iqsRGBbKGD pHYs  tIME +)*WIDATx[PWƿdBHB"IUQ-ޫ 3:N}ЩUZ۱vF_:ӱ툗jkG"P-B!*,$aslbvK:9=M\cy!p|qcND9iQ~%\{5`iz{9=~/( Q^AΝE64zp%W=\~B%3I`=gܨIq``[W>*0kk;37axR3^]sV?pރF&0nF~Yv?ItY|C/%E ŝ6`0%^ZV |A<!?4TTz q/rebJ}u8\cz<־ L&%F'gϓ7[Qֲ|^HDpع9 !ճhĎmf{'ta-Pr?Wr-8FLppvd~8L\+2,@h9"=O#Iы:{}:@UE8Q`@-@uKqG6gz vG`PY=' Q8Xn*$RÏ:U8@QdԒb[ON $)j O F#GE=@¤hZV7$hRnN9^3R]]5Xm: ?ozRF`PJ֤ o7DFE?}vG2(>ɹѢ[2>$@DDE)"f;y:bQs yIL|5I<H|N%KO*)j&9ё^'N9EY;i45ia{#6V sL i F'ü@f3Y,2`c v_Q@P@P@P@P@PLH=l'(IENDB`weboob-1.1/modules/imdb/module.py000066400000000000000000000100701265717027300170620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.cinema import CapCinema, Person, Movie from weboob.tools.backend import Module from .browser import ImdbBrowser from urllib import quote_plus __all__ = ['ImdbModule'] class ImdbModule(Module, CapCinema): NAME = 'imdb' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'Internet Movie Database service' LICENSE = 'AGPLv3+' BROWSER = ImdbBrowser def get_movie(self, id): return self.browser.get_movie(id) def get_person(self, id): return self.browser.get_person(id) def iter_movies(self, pattern): return self.browser.iter_movies(quote_plus(pattern.encode('utf-8'))) def iter_persons(self, pattern): return self.browser.iter_persons(quote_plus(pattern.encode('utf-8'))) def iter_movie_persons(self, id, role=None): return self.browser.iter_movie_persons(id, role) def iter_person_movies(self, id, role=None): return self.browser.iter_person_movies(id, role) def iter_person_movies_ids(self, id): return self.browser.iter_person_movies_ids(id) def iter_movie_persons_ids(self, id): return self.browser.iter_movie_persons_ids(id) def get_person_biography(self, id): return self.browser.get_person_biography(id) def get_movie_releases(self, id, country=None): return self.browser.get_movie_releases(id, country) def fill_person(self, person, fields): if 'real_name' in fields or 'birth_place' in fields\ or 'death_date' in fields or 'nationality' in fields\ or 'short_biography' in fields or 'roles' in fields\ or 'birth_date' in fields or 'thumbnail_url' in fields\ or 'gender' in fields or fields is None: per = self.get_person(person.id) person.real_name = per.real_name person.birth_date = per.birth_date person.death_date = per.death_date person.birth_place = per.birth_place person.gender = per.gender person.nationality = per.nationality person.short_biography = per.short_biography person.short_description = per.short_description person.roles = per.roles person.thumbnail_url = per.thumbnail_url if 'biography' in fields: person.biography = self.get_person_biography(person.id) return person def fill_movie(self, movie, fields): if 'other_titles' in fields or 'release_date' in fields\ or 'duration' in fields or 'country' in fields\ or 'roles' in fields or 'note' in fields\ or 'thumbnail_url' in fields: mov = self.get_movie(movie.id) movie.other_titles = mov.other_titles movie.release_date = mov.release_date movie.duration = mov.duration movie.pitch = mov.pitch movie.country = mov.country movie.note = mov.note movie.roles = mov.roles movie.genres = mov.genres movie.short_description = mov.short_description movie.thumbnail_url = mov.thumbnail_url if 'all_release_dates' in fields: movie.all_release_dates = self.get_movie_releases(movie.id) return movie OBJECTS = { Person: fill_person, Movie: fill_movie } weboob-1.1/modules/imdb/pages.py000066400000000000000000000224731265717027300167060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.cinema import Person, Movie from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page from weboob.tools.html import html2text from datetime import datetime import re class ReleasePage(Page): ''' Page containing releases of a movie ''' def get_movie_releases(self, country_filter): result = unicode() links = self.parser.select(self.document.getroot(), 'table#release_dates a') for a in links: href = a.attrib.get('href', '') # XXX: search() could raise an exception if href.strip('/').split('/')[0] == 'calendar' and\ (country_filter is None or re.search('region=([a-zA-Z]+)&', href).group(1).lower() == country_filter): country = a.text td_date = self.parser.select(a.getparent().getparent().getparent(), 'td')[1] date_links = self.parser.select(td_date, 'a') if len(date_links) > 1: date = date_links[1].attrib.get('href', '').strip('/').split('/')[-1] date += '-'+date_links[0].attrib.get('href', '').strip('/').split('/')[-1] else: date = unicode(self.parser.select(a.getparent().getparent().getparent(), 'td')[1].text_content()) result += '%s : %s\n' % (country, date) if result == u'': result = NotAvailable else: result = result.strip() return result class BiographyPage(Page): ''' Page containing biography of a person ''' def get_biography(self): bio = unicode() start = False tn = self.parser.select(self.document.getroot(), 'div#bio_content', 1) for el in tn.getchildren(): if el.attrib.get('name') == 'mini_bio': start = True if start: bio += html2text(self.parser.tostring(el)) return bio class MovieCrewPage(Page): ''' Page listing all the persons related to a movie ''' def iter_persons(self, role_filter=None): if (role_filter is None or (role_filter is not None and role_filter == 'actor')): tables = self.parser.select(self.document.getroot(), 'table.cast_list') if len(tables) > 0: table = tables[0] tds = self.parser.select(table, 'td.itemprop') for td in tds: id = td.find('a').attrib.get('href', '').strip('/').split('/')[1] name = unicode(td.find('a').text) char_name = unicode(self.parser.select(td.getparent(), 'td.character', 1).text_content()) person = Person(id, name) person.short_description = char_name person.real_name = NotLoaded person.birth_place = NotLoaded person.birth_date = NotLoaded person.death_date = NotLoaded person.gender = NotLoaded person.nationality = NotLoaded person.short_biography = NotLoaded person.roles = NotLoaded person.thumbnail_url = NotLoaded yield person for gloss_link in self.parser.select(self.document.getroot(), 'table[cellspacing="1"] h5 a'): role = gloss_link.attrib.get('name', '').rstrip('s') if (role_filter is None or (role_filter is not None and role == role_filter)): tbody = gloss_link.getparent().getparent().getparent().getparent() for line in self.parser.select(tbody, 'tr')[1:]: for a in self.parser.select(line, 'a'): role_detail = NotAvailable href = a.attrib.get('href', '') if '/name/nm' in href: id = href.strip('/').split('/')[-1] name = unicode(a.text) if 'glossary' in href: role_detail = unicode(a.text) person = Person(id, name) person.short_description = role_detail yield person # yield self.browser.get_person(id) def iter_persons_ids(self): tables = self.parser.select(self.document.getroot(), 'table.cast_list') if len(tables) > 0: table = tables[0] tds = self.parser.select(table, 'td.itemprop') for td in tds: id = td.find('a').attrib.get('href', '').strip('/').split('/')[1] yield id class PersonPage(Page): ''' Page informing about a person It is used to build a Person instance and to get the movie list related to a person ''' def get_person(self, id): name = NotAvailable short_biography = NotAvailable short_description = NotAvailable birth_place = NotAvailable birth_date = NotAvailable death_date = NotAvailable real_name = NotAvailable gender = NotAvailable thumbnail_url = NotAvailable roles = {} nationality = NotAvailable td_overview = self.parser.select(self.document.getroot(), 'td#overview-top', 1) descs = self.parser.select(td_overview, 'span[itemprop=description]') if len(descs) > 0: short_biography = unicode(descs[0].text) rname_block = self.parser.select(td_overview, 'div.txt-block h4.inline') if len(rname_block) > 0 and "born" in rname_block[0].text.lower(): links = self.parser.select(rname_block[0].getparent(), 'a') for a in links: href = a.attrib.get('href', '').strip() if href == 'bio': real_name = unicode(a.text.strip()) elif 'birth_place' in href: birth_place = unicode(a.text.lower().strip()) names = self.parser.select(td_overview, 'h1 span[itemprop=name]') if len(names) > 0: name = unicode(names[0].text.strip()) times = self.parser.select(td_overview, 'time[itemprop=birthDate]') if len(times) > 0: time = times[0].attrib.get('datetime', '').split('-') if len(time) == 3 and int(time[0]) >= 1900: birth_date = datetime(int(time[0]), int(time[1]), int(time[2])) dtimes = self.parser.select(td_overview, 'time[itemprop=deathDate]') if len(dtimes) > 0: dtime = dtimes[0].attrib.get('datetime', '').split('-') if len(dtime) == 3 and int(dtime[0]) >= 1900: death_date = datetime(int(dtime[0]), int(dtime[1]), int(dtime[2])) img_thumbnail = self.parser.select(self.document.getroot(), 'td#img_primary img') if len(img_thumbnail) > 0: thumbnail_url = unicode(img_thumbnail[0].attrib.get('src', '')) roles = self.get_roles() person = Person(id, name) person.real_name = real_name person.birth_date = birth_date person.death_date = death_date person.birth_place = birth_place person.gender = gender person.nationality = nationality person.short_biography = short_biography person.short_description = short_description person.roles = roles person.thumbnail_url = thumbnail_url return person def iter_movies_ids(self): for role_div in self.parser.select(self.document.getroot(), 'div#filmography div.filmo-category-section > div'): for a in self.parser.select(role_div, 'a'): m = re.search('/title/(tt.*)/\?.*', a.attrib.get('href')) if m: yield m.group(1) def get_roles(self): roles = {} for role_div in self.parser.select(self.document.getroot(), 'div#filmography > div.head'): role = self.parser.select(role_div, 'a')[-1].text roles[role] = [] category = role_div.attrib.get('data-category') for infos in self.parser.select(self.document.getroot(), 'div#filmography > div.filmo-category-section > div'): if category in infos.attrib.get('id'): roles[role].append(('N/A',infos.text_content().replace('\n', ' ').strip())) return roles def iter_movies(self, role_filter=None): for role_div in self.parser.select(self.document.getroot(), 'div#filmography > div.filmo-category-section > div'): for a in self.parser.select(role_div, 'a'): m = re.search('/title/(tt.*)/\?.*', a.attrib.get('href')) if m: yield Movie(m.group(1), a.text) weboob-1.1/modules/imdb/test.py000066400000000000000000000054611265717027300165640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class ImdbTest(BackendTest): MODULE = 'imdb' def test_search_movie(self): movies = list(self.backend.iter_movies('spiderman')) assert len(movies) > 0 for movie in movies: assert movie.id def test_get_movie(self): movie = self.backend.get_movie('tt0079980') assert movie assert movie.id assert movie.original_title def test_search_person(self): persons = list(self.backend.iter_persons('dewaere')) assert len(persons) > 0 for person in persons: assert person.id def test_get_person(self): person = self.backend.get_person('nm0223033') assert person assert person.id assert person.name assert person.birth_date def test_movie_persons(self): persons = list(self.backend.iter_movie_persons('tt0079980')) assert len(persons) > 0 for person in persons: assert person.id assert person.name assert person.short_description def test_person_movies(self): movies = list(self.backend.iter_person_movies('nm0223033')) assert len(movies) > 0 for movie in movies: assert movie.id assert movie.original_title def test_get_person_biography(self): bio = self.backend.get_person_biography('nm0223033') assert bio != '' assert bio is not None def test_get_movie_releases(self): rel = self.backend.get_movie_releases('tt0079980', 'fr') assert rel != '' assert rel is not None assert rel == 'France : 25 April 1979' def test_iter_person_movies_ids(self): movies_ids = list(self.backend.iter_person_movies_ids('nm0223033')) assert len(movies_ids) > 0 for movie_id in movies_ids: assert movie_id def test_iter_movie_persons_ids(self): persons_ids = list(self.backend.iter_movie_persons_ids('tt0079980')) assert len(persons_ids) > 0 for person_id in persons_ids: assert person_id weboob-1.1/modules/imgur/000077500000000000000000000000001265717027300154355ustar00rootroot00000000000000weboob-1.1/modules/imgur/__init__.py000066400000000000000000000014301265717027300175440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2016 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import ImgurModule __all__ = ['ImgurModule'] weboob-1.1/modules/imgur/browser.py000066400000000000000000000033061265717027300174740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2016 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.browsers import APIBrowser class ImgurBrowser(APIBrowser): BASEURL = 'https://api.imgur.com' CLIENT_ID = '87a8e692cb09382' def open_raw(self, *args, **kwargs): return super(ImgurBrowser, self).open(*args, **kwargs) def open(self, *args, **kwargs): kwargs.setdefault('headers', {}) kwargs['headers']['Authorization'] = 'Client-ID %s' % self.CLIENT_ID return super(ImgurBrowser, self).open(*args, **kwargs) def post_image(self, b64, title=''): res = {} params = {'image': b64, 'title': title or '', 'type': 'base64'} json = self.request('https://api.imgur.com/3/image', data=params) if json['success']: res['id'] = json['data']['id'] res['delete_url'] = 'https://api.imgur.com/3/image/%s' % json['data']['deletehash'] return res def get_gallery(self, id): json = self.request('https://api.imgur.com/3/album/%s' % id) return json['data'] weboob-1.1/modules/imgur/favicon.png000066400000000000000000000007051265717027300175720ustar00rootroot00000000000000PNG  IHDR@@iqbKGD pHYs  tIME;ϝHtEXtCommentCreated with GIMPW-IDATx1DMJ* i It(o`h)EQV,q}>G #Bm M`9`]apR`v # @]𙘘 T``=ʨ `9Guذn%+qT&pSg^ TC v)O2M DӋ}H#d5L`cz"e2H }ǍԴ[!?u!;QH@4d hf^ @b pjvz!?E]j

. import re from weboob.capabilities.base import StringField from weboob.capabilities.gallery import BaseGallery, BaseImage, CapGallery from weboob.capabilities.paste import BasePaste, CapPaste from weboob.tools.backend import Module from weboob.tools.capabilities.paste import image_mime from weboob.tools.capabilities.thumbnail import Thumbnail from weboob.tools.date import datetime from .browser import ImgurBrowser __all__ = ['ImgurModule'] class ImgPaste(BasePaste): delete_url = StringField('URL to delete the image') @classmethod def id2url(cls, id): return 'https://imgur.com/%s' % id @property def raw_url(self): # TODO get the right extension return 'https://i.imgur.com/%s.png' % self.id class Img(BaseImage): @property def thumbnail_url(self): return ImgPaste(self.id + 't').raw_url @property def raw_url(self): return 'https://i.imgur.com/%s.%s' % (self.id, self.ext) class ImgGallery(BaseGallery): def __init__(self, *args, **kwargs): super(ImgGallery, self).__init__(*args, **kwargs) self._imgs = [] @classmethod def id2url(cls, id): return 'https://imgur.com/gallery/%s' % id def iter_image(self): return self._imgs class ImgurModule(Module, CapPaste, CapGallery): NAME = 'imgur' DESCRIPTION = u'imgur image upload service' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = ImgurBrowser IMGURL = re.compile(r'https?://(?:[a-z]+\.)?imgur.com/([a-zA-Z0-9]+)(?:\.[a-z]+)?$') GALLURL = re.compile(r'https?://(?:[a-z]+\.)?imgur.com/a/([a-zA-Z0-9]+)/?$') ID = re.compile(r'[0-9a-zA-Z]+$') def new_paste(self, *a, **kw): return ImgPaste(*a, **kw) def can_post(self, contents, title=None, public=None, max_age=None): if public is False: return 0 elif re.search(r'[^a-zA-Z0-9=+/\s]', contents): return 0 elif max_age: return 0 else: mime = image_mime(contents, ('gif', 'jpeg', 'png', 'tiff', 'xcf', 'pdf')) return 20 * int(mime is not None) def get_paste(self, id): mtc = self.IMGURL.match(id) if mtc: id = mtc.group(1) elif not self.ID.match(id): return None paste = ImgPaste(id) bin = self.browser.open_raw(paste.raw_url).content paste.contents = bin.encode('base64') return paste def post_paste(self, paste, max_age=None): res = self.browser.post_image(b64=paste.contents, title=paste.title) paste.id = res['id'] paste.delete_url = res['delete_url'] return paste def get_gallery(self, id): mtc = self.GALLURL.match(id) if mtc: id = mtc.group(1) elif not self.ID.match(id): return None d = self.browser.get_gallery(id) gallery = ImgGallery(id, url=d['link']) gallery.title = d['title'] or u'' gallery.description = d['description'] or u'' gallery.date = datetime.fromtimestamp(d['datetime']) gallery.thumbnail = Thumbnail(Img(d['cover']).thumbnail_url) for n, d in enumerate(d['images']): img = Img(d['id'], gallery=gallery, url=d['link'], index=n) img._title = d['title'] or u'' img.ext = img.url.rsplit('.', 1)[-1] img.thumbnail = Thumbnail(img.thumbnail_url) gallery._imgs.append(img) gallery.cardinality = len(gallery._imgs) return gallery def iter_gallery_images(self, gallery): return gallery._imgs def fill_img(self, img, fields): if 'data' in fields: img.data = self.browser.open_raw(img.raw_url).content return img OBJECTS = {Img: fill_img, Thumbnail: fill_img} weboob-1.1/modules/imgur/test.py000066400000000000000000000024461265717027300167740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2016 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class ImgurTest(BackendTest): MODULE = 'imgur' # small gif file DATA = 'R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAAACAkQBADs=\n' def test_imgur(self): assert self.backend.can_post(self.DATA, max_age=0) post = self.backend.new_paste(None) post.contents = self.DATA post.public = True self.backend.post_paste(post, max_age=0) assert post.id got = self.backend.get_paste(post.id) assert got assert got.contents.decode('base64') == self.DATA.decode('base64') weboob-1.1/modules/ina/000077500000000000000000000000001265717027300150615ustar00rootroot00000000000000weboob-1.1/modules/ina/__init__.py000066400000000000000000000000671265717027300171750ustar00rootroot00000000000000from .module import InaModule __all__ = ['InaModule'] weboob-1.1/modules/ina/browser.py000066400000000000000000000043531265717027300171230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import SearchPage, MediaPage, RssPage __all__ = ['InaBrowser'] class InaBrowser(PagesBrowser): BASEURL = 'http://www.ina.fr/' search_page = URL('layout/set/ajax/recherche/result\?q=(?P.*)&autopromote=&b=(?P.*)&type=(?P(Audio|Video))&r=', SearchPage) video_page = URL('/video/(?P.*)', MediaPage) audio_page = URL('/audio/(?P.*)', MediaPage) rss_page = URL('https://player.ina.fr/notices/(?P<_id>.*).mrss', RssPage) @video_page.id2url def get_video(self, url, video=None): if not video: self.location(url) assert self.video_page.is_here() video = self.page.get_video(obj=video) video.url = self.get_media_url(video.id) return video def get_media_url(self, _id): return self.rss_page.go(_id=_id).get_media_url() def search_videos(self, pattern): return self.search_page.go(pattern=pattern.encode('utf-8'), type='Video', first_item='0').iter_videos() def get_audio(self, id, audio=None): if not audio: audio = self.audio_page.go(id=id).get_audio(obj=audio) audio.url = self.get_media_url(id) return audio def search_audio(self, pattern): return self.search_page.go(pattern=pattern.encode('utf-8'), type='Audio', first_item='0').iter_audios() weboob-1.1/modules/ina/favicon.png000066400000000000000000000024211265717027300172130ustar00rootroot00000000000000PNG  IHDR@@iqsRGB pHYs  tIME :8XIDATx]lU}ʺnc1APSQM4zc o71ީc$LJA#&76}X:溭]۵^t-`ўssoyW;r$\   @9J:ro|M3;7`214h E%G6+88C4b:dwg?tր= P^ж<6ZNABy"7_JTd;32_&Z\yPS|(Dfo\WAKcuf*ZdD$bt,ĉӓ<=-ydZ%QƄFoլdZ0^AGP4W{&Xc7MܽKʳM4֯x8{2Qi`ew\/ѱ0387Z 0DlD6kUȲPhN[ ŤةL$X_Zp;㭢XI8MNUG%~vclz o\jdvJ2_A͞}"sլ-AMD`"GK!/,wQXa!Z/.4bhX[A"a"C$ y_Bʄ͢QF+ƥXw:xdﺇO{'.^geK:Y,Kg>8|kvܥGFB|()@@@@@G(r>IENDB`weboob-1.1/modules/ina/module.py000066400000000000000000000047071265717027300167300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.audio import CapAudio, BaseAudio, decode_id from weboob.tools.backend import Module from .browser import InaBrowser __all__ = ['InaModule'] class InaModule(Module, CapVideo, CapAudio): NAME = 'ina' MAINTAINER = u'Christophe Benz' EMAIL = 'christophe.benz@gmail.com' VERSION = '1.1' DESCRIPTION = 'INA French TV video archives' LICENSE = 'AGPLv3+' BROWSER = InaBrowser def get_video(self, _id): return self.browser.get_video(_id) def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): return self.browser.search_videos(pattern) def fill_media(self, media, fields): if fields != ['thumbnail'] and fields != ['url']: # if we don't want only the thumbnail, we probably want also every fields if isinstance(media, BaseVideo): media = self.browser.get_video(media.id, media) else: _id = BaseAudio.decode_id(media.id) media = self.browser.get_audio(_id, media) if 'url' in fields and not media.url: _id = BaseAudio.decode_id(media.id) if isinstance(media, BaseAudio) else media.id media.url = self.browser.get_media_url(_id) if 'thumbnail' in fields and media.thumbnail: media.thumbnail.data = self.browser.open(media.thumbnail.url).content return media def search_audio(self, pattern, sortby=CapAudio.SEARCH_RELEVANCE): return self.browser.search_audio(pattern) @decode_id(BaseAudio.decode_id) def get_audio(self, _id): return self.browser.get_audio(_id) OBJECTS = {BaseVideo: fill_media, BaseAudio: fill_media} weboob-1.1/modules/ina/pages.py000066400000000000000000000117001265717027300165310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from io import StringIO import lxml.html as html from weboob.browser.pages import JsonPage, HTMLPage, XMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import CleanText, Regexp, Duration, Date, BrowserURL, Env from weboob.capabilities.audio import BaseAudio from weboob.capabilities.video import BaseVideo from weboob.capabilities.image import BaseImage from weboob.tools.date import DATE_TRANSLATE_FR from weboob.tools.capabilities.audio.audio import BaseAudioIdFilter class InaDuration(Duration): _regexp = re.compile(r'(?P\d+)h (?P\d+)m (?P\d+)s') class InaDuration2(Duration): _regexp = re.compile(r'(?P\d+)min (?P\d+)s') kwargs = {'minutes': 'mm', 'seconds': 'ss'} class InaJsonHTMLPage(JsonPage): ENCODING = None has_next = None scroll_cursor = None def __init__(self, browser, response, *args, **kwargs): super(InaJsonHTMLPage, self).__init__(browser, response, *args, **kwargs) self.encoding = self.ENCODING or response.encoding parser = html.HTMLParser(encoding=self.encoding) self.doc = html.parse(StringIO(self.doc['content']), parser) class InaListElement(ListElement): item_xpath = '//div[@class="media"]' def next_page(self): first_item = Regexp(CleanText('//li[@class="suiv"]/a/@data-searchparams', default=None), 'b=(.*)&q=.*', default=None) if first_item(self): return BrowserURL('search_page', pattern=Env('pattern'), type=Env('type'), first_item=first_item)(self) class InaItemElement(ItemElement): obj_title = CleanText('./div[@class="media-body"]/h3/a') obj_description = CleanText('./div[@class="media-body"]/div/p[@class="media-body__summary"]') obj_duration = InaDuration(CleanText('./div[@class="media-body"]/div/span[@class="duration"]')) obj_author = u'Institut National de l’Audiovisuel' obj_date = Date(CleanText('./div[@class="media-body"]/div/span[@class="broadcast"]')) def obj_thumbnail(self): url = CleanText('./a/img/@src')(self) thumbnail = BaseImage(url) thumbnail.url = thumbnail.id return thumbnail class InaMediaElement(ItemElement): obj_title = CleanText('//meta[@property="og:title"]/@content') obj_description = CleanText('//div[@class="notice__description"]') obj_duration = InaDuration2(CleanText('(//div[@class="block-infos"])[1]/span[@class="duration"]')) obj_date = Date(CleanText('(//div[@class="block-infos"])[1]/span[@class="broadcast"]'), translations=DATE_TRANSLATE_FR) obj_author = u'Institut National de l’Audiovisuel' def obj_thumbnail(self): url = CleanText('//meta[@property="og:image"]/@content')(self) thumbnail = BaseImage(url) thumbnail.url = thumbnail.id return thumbnail class SearchPage(InaJsonHTMLPage): @pagination @method class iter_audios(InaListElement): class item(InaItemElement): klass = BaseAudio def condition(self): return Regexp(CleanText('./a/@href'), '/audio/(.*)/.*.html', default=None)(self) obj_id = BaseAudioIdFilter(Regexp(CleanText('./a/@href'), '/audio/(.*)/.*.html')) @pagination @method class iter_videos(InaListElement): class item(InaItemElement): klass = BaseVideo def condition(self): return Regexp(CleanText('./a/@href'), '/video/(.*)/.*.html', default=None)(self) obj_id = Regexp(CleanText('./a/@href'), '/video/(.*)/.*.html') class MediaPage(HTMLPage): @method class get_video(InaMediaElement): klass = BaseVideo obj_ext = u'mp4' obj_id = Env('id') @method class get_audio(InaMediaElement): klass = BaseAudio obj_ext = u'mp3' obj_id = BaseAudioIdFilter(Env('id')) class RssPage(XMLPage): def get_media_url(self): url = self.doc.xpath('//media:content', namespaces={'media': 'http://search.yahoo.com/mrss/'}) return CleanText('./@url')(url[0]) weboob-1.1/modules/ina/test.py000066400000000000000000000027261265717027300164210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import itertools from weboob.tools.test import BackendTest class INATest(BackendTest): MODULE = 'ina' def test_video_ina(self): l = list(itertools.islice(self.backend.search_videos('chirac'), 0, 20)) self.assertTrue(len(l) > 0) v_id = l[0].id v = self.backend.get_video(v_id) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) def test_audio_ina(self): l = list(itertools.islice(self.backend.search_audio('chirac'), 0, 20)) self.assertTrue(len(l) > 0) a_id = l[0].id a = self.backend.get_audio(a_id) self.assertTrue(a.url and a.url.startswith('http://'), 'URL for video "%s" not found: %s' % (a.id, a.url)) weboob-1.1/modules/indeed/000077500000000000000000000000001265717027300155425ustar00rootroot00000000000000weboob-1.1/modules/indeed/__init__.py000066400000000000000000000014321265717027300176530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .module import IndeedModule __all__ = ['IndeedModule'] weboob-1.1/modules/indeed/browser.py000066400000000000000000000034531265717027300176040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser import PagesBrowser, URL from .pages import SearchPage, AdvertPage __all__ = ['IndeedBrowser'] class IndeedBrowser(PagesBrowser): BASEURL = 'http://www.indeed.fr' search_page = URL('/emplois(?P.*)', SearchPage) advert_page = URL('/cmp/(?P.*)/jobs/(?P.*)-(?P<nb>.*)', AdvertPage) def search_job(self, metier='', contrat='', limit_date='', radius='', place=''): params = '?as_ttl=%s&limit=10&sort=date&st=employer&sr=directhire&jt=%s&fromage=%s&radius=%s'\ % (metier.replace(' ', '+'), contrat, limit_date, radius) if place: params = '%s&l=%s' % (params, place) self.search_page.go(parameters=params) assert self.search_page.is_here(parameters=params) return self.page.iter_job_adverts() def get_job_advert(self, _id, advert): splitted_id = _id.split('#') return self.advert_page.go(nb=splitted_id[0], title=splitted_id[1], company=splitted_id[2]).get_job_advert(obj=advert) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/indeed/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000007204�12657170273�0017700�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs����+���tIME  5Qi��IDATx[k\U9gfz/B(-jx(  4%H B0 FUc|$5H(E V0V(ҒҴxP^ޙ9>{"ā9ko< �Dn>R|('Rރ B$ Vא6՟}vQE=r,e n�DU]^,ˈ).?t7֣,9k~w/ݬzlnJjѦ[ɦnҹiji_Up;}:1Hfũ#(1۔UEB}T]<&~#i_}2ijĕE4Cm5mlsZ�+1j�qջd9T@8UW'HW"t,7M#Xx96OL4z]`E c,9&ƙ'uE@5PKR+Ő l-|`"f kXfn@M% .=$M6RJUVUNn5})͊�?co"\`~+!4xf1/$zM#hNc%d"k?/;s;m/qSb!1>S{0Ĕ6:@"A KaXWL`R:0?0$dfO@!oF$X ?#8eqK"s n\6ŇFo4{%yfO4I9"% D'W9]I=|xQP;"zsWFib}<k(ڲdReЭ՛ON p?{gŁӻf{g8ȸe&G8.�ḬT+\CTy,Ề|i) F[�%hJ9PRNq`i} O`5QzCP6o22#Ш8 e],hrrJfhDQT,5ScQ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EX&ioiM[%<\+=8cHZ <cj:,fmp@slgVaqH&~DED 7�z#k[t&@9L8lKMeh3^Pbv4N^qaQj+^jETJ-54 H#D,e)OR8K}-΀n$%V]~ 6՝:SYb JP [)-~@����IENDB`��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/indeed/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000006751�12657170273�0017412�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.tools.ordereddict import OrderedDict from weboob.capabilities.job import CapJob, BaseJobAdvert from weboob.tools.value import Value from .browser import IndeedBrowser __all__ = ['IndeedModule'] class IndeedModule(Module, CapJob): NAME = 'indeed' DESCRIPTION = u'indeed website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = IndeedBrowser type_contrat_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ 'all': u'Tous les emplois', 'fulltime': u'Temps plein', 'parttime': u'Temps partiel', 'contract': u'Durée indéterminée', 'internship': u'Stage / Apprentissage', 'temporary': u'Durée déterminée', }.iteritems())]) limit_date_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ 'any': u'à tout moment', '15': u'depuis 15 jours', '7': u'depuis 7 jours', '3': u'depuis 3 jours', '1': u'depuis hier', 'last': u'depuis ma dernière visite', }.iteritems())]) radius_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '0': u'uniquement à cet endroit', '5': u'dans un rayon de 5 kilomètres', '10': u'dans un rayon de 10 kilomètres', '15': u'dans un rayon de 15 kilomètres', '25': u'dans un rayon de 25 kilomètres', '50': u'dans un rayon de 50 kilomètres', '100': u'dans un rayon de 100 kilomètres', }.iteritems())]) CONFIG = BackendConfig(Value('metier', label=u'Job name', masked=False, default=''), Value('limit_date', label=u'Date limite', choices=limit_date_choices, default=''), Value('contrat', label=u'Contract', choices=type_contrat_choices, default=''), Value('place', label=u'Place', masked=False, default=''), Value('radius', label=u'Radius', choices=radius_choices, default='')) def search_job(self, pattern=None): return self.browser.search_job(metier=pattern) def advanced_search_job(self): return self.browser.search_job(metier=self.config['metier'].get(), limit_date=self.config['limit_date'].get(), contrat=self.config['contrat'].get(), place=self.config['place'].get(), radius=self.config['radius'].get()) def get_job_advert(self, _id, advert=None): return self.browser.get_job_advert(_id, advert) def fill_obj(self, advert, fields): return self.get_job_advert(advert.id, advert) OBJECTS = {BaseJobAdvert: fill_obj} �����������������������weboob-1.1/modules/indeed/pages.py������������������������������������������������������������������0000664�0000000�0000000�00000006633�12657170273�0017223�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import timedelta, datetime import re from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import Filter, CleanText, Regexp, Format, Env from weboob.browser.filters.html import CleanHTML, Attr from weboob.capabilities.job import BaseJobAdvert class IndeedDate(Filter): def filter(self, date): now = datetime.now() number = re.search("\d+", date) if number: if 'heures' in date: return now - timedelta(hours=int(number.group(0))) elif 'jour' in date: return now - timedelta(days=int(number.group(0))) return now class SearchPage(HTMLPage): @pagination @method class iter_job_adverts(ListElement): item_xpath = '//div[@itemtype="http://schema.org/JobPosting"]' def next_page(self): for a in self.page.doc.xpath('//a'): if a.xpath('span[@class="pn"]/span[@class="np"]') and "Suivant" in a.xpath('span[@class="pn"]/span[@class="np"]')[0].text: return a.attrib['href'] class Item(ItemElement): klass = BaseJobAdvert obj_id = CleanText(Format('%s#%s#%s', Regexp(Attr('.', 'id'), '^..(.*)'), Attr('h2/a', 'title'), CleanText('span[@class="company"]')), replace=[(" ", "-"), ("/", "-")]) obj_title = Attr('h2/a', 'title') obj_society_name = CleanText('span[@class="company"]') obj_place = CleanText('span/span[@class="location"]') obj_publication_date = IndeedDate(CleanText('table/tr/td/span[@class="date"]')) class AdvertPage(HTMLPage): @method class get_job_advert(ItemElement): klass = BaseJobAdvert def parse(self, el): self.env['url'] = self.page.url self.env['num_id'] = self.page.url.split('-')[-1] obj_id = Format('%s#%s#%s', Env('num_id'), CleanText('//div[@id="job_header"]/b[@class="jobtitle"]'), CleanText('//div[@id="job_header"]/span[@class="company"]'), ) obj_title = CleanText('//div[@id="job_header"]/b[@class="jobtitle"]') obj_place = CleanText('//div[@id="job_header"]/span[@class="location"]') obj_description = CleanHTML('//span[@class="summary"]') obj_job_name = CleanText('//div[@id="job_header"]/b[@class="jobtitle"]') obj_url = Env('url') obj_publication_date = IndeedDate(CleanText('//span[@class="date"]')) �����������������������������������������������������������������������������������������������������weboob-1.1/modules/indeed/test.py�������������������������������������������������������������������0000664�0000000�0000000�00000003177�12657170273�0017103�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class IndeedTest(BackendTest): MODULE = 'indeed' def test_indeed_search(self): l = list(self.backend.search_job('informaticien')) assert len(l) advert = self.backend.get_job_advert(l[0].id, l[0]) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) def test_indeed_advanced_search(self): l = list(self.backend.advanced_search_job()) assert len(l) advert = self.backend.get_job_advert(l[0].id, l[0]) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) def test_indeep_info_from_id(self): l = list(self.backend.advanced_search_job()) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015067�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000001451�12657170273�0017201�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import INGModule __all__ = ['INGModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000026524�12657170273�0017135�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2009-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re import hashlib import time from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword, ParseError from weboob.capabilities.bank import Account, TransferError, AccountNotFound from weboob.capabilities.base import find_object from .pages import AccountsList, LoginPage, NetissimaPage, TitrePage, TitreHistory,\ TransferPage, TransferConfirmPage, BillsPage, StopPage, TitreDetails, TitreValuePage __all__ = ['IngBrowser'] def check_bourse(f): def wrapper(*args): browser = args[0] if browser.where == u"titre": browser.location("https://bourse.ingdirect.fr/priv/redirectIng.php?pageIng=COMPTE") browser.where = u"start" return f(*args) return wrapper class IngBrowser(LoginBrowser): BASEURL = 'https://secure.ingdirect.fr' # Login and error loginpage = URL('/public/displayLogin.jsf.*', LoginPage) errorpage = URL('.*displayCoordonneesCommand.*', StopPage) # CapBank accountspage = URL('/protected/pages/index.jsf', AccountsList) transferpage = URL('/protected/pages/cc/transfer/transferManagement.jsf', TransferPage) dotransferpage = URL('/general\?command=DisplayDoTransferCommand', TransferPage) valtransferpage = URL('/protected/pages/cc/transfer/create/transferCreateValidation.jsf', TransferConfirmPage) titredetails = URL('/general\?command=display.*', TitreDetails) # CapBank-Market netissima = URL('/data/asv/fiches-fonds/fonds-netissima.html', NetissimaPage) starttitre = URL('/general\?command=goToAccount&zone=COMPTE', TitrePage) titrepage = URL('https://bourse.ingdirect.fr/priv/portefeuille-TR.php', TitrePage) titrehistory = URL('https://bourse.ingdirect.fr/priv/compte.php\?ong=3', TitreHistory) titrerealtime = URL('https://bourse.ingdirect.fr/streaming/compteTempsReelCK.php', TitrePage) titrevalue = URL('https://bourse.ingdirect.fr/priv/fiche-valeur.php\?val=(?P<val>.*)&pl=(?P<pl>.*)&popup=1', TitreValuePage) # CapBill billpage = URL('/protected/pages/common/estatement/eStatement.jsf', BillsPage) __states__ = ['where'] def __init__(self, *args, **kwargs): self.birthday = re.sub(r'[^\d]', '', kwargs.pop('birthday')) self.where = None LoginBrowser.__init__(self, *args, **kwargs) def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert isinstance(self.birthday, basestring) assert self.password.isdigit() assert self.birthday.isdigit() self.do_logout() self.loginpage.go() self.page.prelogin(self.username, self.birthday) self.page.login(self.password) if self.page.error(): raise BrowserIncorrectPassword() if self.errorpage.is_here(): raise BrowserIncorrectPassword('Please login on website to fill the form and retry') @need_login @check_bourse def get_accounts_list(self): self.accountspage.go() self.where = "start" return self.page.get_list() def get_account(self, _id): return find_object(self.get_accounts_list(), id=_id, error=AccountNotFound) @need_login @check_bourse def get_coming(self, account): if account.type != Account.TYPE_CHECKING and\ account.type != Account.TYPE_SAVINGS: raise NotImplementedError() if self.where != "start": account = self.get_account(account.id) data = {"AJAX:EVENTS_COUNT": 1, "AJAXREQUEST": "_viewRoot", "ajaxSingle": "index:setAccount", "autoScroll": "", "index": "index", "index:setAccount": "index:setAccount", "javax.faces.ViewState": account._jid, "cptnbr": account._id } self.accountspage.go(data=data) self.where = "history" jid = self.page.get_history_jid() if jid is None: self.logger.info('There is no history for this account') return return self.page.get_coming() @need_login @check_bourse def get_history(self, account): if account.type == Account.TYPE_MARKET: for result in self.get_history_titre(account): yield result return elif account.type != Account.TYPE_CHECKING and\ account.type != Account.TYPE_SAVINGS: raise NotImplementedError() if self.where != "start": account = self.get_account(account.id) data = {"AJAX:EVENTS_COUNT": 1, "AJAXREQUEST": "_viewRoot", "ajaxSingle": "index:setAccount", "autoScroll": "", "index": "index", "index:setAccount": "index:setAccount", "javax.faces.ViewState": account._jid, "cptnbr": account._id } self.accountspage.go(data=data) self.where = "history" jid = self.page.get_history_jid() if jid is None: self.logger.info('There is no history for this account') return if account.type == Account.TYPE_CHECKING: history_function = AccountsList.get_transactions_cc index = -1 # disable the index. It works without it on CC else: history_function = AccountsList.get_transactions_others index = 0 hashlist = [] while True: i = index for transaction in history_function(self.page, index=index): transaction.id = hashlib.md5(transaction._hash).hexdigest() while transaction.id in hashlist: transaction.id = hashlib.md5(transaction.id + "1").hexdigest() hashlist.append(transaction.id) i += 1 yield transaction # if there is no more transactions, it is useless to continue if self.page.islast() or i == index: return if index >= 0: index = i data = {"AJAX:EVENTS_COUNT": 1, "AJAXREQUEST": "_viewRoot", "autoScroll": "", "index": "index", "index:%s:moreTransactions" % jid: "index:%s:moreTransactions" % jid, "javax.faces.ViewState": account._jid } self.accountspage.go(data=data) @need_login @check_bourse def get_recipients(self, account): self.transferpage.stay_or_go() if self.page.ischecked(account.id): return self.page.get_recipients() else: # It is hard to check the box and to get the real list. # We try an alternative way like normal users self.get_history(account).next() self.transferpage.stay_or_go() return self.page.get_recipients() @check_bourse def transfer(self, account, recipient, amount, reason): found = False # Automatically get the good transfer page self.logger.debug('Search %s' % recipient) for destination in self.get_recipients(account): self.logger.debug('Found %s ' % destination.id) if destination.id == recipient: found = True recipient = destination break if found: self.transferpage.open(data=self.page.buildonclick(recipient, account)) self.page.transfer(recipient, amount, reason) self.valtransferpage.go() if not self.valtransferpage.is_here(): raise TransferError("Invalid transfer (no confirmation page)") else: self.page.confirm(self.password) self.valtransferpage.go() recap = self.page.recap() if len(list(recap)) == 0: raise ParseError('Unable to find confirmation') return self.page.recap() else: raise TransferError('Recipient not found') def go_investments(self, account): account = self.get_account(account.id) data = {"AJAX:EVENTS_COUNT": 1, "AJAXREQUEST": "_viewRoot", "ajaxSingle": "index:setAccount", "autoScroll": "", "index": "index", "index:setAccount": "index:setAccount", "javax.faces.ViewState": account._jid, "cptnbr": account._id } # On ASV pages, data maybe not available. for i in range(5): if i > 0: self.logger.debug('Investments list empty, retrying in %s seconds...', (2**i)) time.sleep(2**i) if i > 1: self.do_logout() self.do_login() account = self.get_account(account.id) data['cptnbr'] = account._id data['javax.faces.ViewState'] = account._jid self.accountspage.go(data=data) if not self.page.has_error(): break else: self.logger.warning("Unable to get investments list...") if self.page.is_asv: return self.starttitre.go() self.where = u"titre" self.titrepage.go() @need_login @check_bourse def get_investments(self, account): if account.type not in (Account.TYPE_MARKET, Account.TYPE_LIFE_INSURANCE): raise NotImplementedError() self.go_investments(account) if self.where == u'titre': self.titrerealtime.go() return self.page.iter_investments() def get_history_titre(self, account): self.go_investments(account) if self.where == u'titre': self.titrehistory.go() return self.page.iter_history() else: # No history for ASV accounts. raise NotImplementedError() ############# CapBill ############# @need_login @check_bourse def get_subscriptions(self): return self.billpage.go().iter_account() @need_login def get_bills(self, subscription): self.billpage.go() data = {"AJAXREQUEST": "_viewRoot", "accountsel_form": "accountsel_form", subscription._formid: subscription._formid, "autoScroll": "", "javax.faces.ViewState": subscription._javax, "transfer_issuer_radio": subscription.id } self.billpage.go(data=data) return self.page.iter_bills(subid=subscription.id) def predownload(self, bill): self.page.postpredown(bill._localid) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/favicon.png������������������������������������������������������������������0000664�0000000�0000000�00000005527�12657170273�0017233�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD��f��}a��� pHYs�� �� ����tIME 8% ���tEXtComment�Created with GIMPW�� IDATxytT?o&l$1bdU  GB]V=j9s X<.X[j[VJ](VRbH"ǝy! s-y.{|L:$:8&ً_ gN Ĥ8׳3@R)} N2xjK> U P%惜dtnOlpS13@M2޲J {6䎁Ϡc3&98x`êΟ^�zS-H�yœ烒 >s0gF@|m/`ꎙ<pWOӧ!s  )ϼvR�gL�_b0|D <*YTp]8A[ '?,#^3س5q.sUQ{VΆegú3U"_r/ ! CV>>Yrab*.=>eRoVd:&*} ݠ7NBbי=r\WItkY| 5^Ua|J/ Uc N>˩;q@u/Eq fQj|$�u%y0Z[JYyG/�}cљ=d"Ѡ> H :gڤ@Bjyݸq'цŹcqS=TpiG`8,=fjXƭMUףHk`h[ 4Ն%-޲&̕qXka8W8Nmo UѡtZzoX?7֊wJ51 mg}fFx-!8=ֿr O6:5.p :E_s V82�XlS*APzHT;્gV;% 7vUZ<SbsW 3hX'xx ;.2BNȑݤI<U'�SC̀ƚ cS i|F(p$ V0,ȉ=1%B0 ;? h,YX 3ni=]&;3 H6`laa{4TǠ�f.I@Z?=6hi�Cfu$鍗71D_=AdH#YTIKjmhB[*3(`(T{}%Cr|fݥc ljUfR�bLn+w9CeM-xjAקX+YD18<ѱF09 a3A햟ye[(eޏ'\ַ@_|6n0*\.�ڗA3PfI@<\%m  %Q3>P=0q7iTvUQ} d|4Lןc5dvȴN0('wetU8mSr\ k'Kj u2+pÓ*ax]`x$x9 pXYÀpo߲)\`5+b wkZ0SqOfbWGUN`K]aHGz ,䘦C�tXjq_6,{?#{,:K'KĢ N?'+ Ϛ.ҝC5'5._.TehHrns 6[b77IE?Lz z<{tsy<+6#5PsP Dr{=1>AZ \W`֢?RId^[kJI޳6 fEt_JH6+եpKp8B5DY;+do?Òj64|'BNˆRԝa!#U~gFNwwYylXשk 7"X ^S=l}^VT͓V[;VTVXil1fP./&5K{bBn=Ҭ&�a*IS}PAnĤ,NFMg%WBdZ8[beVERsڛ1BLÀdhWZ+r eooxBB4!gz":$=u2X6P/,G/U(1 8ݪ3qGVz[[j ́{KԪxv@ Jl;٤YR +wbk.ǁ�}:4*Mubt|7BmJ_8L og]ӔY,=νNFW)1!]>zsZ٧%ǫ7E 6O / xWw&~.]Soiw:\n-`=PeZ8:Y=IǷzW8_O`TWܭ ;GvoW'Ʋ[(h՜Jp*�0\/7}0By>ghrEKc>'WܯLS=lg˟=d2tom|V #n-23I8RyH4q{?/sꓗ t۝)o_e5ar/ 7bpI P ����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000011510�12657170273�0016724�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import CapBank, Account, Recipient from weboob.capabilities.bill import CapBill, Bill, Subscription,\ SubscriptionNotFound, BillNotFound from weboob.capabilities.base import UserError, find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import IngBrowser __all__ = ['INGModule'] class INGModule(Module, CapBank, CapBill): NAME = 'ing' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'ING Direct' CONFIG = BackendConfig(ValueBackendPassword('login', label=u'Numéro client', masked=False), ValueBackendPassword('password', label='Code secret', regexp='^(\d{6}|)$'), ValueBackendPassword('birthday', label='Date de naissance', regexp='^(\d{2}[/-]?\d{2}[/-]?\d{4}|)$', masked=False) ) BROWSER = IngBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get(), birthday=self.config['birthday'].get()) def iter_resources(self, objs, split_path): if Account in objs: self._restrict_level(split_path) return self.iter_accounts() if Subscription in objs: self._restrict_level(split_path) return self.iter_subscription() def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return self.browser.get_account(_id) def iter_history(self, account): if not isinstance(account, Account): account = self.get_account(account) return self.browser.get_history(account) def iter_transfer_recipients(self, account): if not isinstance(account, Account): account = self.get_account(account) return self.browser.get_recipients(account) def transfer(self, account, recipient, amount, reason): if not reason: raise UserError('Reason is mandatory to do a transfer on ING website') if not isinstance(account, Account): account = self.get_account(account) if not isinstance(recipient, Recipient): # Remove weboob identifier prefix (LA-, CC-...) if "-" in recipient: recipient = recipient.split('-')[1] return self.browser.transfer(account, recipient, amount, reason) def iter_investment(self, account): if not isinstance(account, Account): account = self.get_account(account) return self.browser.get_investments(account) def iter_coming(self, account): if not isinstance(account, Account): account = self.get_account(account) return self.browser.get_coming(account) def iter_subscription(self): return self.browser.get_subscriptions() def get_subscription(self, _id): return find_object(self.browser.get_subscriptions(), id=_id, error=SubscriptionNotFound) def get_bill(self, _id): subscription = self.get_subscription(_id.split('-')[0]) return find_object(self.browser.get_bills(subscription), id=_id, error=BillNotFound) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.get_bills(subscription) def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) self.browser.predownload(bill) assert(self.browser.response.headers['content-type'] == "application/pdf") return self.browser.response.content ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/pages/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016166�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/pages/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000002420�12657170273�0020275�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2009-2011 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .accounts_list import AccountsList, TitreDetails from .login import LoginPage, StopPage from .transfer import TransferPage, TransferConfirmPage from .bills import BillsPage from .titre import NetissimaPage, TitrePage, TitreHistory, TitreValuePage class AccountPrelevement(AccountsList): pass __all__ = ['AccountsList', 'LoginPage', 'NetissimaPage','TitreDetails', 'AccountPrelevement', 'TransferPage', 'TransferConfirmPage', 'BillsPage', 'StopPage', 'TitrePage', 'TitreHistory', 'TitreValuePage'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/pages/accounts_list.py�������������������������������������������������������0000664�0000000�0000000�00000023117�12657170273�0021416�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2009-2014 Florent Fourcot, Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import date, timedelta import datetime from decimal import Decimal import re from weboob.capabilities.bank import Account, Investment from weboob.capabilities.base import NotAvailable from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, CleanDecimal, Filter, Field, MultiFilter, \ Date, Lower, Regexp, Async, AsyncLoad from weboob.browser.filters.html import Attr from weboob.tools.capabilities.bank.transactions import FrenchTransaction class Transaction(FrenchTransaction): PATTERNS = [(re.compile(u'^retrait dab (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{4}) (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(u'^carte (?P<dd>\d{2})/(?P<mm>\d{2})/(?P<yy>\d{4}) (?P<text>.*)'), FrenchTransaction.TYPE_CARD), (re.compile(u'^virement (sepa )?(emis vers|recu|emis)? (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(u'^cheque (?P<text>.*)'), FrenchTransaction.TYPE_CHECK), (re.compile(u'^prelevement (?P<text>.*)'), FrenchTransaction.TYPE_ORDER), (re.compile(u'^prlv sepa (?P<text>.*)'), FrenchTransaction.TYPE_ORDER), (re.compile(u'^prélèvement sepa en faveur de (?P<text>.*)'), FrenchTransaction.TYPE_ORDER), ] class AddPref(MultiFilter): prefixes = {u'Courant': u'CC-', u'Livret A': 'LA-', u'Orange': 'LEO-', u'Durable': u'LDD-', u"Titres": 'TITRE-', u'PEA': u'PEA-'} def filter(self, values): el, label = values for key, pref in self.prefixes.items(): if key in label: return pref + el return el class AddType(Filter): types = {u'Courant': Account.TYPE_CHECKING, u'Livret A': Account.TYPE_SAVINGS, u'Orange': Account.TYPE_SAVINGS, u'Durable': Account.TYPE_SAVINGS, u'Titres': Account.TYPE_MARKET, u'PEA': Account.TYPE_MARKET, u'Direct Vie': Account.TYPE_LIFE_INSURANCE, u'Assurance Vie': Account.TYPE_LIFE_INSURANCE } def filter(self, label): for key, acc_type in self.types.items(): if key in label: return acc_type return Account.TYPE_UNKNOWN class PreHashmd5(MultiFilter): def filter(self, values): concat = '' for value in values: if type(value) is datetime.date: concat += value.strftime('%d/%m/%Y') else: concat += u'%s' % value return concat.encode('utf-8') class INGDate(Date): monthvalue = {u'janv.': '01', u'févr.': '02', u'mars': '03', u'avr.': '04', u'mai': '05', u'juin': '06', u'juil.': '07', u'août': '08', u'sept.': '09', u'oct.': '10', u'nov.': '11', u'déc.': '12'} def filter(self, txt): if txt == 'hier': return (date.today() - timedelta(days=1)) elif txt == "aujourd'hui": return date.today() elif txt == 'demain': return (date.today() + timedelta(days=1)) else: frenchmonth = txt.split(' ')[1] month = self.monthvalue[frenchmonth] txt = txt.replace(' ', '') txt = txt.replace(frenchmonth, '/%s/' % month) return super(INGDate, self).filter(txt) class INGCategory(Filter): catvalue = {u'virt': u"Virement", u'autre': u"Autre", u'plvt': u'Prélèvement', u'cb_ret': u"Carte retrait", u'cb_ach': u'Carte achat', u'chq': u'Chèque', u'frais': u'Frais bancaire', u'sepaplvt': u'Prélèvement'} def filter(self, txt): txt = txt.split('-')[0].lower() try: return self.catvalue[txt] except: return txt class AccountsList(LoggedPage, HTMLPage): i = 0 def has_error(self): return len(self.doc.xpath('//div[has-class("alert-warning")]')) > 0 @method class get_list(ListElement): item_xpath = '//a[@class="mainclic"]' class item(ItemElement): klass = Account obj_currency = u'EUR' obj__id = CleanText('span[@class="account-number"]') obj_label = CleanText('span[@class="title"]') obj_id = AddPref(Field('_id'), Field('label')) obj_type = AddType(Field('label')) obj_balance = CleanDecimal('span[@class="solde"]/label', replace_dots=True) obj_coming = NotAvailable obj__jid = Attr('//input[@name="javax.faces.ViewState"]', 'value') class generic_transactions(ListElement): class item(ItemElement): klass = Transaction obj_id = None # will be overwrited by the browser # we use lower for compatibility with the old website obj_raw = Transaction.Raw(Lower('.//td[@class="lbl"]')) obj_amount = CleanDecimal('.//td[starts-with(@class, "amount")]', replace_dots=True) obj_date = INGDate(CleanText('.//td[@class="date"]'), dayfirst=True) obj_rdate = Field('date') obj__hash = PreHashmd5(Field('date'), Field('raw'), Field('amount')) obj_category = INGCategory(Attr('.//td[@class="picto"]/span', 'class')) def condition(self): if self.el.find('.//td[@class="date"]') is None: return False if 'index' in self.env and self.env['index'] > 0 and self.page.i < self.env['index']: self.page.i += 1 return False return True @method class get_coming(generic_transactions): item_xpath = '//div[@class="transactions cc future"]//table' @method class get_transactions_cc(generic_transactions): item_xpath = '//div[@class="temporaryTransactionList"]//table' @method class get_transactions_others(generic_transactions): item_xpath = '//table' def get_history_jid(self): span = Attr('//*[starts-with(@id, "index:j_id")]', 'id')(self.doc) jid = span.split(':')[1] return jid def islast(self): havemore = self.doc.getroot().cssselect('.show-more-transactions') if len(havemore) == 0: return True nomore = self.doc.getroot().cssselect('.no-more-transactions') return (len(nomore) > 0) @property def is_asv(self): span = self.doc.xpath('//span[@id="index:panelASV"]') return len(span) > 0 @method class iter_investments(ListElement): item_xpath = '//div[has-class("asv_fond")]' class item(ItemElement): klass = Investment # ASV.popup('/general?command=displayAVEuroEpargne') load_details = Attr('.//div[has-class("asv_fond_view")]//a', 'onclick') & Regexp(pattern="'(.*)'") & AsyncLoad obj_label = CleanText('.//span[has-class("asv_cat_lbl")]') obj_code = Async('details') & CleanText('//li[contains(text(), "Code ISIN")]/span[1]') obj_id = obj_code obj_description = Async('details') & CleanText('//h5') obj_quantity = CleanDecimal('.//dl[contains(dt/text(), "Nombre de parts")]/dd', replace_dots=True) obj_unitvalue = CleanDecimal('.//dl[contains(dt/text(), "Valeur de part")]/dd', replace_dots=True) # There are two kind of lists: # - Header contains percent and valuation is in a specific row ("ligne-montant") # - Header contains valuation, there is no "ligne-montant" row, and percent is in a specific row obj_valuation = CleanDecimal('.//dl[has-class("ligne-montant")]/dd | .//dd[@data-show="header" and not(contains(text(), "%"))]', replace_dots=True) def obj_unitprice(self): if 'eurossima' in self.el.get('class') or \ 'fondsEuro' in self.el.get('class'): # in this case, the content of field is: # <span data-sort="pm_value" class="pmvalue positive">NOT_A_NUMBER</span> return self.obj.unitvalue if self.el.xpath('.//span[has-class("pmvalue")]')[0].text == u'+∞ %': percent = NotAvailable return NotAvailable else: percent = CleanDecimal('.//span[has-class("pmvalue")]', replace_dots=True)(self) return (self.obj.unitvalue / (1 + percent/Decimal('100.0'))).quantize(Decimal('1.00')) def obj_diff(self): if not self.obj.quantity: # Quantity of euro funds is null. return Decimal('0.00') if not self.obj.unitprice: return NotAvailable return (self.obj.valuation - (self.obj.quantity * self.obj.unitprice)).quantize(Decimal('1.00')) class TitreDetails(LoggedPage, HTMLPage): pass �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/pages/bills.py���������������������������������������������������������������0000664�0000000�0000000�00000006543�12657170273�0017655�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2009-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import Bill, Subscription from weboob.browser.pages import HTMLPage, LoggedPage, pagination from weboob.browser.filters.standard import Filter, CleanText, Format, Field, Env, Date from weboob.browser.filters.html import Attr from weboob.browser.elements import ListElement, ItemElement, method from weboob.tools.date import parse_french_date class FormId(Filter): def filter(self, txt): formid = txt.split("parameters")[1] formid = formid.split("'")[2] return formid class BillsPage(LoggedPage, HTMLPage): @method class iter_account(ListElement): item_xpath = '//ul[@class="unstyled striped"]/li' class item(ItemElement): klass = Subscription obj__javax = Attr("//form[@id='accountsel_form']/input[@name='javax.faces.ViewState']", 'value') obj_id = Attr('input', "value") obj_label = CleanText('label') obj__formid = FormId(Attr('input', 'onclick')) def postpredown(self, _id): _id = _id.split("'")[3] form = self.get_form(name="downpdf_form") form['statements_form'] = 'statements_form' form['statements_form:j_idcl'] = _id form.submit() @pagination @method class iter_bills(ListElement): item_xpath = '//ul[@id="statements_form:statementsel"]/li' def next_page(self): lis = self.page.doc.xpath('//form[@name="years_form"]//li') selected = False ref = None for li in lis: if "rich-list-item selected" in li.attrib['class']: selected = True else: if selected: ref = li.find('a').attrib['id'] break if ref is None: return form = self.page.get_form(name="years_form") form.pop('years_form:j_idcl') form.pop('years_form:_link_hidden_') form['AJAXREQUEST'] = "years_form:year_region" form[ref] = ref return form.request class item(ItemElement): klass = Bill condition = lambda self: not (u"tous les relev" in CleanText('a[1]')(self.el)) and not (u'annuel' in CleanText('a[1]')(self.el)) obj_label = CleanText('a[1]', replace=[(' ', '-')]) obj_id = Format(u"%s-%s", Env('subid'), Field('label')) # Force first day of month as label is in form "janvier 2016" obj_date = Format("1 %s", Field('label')) & Date(parse_func=parse_french_date) obj_format = u"pdf" obj__localid = Attr('a[2]', 'onclick') �������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/pages/login.py���������������������������������������������������������������0000664�0000000�0000000�00000010367�12657170273�0017657�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2009-2014 Florent Fourcot, Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from StringIO import StringIO from weboob.exceptions import BrowserIncorrectPassword from weboob.tools.captcha.virtkeyboard import VirtKeyboard from weboob.browser.pages import HTMLPage from weboob.browser.filters.html import Attr class INGVirtKeyboard(VirtKeyboard): symbols = {'0': '327208d491507341908cf6920f26b586', '1': '615ff37b15645da106cebc4605b399de', '2': 'fb04e648c93620f8b187981f9742b57e', '3': 'b786d471a70de83657d57bdedb6a2f38', '4': '41b5501219e8d8f6d3b0baef3352ce88', '5': 'c72b372fb035160f2ff8dae59cd7e174', '6': '392fa79e9a1749f5c8c0170f6a8ec68b', '7': 'fb495b5cf7f46201af0b4977899b56d4', '8': 'e8fea1e1aa86f8fca7f771db9a1dca4d', '9': '82e63914f2e52ec04c11cfc6fecf7e08' } color = 64 coords = {"11": (5, 5, 33, 33), "21": (45, 5, 73, 33), "31": (85, 5, 113, 33), "41": (125, 5, 153, 33), "51": (165, 5, 193, 33), "12": (5, 45, 33, 73), "22": (45, 45, 73, 73), "32": (85, 45, 113, 73), "42": (125, 45, 153, 73), "52": (165, 45, 193, 73) } def __init__(self, page): self.page = page img = page.doc.xpath("//div[has-class('clavier')]/img") if len(img) == 0: raise BrowserIncorrectPassword() url = Attr('.', "src")(img[1]) VirtKeyboard.__init__(self, StringIO(self.page.browser.open(url).content), self.coords, self.color) self.check_symbols(self.symbols, self.page.browser.responses_dirname) def get_string_code(self, string): code = '' first = True for c in string: if not first: code += "," else: first = False codesymbol = self.get_symbol_code(self.symbols[c]) x = (self.coords[codesymbol][0] + self.coords[codesymbol][2]) / 2 y = (self.coords[codesymbol][1] + self.coords[codesymbol][3]) / 2 code += "%d,%d" % (x, y) return code def get_coordinates(self, password): temppasswd = "" elems = self.page.doc.xpath('//div[@class="digitpad"]/span/font') for i, font in enumerate(elems): if Attr('.', 'class')(font) == "vide": temppasswd += password[i] self.page.browser.logger.debug('We are looking for : ' + temppasswd) coordinates = self.get_string_code(temppasswd) self.page.browser.logger.debug("Coordonates: " + coordinates) return coordinates class LoginPage(HTMLPage): def prelogin(self, login, birthday): # First step : login and birthday form = self.get_form(name='zone1Form') form['zone1Form:numClient'] = login form['zone1Form:dateDay'] = birthday[0:2] form['zone1Form:dateMonth'] = birthday[2:4] form['zone1Form:dateYear'] = birthday[4:9] form['zone1Form:idRememberMyCifCheck'] = False form.submit() def error(self): err = self.doc.find('//span[@class="error"]') return err is not None def login(self, password): # 2) And now, the virtual Keyboard vk = INGVirtKeyboard(self) form = self.get_form(name='mrc') form['mrc:mrg'] = 'mrc:mrg' form['AJAXREQUEST'] = '_viewRoot' form['mrc:mrldisplayLogin'] = vk.get_coordinates(password) form.submit() class StopPage(HTMLPage): pass �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/pages/titre.py���������������������������������������������������������������0000664�0000000�0000000�00000010601�12657170273�0017665�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from decimal import Decimal from weboob.capabilities.base import NotAvailable from weboob.capabilities.bank import Investment from weboob.browser.pages import RawPage, HTMLPage, LoggedPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanDecimal, CleanText, Date from weboob.tools.capabilities.bank.transactions import FrenchTransaction class NetissimaPage(HTMLPage): pass class Transaction(FrenchTransaction): pass class TitreValuePage(LoggedPage, HTMLPage): def get_isin(self): return unicode(self.doc.xpath('//div[@id="headFiche"]//span[@id="test3"]/text()')[0].split(' - ')[0].strip()) class TitrePage(LoggedPage, RawPage): def iter_investments(self): # We did not get some html, but something like that (XX is a quantity, YY a price): # message='[...] # popup=2{6{E:ALO{PAR{{reel{695{380{ALSTOM REGROUPT#XX#YY,YY €#YY,YY €#1 YYY,YY €#-YYY,YY €#-42,42%#-0,98 %#42,42 %#|1|AXA#cotationValeur.php?val=E:CS&pl=6&nc=1& # popup=2{6{E:CS{PAR{{reel{695{380{AXA#XX#YY,YY €#YY,YYY €#YYY,YY €#YY,YY €#3,70%#42,42 %#42,42 %#|1|blablablab #cotationValeur.php?val=P:CODE&pl=6&nc=1& # [...] lines = self.doc.split("popup=2") lines.pop(0) for line in lines: columns = line.split('#') _pl = columns[0].split('{')[1] _id = columns[0].split('{')[2] invest = Investment(_id) invest.label = unicode(columns[0].split('{')[-1]) invest.code = unicode(_id) if ':' in invest.code: invest.code = self.browser.titrevalue.open(val=invest.code,pl=_pl).get_isin() # The code we got is not a real ISIN code. if not re.match('^[A-Z]{2}[\d]{10}$|^[A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4}$', invest.code): m = re.search('\{([A-Z]{2}[\d]{10})\{|\{([A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4})\{', line) if m: invest.code = unicode(m.group(1) or m.group(2)) quantity = FrenchTransaction.clean_amount(columns[1]) if quantity != '': invest.quantity = Decimal(quantity) else: invest.quantity = NotAvailable unitprice = FrenchTransaction.clean_amount(columns[2]) if unitprice != '': invest.unitprice = Decimal(unitprice) else: invest.unitprice = NotAvailable unitvalue = FrenchTransaction.clean_amount(columns[3]) if unitvalue != '': invest.unitvalue = Decimal(unitvalue) else: invest.unitvalue = NotAvailable valuation = FrenchTransaction.clean_amount(columns[4]) if valuation != '': invest.valuation = Decimal(valuation) else: # valuation is not nullable. invest.valuation = Decimal('0') diff = FrenchTransaction.clean_amount(columns[5]) if diff != '': invest.diff = Decimal(diff) else: invest.diff = NotAvailable yield invest class TitreHistory(LoggedPage, HTMLPage): @method class iter_history(ListElement): item_xpath = '//table[@class="datas retour"]/tr' class item(ItemElement): klass = Transaction condition = lambda self: len(self.el.xpath('td[@class="impaire"]')) > 0 obj_raw = Transaction.Raw('td[4] | td[3]/a') obj_date = Date(CleanText('td[2]'), dayfirst=True) obj_amount = CleanDecimal('td[7]', replace_dots=True) �������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/pages/transfer.py������������������������������������������������������������0000664�0000000�0000000�00000014500�12657170273�0020364�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2009-2014 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import Recipient, AccountNotFound, Transfer from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, CleanDecimal, Format from weboob.browser.filters.html import Attr from .login import INGVirtKeyboard class TransferPage(LoggedPage, HTMLPage): @method class get_recipients(ListElement): class ExternalRecipients(ListElement): item_xpath = '//select[@id="transfer_form:externalAccounts"]/option' class item(ItemElement): klass = Recipient condition = lambda self: Attr('.', 'value')(self.el) != "na" obj_id = Attr('.', 'value') obj_label = CleanText('.') obj__type = 'ext' class InternalRecipients(ListElement): item_xpath = '//table[@id="transfer_form:receiptAccount"]/tbody/tr' class item(ItemElement): klass = Recipient obj_id = Attr('td[1]/input', 'value') obj_label = Format(u"%s %s %s", CleanText('td[1]/label'), CleanText('td[2]/label'), CleanText('td[3]/label')) obj__type = "int" def ischecked(self, _id): # remove prefix (CC-, LA-, ...) if "-" in _id: _id = _id.split('-')[1] try: option = self.doc.xpath('//input[@value="%s"]' % _id)[0] except: raise AccountNotFound() return option.attrib.get("checked") == "checked" def transfer(self, recipient, amount, reason): form = self.get_form(name="transfer_form") form.pop('transfer_form:_link_hidden_') form.pop('transfer_form:j_idcl') form['AJAXREQUEST'] = "_viewRoot" form['AJAX:EVENTS_COUNT'] = "1" form['transfer_form:transferMotive'] = reason form["transfer_form:valide"] = "transfer_form:valide" form["transfer_form:validateDoTransfer"] = "needed" form["transfer_form:transferAmount"] = str(amount) if recipient._type == "int": form['transfer_recipient_radio'] = recipient.id else: form['transfer_form:externalAccounts'] = recipient.id form.submit() def buildonclick(self, recipient, account): javax = self.doc.xpath('//input[@id="javax.faces.ViewState"]')[0].attrib['value'] if recipient._type == "ext": select = self.doc.xpath('//select[@id="transfer_form:externalAccounts"]')[0] onclick = select.attrib['onchange'] params = onclick.split(',')[3].split('{')[1] idparam = params.split("'")[1] param = params.split("'")[3] request = {"AJAXREQUEST": "transfer_form:transfer_radios_form", "transfer_form:generalMessages": "", "transfer_issuer_radio": account.id[3:], "transfer_form:externalAccounts": recipient.id, "transfer_date": "0", "transfer_form:transferAmount": "", "transfer_form:transferMotive": "", "transfer_form:validateDoTransfer": "needed", "transfer_form": "transfer_form", "autoScrol": "", "javax.faces.ViewState": javax, idparam: param} return request elif recipient._type == "int": for input in self.doc.xpath('//input[@value=%s]' % recipient.id): if input.attrib['name'] == "transfer_recipient_radio": onclick = input.attrib['onclick'] break # Get something like transfer_form:issueAccount:0:click params = onclick.split(',')[3].split('{')[1] idparam = params.split("'")[1] param = params.split("'")[3] request = {"AJAXREQUEST": "transfer_form:transfer_radios_form", 'transfer_issuer_radio': account.id[3:], "transfer_recipient_radio": recipient.id, "transfer_form:externalAccounts": "na", "transfer_date": 0, "transfer_form:transferAmount": "", "transfer_form:transferMotive": "", "transfer_form:validateDoTransfer": "needed", "transfer_form": "transfer_form", "autoScroll": "", "javax.faces.ViewState": javax, idparam: param} return request class TransferConfirmPage(LoggedPage, HTMLPage): def confirm(self, password): vk = INGVirtKeyboard(self) form = self.get_form(xpath='//div[@id="transfer_panel"]//form') for elem in form: if "_link_hidden_" in elem or "j_idcl" in elem: form.pop(elem) form['AJAXREQUEST'] = '_viewRoot' form['%s:mrgtransfer' % form.name] = '%s:mrgtransfer' % form.name form['%s:mrltransfer' % form.name] = vk.get_coordinates(password) form.submit() @method class recap(ListElement): item_xpath = '//div[@class="encadre transfert-validation"]' class item(ItemElement): klass = Transfer obj_amount = CleanDecimal('.//label[@id="confirmtransferAmount"]', replace_dots=True) obj_origin = CleanText('.//span[@id="confirmfromAccount"]') obj_recipient = CleanText('.//span[@id="confirmtoAccount"]') obj_reason = CleanText('.//span[@id="confirmtransferMotive"]') ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ing/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000005053�12657170273�0016423�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.bank import Account from datetime import timedelta import random class INGTest(BackendTest): MODULE = 'ing' def test_accounts(self): l = list(self.backend.iter_accounts()) for account in l: # Test if get_account works _id = self.backend.get_account(account.id) self.assertTrue(_id.id == account.id) # Methods can use Account objects or id. Try one of them id_or_account = random.choice([account, account.id]) if account.type == Account.TYPE_CHECKING or account.type == Account.TYPE_SAVINGS: history = list(self.backend.iter_history(id_or_account)) self.assertTrue(len(history) > 0) date = history.pop(0).date for elem in history: self.assertTrue(date + timedelta(days=2) >= elem.date) date = elem.date recipients = list(self.backend.iter_transfer_recipients(id_or_account)) self.assertTrue(len(recipients) > 0) elif account.type == Account.TYPE_MARKET: invest = list(self.backend.iter_investment(id_or_account)) self.backend.iter_history(id_or_account) # can be empty. Only try to call it self.assertTrue(len(invest) > 0) def test_subscriptions(self): l = list(self.backend.iter_subscription()) for sub in l: _id = self.backend.get_subscription(sub.id) self.assertTrue(_id.id == sub.id) bills = list(self.backend.iter_bills(sub)) self.assertTrue(len(bills) > 0) _id = self.backend.get_bill(bills[0].id) self.assertTrue(_id.id == bills[0].id) self.backend.download_bill(bills[0].id) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015762�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001515�12657170273�0020075�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"init of NewspaperInrocksModule" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NewspaperInrocksModule __all__ = ['NewspaperInrocksModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000003014�12657170273�0020015�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"browser for inrocks.fr website" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .pages.article import ArticlePage from .pages.inrockstv import InrocksTvPage from weboob.deprecated.browser import Browser class NewspaperInrocksBrowser(Browser): "NewspaperInrocksBrowser class" PAGES = { 'http://www.lesinrocks.com/\?p=.+': ArticlePage, 'http://www.lesinrocks.com/\d{4}/\d{2}/\d{2}/actualite/.*': ArticlePage, 'http://www.lesinrocks.com/inrockstv/.*': InrocksTvPage, 'http://blogs.lesinrocks.com/.*': ArticlePage, } def is_logged(self): return False def login(self): pass def fillobj(self, obj, fields): pass def get_content(self, _id): "return page article content" self.location(_id) return self.page.get_article(_id) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000002275�12657170273�0020123�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD���@V)��� pHYs�� �� ����tIME&���tEXtComment�Created with GIMPW��IDATx[MOA~Zh)mZGE h4$`yA!ꅓw"Q$F=Q`bB\i%@[ xXnݙs.<~<`:P0a``P(N?@PZ �W=0o@ay '!p a:%h�_PXfWVǀ@T<!=s (dwXX̽�<~>N y@K?PY"v7Ss9Nَo�i`qTKO]|^e"r{XS� z>fS@N> st@I9~~>2y)$?uVOe)(hz`鍺=^Wʢ"[Ko5-QFiFXĥ<Q& !1Ged,QOz9"nq`q6CVE1tb-h">=dU7-G@TU*PIZ(QRz@iUGlBrI1I+xiu@qI]]HlW}vE>Cr))OL@i5{ #27e@gT- ޖ|'@R?Mmfx8|ƶmg68s*c HQ!CZ\t1C K+V6(ziU枣~DE}ۚէÑ>ckV>s)?Cس,�򗙀440GZ<e&&[Q{Z!t�׸z NՂZQ [nmX]7Fx "'5zbNZ7FDt>.e0j^K c.SݴgkCZJ89[dI<qS!0"MbvVw%'׶v$l3S?C��������BxFeye����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/module.py����������������������������������������������������������������0000664�0000000�0000000�00000002540�12657170273�0017622�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. "backend for http://www.lesinrocks.com" from weboob.capabilities.messages import CapMessages from weboob.tools.capabilities.messages.GenericModule import GenericNewspaperModule from .browser import NewspaperInrocksBrowser from .tools import rssid class NewspaperInrocksModule(GenericNewspaperModule, CapMessages): MAINTAINER = u'Julien Hebert' EMAIL = 'juke@free.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' STORAGE = {'seen': {}} NAME = 'inrocks' DESCRIPTION = u'Les Inrocks French news website' BROWSER = NewspaperInrocksBrowser RSS_FEED = 'http://www.lesinrocks.com/fileadmin/rss/actus.xml' RSSID = rssid ����������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/pages/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017061�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/pages/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021160�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/pages/article.py���������������������������������������������������������0000664�0000000�0000000�00000006647�12657170273�0021073�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"ArticlePage object for inrocks" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import BrokenPageError from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage, try_remove, \ try_remove_from_selector_list, \ drop_comments, NoneMainDiv class ArticlePage(GenericNewsPage): "ArticlePage object for inrocks" def on_loaded(self): main = self.parser.select(self.document.getroot(), "div#content") self.main_div = main[0] if len(main) else None self.element_title_selector = "h1" self.element_author_selector = "div.name>span" self.element_body_selector = "div.maincol" def get_body(self): try: element_body = self.get_element_body() except NoneMainDiv: return u'Ceci est un article payant' else: div_header_element = self.parser.select(element_body, "div.header", 1) element_detail = self.parser.select(element_body, "div.details", 1) div_content_element = self.parser.select(element_body, "div.content", 1) drop_comments(element_body) try_remove(self.parser, element_body, "div.sidebar") try_remove(self.parser, element_detail, "div.footer") try_remove_from_selector_list(self.parser, div_header_element, ["h1", "div.picture", "div.date", "div.news-single-img", "div.metas_img", "strong"]) try_remove_from_selector_list(self.parser, div_content_element, ["div.tw_button", "div.wpfblike"]) try: description_element = self.parser.select(div_header_element, "div.description", 1) except BrokenPageError: pass else: text_content = description_element.text_content() if len(text_content.strip()) == 0: description_element.drop_tree() else: if len(description_element) == 1: description_element.drop_tag() if len(div_header_element.text_content().strip()) == 0: div_header_element.drop_tree() if len(div_header_element) == 1: div_header_element.drop_tag() if len(element_detail) == 1: element_detail.drop_tag() div_content_element.drop_tag() return self.parser.tostring(element_body) �����������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/pages/inrockstv.py�������������������������������������������������������0000664�0000000�0000000�00000002367�12657170273�0021465�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"ArticlePage object for inrocks" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage class InrocksTvPage(GenericNewsPage): "ArticlePage object for inrocks" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "h2" self.element_author_selector = "div.name>span" self.element_body_selector = "span.infos" def get_body(self): element_body = self.get_element_body() return self.parser.tostring(element_body) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/inrocks/test.py������������������������������������������������������������������0000664�0000000�0000000�00000001663�12657170273�0017321�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class InrocksTest(BackendTest): MODULE = 'inrocks' def test_new_messages(self): for message in self.backend.iter_unread_messages(): pass �����������������������������������������������������������������������������weboob-1.1/modules/inrocks/tools.py�����������������������������������������������������������������0000664�0000000�0000000�00000002417�12657170273�0017500�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"common tools for inrocks backend" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re def id2url(_id): "return an url from an id" regexp2 = re.compile("(\w+).([0-9]+).(.*$)") match = regexp2.match(_id) if match: return 'http://www.20minutes.fr/%s/%s/%s' % (match.group(1), match.group(2), match.group(3)) else: raise ValueError("id doesn't match") def url2id(url): "return an id from an url" return url def rssid(entry): return url2id(entry.id) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipapi/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015414�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipapi/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000000073�12657170273�0017525�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import IpapiModule __all__ = ['IpapiModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipapi/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000001376�12657170273�0017556�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME[r��IDATxk`ol]J]Zۿ _(:ԋxx_!9CAOz/ZeEWetuuZ$@dPH<o7ϛ MD7� �@�� �@�� �@if=*I�X$ǃTq6Ȳ }L?zuq添k6mnϮB<{ҋ竈 i[SFpNN G@Y8޼ډ#�ņsֲyi�Dx"q=dx9Uc+TzK7n}>ZE�b\,#gŢw (^g~łٷ{wCAAoz =x4dss-,IA�A�rQjBc :]\ 2t`8_'@_*WiF%]؉631YrnII}l�(CUKY#4 zjn8'-q~z� XWk|30@�� �@�� �@���/3k#����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipapi/module.py������������������������������������������������������������������0000664�0000000�0000000�00000004015�12657170273�0017253�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.geolocip import CapGeolocIp, IpLocation from weboob.tools.backend import Module from weboob.browser.browsers import Browser from weboob.tools.json import json __all__ = ['IpapiModule'] class IpapiModule(Module, CapGeolocIp): NAME = 'ipapi' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u"IP-API Geolocation API" BROWSER = Browser def get_location(self, ipaddr): res = self.browser.location('http://ip-api.com/json/%s' % ipaddr.encode('utf-8')) jres = json.loads(res.text) if "status" in jres and jres["status"] == "fail": raise Exception("IPAPI failure : %s" % jres["message"]) iploc = IpLocation(ipaddr) iploc.city = u'%s'%jres['city'] iploc.region = u'%s'%jres['regionName'] iploc.zipcode = u'%s'%jres['zip'] iploc.country = u'%s'%jres['country'] if jres['lat'] != '': iploc.lt = float(jres['lat']) else: iploc.lt = 0.0 if jres['lon'] != '': iploc.lg = float(jres['lon']) else: iploc.lg = 0.0 #iploc.host = 'NA' #iploc.tld = 'NA' if 'isp' in jres: iploc.isp = u'%s'%jres['isp'] return iploc �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipapi/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000001612�12657170273�0016745�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class IpapiTest(BackendTest): MODULE = 'ipapi' def test_ipapi(self): self.backend.get_location('88.198.11.130') ����������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipinfodb/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016104�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipinfodb/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000000101�12657170273�0020205�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import IpinfodbModule __all__ = ['IpinfodbModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipinfodb/favicon.png�������������������������������������������������������������0000664�0000000�0000000�00000010413�12657170273�0020236�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME  :'��IDATx[k$UνU=ݙ޷ccbC  H!+r �"`$ ~ DlE8!x{^{y{QUÏ{g5b Jꪺ~9qy\Aԋ!] Yy9}=g�=z�A w#]қ)6,)@X J'HG3<_Rp:> ¢P, ~$ֿ�8q#XHZoֳ= ]#ߔg¯=;R7Sz}Qԣ�rn q6 �+cT*55]r؃�!R�g$צr$#~<q_@C72_�N, � Gط۾{O>+:05<3x " bZ#פ<{7M^*� j_e/ɜr(W[ӷcbA"N)hn+ #NOPV[gP[C% xrX|<[:� 2QgGH�'-@m|5l`�#$&%iQ)@#y멁x8T+޳GnsNyU.Цyߧ]"굿}uõPI $ &uBq?1 5`vԡ m" `hvw޷N}̲I+S@C�XЗ)$n,(-gn�e hJs:^sD4HebG�&xe>lh 6_ZqM XT4^S;ѡM}@S{I�D豶eI-+KWL8BDBP֥@Cl O`XL 쀰Mf-rM! x+RY|FB$X dfTQȇtjvV3|v'j�i�Vʱ|'b]3 R9%ſҩ-JREm8f ؤt}I*ؽ%߷v]aԶ�m皾sja[X\Ͻ8No4Z<B�'`�lMibY9(-Gaޘ/Ѓ`W᚝+3(DCq51  WiL601J%* i.CJ,LZ$$K�P$ nFZl09B©ä:cP@AiZ+rCG?]S:Jx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ؘT}HlSK o b i}헞 觅?kmZ1rQB޵ϰ(a "|O6Uذ+, խs"N}s/)Lg'__` T~s8��!Pa[G@Q,BAT IjJ纠\Ӫ{@jQlꋣP.-pZ@d +g&?��'?wz'u4QU:BdUABBA&X�X1Ƥ$*K&`] Lm6iKcn_>Ρohl] VN,&6tT %xiMD}CAR'x'~~+�Vq6ܦ),2 4zP @:"I\KS83feRH}јAμ/ID%^ BS@Pdґr9@@@l .D6S]lxʍH}z�QRa&HP"FC8NјFuSR:r]%\qy\8![wl����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ipinfodb/module.py���������������������������������������������������������������0000664�0000000�0000000�00000005750�12657170273�0017752�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.geolocip import CapGeolocIp, IpLocation from weboob.tools.backend import Module from weboob.deprecated.browser import StandardBrowser __all__ = ['IpinfodbModule'] class IpinfodbModule(Module, CapGeolocIp): NAME = 'ipinfodb' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u"IPInfoDB IP addresses geolocation service" BROWSER = StandardBrowser def get_location(self, ipaddr): self.browser.location("http://ipinfodb.com/ip_locator.php") self.browser.select_form(nr=0) self.browser['ip'] = str(ipaddr) response = self.browser.submit() document = self.browser.get_document(response) tab = {'City' : 'NA' , 'Country name' : 'NA' , 'Region' : 'NA' , 'Latitude' : 'NA' , 'Longitude' : 'NA' , 'hostname' : 'NA' , 'zipcode' : 'NA'} for li in document.getiterator('li'): txt = li.text_content() if 'Country :' in txt: tab['Country name'] = txt.split('Country : ')[1].split('<')[0] elif "State/Province :" in txt: tab['Region'] = txt.split('State/Province : ')[1].split('<')[0] elif "City :" in txt: tab['City'] = txt.split('City : ')[1].split('<')[0] elif "Latitude :" in txt: tab['Latitude'] = txt.split('Latitude : ')[1].split('<')[0] elif "Longitude :" in txt: tab['Longitude'] = txt.split('Longitude : ')[1].split('<')[0] elif "Hostname :" in txt: tab['hostname'] = txt.split('Hostname : ')[1].split('<')[0] iploc = IpLocation(ipaddr) iploc.city = unicode(tab['City'].decode('utf-8')) iploc.region = unicode(tab['Region']) iploc.zipcode = unicode(tab['zipcode']) iploc.country = unicode(tab['Country name']) try : iploc.lt = float(tab['Latitude']) iploc.lg = float(tab['Longitude']) except ValueError: pass iploc.host = unicode(tab['hostname']) iploc.tld = unicode(tab['hostname'].split('.')[-1]) #iploc.isp = 'NA' return iploc ������������������������weboob-1.1/modules/ipinfodb/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000001722�12657170273�0017437�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class IpinfodbTest(BackendTest): MODULE = 'ipinfodb' def test_ipinfobd(self): self.backend.get_location('88.198.11.130') self.backend.get_location('2a01:4f8:130:3062::1') ����������������������������������������������weboob-1.1/modules/itella/��������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015564�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/itella/__init__.py���������������������������������������������������������������0000664�0000000�0000000�00000001437�12657170273�0017702�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import ItellaModule __all__ = ['ItellaModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/itella/browser.py����������������������������������������������������������������0000664�0000000�0000000�00000002107�12657170273�0017621�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import SearchPage class ItellaBrowser(PagesBrowser): BASEURL = 'http://www.itella.fi' search_page = URL('/itemtracking/itella/search_by_shipment_id\?lang=en&ShipmentId=(?P<id>.+)', SearchPage) def get_tracking_info(self, _id): return self.search_page.go(id=_id).get_info(_id) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/itella/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000001230�12657170273�0017713�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���% ��� pHYs�� �� ����tIME xS���tEXtComment�Created with GIMPW��IDAThؿOSQ `D 8!0X&`cbHtPX\IĄտ8�]qG#?NDF!ՔBۈa0ay+yy{9^$<�(`#IB~ V #zDz%�W+�CÏYDORrm!zlg H@S�O30.bDxW^H1(pi:3rBva Y)TT(jAAߢ~\꓆sLr 0ff_C\p@ҟKm[w&R'{]za}\cnBN+@/4@:5G6E>q HY|`-$/+5ه|]VV4ịۥ�:] @sBDQӨC\{i*@6L6?b� ^fU՛zvÌ= <sX*kk<JfY-�(@ P]LQW@ P`zP����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/itella/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000002624�12657170273�0017427�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.parcel import CapParcel from .browser import ItellaBrowser __all__ = ['ItellaModule'] class ItellaModule(Module, CapParcel): NAME = 'itella' DESCRIPTION = u'Itella website' MAINTAINER = u'Matthieu Weber' EMAIL = 'mweber+weboob@free.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = ItellaBrowser def get_parcel_tracking(self, id): """ Get information abouut a parcel. :param id: ID of the parcel :type id: :class:`str` :rtype: :class:`Parcel` :raises: :class:`ParcelNotFound` """ return self.browser.get_tracking_info(id) ������������������������������������������������������������������������������������������������������������weboob-1.1/modules/itella/pages.py������������������������������������������������������������������0000664�0000000�0000000�00000005435�12657170273�0017244�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from dateutil.parser import parse as parse_date from weboob.browser.pages import HTMLPage from weboob.capabilities.parcel import Parcel, Event, ParcelNotFound class SearchPage(HTMLPage): def get_info(self, _id): result_id = self.doc.xpath('//table[@id="shipment-details-table"]//tr[position()=1]/td[@id="td-bold"]') if not result_id: raise ParcelNotFound("No such ID: %s" % _id) result_id = result_id[0].text if result_id != _id: raise ParcelNotFound("ID mismatch: expecting %s, got %s" % (_id, result_id)) p = Parcel(_id) events = self.doc.xpath('//div[@id="shipment-event-table-cell"]') p.history = [self.build_event(i, div) for i, div in enumerate(events)] most_recent = p.history[0] p.status, p.info = self.guess_status(p.history) p.info = most_recent.activity return p def guess_status(self, events): for event in events: txt = event.activity if txt == "Itella has received advance information of the item.": return Parcel.STATUS_PLANNED, txt elif txt == "Item in sorting." or txt == "Item has been registered.": return Parcel.STATUS_IN_TRANSIT, txt elif txt.startswith("Item ready for pick up") or \ txt.startswith("A notice of arrival has been sent to the recipient"): return Parcel.STATUS_ARRIVED, txt else: return Parcel.STATUS_UNKNOWN, events[0].activity def build_event(self, index, div): event = Event(index) event.activity = unicode(div.xpath('div[@class="shipment-event-table-header"]')[0].text) event.date = parse_date(div.xpath('.//span[@class="shipment-event-table-label" and text()="Registration:"]/' 'following-sibling::span')[0].text) event.location = unicode(div.xpath('.//span[@class="shipment-event-table-label" and text()="Location:"]/' 'following-sibling::span')[0].text) return event �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/itella/test.py�������������������������������������������������������������������0000664�0000000�0000000�00000001747�12657170273�0017126�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Matthieu Weber # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.parcel import ParcelNotFound class ItellaTest(BackendTest): MODULE = 'itella' def test_itella(self): self.assertRaises(ParcelNotFound, self.backend.get_parcel_tracking, "foo") �������������������������weboob-1.1/modules/izneo/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015436�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/izneo/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000001434�12657170273�0017551�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import IzneoModule __all__ = ['IzneoModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/izneo/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000002730�12657170273�0017573�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME 8({��XIDATxoHu?6Vc3BH6Ŕ6Jk\G/(A4tAXYzP S%CGH3fl>9ϽK s~|w~w~BEIQJ(nk2�ׁI,d" �Mbhz' Lv`Ou]>[V{:3f)ַ�qy_l[{%C'@69ͮ/9s'Ϸ5[q/syR4[Hpn?| |ܐ[S>($p x( OxJ,|q6~4%&8wX3p!['#|sRdm�9/xx',pM[X(29AN8 AuPRFb4d@l{\l~3[ =3smP]{#x[_�/ a(sjSl1ov=F㏈�%k![v^h|`&[pB#6=E)x60`@Lk `XtРB6Ҟ7*աIE055WaxYoMiS~?KĶPWN|  ? -hP!V)lB�Pj0 ҄r\jk1oKgV#pM9ZC@RݘBV!P}iP!`RMŘ?@Mݑ "PLDp3ִ2Koh5 JaK 3qjuYQT^eACR~*&i!,"ıf&J &nc}FT{2�iKѦV_ ˍ":nrɅGBH/ޝҮD0ۣȐ1 Y 0CK: F/h.Э+8x� Iů mm "QA qGĆ~3gTn..ig="^95]Hs/c.PUϲn+:D@>WZdy IjWb|` WP0)/01�. 㯊OY?ܕejޑ#$Krl"`Z0 |k;D-:?Dau\oqJ[%]^O.~-1:r(42 $<#$mpf% gsBB({X"ʮ (-I<����IENDB`����������������������������������������weboob-1.1/modules/izneo/module.py������������������������������������������������������������������0000664�0000000�0000000�00000006030�12657170273�0017274�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.gallery import CapGallery, BaseGallery, BaseImage from weboob.tools.json import json from weboob.tools.backend import Module from weboob.deprecated.browser import Browser, Page __all__ = ['IzneoModule'] class ReaderV2(Page): def get_ean(self): return self.document.xpath("//div[@id='viewer']/attribute::rel")[0] def iter_gallery_images(self, gallery): ean = self.get_ean() pages = json.load(self.browser.openurl( 'http://www.izneo.com/playerv2/ajax.php?ean=%s&action=get_list_jpg' % ean)) for page in pages['list']: width = 1200 # maximum width yield BaseImage(page['page'], gallery=gallery, url=("http://www.izneo.com/playerv2/%s/%s/%s/%d/%s" % (page['expires'], page['token'], ean, width, page['page']))) class IzneoBrowser(Browser): PAGES = {r'http://.+\.izneo.\w+/readv2-.+': ReaderV2} def iter_gallery_images(self, gallery): self.location(gallery.url) assert self.is_on_page(ReaderV2) return self.page.iter_gallery_images(gallery) def fill_image(self, image, fields): if 'data' in fields: image.data = self.readurl(self.request_class( image.url, None, {'Referer': image.gallery.url})) class IzneoModule(Module, CapGallery): NAME = 'izneo' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' VERSION = '1.1' DESCRIPTION = 'Izneo digital comics' LICENSE = 'AGPLv3+' BROWSER = IzneoBrowser def iter_gallery_images(self, gallery): with self.browser: return self.browser.iter_gallery_images(gallery) def get_gallery(self, _id): match = re.match(r'(?:(?:.+izneo.com/)?readv2-)?(\d+-\d+)/?$', _id) if match is None: return None _id = match.group(1) gallery = BaseGallery(_id, url=('http://www.izneo.com/readv2-%s' % _id)) with self.browser: return gallery def fill_gallery(self, gallery, fields): gallery.title = gallery.id def fill_image(self, image, fields): with self.browser: self.browser.fill_image(image, fields) OBJECTS = { BaseGallery: fill_gallery, BaseImage: fill_image} ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jacquieetmichel/�����������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017446�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jacquieetmichel/__init__.py������������������������������������������������������0000664�0000000�0000000�00000001451�12657170273�0021560�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import JacquieEtMichelModule __all__ = ['JacquieEtMichelModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jacquieetmichel/browser.py�������������������������������������������������������0000664�0000000�0000000�00000003543�12657170273�0021510�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.deprecated.browser import Browser from weboob.deprecated.browser.decorators import id2url from .video import JacquieEtMichelVideo from .pages import VideoPage, ResultsPage __all__ = ['JacquieEtMichelBrowser'] class JacquieEtMichelBrowser(Browser): DOMAIN = u'jacquieetmicheltv.net' ENCODING = None PAGES = {r'https?://.*jacquieetmicheltv.net/': ResultsPage, r'https?://.*jacquieetmicheltv.net/videolist/.*': ResultsPage, r'https?://.*jacquieetmicheltv.net/showvideo/(?P<id>\d+)/.*': VideoPage, } @id2url(JacquieEtMichelVideo.id2url) def get_video(self, url, video=None): self.location(url) assert self.is_on_page(VideoPage), 'Should be on video page.' return self.page.get_video(video) def search_videos(self, pattern): self.location('/videolist/searchmodevideo/query%s/' % (urllib.quote(pattern.encode('utf-8')))) assert self.is_on_page(ResultsPage) return self.page.iter_videos() def latest_videos(self): self.home() assert self.is_on_page(ResultsPage) return self.page.iter_videos() �������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jacquieetmichel/favicon.png������������������������������������������������������0000664�0000000�0000000�00000002130�12657170273�0021575�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME  I|���tEXtComment�Created with GIMPW��IDATxOhu?-HjRЃ˶z==x֣R/OzTA`=x( H KUlGƸdIt&eؙeMj2~~o~((((((tG@pl׀+=ƼpH&٬/af? 4As1KAĈ|> q8O&! <6z!ଵm 0 EDT* *p^."" xwݘA"�F7]Ӏ5qlwV4= (&mDQt9cnuVqEQn->M"-a:#Bb(~KcX,JP88XR1z]߁;Gw صi  It~-JlV>6MiZ|n}j-vhN�;;;""ennj>!m9}b~Ϧvhw0g!j5ن諴JE[Vb~~kF!5.|3`Z+I[ZZT+8NGeYXX(H-OrNr9�DEH=.eޣ\ wNu{,)]Ϗ?xyyE+ClC aV(g=ϋxޏ{)InfI~;& 1Ƥ[ZQ?%dԢ48;;+w^4U*_F[ܕLfvǯ@զB�\> fTcu P1)ZCs%m `0 }YYY[8LPrKEQEQEQEQ<?X����IENDB`����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jacquieetmichel/module.py��������������������������������������������������������0000664�0000000�0000000�00000005556�12657170273�0021320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound from weboob.tools.backend import Module from .browser import JacquieEtMichelBrowser from .video import JacquieEtMichelVideo __all__ = ['JacquieEtMichelModule'] class JacquieEtMichelModule(Module, CapVideo, CapCollection): NAME = 'jacquieetmichel' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' VERSION = '1.1' DESCRIPTION = 'Jacquie et Michel TV' LICENSE = 'AGPLv3+' BROWSER = JacquieEtMichelBrowser def get_video(self, _id): with self.browser: video = self.browser.get_video(_id) return video def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): if not nsfw: return iter([]) with self.browser: return self.browser.search_videos(pattern) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields with self.browser: video = self.browser.get_video(JacquieEtMichelVideo.id2url(video.id), video) if 'thumbnail' in fields and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest_nsfw']) if collection.split_path == [u'latest_nsfw']: for video in self.browser.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest_nsfw']: collection.title = u'Latest Jacquie & Michel videos (NSFW)' return raise CollectionNotFound(collection.split_path) OBJECTS = {JacquieEtMichelVideo: fill_video} ��������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jacquieetmichel/pages.py���������������������������������������������������������0000664�0000000�0000000�00000005040�12657170273�0021116�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.base import NotAvailable from weboob.capabilities.image import BaseImage from weboob.deprecated.browser import Page, BrokenPageError from weboob.tools.misc import to_unicode from .video import JacquieEtMichelVideo class ResultsPage(Page): def iter_videos(self): for span in self.document.xpath('//ul[@id="list"]/li'): a = self.parser.select(span, 'a', 1) url = a.attrib['href'] _id = re.sub(r'/showvideo/(\d+)/.*', r'\1', url) video = JacquieEtMichelVideo(_id) url = span.find('.//img').attrib['src'] video.thumbnail = BaseImage(url) video.thumbnail.url = video.thumbnail.id title_el = self.parser.select(span, 'h2', 1) video.title = to_unicode(title_el.text.strip()) video.description = self.parser.tocleanstring(span.xpath('.//div[@class="desc"]')[0]) video.set_empty_fields(NotAvailable, ('url,')) yield video class VideoPage(Page): def get_video(self, video=None): _id = to_unicode(self.group_dict['id']) if video is None: video = JacquieEtMichelVideo(_id) title_el = self.parser.select(self.document.getroot(), 'h1', 1) video.title = to_unicode(title_el.text.strip()) video.description = self.document.xpath('//meta[@name="description"]')[0].attrib['content'] for script in self.document.xpath('.//script'): if script.text is None: continue m = re.search('"(http://[^"]+.mp4)"', script.text, re.MULTILINE) if m: video.url = to_unicode(m.group(1)) break if not video.url: raise BrokenPageError('Unable to find URL') video.set_empty_fields(NotAvailable) return video ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jacquieetmichel/test.py����������������������������������������������������������0000664�0000000�0000000�00000003156�12657170273�0021004�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo class JacquieEtMichelTest(BackendTest): MODULE = 'jacquieetmichel' def test_search(self): self.assertTrue(len(list(self.backend.search_videos('anus', nsfw=False))) == 0) l = list(self.backend.search_videos('anus', nsfw=True)) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) self.backend.browser.openurl(v.url) def test_latest(self): l = list(self.backend.iter_resources([BaseVideo], [u'latest_nsfw'])) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jacquieetmichel/video.py���������������������������������������������������������0000664�0000000�0000000�00000002064�12657170273�0021130�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo class JacquieEtMichelVideo(BaseVideo): def __init__(self, *args, **kwargs): BaseVideo.__init__(self, *args, **kwargs) self.ext = u'mp4' self.nsfw = True @classmethod def id2url(cls, _id): return 'http://jacquieetmicheltv.net/showvideo/%s/t/' % _id ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jcvelaux/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016133�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jcvelaux/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001430�12657170273�0020242�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 dud # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import jcvelauxModule __all__ = ['jcvelauxModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jcvelaux/browser.py��������������������������������������������������������������0000664�0000000�0000000�00000004424�12657170273�0020174�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 dud # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import datetime from weboob.deprecated.browser import Browser __all__ = ['VelibBrowser'] class VelibBrowser(Browser): ENCODING = 'utf-8' API_KEY = '2282a34b49cf45d8129cdf93d88762914cece88b' BASE_URL = 'https://api.jcdecaux.com/vls/v1/' def __init__(self, *a, **kw): kw['parser'] = 'json' Browser.__init__(self, *a, **kw) def do_get(self, path, **query): qs = '&'.join('%s=%s' % kv for kv in query.items()) if qs: qs = '&' + qs url = '%s%s?apiKey=%s%s' % (self.BASE_URL, path, self.API_KEY, qs) return self.get_document(self.openurl(url)) def get_contracts_list(self): return self.do_get('contracts') def get_station_list(self, contract=None): if contract: doc = self.do_get('stations', contract=contract) else: doc = self.do_get('stations') for jgauge in doc: self._transform(jgauge) return doc def get_station_infos(self, gauge): station_id, contract = gauge.split('.', 1) doc = self.do_get('stations/%s' % station_id, contract=contract) return self._transform(doc) def _transform(self, jgauge): jgauge['id'] = '%s.%s' % (jgauge['number'], jgauge['contract_name']) jgauge['city'] = jgauge['contract_name'] jgauge['last_update'] = datetime.datetime.fromtimestamp(jgauge['last_update'] / 1000) jgauge['latitude'] = str(jgauge['position']['lat']) jgauge['longitude'] = str(jgauge['position']['lng']) del jgauge['position'] return jgauge ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jcvelaux/favicon.png�������������������������������������������������������������0000664�0000000�0000000�00000004152�12657170273�0020270�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���tEXtSoftware�Adobe ImageReadyqe<�� IDATx[[lE @(B@A jbŠH$JĘJA%R|,D6h,-"5RQ- 86[ʐNlW#`ns_O?*豀n8ӣzVO�h|7R*\� L#A`@\3~CKmsp  �NO{'@Ff: p(9@x`_9"@(tHcWD=܂!D', }u':^#1q-3;E AY� � ϑ'7!y3p"_ӭkQy ǜڧ28ٌk RI8R%%E̹s@m#xl+8) N8]/�3ֻ}roj׹eI*6Te85xjnh0`jFk|vL՘( X�PyW7g8`2@f^"�Y+ �XҀpuhj04 '7;k"ܡSܚ8-= nsw�,|x}VX,rY_ިlʧ }[U@`h/ xH@ iT$� HIMFjV|>D!67fh6W ˬ4�Xɦ�FG nȡl_ 3;u N7XLƇ1L+ @,+oc<?: ?v%{/j- dE2'|Rf-p%Df`\j*6=~6md;yiGȾyGXVow[ zNoYdS FZ ɀFcҌb^A)*Q�w{]+7zcd{ܫJi43\r}Jf%P҄5`x0TR̎{#%E4&]z4-,xNqB0vb\WF=PFU5jekڔCgrktSc~9X852u>eb�so?i ^+Sz55{"<y5du�5iP`´[=4 .�YĂj(3´WxST\r< q>X%;6txqe) 픶~`@s&K`غnO UAtS>3B�(}xFy\25As}_Kbe`@> * oS^pq&Kj ".�<_izaS_S` fH)R@cH�/+IQ�lcKO-f55i0dE\> aPf _}~.wBިtGǛbCӤpVkd!JׅL^C{mۘM#:=` ͢Tio+ 68\ h0mlcT\Uh,đz"�`۵WbFSob.nLWG%j֦qň ~9Ҳ<gK {妇 qrhw>QKeruBJ+�W~aYozI)_AuW`^� }P")V}w)pIZ To1)q(X!嶂hz"I (wv|M/VĽ!HILf0pIR�?@nd\i*V6= . i'+M/V$ �m=KjSBOP(+\t�9 )E�R9O5MQ44AZדeaE�m y߳Ԓp{|Ņo/�𽺤5ֵ5@y9j`A@ �t ~x֫^/�mY9 ����IENDB`����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jcvelaux/module.py���������������������������������������������������������������0000664�0000000�0000000�00000013256�12657170273�0020001�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 dud # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.base import StringField from weboob.capabilities.gauge import CapGauge, GaugeSensor, Gauge, GaugeMeasure, SensorNotFound from weboob.tools.value import Value from weboob.tools.ordereddict import OrderedDict from .browser import VelibBrowser __all__ = ['jcvelauxModule'] SENSOR_TYPES = OrderedDict(((u'available_bikes', u'Available bikes'), (u'available_bike_stands', u'Free stands'), (u'bike_stands', u'Total stands'))) CITIES = ("Paris", "Rouen", "Toulouse", "Luxembourg", "Valence", "Stockholm", "Goteborg", "Santander", "Amiens", "Lillestrom", "Mulhouse", "Lyon", "Ljubljana", "Seville", "Namur", "Nancy", "Creteil", "Bruxelles-Capitale", "Cergy-Pontoise", "Vilnius", "Toyama", "Kazan", "Marseille", "Nantes", "Besancon") class BikeMeasure(GaugeMeasure): def __repr__(self): return '<GaugeMeasure level=%d>' % self.level class BikeSensor(GaugeSensor): longitude = StringField('Longitude of the sensor') latitude = StringField('Latitude of the sensor') class jcvelauxModule(Module, CapGauge): NAME = 'jcvelaux' DESCRIPTION = (u'City bike renting availability information.\nCities: %s' % u', '.join(CITIES)) MAINTAINER = u'Herve Werner' EMAIL = 'dud225@hotmail.com' VERSION = '1.1' LICENSE = 'AGPLv3' BROWSER = VelibBrowser STORAGE = {'boards': {}} CONFIG = BackendConfig(Value('city', label='City', default='Paris', choices=CITIES + ("ALL",))) def __init__(self, *a, **kw): super(jcvelauxModule, self).__init__(*a, **kw) self.cities = None def _make_gauge(self, info): gauge = Gauge(info['id']) gauge.name = unicode(info['name']) gauge.city = unicode(info['city']) gauge.object = u'bikes' return gauge def _make_sensor(self, sensor_type, info, gauge): id = '%s.%s' % (sensor_type, gauge.id) sensor = BikeSensor(id) sensor.gaugeid = gauge.id sensor.name = SENSOR_TYPES[sensor_type] sensor.address = unicode(info['address']) sensor.longitude = info['longitude'] sensor.latitude = info['latitude'] sensor.history = [] return sensor def _make_measure(self, sensor_type, info): measure = BikeMeasure() measure.date = info['last_update'] measure.level = float(info[sensor_type]) return measure def _parse_gauge(self, info): gauge = self._make_gauge(info) gauge.sensors = [] for type in SENSOR_TYPES: sensor = self._make_sensor(type, info, gauge) measure = self._make_measure(type, info) sensor.lastvalue = measure gauge.sensors.append(sensor) return gauge def _contract(self): contract = self.config.get('city').get() if contract.lower() == 'all': contract = None return contract def iter_gauges(self, pattern=None): if pattern is None: for jgauge in self.browser.get_station_list(contract=self._contract()): yield self._parse_gauge(jgauge) else: lowpattern = pattern.lower() for jgauge in self.browser.get_station_list(contract=self._contract()): gauge = self._parse_gauge(jgauge) if lowpattern in gauge.name.lower() or lowpattern in gauge.city.lower(): yield gauge def iter_sensors(self, gauge, pattern=None): if not isinstance(gauge, Gauge): gauge = self._get_gauge_by_id(gauge) if gauge is None: raise SensorNotFound() if pattern is None: for sensor in gauge.sensors: yield sensor else: lowpattern = pattern.lower() for sensor in gauge.sensors: if lowpattern in sensor.name.lower(): yield sensor def get_last_measure(self, sensor): if not isinstance(sensor, GaugeSensor): sensor = self._get_sensor_by_id(sensor) if sensor is None: raise SensorNotFound() return sensor.lastvalue def _fetch_cities(self): if self.cities: return self.cities = {} jcontract = self.browser.get_contracts_list() for jcontract in jcontract: for city in jcontract['cities']: self.cities[city.lower()] = jcontract['name'] def _get_gauge_by_id(self, id): jgauge = self.browser.get_station_infos(id) if jgauge: return self._parse_gauge(jgauge) else: return None def _get_sensor_by_id(self, id): _, gauge_id = id.split('.', 1) gauge = self._get_gauge_by_id(gauge_id) if not gauge: raise SensorNotFound() for sensor in gauge.sensors: if sensor.id.lower() == id.lower(): return sensor ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jcvelaux/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000002165�12657170273�0017470�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 dud # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class VelibTest(BackendTest): MODULE = 'jcvelaux' def test_velib(self): l = list(self.backend.iter_gauges()) self.assertTrue(len(l) > 0) gauge = l[0] s = list(self.backend.iter_sensors(gauge)) self.assertTrue(len(s) > 0) sensor = s[0] self.assertTrue(self.backend.get_last_measure(sensor.id) is not None) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jvmalin/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015752�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jvmalin/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001434�12657170273�0020065�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Alexandre Lissy # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import JVMalinModule __all__ = ['JVMalinModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jvmalin/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000003764�12657170273�0020021�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Alexandre Lissy # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser from .pages import RoadmapSearchPage, RoadmapResultsPage, RoadmapPage, RoadmapAmbiguity __all__ = ['JVMalin'] class JVMalin(Browser): DOMAIN = 'www.jvmalin.fr' PAGES = { 'http://www\.jvmalin\.fr/Itineraires/Recherche.*': RoadmapSearchPage, 'http://www\.jvmalin\.fr/Itineraires/Precision.*': RoadmapResultsPage, 'http://www\.jvmalin\.fr/route/vuesearch/result.*': RoadmapPage } def __init__(self, **kwargs): Browser.__init__(self, '', **kwargs) def get_roadmap(self, departure, arrival, filters): self.location('/Itineraires/Recherche') assert self.is_on_page(RoadmapSearchPage) self.page.search(departure, arrival, filters.departure_time, filters.arrival_time) assert self.is_on_page(RoadmapResultsPage) dest = '' try: dest = self.page.find_best() except RoadmapAmbiguity: self.page.resubmit_best_form() assert self.is_on_page(RoadmapResultsPage) dest = self.page.find_best() self.location(dest) roadmap = {} roadmap['steps'] = list(self.page.get_steps()) return roadmap def is_logged(self): """ Do not need to be logged """ return True ������������weboob-1.1/modules/jvmalin/module.py����������������������������������������������������������������0000664�0000000�0000000�00000003216�12657170273�0017613�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Alexandre Lissy # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.travel import CapTravel, RoadStep from weboob.tools.backend import Module from .browser import JVMalin __all__ = ['JVMalinModule'] class JVMalinModule(Module, CapTravel): NAME = 'jvmalin' MAINTAINER = u'Alexandre Lissy' EMAIL = 'github@lissy.me' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u"Multimodal public transportation for whole Région Centre, France" BROWSER = JVMalin def iter_roadmap(self, departure, arrival, filters): with self.browser: roadmap = self.browser.get_roadmap(departure, arrival, filters) for s in roadmap['steps']: step = RoadStep(s['id']) step.line = s['line'] step.start_time = s['start_time'] step.end_time = s['end_time'] step.departure = s['departure'] step.arrival = s['arrival'] step.duration = s['duration'] yield step ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jvmalin/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000020204�12657170273�0017421�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- import re import datetime from weboob.capabilities.travel import RoadmapError from weboob.tools.misc import to_unicode from weboob.deprecated.mech import ClientForm from weboob.deprecated.browser import Page class RoadmapAmbiguity(RoadmapError): def __init__(self, error): RoadmapError.__init__(self, error) class RoadmapSearchPage(Page): def search(self, departure, arrival, departure_time, arrival_time): match = -1 i = 0 for form in self.browser.forms(): try: if form.attrs['id'] == 'rech-iti': match = i except KeyError: pass i += 1 self.browser.select_form(nr=match) self.browser['Departure'] = departure self.browser['Destination'] = arrival time = None if departure_time: self.browser['sens'] = ['1'] time = departure_time elif arrival_time: self.browser['sens'] = ['-1'] time = arrival_time if time: try: self.browser['dateFull'] = '%02d/%02d/%d' % (time.day, time.month, time.year) self.browser['hour'] = ['%02d' % time.hour] self.browser['minute'] = ['%02d' % (time.minute - (time.minute % 5))] except ClientForm.ItemNotFoundError: raise RoadmapError('Unable to establish a roadmap with %s time at "%s"' % ('departure' if departure_time else 'arrival', time)) self.browser.submit() class RoadmapResultsPage(Page): def html_br_strip(self, text): return "".join([l.strip() for l in text.split("\n")]).strip().replace(' ', '%20') def find_best(self): if len(self.parser.select(self.document.getroot(), 'img.img-error')) > 0: if len(self.parser.select(self.document.getroot(), 'form#iti-ambi')) > 0: raise RoadmapAmbiguity('Ambigious stop name') else: raise RoadmapError('Error when submitting form') best = self.parser.select(self.document.getroot(), 'div.alerte-bloc-important div.bloc-iti') if len(best) == 0: best = self.parser.select(self.document.getroot(), 'div.bloc-iti') if len(best) == 0: raise RoadmapError('Unable to get the best roadmap') link = self.parser.select(best[0], 'a.btn-submit') if len(link) == 0: raise RoadmapError('Unable to get a link to best roadmap') return self.html_br_strip(link[0].attrib['href']) def resubmit_best_form(self): if len(self.parser.select(self.document.getroot(), 'img.img-error')) == 0: raise RoadmapError('No error reported!') ambi = None i = 0 for form in self.parser.select(self.document.getroot(), 'form'): if 'id' in form.attrib and form.attrib['id'] == 'iti-ambi': ambi = form break i += 1 if ambi is None: raise RoadmapError('No ambigous form!') props = self.parser.select(ambi, 'span.precision-arret input') if len(props) == 0: props = self.parser.select(ambi, 'span.precision-adresse input') if len(props) == 0: raise RoadmapError('Nothing to select to get a roadmap') self.browser.select_form(nr=i) propname = props[0].attrib['name'] propvalue = props[0].attrib['value'].encode('utf-8') self.browser[propname] = [ propvalue ] self.browser.submit() class RoadmapPage(Page): def get_steps(self): errors = [] # for p in self.parser.select(self.document.getroot(), 'p.errors'): # if p.text: # errors.append(p.text.strip()) if len(errors) > 0: raise RoadmapError('Unable to establish a roadmap: %s' % ', '.join(errors)) current_step = None i = 0 for tr in self.parser.select(self.document.getroot(), 'table.itineraire-detail tr'): if current_step is None: current_step = { 'id': i, 'start_time': datetime.datetime.now(), 'end_time': datetime.datetime.now(), 'line': '', 'departure': '', 'arrival': '', 'duration': datetime.timedelta() } if 'class' in tr.attrib: if 'bg-ligne' in tr.attrib['class']: continue if 'iti-map' in tr.attrib['class']: continue for td in self.parser.select(tr, 'td'): if 'class' not in td.attrib: continue if 'iti-inner' in td.attrib['class']: continue if 'cell-infos' in td.attrib['class']: if 'id' in td.attrib: if td.attrib['id'].find('MapOpenLink') >= 0: hasA = self.parser.select(td, 'a') if len(hasA) == 0: if len(current_step['line']) > 0 and \ len(current_step['departure']) > 0 and \ len(current_step['arrival']) > 0: current_step['line'] = to_unicode("%s : %s" % (current_step['mode'], current_step['line'])) del current_step['mode'] yield current_step i += 1 current_step = None continue if 'cell-horaires' in td.attrib['class']: # real start for heure in self.parser.select(td, 'span.heure'): if heure.attrib['id'].find('FromTime') >= 0: current_step['start_time'] = self.parse_time(heure.text) if heure.attrib['id'].find('ToTime') >= 0: current_step['end_time'] = self.parse_time(heure.text) for mode in self.parser.select(td, 'span.mode-locomotion img'): current_step['mode'] = mode.attrib['title'] if 'cell-details' in td.attrib['class']: # If we get a span, it's a line indication, # otherwise check for id containing LibDeparture or # LibDestination spans = self.parser.select(td, 'span.itineraire-ligne') if len(spans) == 1: line = self.html_br_strip(spans[0].text, " ").replace('Ligne ', '') if line.index('- ') == 0: line = re.sub(r'^- ', '', line) current_step['line'] = line elif 'id' in td.attrib: stops = self.parser.select(td, 'strong') stop = self.html_br_strip(stops[0].text, " ") if td.attrib['id'].find('LibDeparture') >= 0: current_step['departure'] = to_unicode(stop) if td.attrib['id'].find('LibDestination') >= 0: current_step['arrival'] = to_unicode(stop) duree = self.parser.select(td, 'span.duree strong') if len(duree) == 1: current_step['duration'] = self.parse_duration(duree[0].text) def html_br_strip(self, text, joining=""): return joining.join([l.strip() for l in text.split("\n")]).strip() def parse_time(self, time): time = self.html_br_strip(time) h, m = time.split('h') return datetime.time(int(h), int(m)) def parse_duration(self, dur): dur = self.html_br_strip(dur) m = re.match('(\d+)min', dur) if m: return datetime.timedelta(minutes=int(m.group(1))) m = re.match('(\d+)h(\d+)', dur) if m: return datetime.timedelta(hours=int(m.group(1)), minutes=int(m.group(2))) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/jvmalin/test.py������������������������������������������������������������������0000664�0000000�0000000�00000005245�12657170273�0017311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Alexandre Lissy # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import datetime from weboob.capabilities.travel import RoadmapFilters from weboob.tools.test import BackendTest class JVMalinTest(BackendTest): MODULE = 'jvmalin' def test_roadmap_cities(self): filters = RoadmapFilters() roadmap = list(self.backend.iter_roadmap('Tours', 'Orléans', filters)) self.assertTrue(len(roadmap) > 0) def test_roadmap_stop_intercity(self): filters = RoadmapFilters() roadmap = list(self.backend.iter_roadmap('Tours Jean-Jaurès', 'Orléans', filters)) self.assertTrue(len(roadmap) > 0) def test_roadmap_stop_intracity(self): filters = RoadmapFilters() roadmap = list(self.backend.iter_roadmap('Tours Jean-Jaurès', 'Polytech Tours', filters)) self.assertTrue(len(roadmap) > 0) def test_roadmap_stop_intracity2(self): filters = RoadmapFilters() roadmap = list(self.backend.iter_roadmap('J.P.Rameau', 'Polytech Tours', filters)) self.assertTrue(len(roadmap) > 0) def test_roadmap_names(self): filters = RoadmapFilters() roadmap = list(self.backend.iter_roadmap('Artannes Mairie', 'Château de Blois', filters)) self.assertTrue(len(roadmap) > 0) def test_roadmap_long(self): filters = RoadmapFilters() roadmap = list(self.backend.iter_roadmap('Chartres', 'Ballan-Miré', filters)) self.assertTrue(len(roadmap) > 0) def test_roadmap_departure(self): filters = RoadmapFilters() filters.departure_time = datetime.datetime.now() + datetime.timedelta(days=1) roadmap = list(self.backend.iter_roadmap('Chartres', 'Ballan-Miré', filters)) self.assertTrue(len(roadmap) > 0) def test_roadmap_arrival(self): filters = RoadmapFilters() filters.arrival_time = datetime.datetime.now() + datetime.timedelta(days=1) roadmap = list(self.backend.iter_roadmap('Chartres', 'Ballan-Miré', filters)) self.assertTrue(len(roadmap) > 0) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kickass/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015742�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kickass/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000000077�12657170273�0020057�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import KickassModule __all__ = ['KickassModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kickass/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000003231�12657170273�0017776�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2016 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.exceptions import BrowserHTTPNotFound from weboob.browser import PagesBrowser from weboob.browser.url import URL from weboob.browser.profiles import Firefox from .pages import SearchPage, TorrentPage __all__ = ['KickassBrowser'] class KickassBrowser(PagesBrowser): PROFILE = Firefox() TIMEOUT = 30 BASEURL = 'https://kat.cr/' search = URL('usearch/(?P<pattern>.*)/\?field=seeders&sorder=desc', SearchPage) torrent = URL('torrent-t(?P<id>.*).html', '.*-t[0-9]*\.html', TorrentPage) def iter_torrents(self, pattern): self.search.go(pattern=pattern) #print( self.page.content) return self.page.iter_torrents() def get_torrent(self, fullid): try: self.torrent.go(id=fullid) torrent = self.page.get_torrent() return torrent except BrowserHTTPNotFound: return �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kickass/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000004535�12657170273�0020104�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME ��IDATxkl{}kq&(` * "RQR&HIūQʣ*X4%<Jxpy8`ď뻻wwÝ.q\dT7ݿ4ڝ9s $H A $H ;<X@LyB\R3b:4XCN B 3抳^2x&'1KI-c7 !- xq(n+R7/J5߂9G�<�88 | 8GJ"&va 1Vp jʮJ�.V4e8NZ_4GdSVY(/=-7ذ4Cne[l<|950f)-#n*V"G7 ̕xR ;Lv42Q;Ǧ)avHWLI#s?z `//19!b#[.lJ*FEJ$dûXeCt)~sp+wX[r*0`T%Y:4(K1"�2up6O_ꯙϩdM<YImaB{D!%A/\%wh9+q_W@SBe,!zKF7^e]= d&6o݌{=WSMY: |9MK,AD�d2kjjVZy0r"Wp\C㱂2̣H9ilhh`ժUY}ʹsR(.k H):1;u7-�C.}u? g!0Ky@xpppDf477g?Kjkkimmw2ܯ9Rq>P?'cn(-% u` *,^&3- M56H\n!p7qn:o ?dJeX_%N@X фh;DGѹuii3e`$sr)PcZ~g, Dc-^۷ˋ9+2͸i"D{~Qj`2�536`+:ﲌ[)u.'X T[U R|i>,R%=fr*C<t:=J5kt.ZS8c" 6ȓ2?k죇}bL#.YFzg %svR#+fכzvmyZ+DwAvȵl`yWcH?0'7` pDb@Lb�C R @#XH"Ot p#8XlI .?*54;mk cilWz]{(;.xZfg||\hlٲ3co>PFG\#(RGy4m>8hxrԄmWW�J h2դAb )5ᦾbBdKn?2uJ  ;Sk MMM7o>~&:Ϙ$#Ìe?:?Fw d^"t9A֜QIq2K-JaWAJ)U@-TR*cP½t L7 c-`KHacER�"AS]y(}2� <fL.7ދL*7+GWJMMB@)TVSB| n7Jϳ~ hi%Pd{ 4&-*Usggfږ2e6uh K zWޟH�}H *&gJ,ge6.h2w0*aA)ĥ@Dk%$ns>}RPPQ 򁖖>7 ;�i�m9  :ɻf: ?)ȈPS7ൽJFd<<n |<C9!C8ΏuO.:4@UXpr9&-hT!j[ާ-_@<i_!lm̱^zyQvlf̓&mEV/XO'L_?Kuys-6-ݱEhGv*<5Zkc|#G $H A $H /Sf����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kickass/module.py����������������������������������������������������������������0000664�0000000�0000000�00000004146�12657170273�0017606�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2016 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.torrent import CapTorrent, Torrent from weboob.tools.backend import Module from .browser import KickassBrowser from urllib import quote_plus #from contextlib import closing #from gzip import GzipFile __all__ = ['KickassModule'] class KickassModule(Module, CapTorrent): NAME = 'kickass' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'Kickass Torrents BitTorrent tracker' LICENSE = 'AGPLv3+' BROWSER = KickassBrowser def get_torrent(self, id): return self.browser.get_torrent(id) def get_torrent_file(self, id): torrent = self.browser.get_torrent(id) if not torrent: return None resp = self.browser.open(torrent.url) #headers = response.info() #if headers.get('Content-Encoding', '') == 'gzip': # with closing(GzipFile(fileobj=response, mode='rb')) as gz: # data = gz.read() #else: # data = response.read() return resp.content def iter_torrents(self, pattern): return self.browser.iter_torrents(quote_plus(pattern.encode('utf-8'))) def fill_torrent(self, torrent, fields): if 'description' in fields or 'files' in fields: torrent = self.browser.get_torrent(torrent.id) return torrent OBJECTS = { Torrent: fill_torrent } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kickass/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000010431�12657170273�0017412�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2016 Julien Veyssier, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.torrent import Torrent from weboob.capabilities.base import NotLoaded, NotAvailable from weboob.tools.misc import get_bytes_size from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.pages import HTMLPage from weboob.browser.filters.standard import Regexp, CleanText, Type class SearchPage(HTMLPage): @method class iter_torrents(ListElement): item_xpath = '//table[has-class("data")]//tr[@class="odd" or @class="even"]' class item(ItemElement): klass = Torrent obj_id = Regexp(CleanText('.//div[@class="torrentname"]//a[@class="cellMainLink"]/@href'), '.*-t([0-9]*).html') obj_name = CleanText('.//a[@class="cellMainLink"]', default=NotAvailable) obj_magnet = CleanText('.//div[has-class("iaconbox")]//a[starts-with(@href,"magnet")]/@href', default=NotAvailable) obj_seeders = CleanText('.//td[has-class("green") and has-class("center")]', default=NotAvailable) & Type(type=int) obj_leechers = CleanText('.//td[has-class("red") and has-class("center")]', default=NotAvailable) & Type(type=int) obj_description = NotLoaded obj_files = NotLoaded def obj_url(self): href = CleanText('.//div[has-class("iaconbox")]//a[starts-with(@href,"//")]/@href')(self) return 'https:%s'%href def obj_size(self): rawsize = CleanText('./td[2]')(self) rawsize = rawsize.replace(',','.') nsize = float(rawsize.split()[0]) usize = rawsize.split()[-1].upper() size = get_bytes_size(nsize,usize) return size obj_filename = CleanText(Regexp(CleanText('.//div[has-class("iaconbox")]//a[starts-with(@href,"//")]/@href'), '.*title=(.*)'), default=NotAvailable) class TorrentPage(HTMLPage): @method class get_torrent(ItemElement): klass = Torrent obj_description = CleanText('//div[@id="desc"]', default=NotAvailable) obj_seeders = CleanText('(//div[has-class("seedBlock")]/strong)[1]') & Type(type=int) obj_leechers = CleanText('(//div[has-class("leechBlock")]/strong)[1]') & Type(type=int) obj_name = CleanText('//h1[has-class("novertmarg")]//span', default=NotAvailable) obj_magnet = CleanText('//div[has-class("downloadButtonGroup")]//a[starts-with(@href,"magnet")]/@href', default=NotAvailable) obj_id = Regexp(CleanText('//h1[has-class("novertmarg")]/a/@href'), '.*-t([0-9]*)\.html') def obj_url(self): href = CleanText('//div[has-class("downloadButtonGroup")]//a[starts-with(@href,"//")]/@href')(self) return u'https:%s'%href def obj_size(self): rawsize = CleanText('//span[has-class("folder") or has-class("folderopen")]')(self) rawsize = rawsize.split(': ')[-1].split(')')[0].strip() rawsize = rawsize.replace(',','.') nsize = float(rawsize.split()[0]) usize = rawsize.split()[-1].upper() size = get_bytes_size(nsize,usize) return size def obj_files(self): res = [] for f in Type('//td[has-class("torFileName")]', type=list)(self): res.append(CleanText(f)(self)) return res obj_filename = CleanText(Regexp(CleanText('//div[has-class("downloadButtonGroup")]//a[starts-with(@href,"//")]/@href'), '.*title=(.*)'), default=NotAvailable) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kickass/test.py������������������������������������������������������������������0000664�0000000�0000000�00000003550�12657170273�0017276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.base import NotLoaded import urllib from random import choice class KickassTest(BackendTest): MODULE = 'kickass' def test_torrent(self): torrents = list(self.backend.iter_torrents('debian')) for torrent in torrents: path, qs = urllib.splitquery(torrent.url) assert path.endswith('.torrent') if qs: assert torrent.filename assert torrent.id assert torrent.name assert torrent.description is NotLoaded full_torrent = self.backend.get_torrent(torrent.id) # do not assert torrent.name is full_torrent.name # (or even that one contains another), it isn't always true! assert full_torrent.name assert full_torrent.url assert full_torrent.description is not NotLoaded # get the file of a random torrent # from the list (getting them all would be too long) if len(torrents): torrent = choice(torrents) self.backend.get_torrent_file(torrent.id) ��������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kiwibank/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016111�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kiwibank/README.md���������������������������������������������������������������0000664�0000000�0000000�00000000236�12657170273�0017371�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# [weboob-kiwibank](https://github.com/infertux/weboob-kiwibank) [Kiwibank](http://www.kiwibank.co.nz/) module for the [Weboob](http://weboob.org/) project ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kiwibank/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0020221�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Cédric Félizard # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import KiwibankModule __all__ = ['KiwibankModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kiwibank/browser.py��������������������������������������������������������������0000664�0000000�0000000�00000003427�12657170273�0020154�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Cédric Félizard # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, AccountPage, HistoryPage __all__ = ['Kiwibank'] class HistoryUnavailable(Exception): pass class Kiwibank(LoginBrowser): BASEURL = 'https://www.ib.kiwibank.co.nz/mobile/' TIMEOUT = 30 login = URL('login/', LoginPage) login_error = URL('login-error/', LoginPage) accounts = URL('accounts/$', AccountPage) account = URL('/accounts/view/[0-9A-F]+$', HistoryPage) def do_login(self): self.login.stay_or_go() self.page.login(self.username, self.password) if self.login.is_here() or self.login_error.is_here(): raise BrowserIncorrectPassword() @need_login def get_accounts(self): self.accounts.stay_or_go() return self.page.get_accounts() @need_login def get_history(self, account): if account._link is None: raise HistoryUnavailable() self.location(account._link) return self.page.get_history() �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kiwibank/favicon.png�������������������������������������������������������������0000664�0000000�0000000�00000003142�12657170273�0020244�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD�h��i_H��� pHYs�� �� ����tIME 0ś`���iTXtComment�����Created with GIMPd.e��IDATx{LSWǿ>n^˫"%B'2$Aӱe4ӱmfmn&{gq˒mL]dqqht KT[@zy}GF[.%={ιs~ReG4Lc1͍� ��� ��� ��� ��� �3)fm(lD)&@J5hYz!ǃI(UC򑞐?E[@)(f^lC1L@- Ű @CYл$"ft 4*`=/L]^hG$nvU=!9ݘ�J@�jVV&k,{l6ǘs>_}[f<^* =FB x~Z|M�x6YSQI��W.BCcUbPRH"VcjbxtyE xR -8p$PUZbfj82 xhDh؄1BTHGiA+2_D ]=XVՖ5e}`ׁ饈S,z[C4l"\=V'KT(4oGQHh9<>'*?i  +w+=&!ƄKBm xz>gVm?_FC[hhcjgq۟Ըi1j`E`*3MK՘&Z60$EmT.z1l> @΢_=^&p霭8X(,2m_6AN?ly<FuN ˸S}#Yӷ9^pV_ K#tJ=( h#&wg@)*{ט;;ta b31(܎ pJ#8L4߯Au󑩽zzT(+HUXcfp–l8V el q^'jM\^Gt�xWAS9<JY1Vys:>pJ#\i:2{;;aݼ�CKE) <|pӽhKwʱ<,dZ$hjV*UqXQ6~[^'^D=f6SBT)c ܘlfPIl|x=#'qT7Q{(8NO׭&l59xPg=�ia+5쟭ˍxd6:|!5Yt6b}}Y"¢Ǡqc^bD/@ ⷄHqvg5;ZZk8}c?N z~*4ńT{ppkVV4vE,nGk Xi tdN!(wIRԃ Q^wl@Ns#��� ��� ��� ��� ��`zߦPs'����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kiwibank/module.py���������������������������������������������������������������0000664�0000000�0000000�00000003517�12657170273�0017756�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Cédric Félizard # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Kiwibank __all__ = ['KiwibankModule'] class KiwibankModule(Module, CapBank): NAME = 'kiwibank' MAINTAINER = u'Cédric Félizard' EMAIL = 'cedric@felizard.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Kiwibank' CONFIG = BackendConfig( ValueBackendPassword('login', label='Access number', masked=False), ValueBackendPassword('password', label='Password'), ) BROWSER = Kiwibank def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts() def get_account(self, _id): return find_object(self.browser.get_accounts(), id=_id, error=AccountNotFound) def iter_history(self, account): for transaction in self.browser.get_history(account): yield transaction ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kiwibank/pages.py����������������������������������������������������������������0000664�0000000�0000000�00000006277�12657170273�0017576�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Cédric Félizard # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import datetime import re from decimal import Decimal from weboob.browser.pages import HTMLPage, LoggedPage from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import AmericanTransaction as EnglishTransaction __all__ = ['LoginPage', 'AccountPage', 'HistoryPage'] class LoginPage(HTMLPage): def login(self, username, password): form = self.get_form(name='aspnetForm') form['ctl00$chi$txtUserName'] = username form['ctl00$chi$txtPassword'] = password form.submit() class AccountPage(LoggedPage, HTMLPage): def get_accounts(self): for el in self.doc.getroot().cssselect('div#content tr.row'): account = Account() balance = el.cssselect('td.Balance')[0].text account.balance = Decimal(Transaction.clean_amount(balance)) account.id = el.cssselect('span')[0].text.strip() account.currency = u'NZD' # TODO: handle other currencies if el.cssselect('td.AccountName > a'): label_el = el.cssselect('td.AccountName > a')[0] account._link = label_el.get('href') else: label_el = el.cssselect('td.AccountName')[0] account._link = None account.label = unicode(label_el.text.strip()) yield account class HistoryPage(LoggedPage, HTMLPage): def get_history(self): # TODO: get more results from "next" page, only 15 transactions per page for el in self.doc.getroot().cssselect('div#content tr.row'): transaction = Transaction() label = unicode(el.cssselect('td.tranDesc')[0].text) transaction.label = label for pattern, _type in Transaction.PATTERNS: match = pattern.match(label) if match: transaction.type = _type break date = el.cssselect('td.tranDate')[0].text transaction.date = datetime.datetime.strptime(date, '%d %b \'%y') amount = el.cssselect('td.tranAmnt')[0].text transaction.amount = Decimal(Transaction.clean_amount(amount)) yield transaction class Transaction(EnglishTransaction): PATTERNS = [ (re.compile(r'^POS W/D (?P<text>.*)'), EnglishTransaction.TYPE_CARD), (re.compile(r'^ATM W/D (?P<text>.*)'), EnglishTransaction.TYPE_WITHDRAWAL), (re.compile(r'^(PAY|FROM) (?P<text>.*)'), EnglishTransaction.TYPE_TRANSFER), ] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/kiwibank/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000002011�12657170273�0017434�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Cédric Félizard # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest __all__ = ['KiwibankTest'] class KiwibankTest(BackendTest): MODULE = 'kiwibank' def test_kiwibank(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lacentrale/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016424�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lacentrale/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000000105�12657170273�0020531�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import LaCentraleModule __all__ = ['LaCentraleModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lacentrale/browser.py������������������������������������������������������������0000664�0000000�0000000�00000006017�12657170273�0020465�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vicnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.deprecated.browser import Browser from .pages import MainPage, ListingAutoPage, AnnoncePage __all__ = ['LaCentraleBrowser'] # I manage urls and page location, then trasnfert to page class LaCentraleBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'www.lacentrale.fr' ENCODING = 'windows-1252' PAGES = {'http://www.lacentrale.fr/': MainPage, 'http://www.lacentrale.fr/listing_auto.php?.*': ListingAutoPage, 'http://www.lacentrale.fr/auto-occasion-annonce-.*': AnnoncePage, } def iter_products(self, criteria): if not self.is_on_page(MainPage): self.location('/') assert self.is_on_page(MainPage) return self.page.iter_products(criteria) def _buildUrl(self, product, request, criteria): if criteria in product._criteria: return '&' + request.format(product._criteria.get(criteria)) return '' def iter_prices(self, product): # convert product criteria to url encoding if not self.is_on_page(ListingAutoPage): #TODO use urllib.urlencode(data) ? url = '/listing_auto.php?num=1&witchSearch=0' url += self._buildUrl(product, 'Citadine={}', 'urban') url += self._buildUrl(product, 'prix_maxi={}', 'maxprice') url += self._buildUrl(product, 'km_maxi={}', 'maxdist') url += self._buildUrl(product, 'nbportes=%3D{}', 'nbdoors') url += self._buildUrl(product, 'cp={}', 'dept') url += self._buildUrl(product, 'origine={}', 'origin') #print url self.location(url) assert self.is_on_page(ListingAutoPage) numpage = 1 while True: # parse the current page for price in self.page.iter_prices(product, numpage): yield price # check if next page numpage = self.page.get_next() if not numpage: break url = re.sub('num=(\d+)', 'num={}'.format(numpage), url) self.location(url) assert self.is_on_page(ListingAutoPage) def get_price(self, id): #/auto-occasion-annonce-23440064.html self.location('/auto-occasion-annonce-'+id+'.html') assert self.is_on_page(AnnoncePage) return self.page.get_price(id) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lacentrale/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000040373�12657170273�0020566�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME .֖O/���tEXtComment�Created with GIMPW�� �IDATx@@��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������^^����������^^5���>���������� ������������������������������������������������������������������������������������������������������������������^^���^���<������������������������������������������������� �������������������� �����������������������������������������������������������������������������������������������������������������������������������������������������^^U���u�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������}��������������������������������������������^^s���_�������������������������������������������������������� �����������������������������(1""������������������������������������������������������^^����������   ����  �������������������������������������������������������������������������������������������������������������������� V;;����������>������������������������������������^^i���i���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� P77����������F�����������������������������������i�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������0����������>����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������8��������������������������������^^�������� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ������������������������������������������������������������������������������������������������������������������������������������������������� �������(������������������������������������������������� ������������ �%�.�������������������������������������������������������������������������������������������������������������������������� ���������������������������������������������������������������������������B �-� �������������������������������������������������������������������������������������������������������������������������������� ^^��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� �����������%����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������&�������������������������������/������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������=����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ����������������������� ��������������������������������� �������������������������������������������������������������������������������������������������������������������������������^^������������������������������������������������������������� �������������������������������������������������������������������������������������������� � � � �����������������������������������������������������������������������������������%�+��������������������� �%���������������������������������������������������������� �<<� JJ�))�� �����������֟������ �����������������������������������������������������������������3�������������������"���������������������������������������������������������� �$SS�,ee� �������������������������������������FF���������������������������������������������*�������������������������������������������������� ����������������������������������������������������"OO�$SS� ������������������������������������������������������������������ ��������������������������������������������������������������������������������������������������������������������������������������������$$�/kk�EE� ����������������������������������������������������������������������������G���� ������������������������������������������������������������������������������������������������������??�CC� �������������������������������������������������������������������������������� ��������������������������������������������������������������������������������������������������>>� ����������侾�Ύ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������77�--�����������٨������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� �"LL�����������٧���������������������������������������������������������������� ������������������������������������������������������������������������������������������� ���������������������������������������������!!�..��������֟���������������������������������������������������������������� ����������������������������������������������� ����������������������������������������������������������������������������������66� ������������������������������������������������������������������������lt�� �IDAT�������������������� ^^5����������������������������^^���������������������������������������� ����������������������������������������%%�����������������������������������������������������������������������������������������������N�������������������������������%����������������������������������������������� � ������������������������������������������ ���������������������������������������������������������������������������������� ������������������������������������������&������������������������������������������������������ ��������������������������������������������������������������������������������������������������������������������������������� �������������������������������������������*�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ������������������������������������������ ����������������������������������������������� ������������������������������������������������������������ ��������������������������������������������������������������������������,�����������������������������������������������������������������������������������������"���������������������������������������������������������� ��������������������������������������������������������������������������������������������������������������������������������������������������������������4� �������������������������������������������������������������99� ��������������������������������������������������������������������������������������������������������������������������������������������������������� ����������������������������������������������������������==�!MM���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������+cc�%%��������������������������������������������������������������������������������������������������������������� ������������������������������������������������������������������������������������Ҙ��������&&�+aa���������������������������������������������������������������������������������������������������������� ������������������������������������������������������������������������������������������������ܮ����������� JJ�$RR����������������������������������������������������������� ���$^^��������������������������������������������������������������������������������������������������������إ������������4ww�G�7}}�@@� ��������������������������������������������������>������������������������������������������� ���������������������������� �����������������������՝� � �������33�//�"OO�������������������� ������)�����������������������������������  �������� �������������������������������������������������������������> �+� ���٧�-ff� ����������� � �22��������൵�⻻������������������������������������������������������������������������������������������������������������������������������������������ �*������֠��#OO� ������������������������� � ���������������������*����������������������������������������������� �8 ��������������������������������������������������������������������������������������В�ϑ������������������������� ������� ������ ���������������������������������������������������(�X�������������������������������������������������������������������������������ԛ�ܮ� �%%� � � � ������������� ��������������������������������������������������������������0 �!������������������������������������������ �> �!�������������������������������''�11  ������������������#������� �����������������������������������������������������������������G �@ ������������������������%��������������������������������������������������������������������!�������������������������������������������������(����������������������������������&���������������������������������������������������������������������������������������������������������������������������������������� ���������������������������������������������������!�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������( ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������;((������������������������������������������������������>++ ������������������������������������������������������������������������������������������������������������������������������������������������������� ���������������������������������������������������������� 3##����������������������������������������������������������������������������������������������������������������������������������������������������������������������-D.. �������������������������������������������������^^�������������V����������������������������������������������������������������������������������������������������������������������������������������  &.��������������}������������������������������������������������^^���O������������ ����� ����� '!����������������������������������������������������������������������������������^^5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������^^5���^���/����������������� ������ ������ ���������������������������������������� ������������������������������������������ �����������������������������������������������������������������������������������������������������������������������������������������������������������^^5���4������(������������������������^^���%������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Bx���KIDAT�����������������������������������������������������������������������EG����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lacentrale/module.py�������������������������������������������������������������0000664�0000000�0000000�00000005607�12657170273�0020273�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vicnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.pricecomparison import CapPriceComparison, Price from weboob.tools.backend import Module #from weboob.tools.value import Value from .browser import LaCentraleBrowser __all__ = ['LaCentraleModule'] # I implement capability class LaCentraleModule(Module, CapPriceComparison): NAME = 'lacentrale' MAINTAINER = u'Vicnet' EMAIL = 'vo.publique@gmail.com' VERSION = '1.1' DESCRIPTION = 'Vehicule prices at LaCentrale.fr' LICENSE = 'AGPLv3+' BROWSER = LaCentraleBrowser # inherited from CapPriceComparison def search_products(self, patternString=None): # convert pattern to criteria criteria = {} patterns = [] if patternString: patterns = patternString.split(',') for pattern in patterns: pattern = pattern.lower() if u'€' in pattern: criteria['maxprice'] = pattern[:pattern.find(u'€')].strip() if u'km' in pattern: criteria['maxdist'] = pattern[:pattern.find(u'km')].strip() if u'p' in pattern[-1]: # last char = p criteria['nbdoors'] = pattern[:pattern.find(u'p')].strip() if u'cit' in pattern: criteria['urban'] = 'citadine&SS_CATEGORIE=40' if u'dep' in pattern: criteria['dept'] = re.findall('\d+', pattern)[0] if u'pro' in pattern: criteria['origin'] = 1 if u'part' in pattern: criteria['origin'] = 0 #print criteria # browse product with self.browser: for product in self.browser.iter_products(criteria): yield product # inherited from CapPriceComparison def iter_prices(self, product): # inherited from CapPriceComparison with self.browser: return self.browser.iter_prices(product) # inherited from CapPriceComparison def get_price(self, id): # id is a url code part for one car page with self.browser: return self.browser.get_price(id) def fill_price(self, price, fields): return self.get_price(price.id) OBJECTS = {Price: fill_price, } �������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lacentrale/pages.py��������������������������������������������������������������0000664�0000000�0000000�00000013623�12657170273�0020102�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vicnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from decimal import Decimal import re from weboob.deprecated.browser import Page from weboob.capabilities import NotAvailable, NotLoaded from weboob.capabilities.pricecomparison import Product, Price, Shop # I manage main page, ie do nothing yet class MainPage(Page): def iter_products(self, criteria): product = Product(1) # TODO check if criteria exists in main page # and get the GET keyword to fill request ? product.name = unicode('Occasion') product._criteria = criteria yield product def get_decimal(s): return re.findall(r'\d+', s.replace(' ', ''))[0] def new_shop(id): shop = Shop(id) shop.set_empty_fields(NotLoaded) return shop def new_price(id, product, cost, title): price = Price(id) price.product = product price.cost = Decimal(get_decimal(cost)) price.currency = u'EUR' price.message = unicode(title) price.set_empty_fields(NotAvailable) price.shop = new_shop(id) return price # I manage listing page and extract information class ListingAutoPage(Page): def _extract(self, tr, name): 'Extract content from td element with class name' td = tr.cssselect('td.' + name + ' a') if not td: return '' return td[-1].text_content().strip() def _extract_id(self, tr): tdas = tr.cssselect('td.lcbrand a') if tdas is None or len(tdas) == 0: return None tda = tdas[0] m = re.search('annonce-(\d+)\.html', tda.get('href')) if not m: return None return m.group(1) def iter_prices(self, product, numpage): for tr in self.document.getroot().cssselect('tr.lcline[id],tr.lclineJB[id],tr.lclineJ[id],tr.lclineB[id]'): id = self._extract_id(tr) title = self._extract(tr, 'lcbrand') if not title: continue title += ', ' + self._extract(tr, 'lcmodel') ntr = tr.getnext() title += ', ' + self._extract(ntr, 'lcversion') title += ', ' + self._extract(tr, 'lcyear') dist = self._extract(tr, 'lcmileage') + 'km' title += ', ' + dist.replace(' ', '') cost = ', ' + self._extract(tr, 'lcprice') yield new_price(id, product, cost, title) def get_next(self): for a in self.document.getroot().cssselect('a.page'): s = a.getprevious() if s is not None and s.tag == 'span': m = re.search('num=(\d+)', a.get('href')) if not m: return None return int(m.group(1)) return None # I manage one car page (annonce) )and extract information class AnnoncePage(Page): def _extract(self, e, name): 'Extract content from li element with class name' li = e.cssselect('li.' + name) if not li: return '' return li[0].text_content().strip() def _extract_info(self, e, name): 'Extract content from InfoLib' for td in e.cssselect('td.InfoLib'): if name in td.text_content(): ntd = td.getnext() if ntd is None: continue return ntd.text_content().strip() return None def _extract_vendor(self, e, name): 'Extract content from VendorLib' for span in e.cssselect('span.VendeurLib'): if name in span.text_content(): li = span.getparent() if li is None: continue # get all text s = li.text_content() # get text without header s = s[len(span.text_content())+1:] # special case for not pro if '\n' in s: s = s[:s.find('\n')] return s.strip() return None def get_shop(self, id): shop = Shop(id) for e in self.document.getroot().cssselect('div#Vendeur'): shop.name = self._extract_vendor(e, 'Nom') + '(' + self._extract_vendor(e, 'Vendeur') + ')' shop.location = '' for adr in self.document.getroot().cssselect('span#AdresseL1,span#AdresseL2'): if shop.location: shop.location += ', ' shop.location += adr.text_content().strip() for tel in self.document.getroot().cssselect('span.Tel'): s = tel.text_content().strip() if shop.location: shop.location += ', ' shop.location += re.sub('\s+', ' ', s) shop.set_empty_fields(NotAvailable) return shop def get_price(self, id): for e in self.document.getroot().cssselect('div#DescBar'): product = Product(1) product.name = unicode('Occasion') cost = self._extract(e, 'PriceLc') title = self._extract(e, 'BrandLc') title += ', ' + self._extract(e, 'modeleCom') title += ', ' + self._extract_info(e, 'Version') title += ', ' + self._extract_info(e, 'Ann') title += ', ' + get_decimal(self._extract_info(e, 'Kilom')) + 'km' price = new_price(id, product, cost, title) price.shop = self.get_shop(id) return price �������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lacentrale/test.py���������������������������������������������������������������0000664�0000000�0000000�00000002116�12657170273�0017755�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vicnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class LaCentraleTest(BackendTest): MODULE = 'lacentrale' def test_lacentrale(self): products = list(self.backend.search_products('1000€,pro')) self.assertTrue(len(products) > 0) product = products[0] prices = list(self.backend.iter_prices(product)) self.assertTrue(len(prices) > 0) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015064�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000001427�12657170273�0017201�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import LCLModule __all__ = ['LCLModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000017553�12657170273�0017134�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon, Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import requests import urllib from urlparse import urlsplit, parse_qsl from weboob.exceptions import BrowserIncorrectPassword from weboob.browser import LoginBrowser, URL, need_login from weboob.capabilities.bank import Account from .pages import LoginPage, AccountsPage, AccountHistoryPage, \ CBListPage, CBHistoryPage, ContractsPage, BoursePage, \ AVPage, AVDetailPage, DiscPage, NoPermissionPage, RibPage, \ HomePage __all__ = ['LCLBrowser','LCLProBrowser'] # Browser class LCLBrowser(LoginBrowser): BASEURL = 'https://particuliers.secure.lcl.fr' VERIFY = False login = URL('/outil/UAUT/Authentication/authenticate', '/outil/UAUT\?from=.*', '/outil/UWER/Accueil/majicER', '/outil/UWER/Enregistrement/forwardAcc', LoginPage) contracts = URL('/outil/UAUT/Contrat/choixContrat.*', '/outil/UAUT/Contract/getContract.*', '/outil/UAUT/Contract/selectContracts.*', '/outil/UAUT/Accueil/preRoutageLogin', '.*outil/UAUT/Contract/routing', ContractsPage) home = URL('/outil/UWHO/Accueil/', HomePage) accounts = URL('/outil/UWSP/Synthese', AccountsPage) history = URL('/outil/UWLM/ListeMouvements.*/accesListeMouvements.*', '/outil/UWLM/DetailMouvement.*/accesDetailMouvement.*', '/outil/UWLM/Rebond', AccountHistoryPage) rib = URL('/outil/UWRI/Accueil/detailRib', '/outil/UWRI/Accueil/listeRib', RibPage) cb_list = URL('/outil/UWCB/UWCBEncours.*/listeCBCompte.*', CBListPage) cb_history = URL('/outil/UWCB/UWCBEncours.*/listeOperations.*', CBHistoryPage) skip = URL('/outil/UAUT/Contrat/selectionnerContrat.*', '/index.html') no_perm = URL('/outil/UAUT/SansDroit/affichePageSansDroit.*', NoPermissionPage) bourse = URL('https://bourse.secure.lcl.fr/netfinca-titres/servlet/com.netfinca.frontcr.synthesis.HomeSynthesis', 'https://bourse.secure.lcl.fr/netfinca-titres/servlet/com.netfinca.frontcr.account.*', '/outil/UWBO.*', BoursePage) disc = URL('https://bourse.secure.lcl.fr/netfinca-titres/servlet/com.netfinca.frontcr.login.ContextTransferDisconnect', '/outil/UAUT/RetourPartenaire/retourCar', DiscPage) assurancevie = URL('/outil/UWVI/AssuranceVie/accesSynthese', AVPage) avdetail = URL('https://ASSURANCE-VIE-et-prevoyance.secure.lcl.fr.*', 'https://assurance-vie-et-prevoyance.secure.lcl.fr.*', '/outil/UWVI/Routage', AVDetailPage) TIMEOUT = 30.0 def __init__(self, *args, **kwargs): if hasattr(requests.packages.urllib3.contrib, 'pyopenssl') \ and ':RC4' not in requests.packages.urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST: requests.packages.urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST += ':RC4' super(LCLBrowser, self).__init__(*args, **kwargs) def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.password.isdigit() # we force the browser to go to login page so it's work even # if the session expire self.login.go() if not self.page.login(self.username, self.password) or \ (self.login.is_here() and self.page.is_error()) : raise BrowserIncorrectPassword("invalid login/password.\nIf you did not change anything, be sure to check for password renewal request\non the original web site.\nAutomatic renewal will be implemented later.") self.accounts.stay_or_go() @need_login def connexion_bourse(self): self.location('/outil/UWBO/AccesBourse/temporisationCar?codeTicker=TICKERBOURSECLI') if self.no_perm.is_here(): return False self.location(self.page.get_next()) self.bourse.stay_or_go() return True def deconnexion_bourse(self): self.disc.stay_or_go() self.page.come_back() self.page.come_back() @need_login def get_accounts_list(self): self.assurancevie.stay_or_go() if self.no_perm.is_here(): self.logger.warning('Life insurances are unavailable.') else: for a in self.page.get_list(): yield a self.accounts.stay_or_go() accounts = list() for acc in self.page.get_list(): self.location('/outil/UWRI/Accueil/') self.rib.go(data={'compte': '%s/%s/%s' % (acc.id[0:5],acc.id[5:11],acc.id[11:])}) if self.rib.is_here(): acc.iban = self.page.get_iban() accounts.append(acc) if self.connexion_bourse(): acc = list(self.page.populate(accounts)) self.deconnexion_bourse() # Disconnecting from bourse portal before returning account list # to be sure that we are on the banque portal for a in acc: yield a else: for a in accounts: yield a @need_login def get_history(self, account): if not account._link_id: return self.location(account._link_id) for tr in self.page.get_operations(): yield tr for tr in self.get_cb_operations(account, 1): yield tr @need_login def get_cb_operations(self, account, month=0): """ Get CB operations. * month=0 : current operations (non debited) * month=1 : previous month operations (debited) """ for link in account._coming_links: v = urlsplit(self.absurl(link)) args = dict(parse_qsl(v.query)) args['MOIS'] = month self.location('%s?%s' % (v.path, urllib.urlencode(args))) for tr in self.page.get_operations(): yield tr for card_link in self.page.get_cards(): self.location(card_link) for tr in self.page.get_operations(): yield tr def disc_from_AV_investment_detail(self): self.page.come_back() self.page.sub() self.page.come_back() @need_login def get_investment(self, account): if account.type == Account.TYPE_LIFE_INSURANCE and account._form: self.assurancevie.stay_or_go() account._form.submit() self.page.sub() self.page.sub() for inv in self.page.iter_investment(): yield inv self.disc_from_AV_investment_detail() elif account._market_link: self.connexion_bourse() self.location(account._market_link) for inv in self.page.iter_investment(): yield inv self.deconnexion_bourse() class LCLProBrowser(LCLBrowser): BASEURL = 'https://professionnels.secure.lcl.fr' #We need to add this on the login form IDENTIFIANT_ROUTING = 'CLA' def __init__(self, *args, **kwargs): super(LCLProBrowser, self).__init__(*args, **kwargs) self.session.cookies.set("lclgen","professionnels") �����������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/enterprise/������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017244�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/enterprise/__init__.py�������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021343�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/enterprise/browser.py��������������������������������������������������������0000664�0000000�0000000�00000011763�12657170273�0021311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon, Pierre Mazière, Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from urllib import urlencode from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import HomePage, MessagesPage, LogoutPage, LogoutOkPage, \ AlreadyConnectedPage, ExpiredPage, MovementsPage, RootPage __all__ = ['LCLEnterpriseBrowser'] class LCLEnterpriseBrowser(Browser): BASEURL = 'https://entreprises.secure.lcl.fr' CERTHASH = ['04e3509c20ac8bdbdb3d0ed37bc34db2dde5ed4bc4c30a3605f63403413099a9', '5fcf4a9ceeec25e406a04dffe0c6eacbdf72d11d394cd049701bfbaba3d853d9', '774ac6f1c419083541a27d95672a87a5edf5c82d948368008eab2764e65866f9', '736ead61d4347035622500a2ed0f251317fa8dfa3e8c5832b2093bb6d269e00e', '3db256edfeb7ba255625724b7e62d4dab229557226336ba87b9753006721f16f'] ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] def __init__(self, *args, **kwargs): BASEURL = self.BASEURL.rstrip('/') self.PROTOCOL, self.DOMAIN = BASEURL.split('://', 2) self.PAGES_REV = { LogoutPage: BASEURL + '/outil/IQEN/Authentication/logout', LogoutOkPage: BASEURL + '/outil/IQEN/Authentication/logoutOk', HomePage: BASEURL + '/indexcle.html', MessagesPage: BASEURL + '/outil/IQEN/Bureau/mesMessages', MovementsPage: BASEURL + '/outil/IQMT/mvt.Synthese/syntheseMouvementPerso', } self.PAGES = { self.PAGES_REV[HomePage]: HomePage, self.PAGES_REV[LogoutPage]: LogoutPage, self.PAGES_REV[LogoutOkPage]: LogoutOkPage, self.PAGES_REV[MessagesPage]: MessagesPage, self.PAGES_REV[MovementsPage]: MovementsPage, BASEURL + '/outil/IQMT/mvt.Synthese/paginerReleve': MovementsPage, BASEURL + '/': RootPage, BASEURL + '/outil/IQEN/Authentication/dejaConnecte': AlreadyConnectedPage, BASEURL + '/outil/IQEN/Authentication/sessionExpiree': ExpiredPage, } Browser.__init__(self, *args, **kwargs) self._logged = False def deinit(self): if self._logged: self.logout() def is_logged(self): if self.page: ID_XPATH = '//div[@id="headerIdentite"]' self._logged = bool(self.page.document.xpath(ID_XPATH)) return self._logged return False def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(HomePage): self.location('/indexcle.html', no_login=True) self.page.login(self.username, self.password) if self.is_on_page(AlreadyConnectedPage): raise BrowserIncorrectPassword("Another session is already open. Please try again later.") if not self.is_logged(): raise BrowserIncorrectPassword( "Invalid login/password.\n" "If you did not change anything, be sure to check for password renewal request\n" "on the original website.\n" "Automatic renewal will be implemented later.") def logout(self): self.location(self.PAGES_REV[LogoutPage], no_login=True) self.location(self.PAGES_REV[LogoutOkPage], no_login=True) assert self.is_on_page(LogoutOkPage) def get_accounts_list(self): return [self.get_account()] def get_account(self, id=None): if not self.is_on_page(MovementsPage): self.location(self.PAGES_REV[MovementsPage]) return self.page.get_account() def get_history(self, account): if not self.is_on_page(MovementsPage): self.location(self.PAGES_REV[MovementsPage]) for n in range(1, self.page.nb_pages()): self.location('/outil/IQMT/mvt.Synthese/paginerReleve', urlencode({'numPage': str(n)}), no_login=True) for tr in self.page.get_operations(): yield tr def get_cb_operations(self, account): raise NotImplementedError() def get_investment(self, account): raise NotImplementedError() class LCLEspaceProBrowser(LCLEnterpriseBrowser): BASEURL = 'https://espacepro.secure.lcl.fr' CERTHASH = 'fa57ae1f3ea27af8a78e8e7d8eb40fc15eb7a5665af27a861fd28f259cae7d57' �������������weboob-1.1/modules/lcl/enterprise/pages.py����������������������������������������������������������0000664�0000000�0000000�00000005265�12657170273�0020725�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon, Pierre Mazière, Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from decimal import Decimal from weboob.capabilities.bank import Account from weboob.deprecated.browser import Page from weboob.tools.capabilities.bank.transactions import FrenchTransaction from ..pages import Transaction class RootPage(Page): pass class LogoutPage(Page): pass class LogoutOkPage(Page): pass class MessagesPage(Page): pass class AlreadyConnectedPage(Page): pass class ExpiredPage(Page): pass class MovementsPage(Page): def get_account(self): LABEL_XPATH = '//*[@id="perimetreMandatEnfantLib"]' BALANCE_XPATH = '//div[contains(text(),"Solde comptable :")]/strong' account = Account() account.id = 0 account.label = self.document.xpath(LABEL_XPATH)[0] \ .text_content().strip() balance_txt = self.document.xpath(BALANCE_XPATH)[0] \ .text_content().strip() account.balance = Decimal(FrenchTransaction.clean_amount(balance_txt)) account.currency = Account.get_currency(balance_txt) return account def nb_pages(self): return int(self.document.xpath('//input[@name="nbPages"]/@value')[0]) def get_operations(self): LINE_XPATH = '//table[@id="listeEffets"]/tbody/tr' for line in self.document.xpath(LINE_XPATH): _id = line.xpath('./@id')[0] tds = line.xpath('./td') [date, vdate, raw, debit, credit] = [td.text_content() for td in tds] operation = Transaction(_id) operation.parse(date=date, raw=raw) operation.set_amount(credit, debit) yield operation class HomePage(Page): def login(self, login, passwd): p = lambda f: f.attrs.get('id') == "form_autoComplete" self.browser.select_form(predicate=p) self.browser["Ident_identifiant_"] = login.encode('utf-8') self.browser["Ident_password_"] = passwd.encode('utf-8') self.browser.submit(nologin=True) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/favicon.png������������������������������������������������������������������0000664�0000000�0000000�00000004541�12657170273�0017223�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME 08u���tEXtComment�Created with GIMPW��IDATx{pT眽&l$DB6$ HKLZ2ZPzbձNGءDڢlKk)X$ؐYe{.0,źKesyl}B#M$&�7 M� (6!DO-6#+#ȚQh3꟧M~W8#wwj_$=4ax„{{ⰻ:Mt8L� g Rp it(su8 T_@?/BXԹ=:3a`T^u`œR\>?3 QCg`wSBJg~ JBzQskq~I|C },.}Ȋ@Y3G,9]%mO}�2FDAA FW|w:1FanB5<siW5?9nx̒DۃNÛM -?q_b =<<Dr( 'o!Nol+w[wf#=,B{ Qcfז&�(Ra5e ڌI‘udQcܹh"[;whmeLGt#@U3c.z=iob_v/waoK^Ɋg}0-!'tq3V$$&ŗؿZtZyd{9Z|3`닉d7% as$ aT0AYA2Uȇygr<ygypuy-d].iKhZ7N5goG]0$mJC-z\` &�QU9Ŭk2:sjAR�hn͌;sǵso(vo6s$�zvЃŸz}ъR�k㳹zұ'4\Tܖ~ת{;R9Z&'Ҷl+B {͗V=x>tr~{8�f,wbBt2n@8z<7Ň5/3 "3*c@GobÁEq0avյ;X]{㠌k*홟h&u -|VD~h:քGDCL2?3Ѵ84 T-7KP =ިH_0ٳk ~; "x<K<Xo.aך{r%^rdYig\zm줈p.P`=[ljok.ӚmW2dlz}?3{ Rv_Ux!Q՝C65cP J"`ѢX<7:1)?)@l}Pعs5Q2:}_Qʁ/A=˛o$`@ !Er{`ιkXX-:f��ir5k?D(b8 I*/1['ADW>i#jH |Mxԇet+DMRT0~�4Ecqd8SDq q}>?6m?oY7ªd0&nrTUt,YVFA`A00dEndF�0jdCvVw|7/ǿEKz<QLq:Y@Eyvht(aA]$\`jC틠x7\hzϤɫB;:Ow\-i KJ09llD> _19R UX,FBʝ#QzonZDE )(!՞Lib^vgQ6#kth7ad7aȳ fd Y%s~'^�T* y5̟7 7Rݭgx݁yL ʠh8wT^.LL_y�v G>-?ošaL< AT?0,|9?Ngr})Y ͧX@'NtpהX rzޅ?|~Px (*o-�Qކ? %C](B7 R�6l~}DZ!JŨJ#$R̂ 0%mfg&�O:A{(c1f/F u�WK$Q*F2Q[Xa0;B7 @We,i����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000006102�12657170273�0016722�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon, Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from weboob.capabilities.base import find_object from .browser import LCLBrowser, LCLProBrowser from .enterprise.browser import LCLEnterpriseBrowser, LCLEspaceProBrowser __all__ = ['LCLModule'] class LCLModule(Module, CapBank): NAME = 'lcl' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'LCL' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Code personnel'), Value('website', label='Type de compte', default='par', choices={'par': 'Particuliers', 'pro': 'Professionnels', 'ent': 'Entreprises', 'esp': 'Espace Pro'})) BROWSER = LCLBrowser def create_default_browser(self): # assume all `website` option choices are defined here browsers = {'par': LCLBrowser, 'pro': LCLProBrowser, 'ent': LCLEnterpriseBrowser, 'esp': LCLEspaceProBrowser} website_value = self.config['website'] self.BROWSER = browsers.get(website_value.get(), browsers[website_value.default]) return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_coming(self, account): transactions = list(self.browser.get_cb_operations(account)) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return transactions def iter_history(self, account): transactions = list(self.browser.get_history(account)) transactions.sort(key=lambda tr: tr.rdate, reverse=True) return transactions def iter_investment(self, account): return self.browser.get_investment(account) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/pages.py���������������������������������������������������������������������0000664�0000000�0000000�00000044604�12657170273�0016545�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re import base64 from decimal import Decimal import math import random from cStringIO import StringIO from urllib import urlencode from weboob.capabilities import NotAvailable from weboob.capabilities.bank import Account, Investment from weboob.browser.elements import method, ListElement, ItemElement, SkipItem from weboob.exceptions import ParseError from weboob.browser.pages import LoggedPage, HTMLPage, FormNotFound, pagination from weboob.browser.filters.html import Attr from weboob.browser.filters.standard import CleanText, Field, Regexp, Format, Date, \ CleanDecimal, Map, AsyncLoad, Async from weboob.exceptions import BrowserUnavailable, BrowserIncorrectPassword from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard, VirtKeyboardError def MyDecimal(*args, **kwargs): kwargs.update(replace_dots=True, default=Decimal(0)) return CleanDecimal(*args, **kwargs) class LCLBasePage(HTMLPage): def get_from_js(self, pattern, end, is_list=False): """ find a pattern in any javascript text """ value = None for script in self.doc.xpath('//script'): txt = script.text if txt is None: continue start = txt.find(pattern) if start < 0: continue while True: if value is None: value = '' else: value += ',' value += txt[start+len(pattern):start+txt[start+len(pattern):].find(end)+len(pattern)] if not is_list: break txt = txt[start+len(pattern)+txt[start+len(pattern):].find(end):] start = txt.find(pattern) if start < 0: break return value class LCLVirtKeyboard(MappedVirtKeyboard): symbols={'0': '9da2724133f2221482013151735f033c', '1': '873ab0087447610841ae1332221be37b', '2': '93ce6c330393ff5980949d7b6c800f77', '3': 'b2d70c69693784e1bf1f0973d81223c0', '4': '498c8f5d885611938f94f1c746c32978', '5': '359bcd60a9b8565917a7bf34522052c3', '6': 'aba912172f21f78cd6da437cfc4cdbd0', '7': 'f710190d6b947869879ec02d8e851dfa', '8': 'b42cc25e1539a15f767aa7a641f3bfec', '9': 'cc60e5894a9d8e12ee0c2c104c1d5490' } url="/outil/UAUT/Clavier/creationClavier?random=" color=(255,255,255,255) def __init__(self, basepage): img=basepage.doc.find("//img[@id='idImageClavier']") random.seed() self.url += "%s"%str(long(math.floor(long(random.random()*1000000000000000000000)))) super(LCLVirtKeyboard, self).__init__(StringIO(basepage.browser.open(self.url).content), basepage.doc,img,self.color, "id") self.check_symbols(self.symbols,basepage.browser.responses_dirname) def get_symbol_code(self, md5sum): code=MappedVirtKeyboard.get_symbol_code(self, md5sum) return code[-2:] def get_string_code(self, string): code='' for c in string: code += self.get_symbol_code(self.symbols[c]) return code class LoginPage(HTMLPage): def on_load(self): try: form = self.get_form(xpath='//form[@id="setInfosCGS" or @name="form"]') except FormNotFound: return form.submit() def myXOR(self,value,seed): s = '' for i in xrange(len(value)): s += chr(seed^ord(value[i])) return s def login(self, login, passwd): try: vk = LCLVirtKeyboard(self) except VirtKeyboardError as err: self.logger.exception(err) return False password = vk.get_string_code(passwd) seed = -1 s = "var aleatoire = " for script in self.doc.findall("//script"): if script.text is None or len(script.text) == 0: continue offset = script.text.find(s) if offset != -1: seed = int(script.text[offset+len(s)+1:offset+len(s)+2]) break if seed==-1: raise ParseError("Variable 'aleatoire' not found") form = self.get_form('//form[@id="formAuthenticate"]') form['identifiant'] = login form['postClavierXor'] = base64.b64encode(self.myXOR(password,seed)) try: form['identifiantRouting'] = self.browser.IDENTIFIANT_ROUTING except AttributeError: pass try: form.submit() except BrowserUnavailable: # Login is not valid return False return True def is_error(self): errors = self.doc.xpath(u'//*[@class="erreur" or @class="messError"]') return len(errors) > 0 and not self.doc.xpath('//a[@href="/outil/UWHO/Accueil/"]') class ContractsPage(LoginPage): def on_load(self): if self.is_error(): raise BrowserIncorrectPassword() self.select_contract() def select_contract(self): # XXX We select automatically the default contract in list. We should let user # ask what contract he wants to see, or display accounts for all contracts. link = self.doc.xpath('//a[contains(text(), "Votre situation globale")]') if len(link): self.browser.location(link[0].attrib['href']) else: form = self.get_form(nr=0) form.submit() class AccountsPage(LoggedPage, HTMLPage): def on_load(self): warn = self.doc.xpath('//div[@id="attTxt"]') if len(warn) > 0: raise BrowserIncorrectPassword(warn[0].text) @method class get_list(ListElement): item_xpath = '//tr[contains(@onclick, "redirect")]' flush_at_end = True class account(ItemElement): klass = Account def condition(self): return '/outil/UWLM/ListeMouvement' in self.el.attrib['onclick'] NATURE2TYPE = {'001': Account.TYPE_SAVINGS, '005': Account.TYPE_CHECKING, '006': Account.TYPE_CHECKING, '007': Account.TYPE_SAVINGS, '012': Account.TYPE_SAVINGS, '023': Account.TYPE_CHECKING, '046': Account.TYPE_SAVINGS, '049': Account.TYPE_SAVINGS, '068': Account.TYPE_MARKET, '069': Account.TYPE_SAVINGS, } obj__link_id = Format('%s&mode=55', Regexp(CleanText('./@onclick'), "'(.*)'")) obj_id = Regexp(Field('_link_id'), r'.*agence=(\w+).*compte=(\w+)', r'\1\2') obj__coming_links = [] obj_label = CleanText('.//div[@class="libelleCompte"]') obj_balance = CleanDecimal('.//td[has-class("right")]', replace_dots=True) obj_currency = FrenchTransaction.Currency('.//td[has-class("right")]') obj_type = Map(Regexp(Field('_link_id'), r'.*nature=(\w+)'), NATURE2TYPE, default=Account.TYPE_UNKNOWN) obj__market_link = None class card(ItemElement): def condition(self): return '/outil/UWCB/UWCBEncours' in self.el.attrib['onclick'] def parse(self, el): link = Regexp(CleanText('./@onclick'), "'(.*)'")(el) id = Regexp(CleanText('./@onclick'), r'.*AGENCE=(\w+).*COMPTE=(\w+).*CLE=(\w+)', r'\1\2\3')(el) account = self.parent.objects[id] if not account.coming: account.coming = Decimal('0') account.coming += CleanDecimal('.//td[has-class("right")]', replace_dots=True)(el) account._coming_links.append(link) raise SkipItem() class Transaction(FrenchTransaction): PATTERNS = [(re.compile('^(?P<category>CB) (?P<text>RETRAIT) DU (?P<dd>\d+)/(?P<mm>\d+)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile('^(?P<category>(PRLV|PE)( SEPA)?) (?P<text>.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?P<category>CHQ\.) (?P<text>.*)'), FrenchTransaction.TYPE_CHECK), (re.compile('^(?P<category>RELEVE CB) AU (\d+)/(\d+)/(\d+)'), FrenchTransaction.TYPE_CARD), (re.compile('^(?P<category>CB) (?P<text>.*) (?P<dd>\d+)/(?P<mm>\d+)/(?P<yy>\d+)'), FrenchTransaction.TYPE_CARD), (re.compile('^(?P<category>(PRELEVEMENT|TELEREGLEMENT|TIP)) (?P<text>.*)'), FrenchTransaction.TYPE_ORDER), (re.compile('^(?P<category>(ECHEANCE\s*)?PRET)(?P<text>.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile('^(?P<category>(EVI|VIR(EM(EN)?)?T?)(.PERMANENT)? ((RECU|FAVEUR) TIERS|SEPA RECU)?)( /FRM)?(?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile('^(?P<category>REMBOURST)(?P<text>.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile('^(?P<category>COM(MISSIONS?)?)(?P<text>.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P<text>(?P<category>REMUNERATION).*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P<text>(?P<category>ABON.*?)\s*.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P<text>(?P<category>RESULTAT .*?)\s*.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P<text>(?P<category>TRAIT\..*?)\s*.*)'), FrenchTransaction.TYPE_BANK), (re.compile('^(?P<category>REM CHQ) (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT), ] class Pagination(object): def next_page(self): links = self.page.doc.xpath('//div[@class="pagination"] /a') if len(links) == 0: return for link in links: if link.xpath('./span')[0].text == 'Page suivante': return link.attrib.get('href') return class AccountHistoryPage(LoggedPage, HTMLPage): class _get_operations(Pagination, Transaction.TransactionsElement): item_xpath = '//table[has-class("tagTab") and (not(@style) or @style="")]/tr' head_xpath = '//table[has-class("tagTab") and (not(@style) or @style="")]/tr/th' col_raw = [u'Vos opérations', u'Libellé'] class item(Transaction.TransactionElement): load_details = Attr('.', 'href', default=None) & AsyncLoad def condition(self): return self.parent.get_colnum('date') is not None and \ len(self.el.findall('td')) >= 3 and \ self.el.get('class') and \ 'tableTr' not in self.el.get('class') def validate(self, obj): if obj.category == 'RELEVE CB': return raw = Async('details', CleanText(u'//td[contains(text(), "Libellé")]/following-sibling::*[1]|//td[contains(text(), "Nom du donneur")]/following-sibling::*[1]', default=obj.raw))(self) if raw: obj.raw = raw obj.label = raw if not obj.date: obj.date = Async('details', Date(CleanText(u'//td[contains(text(), "Date de l\'opération")]/following-sibling::*[1]', default=u''), default=NotAvailable))(self) obj.rdate = obj.date obj.vdate = Async('details', Date(CleanText(u'//td[contains(text(), "Date de valeur")]/following-sibling::*[1]', default=u''), default=NotAvailable))(self) obj.amount = Async('details', CleanDecimal(u'//td[contains(text(), "Montant")]/following-sibling::*[1]', replace_dots=True, default=NotAvailable))(self) return True @pagination def get_operations(self): return self._get_operations(self)() class CBHistoryPage(AccountHistoryPage): def get_operations(self): for tr in self._get_operations(self)(): tr.type = tr.TYPE_CARD yield tr class CBListPage(CBHistoryPage): def get_cards(self): cards = [] for tr in self.doc.getiterator('tr'): link = Regexp(CleanText('./@onclick'), "'(.*)'", default=None)(tr) if link is not None and link.startswith('/outil/UWCB/UWCBEncours') and 'listeOperations' in link: cards.append(link) return cards class BoursePage(LoggedPage, HTMLPage): def get_next(self): return re.search('"(.*?)"', self.doc.xpath('.//body')[0].attrib['onload']).group(1) def populate(self, accounts): for a in accounts: for tr in self.doc.xpath('.//table[contains(@class, "tableau_comptes_details")]/tbody/tr'): ac_code = tr.xpath('.//td[2]/div/br | .//td[2]/div')[-1] ac_code = ac_code.text or ac_code.tail ac_code = ac_code.strip().split(' - ') if a.id == '%s%s' % (ac_code[0], ac_code[1]): a._market_link = Regexp(CleanText('.//td[2]/@onclick'), "'(.*?)'")(tr) a.balance += CleanDecimal('.//td[has-class("last")]', replace_dots=True)(tr) yield a @method class iter_investment(ListElement): item_xpath = '//table[@id="tableValeurs"]/tbody/tr[not(@class) and count(descendant::td) > 1]' class item(ItemElement): klass = Investment obj_label = CleanText('.//td[2]/div/a') obj_code = CleanText('.//td[2]/div/br/following-sibling::text()') obj_quantity = MyDecimal('.//td[3]/span') obj_diff = MyDecimal('.//td[7]/span') obj_valuation = MyDecimal('.//td[5]') def obj_unitvalue(self): if "%" in CleanText('.//td[4]')(self) and "%" in CleanText('.//td[6]')(self): return self.obj_valuation(self) / self.obj_quantity(self) else: return MyDecimal('.//td[4]')(self) def obj_unitprice(self): if "%" in CleanText('.//td[4]')(self) and "%" in CleanText('.//td[6]')(self): return self.obj_valuation(self) / self.obj_quantity(self) return (self.obj_valuation(self) - self.obj_diff(self)) / self.obj_quantity(self) else: return MyDecimal('.//td[6]')(self) class DiscPage(LoggedPage, HTMLPage): def come_back(self): form = self.get_form() form.submit() class NoPermissionPage(LoggedPage, HTMLPage): pass class AVPage(LoggedPage, HTMLPage): @method class get_list(ListElement): item_xpath = '//table[@class]/tbody/tr' class account(ItemElement): klass = Account obj__owner = CleanText('.//td[1]') & Regexp(pattern=r' ([^ ]+)$') obj_label = Format(u'%s %s', CleanText('.//td/a'), obj__owner) obj_balance = CleanDecimal('.//td[has-class("right")]', replace_dots=True) obj_type = Account.TYPE_LIFE_INSURANCE obj__link_id = None obj__market_link = None obj__coming_links = [] def obj_id(self): _id = CleanText('.//td/a/@id')(self) if not _id: _id = Regexp(CleanText('.//td/a/@href'), r'ID_CONTRAT=(\d+)')(self) return Format(u'%s%s', CleanText(Field('label'), replace=[(' ', '')]), _id)(self) def obj__form(self): form_id = Attr('.//td/a', 'id', default=None)(self) if not form_id: return form = self.page.get_form('//form[@id="formRoutage"]') form['ID_CONTRAT'] = re.search(r'^(.*?)-', form_id).group(1) form['PRODUCTEUR'] = re.search(r'-(.*?)$', form_id).group(1) return form class AVDetailPage(LoggedPage, LCLBasePage): def sub(self): form = self.get_form(name="formulaire") cName = self.get_from_js('.cName.value = "', '";') if cName: form['cName'] = cName form['cValue'] = self.get_from_js('.cValue.value = "', '";') form['cMaxAge'] = '-1' form.submit() def come_back(self): session = self.get_from_js('idSessionSag = "', '"') params = {} params['sessionSAG'] = session params['stbpg'] = 'pagePU' params['act'] = '' params['typeaction'] = 'reroutage_retour' params['site'] = 'LCLI' params['stbzn'] = 'bnc' self.browser.location('https://assurance-vie-et-prevoyance.secure.lcl.fr/filiale/entreeBam?%s' % urlencode(params)) @method class iter_investment(ListElement): item_xpath = '(//table[@class="table"])[1]/tbody/tr' class item(ItemElement): klass = Investment obj_label = CleanText('.//td[1]/a | .//td[1]/span ') obj_code = CleanText('.//td[1]/a/@id') obj_quantity = MyDecimal('.//td[4]/span') obj_unitvalue = MyDecimal('.//td[2]/span') obj_valuation = MyDecimal('.//td[5]/span') class RibPage(LoggedPage, LCLBasePage): def get_iban(self): if (self.doc.xpath('//div[contains(@class, "rib_cadre")]//div[contains(@class, "rib_internat")]')): return CleanText().filter(self.doc.xpath('//div[contains(@class, "rib_cadre")]//div[contains(@class, "rib_internat")]//p//strong')[0].text).replace(' ','') class HomePage(LoggedPage, HTMLPage): pass ����������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lcl/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000001600�12657170273�0016412�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class LCLtTest(BackendTest): MODULE = 'lcl' def test_lcl(self): list(self.backend.iter_accounts()) ��������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ldlc/����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015230�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ldlc/__init__.py�����������������������������������������������������������������0000664�0000000�0000000�00000001434�12657170273�0017343�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import LdlcModule __all__ = ['LdlcModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ldlc/browser.py������������������������������������������������������������������0000664�0000000�0000000�00000004345�12657170273�0017273�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import HomePage, BillsPage class LdlcBrowser(LoginBrowser): home = URL('/default.aspx', HomePage) bills = URL('/Account/CommandListingPage.aspx', BillsPage) def __init__(self, website, *args, **kwargs): self.website = website if website == 'pro': self.BASEURL = 'https://secure.ldlc-pro.com/' else: self.BASEURL = 'https://secure.ldlc.com/' super(LdlcBrowser, self).__init__(*args, **kwargs) def do_login(self): self.location('/Account/LoginPage.aspx', data={'log' : self.username, 'pass': self.password}) self.home.stay_or_go() if not self.home.is_here(): raise BrowserIncorrectPassword @need_login def get_subscription_list(self): return self.home.stay_or_go().get_list() @need_login def iter_bills(self, subscription): self.bills.stay_or_go() bills = list() for value in self.page.get_range(): if self.website == 'pro': event = 'ctl00$cphMainContent$ddlDate' else: event = 'ctl00$ctl00$cphMainContent$cphMainContent$ddlDate' self.bills.go(data={event: value, '__EVENTTARGET': 'ctl00$cphMainContent$ddlDate'}) for i in self.page.get_bills(subid=subscription.id): bills.append(i) return bills �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ldlc/module.py�������������������������������������������������������������������0000664�0000000�0000000�00000005212�12657170273�0017067�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import CapBill, Subscription, Bill, SubscriptionNotFound, BillNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import LdlcBrowser __all__ = ['LdlcModule'] class LdlcModule(Module, CapBill): NAME = 'ldlc' DESCRIPTION = u'ldlc website' MAINTAINER = u'Vincent Paredes' EMAIL = 'vparedes@budget-insight.com' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(Value('login', label='Email'), ValueBackendPassword('password', label='Password'), Value('website', label='Site web', default='part', choices={'pro': 'Professionnels', 'part': 'Particuliers'})) BROWSER = LdlcBrowser def create_default_browser(self): return self.create_browser(self.config['website'].get(), self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): return self.browser.get_subscription_list() def get_subscription(self, _id): return find_object(self.iter_subscription(), id=_id, error=SubscriptionNotFound) def get_bill(self, _id): subid = _id.split('_')[0] subscription = self.get_subscription(subid) return find_object(self.iter_bills(subscription), id=_id, error=BillNotFound) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_bills(subscription) def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) return self.browser.open(bill._url).content ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ldlc/pages.py��������������������������������������������������������������������0000664�0000000�0000000�00000004774�12657170273�0016715�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.filters.standard import CleanDecimal, CleanText, Env, Format from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.html import Attr from weboob.capabilities.bill import Bill, Subscription from weboob.tools.date import parse_french_date class HomePage(HTMLPage, LoggedPage): @method class get_list(ListElement): item_xpath = '//div[@id="divAccueilInformationClient"]//div[@id="divInformationClient"]' class item(ItemElement): klass = Subscription obj_subscriber = CleanText('.//div[@id="divlblTitleFirstNameLastName"]/span') obj_id = CleanText('.//span[2]') obj_label = CleanText('.//div[@id="divlblTitleFirstNameLastName"]/span') class BillsPage(HTMLPage, LoggedPage): def get_range(self): for value in self.doc.xpath('//div[@class="commandListing content clearfix"]//select/option/@value'): yield value @method class get_bills(ListElement): item_xpath = '//table[@id="TopListing"]//tr' class item(ItemElement): klass = Bill obj_id = Format('%s_%s', Env('subid'), CleanText('./td[3]')) obj__url = Attr('./td[@class="center" or @class="center pdf"]/a', 'href') obj_date = Env('date') obj_format = u"pdf" obj_price = CleanDecimal('./td[@class="center montant"]/span', replace_dots=True) def parse(self, el): self.env['date'] = parse_french_date(el.xpath('./td[2]')[0].text).date() def condition(self): return CleanText().filter(self.el.xpath('.//td')[-1]) != "" and len(self.el.xpath('./td[@class="center" or @class="center pdf"]/a/@href')) == 1 ����weboob-1.1/modules/leboncoin/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016262�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leboncoin/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0020372�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import LeboncoinModule __all__ = ['LeboncoinModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leboncoin/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000010124�12657170273�0020315�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from weboob.capabilities.housing import Query, TypeNotSupported from .pages import CityListPage, HousingListPage, HousingPage class LeboncoinBrowser(PagesBrowser): BASEURL = 'http://www.leboncoin.fr/' city = URL('ajax/location_list.html\?city=(?P<city>.*)&zipcode=(?P<zip>.*)', CityListPage) search = URL('(?P<type>.*)/offres/(?P<region>.*)/occasions/\?(?P<_ps>ps|mrs)=(?P<ps>.*)&(?P<_pe>pe|mre)=(?P<pe>.*)&ros=(?P<ros>.*)&location=(?P<location>.*)&sqs=(?P<sqs>.*)&sqe=(?P<sqe>.*)&ret=(?P<ret>.*)&f=(?P<advert_type>.*)', '(?P<_type>.*)/offres/(?P<_region>.*)/occasions.*?', HousingListPage) housing = URL('ventes_immobilieres/(?P<_id>.*).htm', HousingPage) TYPES = {Query.TYPE_RENT: 'locations', Query.TYPE_SALE: 'ventes_immobilieres', Query.TYPE_SHARING: 'colocations', } RET = {Query.HOUSE_TYPES.HOUSE: '1', Query.HOUSE_TYPES.APART: '2', Query.HOUSE_TYPES.LAND: '3', Query.HOUSE_TYPES.PARKING: '4', Query.HOUSE_TYPES.OTHER: '5'} def __init__(self, region, *args, **kwargs): super(LeboncoinBrowser, self).__init__(*args, **kwargs) self.region = region def get_cities(self, pattern): city = '' zip_code = '' if pattern.isdigit(): zip_code = pattern else: city = pattern return self.city.go(city=city, zip=zip_code).get_cities() def search_housings(self, query, advert_type, module_name): if query.type not in self.TYPES: return TypeNotSupported() type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, ret = self.decode_query(query, module_name) if len(cities) == 0 or len(ret) == 0: return list() return self.search.go(region=self.region, location=cities, ros=nb_rooms, sqs=area_min, sqe=area_max, _ps="mrs" if query.type == Query.TYPE_RENT else "ps", ps=cost_min, _pe="mre" if query.type == Query.TYPE_RENT else "pe", pe=cost_max, type=type, advert_type=advert_type, ret=ret).get_housing_list() def get_housing(self, _id, obj=None): return self.housing.go(_id=_id).get_housing(obj=obj) def decode_query(self, query, module_name): cities = [c.name for c in query.cities if c.backend == module_name] ret = [self.RET.get(g) for g in query.house_types if g in self.RET] _type = self.TYPES.get(query.type) self.search.go(_type=_type, _region=self.region) nb_rooms = '' if not query.nb_rooms else self.page.get_rooms_min(query.nb_rooms) area_min = '' if not query.area_min else self.page.get_area_min(query.area_min) area_max = '' if not query.area_max else self.page.get_area_max(query.area_max) cost_min = '' if not query.cost_min else self.page.get_cost_min(query.cost_min, query.type) cost_max = '' if not query.cost_max else self.page.get_cost_max(query.cost_max, query.type) return _type, ','.join(cities), nb_rooms, area_min, area_max, cost_min, cost_max, '&ret='.join(ret) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leboncoin/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000001376�12657170273�0020424�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���% ���sRGB����gAMA�� a��� pHYs����od��IDAThCZK0 @p. F!cǎ;vb'v4)q~ЙnPqbV _�|Z 7RSK \OJ]XHIq.۱_E*�Vؑ(0�XyڗP�rET@uz�|uM@"B&OϮθlYF�Gw}W*I-�ު��$ �te`!7ǜwĶUX69=�C<_ � N�IbwyLI1Y7`Lբ#�$=I SeX .$6|ak�@"Hɼs|ʟswFS /UT}hV@Uhn 4#F֒pC/eh<5=-]VzY0dd ;i[eتX*)@46 q.;A.>X6"�# 'E�,�t9O1]Q^R1bV�dh^5F&o�$9-w3m9)S=3 &EQnQR96Y w|cTHX!Qp™?0^q^ۘMG@m+ k�*@S [ɚ6N}����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leboncoin/module.py��������������������������������������������������������������0000664�0000000�0000000�00000007236�12657170273�0020131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.housing import CapHousing, Housing, HousingPhoto from weboob.tools.value import Value from .browser import LeboncoinBrowser __all__ = ['LeboncoinModule'] class LeboncoinModule(Module, CapHousing): NAME = 'leboncoin' DESCRIPTION = u'search house on leboncoin website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = LeboncoinBrowser CONFIG = BackendConfig(Value('advert_type', label='Advert type', choices={'c': 'Agency', 'p': 'Owner', 'a': 'All'}, default='a'), Value('region', label='Region', choices=['alsace', 'aquitaine', 'auvergne', 'basse_normandie', 'bourgogne', 'bretagne', 'centre', 'champagne_ardenne', 'corse', 'franche_comte', 'haute_normandie', 'ile_de_france', 'languedoc_roussillon', 'limousin', 'lorraine', 'midi_pyrenees', 'nord_pas_de_calais', 'pays_de_la_loire', 'picardie', 'poitou_chanrentes', 'provence_alpes_cote_d_azur', 'rhone_alpes', 'guadeloupe', 'martinique', 'guyane', 'reunion'])) def create_default_browser(self): region = self.config['region'].get() return self.create_browser(region) def get_housing(self, _id): return self.browser.get_housing(_id) def fill_housing(self, housing, fields): return self.browser.get_housing(housing.id, housing) def fill_photo(self, photo, fields): if 'data' in fields and photo.url and not photo.data: photo.data = self.browser.open(photo.url).content return photo def search_city(self, pattern): return self.browser.get_cities(pattern) def search_housings(self, query): return self.browser.search_housings(query, self.config['advert_type'].get(), self.name) OBJECTS = {Housing: fill_housing, HousingPhoto: fill_photo} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leboncoin/pages.py���������������������������������������������������������������0000664�0000000�0000000�00000017343�12657170273�0017743�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from decimal import Decimal from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import CleanText, Regexp, CleanDecimal, Env, DateTime, BrowserURL, Format from weboob.browser.filters.html import Attr, Link, CleanHTML from weboob.capabilities.housing import City, Housing, HousingPhoto, Query from weboob.capabilities.base import NotAvailable from datetime import date, timedelta from weboob.tools.date import DATE_TRANSLATE_FR, LinearDateGuesser class CityListPage(HTMLPage): @method class get_cities(ListElement): item_xpath = '//li' class item(ItemElement): klass = City obj_id = Format('%s %s', CleanText('./span[has-class("city")]'), CleanText('./span[@class="zipcode"]')) obj_name = Format('%s %s', CleanText('./span[has-class("city")]'), CleanText('./span[@class="zipcode"]')) class HousingListPage(HTMLPage): def get_area_min(self, asked_area): return self.find_select_value(asked_area, '//select[@id="sqs"]/option') def get_area_max(self, asked_area): return self.find_select_value(asked_area, '//select[@id="sqe"]/option') def get_rooms_min(self, asked_rooms): return self.find_select_value(asked_rooms, '//select[@id="rooms_ros"]/option') # def get_rooms_max(self, asked_rooms): # return self.find_select_value(asked_rooms, '//select[@id="roe"]/option') def get_cost_min(self, asked_cost, _type): _id = "ps" if _type == Query.TYPE_SALE else "mrs" return self.find_select_value(asked_cost, '//select[@id="%s"]/option' % _id) def get_cost_max(self, asked_cost, _type): _id = "pe" if _type == Query.TYPE_SALE else "mre" return self.find_select_value(asked_cost, '//select[@id="%s"]/option' % _id) def find_select_value(self, ref_value, selector): select = {} for item in self.doc.xpath(selector): if item.attrib['value']: select[CleanDecimal('.')(item)] = CleanDecimal('./@value')(item) select_keys = select.keys() select_keys.sort() for select_value in select_keys: if select_value >= ref_value: return select[select_value] return select[select_keys[-1]] if select else 0 @pagination @method class get_housing_list(ListElement): item_xpath = '//div[@class="list-lbc"]/a' def next_page(self): return Link('//li[@class="page"]/a[contains(text(),"Page suivante")]')(self) class item(ItemElement): klass = Housing obj_id = Regexp(Link('.'), '//www.leboncoin.fr/(ventes_immobilieres|locations|colocations)/(.*).htm.*', '\\2') obj_title = CleanText('./div[@class="lbc"]/div/h2[@class="title"]') obj_cost = CleanDecimal('./div[@class="lbc"]/div/div[@class="price"]', replace_dots=(',', '.'), default=Decimal(0)) obj_currency = Regexp(CleanText('./div[@class="lbc"]/div/div[@class="price"]'), '.*([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') obj_text = CleanText('./div[@class="lbc"]/div[@class="detail"]') def obj_date(self): _date = CleanText('./div[@class="lbc"]/div[@class="date"]', replace=[('Aujourd\'hui', str(date.today())), ('Hier', str((date.today() - timedelta(1))))])(self) for fr, en in DATE_TRANSLATE_FR: _date = fr.sub(en, _date) self.env['tmp'] = _date return DateTime(Env('tmp'), LinearDateGuesser())(self) def obj_photos(self): photos = [] url = Attr('./div[@class="lbc"]/div[@class="image"]/div/img', 'src', default=None)(self) if url: photos.append(HousingPhoto(url)) return photos class HousingPage(HTMLPage): @method class get_housing(ItemElement): klass = Housing def parse(self, el): details = dict() self.env['location'] = NotAvailable for tr in el.xpath('//div[@class="floatLeft"]/table/tbody/tr'): if 'Ville' in CleanText('./th')(tr): self.env['location'] = CleanText('./td')(tr) else: details['%s' % CleanText('./th', replace=[(':', '')])(tr)] = CleanText('./td')(tr) self.env['area'] = NotAvailable for tr in el.xpath('//div[@class="lbcParams criterias"]/table/tr'): if 'Surface' in CleanText('./th')(tr): self.env['area'] = CleanDecimal(Regexp(CleanText('./td'), '(.*)m.*'), replace_dots=(',', '.'))(tr) else: key = '%s' % CleanText('./th', replace=[(':', '')])(tr) if 'GES' in key or 'Classe' in key: details[key] = CleanText('./td/noscript/a')(tr) else: details[key] = CleanText('./td')(tr) self.env['details'] = details obj_id = Env('_id') obj_title = CleanText('//h1[@id="ad_subject"]') obj_cost = CleanDecimal('//span[@class="price"]', replace_dots=(',', '.'), default=Decimal(0)) obj_currency = Regexp(CleanText('//span[@class="price"]'), '.*([%s%s%s])' % (u'€', u'$', u'£'), default='') obj_text = CleanHTML('//div[@class="content"]') obj_location = Env('location') obj_details = Env('details') obj_area = Env('area') obj_url = BrowserURL('housing', _id=Env('_id')) def obj_date(self): _date = Regexp(CleanText('//div[@class="upload_by"]', replace=[(u'à', '')]), '.*- Mise en ligne le (.*).')(self) for fr, en in DATE_TRANSLATE_FR: _date = fr.sub(en, _date) self.env['tmp'] = _date return DateTime(Env('tmp'), LinearDateGuesser())(self) def obj_photos(self): photos = [] for img in self.el.xpath('//div[@id="thumbs_carousel"]/a/span'): url = CleanText(Regexp(Attr('.', 'style', default=''), "background-image: url\('(.*)'\);", default=''), replace=[('thumbs', 'images')], default='')(img) if url: photos.append(HousingPhoto(url)) if not photos: img = self.el.xpath('//div[@class="lbcImages"]/meta/@content') if img: photos.append(HousingPhoto(img[0])) return photos ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leboncoin/test.py����������������������������������������������������������������0000664�0000000�0000000�00000002573�12657170273�0017622�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import itertools from weboob.tools.test import BackendTest from weboob.capabilities.housing import Query class LeboncoinTest(BackendTest): MODULE = 'leboncoin' def test_leboncoin(self): query = Query() query.cities = [] query.type = Query.TYPE_SALE for city in self.backend.search_city('lille'): city.backend = self.backend.name query.cities.append(city) results = list(itertools.islice(self.backend.search_housings(query), 0, 20)) self.assertTrue(len(results) > 0) obj = self.backend.fillobj(results[0]) self.assertTrue(obj.area is not None, 'Area for "%s"' % (obj.id)) �������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017113�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000001450�12657170273�0021224�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import LeclercMobileModule __all__ = ['LeclercMobileModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/browser.py���������������������������������������������������������0000664�0000000�0000000�00000011706�12657170273�0021155�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Fourcot Florent # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import time import StringIO from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import HomePage, LoginPage, HistoryPage, PdfPage from weboob.capabilities.bill import Detail from weboob.capabilities.base import NotAvailable __all__ = ['Leclercmobile'] class Leclercmobile(Browser): DOMAIN = 'www.securelmobile.fr' PROTOCOL = 'https' ENCODING = 'utf-8' PAGES = {'.*pgeWERL008_Login.aspx.*': LoginPage, '.*EspaceClient/pgeWERL013_Accueil.aspx': HomePage, '.*pgeWERL009_ReleveConso.aspx.*': HistoryPage, '.*ReleveConso.ashx.*': PdfPage } accueil = "/EspaceClient/pgeWERL013_Accueil.aspx" login = "/EspaceClient/pgeWERL008_Login.aspx" conso = "/EspaceClient/pgeWERL009_ReleveConso.aspx" bills = '/EspaceClient/pgeWERL015_RecupReleveConso.aspx?m=-' def __init__(self, *args, **kwargs): Browser.__init__(self, *args, **kwargs) def home(self): self.location(self.accueil) def is_logged(self): return not self.is_on_page(LoginPage) def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.username.isdigit() if not self.is_on_page(LoginPage): self.location(self.login) form = self.page.login(self.username, self.password) # Site display a javascript popup to wait while self.page.iswait(): # In this popup can be an error displayed if self.page.iserror(): raise BrowserIncorrectPassword() time.sleep(1) self.page.next(self.username, form) # The last document contain a redirect url in the javascript self.location(self.page.getredirect()) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() def viewing_html(self): # To prevent unknown mimetypes sent by server, we assume we # are always on a HTML document. return True def get_subscription_list(self): if not self.is_on_page(HomePage): self.location(self.acceuil) return self.page.get_list() def get_subscription(self, id): assert isinstance(id, basestring) if not self.is_on_page(HomePage): self.location(self.accueil) l = self.page.get_list() for a in l: if a.id == id: return a return None def get_history(self): if not self.is_on_page(HistoryPage): self.location(self.conso) maxid = self.page.getmaxid() for i in range(maxid + 1): response = self.openurl(self.bills + str(i)) mimetype = response.info().get('Content-Type', '').split(';')[0] if mimetype == "application/pdf": pdf = PdfPage(StringIO.StringIO(response.read())) for call in pdf.get_calls(): call.label = call.label.strip() yield call def get_details(self): if not self.is_on_page(HistoryPage): self.location(self.conso) response = self.openurl(self.bills + "0") mimetype = response.info().get('Content-Type', '').split(';')[0] if mimetype == "application/pdf": pdf = PdfPage(StringIO.StringIO(response.read())) for detail in pdf.get_details(): yield detail def iter_bills(self, parentid): if not self.is_on_page(HistoryPage): self.location(self.conso) return self.page.date_bills(parentid) def get_bill(self, id): assert isinstance(id, basestring) if not self.is_on_page(HistoryPage): self.location(self.conso) parentid = id[0:10] l = self.page.date_bills(parentid) for a in l: if a.id == id: return a def get_balance(self): if not self.is_on_page(HistoryPage): self.location(self.conso) detail = Detail() detail.label = u"Balance" for calls in self.get_history(): if "Votre solde" in calls.label: detail.price = calls.price return detail detail.price = NotAvailable return detail ����������������������������������������������������������weboob-1.1/modules/leclercmobile/favicon.png��������������������������������������������������������0000664�0000000�0000000�00000001534�12657170273�0021251�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME 3c���tEXtComment�Created with GIMPW��IDATx[m0 LLA(}_VP_ dIH@Pĩmxd{sλ[]xy.[)@x!X�$B-[1Lϯw3"XA!"@<mxG6Z[�(C>) ,c F@&@[1c$H<D�^sSݏ@gPhOKd~wH9kO^`*@M4<6Ш^i`EJ*-yASPӠ+y>'F^o@ F$p;DvF_ISt>?� hKeeSP" Tc�VX#)JS(c=tpwP@/=襂89U% ,QGʠqgt"'#`Y &]kWi}K`=;MB`aEHjGHQ#<]9BD+CK-҈| D ſz}#i iSW$枣M0ٵ  IQn ݷ TVQf & =%%08ayJ@4R*{&' hQPy1*8Skgg`4%PǛ,N z';Eggs֘"\78onADw5 l�oЛ ����IENDB`��������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/module.py����������������������������������������������������������0000664�0000000�0000000�00000007352�12657170273�0020761�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import CapBill, SubscriptionNotFound,\ BillNotFound, Subscription, Bill from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Leclercmobile __all__ = ['LeclercMobileModule'] class LeclercMobileModule(Module, CapBill): NAME = 'leclercmobile' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'Leclerc Mobile website' CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False, regexp='^(\d{10}|)$'), ValueBackendPassword('password', label='Password') ) BROWSER = Leclercmobile def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): for subscription in self.browser.get_subscription_list(): yield subscription def get_subscription(self, _id): if not _id.isdigit(): raise SubscriptionNotFound() with self.browser: subscription = self.browser.get_subscription(_id) if subscription: return subscription else: raise SubscriptionNotFound() def iter_bills_history(self, subscription): with self.browser: for history in self.browser.get_history(): if history.label != "Votre solde": yield history def get_bill(self, id): with self.browser: bill = self.browser.get_bill(id) if bill: return bill else: raise BillNotFound() def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) with self.browser: for bill in self.browser.iter_bills(subscription.id): yield bill # The subscription is actually useless, but maybe for the futur... def get_details(self, subscription): with self.browser: for detail in self.browser.get_details(): yield detail def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) with self.browser: return self.browser.readurl(bill._url) def get_balance(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) with self.browser: balance = self.browser.get_balance() balance.label = u"Balance %s" % subscription.id balance.id = "%s-balance" % subscription.id balance.currency = u'EUR' return balance ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/pages/�������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020212�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/pages/__init__.py��������������������������������������������������0000664�0000000�0000000�00000001603�12657170273�0022323�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .homepage import HomePage from .history import HistoryPage, PdfPage from .login import LoginPage __all__ = ['LoginPage', 'HomePage', 'HistoryPage', 'PdfPage'] �����������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/pages/history.py���������������������������������������������������0000664�0000000�0000000�00000015663�12657170273�0022300�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re import os import subprocess import tempfile import shutil from datetime import datetime, date, time from decimal import Decimal from weboob.deprecated.browser import Page from weboob.capabilities.bill import Detail, Bill def _get_date(detail): return detail.datetime class PdfPage(): def __init__(self, file): self.pdf = file def _parse_pdf(self): pdffile = tempfile.NamedTemporaryFile(bufsize=100000, mode='w', suffix='.pdf') temptxt = pdffile.name.replace('.pdf', '.txt') cmd = "ebook-convert" stdout = open("/dev/null", "w") shutil.copyfileobj(self.pdf, pdffile) pdffile.flush() subprocess.call([cmd, pdffile.name, temptxt], stdout=stdout) pdffile.close() txtfile = open(temptxt, 'r') txt = txtfile.read() txtfile.close() os.remove(temptxt) return txt def get_details(self): txt = self._parse_pdf() page = txt.split('CONSOMMATION')[2].split('ACTIVITE DETAILLEE')[0] lines = page.split('\n') lines = [x for x in lines if len(x) > 0] # Remove empty lines details = [] detail = None lines.pop(-1) # Line to describes pictures twolines = False for line in lines: if "Votre consommation" in line: line = line.split(": ", 1)[1] if twolines: twolines = False detail.infos = unicode(line, encoding='utf-8') elif re.match('[A-Za-z]', line[0]): # We have a new element, return the other one if detail is not None: details.append(detail) detail = Detail() split = re.split("(\d)", line, maxsplit=1) detail.price = Decimal(0) if len(split) > 2: detail.infos = unicode(split[1] + split[2], encoding='utf-8') else: twolines = True if '€' in line: specialprice = split[1] + split[2] detail.price = Decimal(specialprice.replace('€', '')) detail.label = unicode(split[0], encoding='utf-8') elif '€' in line: detail.price = Decimal(line.replace('€', '')) else: detail.infos = unicode(line, encoding='utf-8') details.append(detail) return details # Standard pdf text extractor take text line by line # But the position in the file is not always the "real" position to display... # It produce some unsorted and unparsable data # Example of bad software: pdfminer and others python tools # This is why we have to use "ebook-convert" from calibre software, # it is the only one to 'reflow" text and give some relevant results # The bad new is that ebook-convert doesn't support simple use with stdin/stdout def get_calls(self): txt = self._parse_pdf() pages = txt.split("DEBIT") pages.pop(0) # remove headers details = [] for page in pages: page = page.split('RÉGLO MOBILE')[0].split('N.B. Prévoir')[0] # remove footers lines = page.split('\n') lines = [x for x in lines if len(x) > 0] # Remove empty lines numitems = (len(lines) + 1) / 4 # Each line has five columns lines.pop(0) # remove the extra € symbol modif = 0 i = 0 while i < numitems: if modif != 0: numitems = ((len(lines) + 1 + modif) / 4) base = i * 4 - modif dateop = base corres = base + 1 duree = base + 2 price = base + 3 if "Changement vers le Forfait" in lines[base]: modif += 1 i += 1 continue # Special case with 5 columns, the operation date is not in the first one if len(re.split("(\d+\/\d+\/\d+)", lines[dateop])) < 2: lines[base + 1] = lines[base] + " " + lines[base + 1] dateop = base + 1 corres = base + 2 duree = base + 3 price = base + 4 modif -= 1 detail = Detail() splits = re.split("(\d+\/\d+\/\d+)", lines[dateop]) mydate = date(*reversed([int(x) for x in splits[1].split("/")])) mytime = time(*[int(x) for x in splits[2].split(":")]) detail.datetime = datetime.combine(mydate, mytime) if lines[corres] == '-': lines[corres] = "" if lines[duree] == '-': lines[duree] = '' detail.label = unicode(splits[0], encoding='utf-8', errors='replace') + u" " + lines[corres] + u" " + lines[duree] # Special case with only 3 columns, we insert a price if "Activation de votre ligne" in detail.label or u"Résiliation" in detail.label: lines.insert(price, '0') try: detail.price = Decimal(lines[price].replace(',', '.')) except: # In some special cases, there are no price column. Try to detect it if "Inclus" not in lines[price]: modif += 1 detail.price = Decimal(0) details.append(detail) i += 1 return sorted(details, key=_get_date, reverse=True) class HistoryPage(Page): def on_loaded(self): pass def getmaxid(self): max = 1 while len(self.document.xpath('//li[@id="liMois%s"]' % max)) > 0: max += 1 return max - 1 def date_bills(self, parentid): max = 1 while len(self.document.xpath('//li[@id="liMois%s"]' % max)) > 0: li = self.document.xpath('//li[@id="liMois%s"]' % max)[0] max += 1 link = li.xpath('a')[0] bill = Bill() bill._url = link.attrib['href'] bill.label = unicode(link.text) bill.format = u"pdf" bill.id = parentid + bill.label.replace(' ', '') yield bill �����������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/pages/homepage.py��������������������������������������������������0000664�0000000�0000000�00000002737�12657170273�0022362�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import Subscription from weboob.deprecated.browser import Page class HomePage(Page): def on_loaded(self): pass def get_list(self): l = [] phone = unicode(self.document.xpath('//span[@id="ctl00_ctl00_cMain_cEspCli_lblMsIsdn"]')[0].text.replace(' ', '')) self.browser.logger.debug('Found ' + phone + ' has phone number') phoneplan = unicode(self.document.xpath('//span[@id="ctl00_ctl00_cMain_cEspCli_aoaOffreActuelle_aooOffreEtOptions"]/dl/dd/span')[0].text) self.browser.logger.debug('Found ' + phoneplan + ' has subscription type') subscription = Subscription(phone) subscription.label = phone + ' - ' + phoneplan l.append(subscription) return l ���������������������������������weboob-1.1/modules/leclercmobile/pages/login.py�����������������������������������������������������0000664�0000000�0000000�00000005425�12657170273�0021702�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import StringIO from weboob.deprecated.browser import Page from weboob.deprecated.mech import ClientForm class LoginPage(Page): def on_loaded(self): pass def login(self, login, password): form = list(self.browser.forms())[0] self.browser.select_form("aspnetForm") self.browser.set_all_readonly(False) self.browser.controls.append(ClientForm.TextControl('text', '__ASYNCPOST', {'value': "true"})) self.browser['__EVENTTARGET'] = "ctl00$cMain$lnkValider" self.browser['ctl00$cMain$ascSaisieMsIsdn$txtMsIsdn'] = login.encode('iso-8859-1') self.browser['ctl00$cMain$txtMdp'] = password.encode('iso-8859-1') self.browser.submit(nologin=True) return form def iswait(self): spanwait = self.document.xpath('//span[@id="ctl00_ascAttente_timerAttente"]') return len(spanwait) > 0 def iserror(self): error = self.document.xpath('//span[@id="ctl00_cMain_ascLibErreur_lblErreur"]') return len(error) > 0 def getredirect(self): string = StringIO.StringIO() self.document.write(string) try: redirect = string.getvalue().split('pageRedirect')[1].split('|')[2] except: redirect = '' return redirect def next(self, login, form): self.browser.form = form string = StringIO.StringIO() self.document.write(string) controlvalue = string.getvalue().split('__EVENTVALIDATION')[1].split('|')[1] state = string.getvalue().split('__VIEWSTATE')[1].split('|')[1] self.browser.controls.append(ClientForm.TextControl('text', 'ctl00$objScriptManager', {'value': "ctl00$ascAttente$panelAttente|ctl00$ascAttente$timerAttente"})) self.browser['__VIEWSTATE'] = state self.browser['__EVENTTARGET'] = "ctl00$ascAttente$timerAttente" self.browser['__EVENTVALIDATION'] = controlvalue self.browser['ctl00$cMain$ascSaisieMsIsdn$txtMsIsdn'] = login.encode('iso-8859-1') self.browser['ctl00$cMain$txtMdp'] = "" self.browser.submit(nologin=True) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/leclercmobile/test.py������������������������������������������������������������0000664�0000000�0000000�00000004250�12657170273�0020445�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Fourcot Florent # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class LeclercMobileTest(BackendTest): MODULE = 'leclercmobile' def test_list(self): """ Test listing of subscriptions . No support of multi-account on the website, we could assume to have only one subscription. Check the balance if the subscription is ok. """ subscriptions = list(self.backend.iter_subscription()) self.assertTrue(len(subscriptions) == 1, msg="Account listing failed") self.assertTrue(self.backend.get_balance(subscriptions[0]) > 0, msg="Get balance failed") def test_downloadbills(self): """ Iter all bills and try to download it. """ for subscription in self.backend.iter_subscription(): for bill in self.backend.iter_bills(subscription.id): self.backend.download_bill(bill.id) def test_history(self): for subscription in self.backend.iter_subscription(): self.assertTrue(len(list(self.backend.iter_bills_history(subscription))) > 0) def test_details(self): for subscription in self.backend.iter_subscription(): details = list(self.backend.get_details(subscription)) self.assertTrue(len(details) > 5, msg="Not enough details") total = 0 for d in details: total += d.price self.assertTrue(total > 0, msg="Parsing of price failed") ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016102�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001510�12657170273�0020210�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"NewspaperFigaroModule init" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NewspaperFigaroModule __all__ = ['NewspaperFigaroModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/browser.py��������������������������������������������������������������0000664�0000000�0000000�00000003746�12657170273�0020151�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"browser for lefigaro website" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .pages.article import ArticlePage, ActuPage from .pages.flashactu import FlashActuPage from weboob.deprecated.browser import Browser, Page class IndexPage(Page): pass class NewspaperFigaroBrowser(Browser): "NewspaperFigaroBrowser class" ENCODING = "UTF-8" PAGES = {"http://\w+.lefigaro.fr/flash-.*/(\d{4})/(\d{2})/(\d{2})/(.*$)": FlashActuPage, "http://\w+.lefigaro.fr/bd/(\d{4})/(\d{2})/(\d{2})/(.*$)": FlashActuPage, "http://\w+.lefigaro.fr/(?!flash-|bd|actualite).+/(\d{4})/(\d{2})/(\d{2})/(.*$)": ArticlePage, "http://\w+.lefigaro.fr/actualite/(\d{4})/(\d{2})/(\d{2})/(.*$)": ActuPage, "http://\w+.lefigaro.fr/actualite-.*/(\d{4})/(\d{2})/(\d{2})/(.*$)": ArticlePage, "http://\w+.lefigaro.fr/": IndexPage, "http://feeds.lefigaro.fr/c/32266/f/438190/s/\w+/sc/\d{2}/\d{1}/\w+/story01.htm": FlashActuPage, } def is_logged(self): return False def login(self): pass def fillobj(self, obj, fields): pass def get_content(self, _id): "return page article content" self.location(_id) if self.is_on_page(IndexPage): return None return self.page.get_article(_id) ��������������������������weboob-1.1/modules/lefigaro/favicon.png�������������������������������������������������������������0000664�0000000�0000000�00000001610�12657170273�0020233�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME 5T,���iTXtComment�����Created with GIMPd.e��IDATx_HSQ?:MM&e!9IRS{(% HB(S􏐢'!zE4"+(P,*0B313v{/sݛcw9_ܝ9&QEA`\ H� b:Ó}ס;\π +�)l(XM&LWlsAj@lHOi{5B o];j[߭(\�) ]ns@svۓ_<O<: `t"n+aOmGNNÕ:淫.@�#5ҬP=c/㰫.= KCT Ԍvۉ��Ūc jX( ꀯproM TR ǿ:̽ 8 |ƇGm⃛nA! ,P\VN dm`j ѢㅭMAꂳc Ԯ}>*y$&H� [qLxq شJ0UgN_s@׀ �FCpp m=kF �c:C #!. KDɋ@]3) Ԕh.fl)Zacv .xQ 'tR|p'BBl AnwՕ D@;@�$� @�$� @�$� B?V.����IENDB`������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/module.py���������������������������������������������������������������0000664�0000000�0000000�00000002535�12657170273�0017746�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. "backend for http://www.lefigaro.fr" from weboob.capabilities.messages import CapMessages from weboob.tools.capabilities.messages.GenericModule import GenericNewspaperModule from .browser import NewspaperFigaroBrowser from .tools import rssid class NewspaperFigaroModule(GenericNewspaperModule, CapMessages): MAINTAINER = u'Julien Hebert' EMAIL = 'juke@free.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' STORAGE = {'seen': {}} NAME = 'lefigaro' DESCRIPTION = u'Le Figaro French newspaper website' BROWSER = NewspaperFigaroBrowser RSS_FEED = 'http://rss.lefigaro.fr/lefigaro/laune?format=xml' RSSID = rssid �������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/pages/������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017201�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/pages/__init__.py�������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021300�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/pages/article.py��������������������������������������������������������0000664�0000000�0000000�00000006610�12657170273�0021201�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"ArticlePage object for lefigaro" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage, drop_comments, try_drop_tree, try_remove_from_selector_list class ArticlePage(GenericNewsPage): "ArticlePage object for lefigaro" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "h1" self.element_author_selector = "span.auteur>a, span.auteur_long>div" self.element_body_selector = "article div.fig-article-body" def get_body(self): element_body = self.get_element_body() drop_comments(element_body) try_drop_tree(self.parser, element_body, "script") try_drop_tree(self.parser, element_body, "liste") try_remove_from_selector_list(self.parser, element_body, ["div#article-comments", "div.infos", "div.photo", "div.art_bandeau_bottom", "div.view", "span.auteur_long", "#toolsbar", 'link']) for image in self.parser.select(element_body, 'img'): if image.attrib['src'].endswith('coeur-.gif'): image.drop_tree() for div in self.parser.select(element_body, 'div'): if div.text == ' Player Figaro BFM ': obj = div.getnext() a = obj.getnext() if obj.tag == 'object': obj.drop_tree() if a.tag == 'a' and 'BFM' in a.text: a.drop_tree() div.drop_tree() # This part of the article seems manually generated. for crappy_title in self.parser.select(element_body, 'p strong'): if crappy_title.text == 'LIRE AUSSI :' or crappy_title.text == 'LIRE AUSSI:': # Remove if it has only links for related in crappy_title.getparent().itersiblings(tag='p'): if len(related) == len(list(related.iterchildren(tag='a'))): related.drop_tree() else: break crappy_title.drop_tree() txts = element_body.find_class("texte") if len(txts) > 0: txts[0].drop_tag() element_body.tag = "div" return self.parser.tostring(element_body) class ActuPage(GenericNewsPage): def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "h2" self.element_author_selector = "div.name>span" self.element_body_selector = ".block-text" def get_body(self): element_body = self.get_element_body() try_remove_from_selector_list(self.parser, element_body, ['div']) element_body.tag = "div" return self.parser.tostring(element_body) ������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/pages/flashactu.py������������������������������������������������������0000664�0000000�0000000�00000002455�12657170273�0021533�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"ArticlePage object for lefigaro" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage class FlashActuPage(GenericNewsPage): "ArticlePage object for lefigaro" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "h1" self.element_author_selector = "div.name>span" self.element_body_selector = "article, fig-article-body" def get_body(self): element_body = self.get_element_body() element_body.tag = "div" return self.parser.tostring(element_body) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000002135�12657170273�0017434�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.tools.html import html2text class LeFigaroTest(BackendTest): MODULE = 'lefigaro' def test_lefigaro(self): l = list(self.backend.iter_threads()) assert len(l) thread = self.backend.get_thread(l[0].id) assert len(thread.root.content) assert len(html2text(thread.root.content)) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lefigaro/tools.py����������������������������������������������������������������0000664�0000000�0000000�00000001550�12657170273�0017615�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"tools for lefigaro backend" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. def url2id(url): "return an id from an url" return url def rssid(entry): return url2id(entry.id) ��������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/liberation/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016442�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/liberation/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000001504�12657170273�0020553�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"NewspaperLibeModule init" # -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NewspaperLibeModule __all__ = ['NewspaperLibeModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/liberation/browser.py������������������������������������������������������������0000664�0000000�0000000�00000002300�12657170273�0020472�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .pages.article import ArticlePage from weboob.deprecated.browser import Browser class NewspaperLibeBrowser(Browser): "NewspaperLibeBrowser class" PAGES = {"http://.*liberation.fr/.*": ArticlePage} def is_logged(self): return False def login(self): pass def fillobj(self, obj, fields): pass def get_content(self, _id): "return page article content" self.location(_id) return self.page.get_article(_id) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/liberation/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000002622�12657170273�0020577�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������C��� pHYs�� �� ����tIME ' v���tEXtComment�Created with GIMPW��IDATxoUǿgvȯ6�Kl4En Q !$ȃ11]m֤J؅Re۝n0eg;]4'3g9{gν3`0 `0 `xv8­B/h%xׅ$rd O�hjx\` & �@/@bnV�LK':HC"$E1�ҭ3D&cc%a4m !FHPE‗$bL NAk E@�Ķ J']K �6 gn~�ȣ!�AydK@R`!aJMRj%]OsG.RwKTlR@jIJ4h LtsivG^r;_|M5aoҹ4Heh捖ơ~ȅ%.zzr9\Y �u:}t?s-:]=^Ug=wG;w| IRem`~<wRT_/s}*U:P�0n9^9xR*)Q j.Khf؎kU_x$Y~LX_Oe[f<}.糹~ Kj�–x��aQl$ mƝ3^+ʶgm{CYB˅?BcU`M.n615p�{�zg ?<pi'f'|{МH!:No?I2}^WOVix[Sv�]gj{g!h._�y-;zl59ֶP,2Q*$I~A ^Z w^u>'?KRQ+_%ʋ]NoBBnc@k}JkU?=g}E�z{1?w };,_~;>}ntsֶ:;E�=-yoaˆIv+LPwDAǯV_/jee*+ز.9>b4zvُ+=P#귡&waږ:gsտ[ K+䂗4Gi j@ZѤWO@h76xFu}i# +48^LXpaf{ ~2 XP!>w@g1+`0 `0 `0 O)Xuݧު����IENDB`��������������������������������������������������������������������������������������������������������������weboob-1.1/modules/liberation/module.py�������������������������������������������������������������0000664�0000000�0000000�00000005364�12657170273�0020311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. "backend for http://liberation.fr" from weboob.tools.newsfeed import Newsfeed from weboob.capabilities.messages import CapMessages, Thread from weboob.tools.capabilities.messages.GenericModule import GenericNewspaperModule from weboob.tools.backend import BackendConfig from weboob.tools.value import Value from .browser import NewspaperLibeBrowser from .tools import rssid, url2id class NewspaperLibeModule(GenericNewspaperModule, CapMessages): MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' STORAGE = {'seen': {}} NAME = 'liberation' DESCRIPTION = u'Libération newspaper website' BROWSER = NewspaperLibeBrowser RSSID = staticmethod(rssid) URL2ID = staticmethod(url2id) RSSSIZE = 30 CONFIG = BackendConfig(Value('feed', label='RSS feed', choices={'9': u'A la une sur Libération', '10': u'Monde', '11': u'Politiques', '12': u'Société', '13': u'Économie', '14': u'Sports', '17': u'Labo: audio, vidéo, diapos, podcasts', '18': u'Rebonds', '44': u'Les chroniques de Libération', '53': u'Écrans', '54': u'Next', '58': u'Cinéma' } )) def __init__(self, *args, **kwargs): GenericNewspaperModule.__init__(self, *args, **kwargs) self.RSS_FEED = "http://www.liberation.fr/rss/%s" % self.config['feed'].get() def iter_threads(self): for article in Newsfeed(self.RSS_FEED, self.RSSID).iter_entries(): thread = Thread(article.id) thread.title = article.title thread.date = article.datetime yield(thread) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/liberation/pages/����������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017541�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/liberation/pages/__init__.py�����������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021640�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/liberation/pages/article.py������������������������������������������������������0000664�0000000�0000000�00000003750�12657170273�0021543�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage,\ NoBodyElement, NoAuthorElement, NoneMainDiv class ArticlePage(GenericNewsPage): "ArticlePage object for Libe" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "title" self.element_author_selector = "span.author" self.element_body_selector = "div.article-body" def get_body(self): if '.blogs.liberation.fr/' in self.url: self.element_body_selector = "div.entry-content" try: return self.parser.tostring(self.get_element_body()) except NoBodyElement: meta = self.document.xpath('//meta[@name="description"]')[0] txt = meta.attrib['content'] return txt def get_title(self): title = GenericNewsPage.get_title(self) return title.replace(u' - Libération', '') def get_author(self): try: author = self.get_element_author().text_content().strip() if author.startswith('Par '): return author.split('Par ', 1)[1] else: return author except (NoAuthorElement, NoneMainDiv): #TODO: Mettre un warning return None ������������������������weboob-1.1/modules/liberation/test.py���������������������������������������������������������������0000664�0000000�0000000�00000001665�12657170273�0020003�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class LiberationTest(BackendTest): MODULE = 'liberation' def test_new_messages(self): for message in self.backend.iter_unread_messages(): pass ���������������������������������������������������������������������������weboob-1.1/modules/liberation/tools.py��������������������������������������������������������������0000664�0000000�0000000�00000001553�12657170273�0020160�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re def url2id(url): return re.sub(u'[^\d]', '', url.split('0Dxtor')[0].split('0I')[-1]) def rssid(entry): return entry.link �����������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/logicimmo/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016271�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/logicimmo/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0020401�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import LogicimmoModule __all__ = ['LogicimmoModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/logicimmo/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000007337�12657170273�0020340�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from weboob.capabilities.housing import Query, TypeNotSupported from .pages import CitiesPage, SearchPage, HousingPage, PhonePage class LogicimmoBrowser(PagesBrowser): BASEURL = 'http://www.logic-immo.com/' city = URL('asset/t9/t9_district/fr/(?P<size>\d*)/(?P<first_letter>\w)/(?P<pattern>.*)\.txt\?json=%22(?P<pattern2>.*)%22', CitiesPage) search = URL('(?P<type>location-immobilier|vente-immobilier|recherche-colocation)-(?P<cities>.*)/options/(?P<options>.*)', SearchPage) housing = URL('detail-(?P<_id>.*).htm', HousingPage) phone = URL('(?P<urlcontact>.*)', PhonePage) TYPES = {Query.TYPE_RENT: 'location-immobilier', Query.TYPE_SALE: 'vente-immobilier', Query.TYPE_SHARING: 'recherche-colocation'} RET = {Query.HOUSE_TYPES.HOUSE: '2', Query.HOUSE_TYPES.APART: '1', Query.HOUSE_TYPES.LAND: '3', Query.HOUSE_TYPES.PARKING: '10', Query.HOUSE_TYPES.OTHER: '14'} def get_cities(self, pattern): if pattern: pattern1 = pattern if len(pattern) < 5 else pattern[:5] size = len(pattern1) first_letter = pattern[0].upper() return self.city.go(size=size, first_letter=first_letter, pattern=pattern1.upper(), pattern2=pattern.upper()).get_cities() def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types): if type not in self.TYPES: raise TypeNotSupported() options = [] ret = [] for house_type in house_types: if house_type in self.RET: ret.append(self.RET.get(house_type)) if len(ret): options.append('groupprptypesids=%s' % ','.join(ret)) options.append('pricemin=%s' % (cost_min if cost_min else '0')) if cost_max: options.append('pricemax=%s' % cost_max) options.append('areamin=%s' % (area_min if area_min else '0')) if area_max: options.append('areamax=%s' % area_max) if nb_rooms: if type == Query.TYPE_SHARING: options.append('nbbedrooms=%s' % ','.join([str(i) for i in range(nb_rooms, 7)])) else: options.append('nbrooms=%s' % ','.join([str(i) for i in range(nb_rooms, 7)])) self.search.go(type=self.TYPES.get(type, 'location-immobilier'), cities=cities, options='/'.join(options)) if type == Query.TYPE_SHARING: return self.page.iter_sharing() return self.page.iter_housings() def get_housing(self, _id, housing=None): return self.housing.go(_id=_id).get_housing(obj=housing) def get_phone(self, _id): if _id.startswith('location') or _id.startswith('vente'): urlcontact, params = self.housing.stay_or_go(_id=_id).get_phone_url_datas() return self.phone.go(urlcontact=urlcontact, params=params).get_phone() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/logicimmo/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000006767�12657170273�0020444�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����gAMA�� a��� pHYs����+�� IDATx^Y lkK wE@Ql]eI:3FI&@2n@. db@=A6Q  u q "nI˥;__l><~uǡQ@Bໝr@]P)wu>5!ӑ:Ϸϣ<)ߑzuno1w~Ҙd:Uʀʭ,@BtX܉C*dUgVq9u] y@'ϣjbBd[AlPǪ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3Զ,u7jwtLr -IOtH xݸI7K uڵkrq9\twޢͳ4Jy{_fY0# +%Bd귢vyoR)cʚ:L~lwoӏ2 R*^LSN{uZڏ=Zի+$#i\B\'wlArGQ�~} <ۍN|My ko*ag?эti`4*�(>fh��x$g}V"cْΊ $~--]G=@~_@| 8Dx]tdG/{WF1]|ouEǻr`NןJ7oCN>M(ux~ :uꔀ�+FI'OWF19tiktGΏr%b?ԅ/@^]LNs Jo:HnJQ&G%e8@-O/vwwX'#Mδ :ƥU^e /@kdES . @*E>+P#n@hrWaj3@!]@v0=řzm2?.9LR%>=cܔD:J= 0cΖ!52a+uim�C.^'r.xf0a\{!^zAx",S*cNޮKtFh'l@ qp2DCǬ gYi??IL;*Q㥔%Pg# F8ġ�`+#<e{b&<[hx+?q$O0 -4<&:㬲 k^ T h^0;Š{Hn)H8KU0T}~;dP[=WSz1rP[=WSz1rP[=WSz1rP[=W#zye����IENDB`���������weboob-1.1/modules/logicimmo/module.py��������������������������������������������������������������0000664�0000000�0000000�00000005732�12657170273�0020137�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.housing import CapHousing, Housing, HousingPhoto from weboob.capabilities.base import UserError from .browser import LogicimmoBrowser __all__ = ['LogicimmoModule'] class LogicImmoCitiesError(UserError): """ Raised when more than 3 cities are selected """ def __init__(self, msg='You cannot select more than three cities'): UserError.__init__(self, msg) class LogicimmoModule(Module, CapHousing): NAME = 'logicimmo' DESCRIPTION = u'logicimmo website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = LogicimmoBrowser def get_housing(self, housing): if isinstance(housing, Housing): id = housing.id else: id = housing housing = None housing = self.browser.get_housing(id, housing) housing.phone = self.browser.get_phone(id) return housing def search_city(self, pattern): return self.browser.get_cities(pattern) def search_housings(self, query): cities_names = ['%s' % c.name.replace(' ', '-') for c in query.cities if c.backend == self.name] cities_ids = ['%s' % c.id for c in query.cities if c.backend == self.name] if len(cities_names) == 0: return list() if len(cities_names) > 3: raise LogicImmoCitiesError() cities = ','.join(cities_names + cities_ids) return self.browser.search_housings(query.type, cities.lower(), query.nb_rooms, query.area_min, query.area_max, query.cost_min, query.cost_max, query.house_types) def fill_housing(self, housing, fields): self.browser.get_housing(housing.id, housing) if 'phone' in fields: housing.phone = self.browser.get_phone(housing.id) return housing def fill_photo(self, photo, fields): if 'data' in fields and photo.url and not photo.data: photo.data = self.browser.open(photo.url).content return photo OBJECTS = {Housing: fill_housing, HousingPhoto: fill_photo, } ��������������������������������������weboob-1.1/modules/logicimmo/pages.py���������������������������������������������������������������0000664�0000000�0000000�00000020136�12657170273�0017744�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from decimal import Decimal from weboob.browser.pages import HTMLPage, JsonPage from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.browser.filters.json import Dict from weboob.browser.filters.standard import Format, CleanText, Regexp, CleanDecimal, Date, Env, BrowserURL from weboob.browser.filters.html import XPath, CleanHTML from weboob.capabilities.housing import Housing, HousingPhoto, City from weboob.capabilities.base import NotAvailable class CitiesPage(JsonPage): @method class get_cities(DictElement): class item(ItemElement): klass = City obj_id = Format('%s_%s', Dict('lct_id'), Dict('lct_level')) obj_name = Format('%s %s', Dict('lct_name'), Dict('lct_post_code')) class PhonePage(HTMLPage): def get_phone(self): return CleanText('//div[has-class("phone")]', children=False)(self.doc) class HousingPage(HTMLPage): @method class get_housing(ItemElement): klass = Housing obj_id = Env('_id') obj_title = CleanText(CleanHTML('//meta[@itemprop="name"]/@content')) obj_area = CleanDecimal(Regexp(CleanText(CleanHTML('//meta[@itemprop="name"]/@content')), '(.*?)(\d*) m\xb2(.*?)', '\\2'), default=NotAvailable) obj_cost = CleanDecimal('//*[@itemprop="price"]') obj_currency = Regexp(CleanText('//*[@itemprop="price"]'), '.*([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') obj_date = Date(Regexp(CleanText('//p[@class="offer-description-notes"]|//p[has-class("darkergrey")]'), u'.* Mis à jour : (\d{2}/\d{2}/\d{4}).*')) obj_text = CleanHTML('//div[@class="offer-description-text"]|//div[has-class("offer-description")]') obj_location = CleanText('//*[@itemprop="address"]') obj_url = BrowserURL('housing', _id=Env('_id')) def obj_photos(self): photos = [] for img in XPath('//div[@class="carousel-content"]/ul/li/a/img/@src|//div[@class="carousel"]/ul/li/a/img/@src')(self): photos.append(HousingPhoto(u'%s' % img)) return photos def obj_details(self): details = {} energy = CleanText('//div[has-class("energy-summary")]/span[@class="section-label"]|//div[has-class("energy-summary")]/div/span[@class="section-label"]', default='')(self) energy_value = CleanText('//div[has-class("energy-summary")]/span[@class="energy-msg"]', default='')(self) if energy and energy_value: details[energy] = energy_value greenhouse = CleanText('//div[has-class("greenhouse-summary")]/span[@class="section-label"]|//div[has-class("greenhouse-summary")]/div/span[@class="section-label"]', default='')(self) greenhouse_value = CleanText('//div[has-class("greenhouse-summary")]/span[@class="energy-msg"]', default='')(self) if greenhouse and greenhouse_value: details[greenhouse] = greenhouse_value for li in XPath('//ul[@itemprop="description"]/li')(self): label = CleanText('./div[has-class("criteria-label")]')(li) value = CleanText('./div[has-class("criteria-value")]')(li) details[label] = value return details def get_phone_url_datas(self): a = XPath('//button[has-class("offer-contact-vertical-phone")]')(self.doc)[0] urlcontact = 'http://www.logic-immo.com/modalMail' params = {} params['universe'] = CleanText('./@data-univers')(a) params['source'] = CleanText('./@data-source')(a) params['pushcontact'] = CleanText('./@data-pushcontact')(a) params['mapper'] = CleanText('./@data-mapper')(a) params['offerid'] = CleanText('./@data-offerid')(a) params['offerflag'] = CleanText('./@data-offerflag')(a) params['campaign'] = CleanText('./@data-campaign')(a) params['xtpage'] = CleanText('./@data-xtpage')(a) params['offertransactiontype'] = CleanText('./@data-offertransactiontype')(a) params['aeisource'] = CleanText('./@data-aeisource')(a) params['shownumber'] = CleanText('./@data-shownumber')(a) params['corail'] = 1 return urlcontact, params class SearchPage(HTMLPage): @method class iter_sharing(ListElement): item_xpath = '//article[has-class("offer-block")]' class item(ItemElement): klass = Housing obj_id = Format('colocation-%s', CleanText('./div/header/@id', replace=[('header-offer-', '')])) obj_title = CleanText(CleanHTML('./div/header/section/p[@class="property-type"]/span/@title')) obj_area = CleanDecimal('./div/header/section/p[@class="offer-attributes"]/a/span[@class="offer-area-number"]', default=0) obj_cost = CleanDecimal('./div/header/section/p[@class="price"]') obj_currency = Regexp(CleanText('./div/header/section/p[@class="price"]', default=NotAvailable), '.* ([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') obj_text = CleanText('./div/div[@class="content-offer"]/section[has-class("content-desc")]/p/span[has-class("offer-text")]/@title') obj_date = Date(Regexp(CleanText('./div/header/section/p[has-class("update-date")]'), ".*(\d{2}/\d{2}/\d{4}).*")) obj_location = CleanText('(./div/div[@class="content-offer"]/section[has-class("content-desc")]/p)[1]/span/@title') @method class iter_housings(ListElement): item_xpath = '//div[@class="offer-block "]' class item(ItemElement): klass = Housing obj_id = Format('%s-%s', Regexp(Env('type'), '(.*)-.*'), CleanText('./@id', replace=[('header-offer-', '')])) obj_title = CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/p[@class="offer-type"]/span/@title') obj_area = CleanDecimal(CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/div/div/h3/a/span[@class="offer-area-number"]', default=NotAvailable)) obj_cost = CleanDecimal(Regexp(CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/p[@class="offer-price"]/span', default=NotAvailable), '(.*) [%s%s%s]' % (u'€', u'$', u'£'), default=NotAvailable), default=Decimal(0)) obj_currency = Regexp(CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/p[@class="offer-price"]/span', default=NotAvailable), '.* ([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') obj_date = Date(Regexp(CleanText('./div/div/div[has-class("offer-picture-more")]/div/p[@class="offer-update"]'), ".*(\d{2}/\d{2}/\d{4}).*")) obj_text = CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/div/p[has-class("offer-description")]/span') obj_location = CleanText('./div/div/div[@class="offer-details-wrapper"]/div/div/div/div/h2') ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/logicimmo/test.py����������������������������������������������������������������0000664�0000000�0000000�00000002653�12657170273�0017630�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import itertools from weboob.capabilities.housing import Query from weboob.tools.test import BackendTest class LogicimmoTest(BackendTest): MODULE = 'logicimmo' def test_logicimmo(self): query = Query() query.area_min = 20 query.cost_max = 900 query.cities = [] query.type = Query.TYPE_RENT for city in self.backend.search_city('paris'): if len(query.cities) >= 3: break city.backend = self.backend.name query.cities.append(city) results = list(itertools.islice(self.backend.search_housings(query), 0, 20)) self.assertTrue(len(results) > 0) self.backend.fillobj(results[0], 'phone') �������������������������������������������������������������������������������������weboob-1.1/modules/lolix/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015441�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lolix/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000001430�12657170273�0017550�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import LolixModule __all__ = ['LolixModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lolix/browser.py�����������������������������������������������������������������0000664�0000000�0000000�00000003616�12657170273�0017504�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser.decorators import id2url from weboob.deprecated.browser import Browser from .job import LolixJobAdvert from .pages import SearchPage, AdvertPage import urllib __all__ = ['LolixBrowser'] class LolixBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'fr.lolix.org/search/offre' ENCODING = 'iso-8859-1' PAGES = { '%s://%s/search.php' % (PROTOCOL, DOMAIN): SearchPage, '%s://%s/offre.php\?id=(?P<id>.+)' % (PROTOCOL, DOMAIN): AdvertPage, } def advanced_search_job(self, region=0, poste=0, contrat=0, limit_date=0, pattern=None): data = { 'mode': 'find', 'page': '0', 'posteid': poste, 'contratid': contrat, 'regionid': region, 'limitjour': limit_date } self.location('%s://%s/search.php' % (self.PROTOCOL, self.DOMAIN), urllib.urlencode(data)) assert self.is_on_page(SearchPage) return self.page.iter_job_adverts(pattern) @id2url(LolixJobAdvert.id2url) def get_job_advert(self, url, advert): self.location(url) assert self.is_on_page(AdvertPage) return self.page.get_job_advert(url, advert) ������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lolix/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000022616�12657170273�0017603�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs����+���tIME)֤�� �IDATxyx]WuksYd<v;ؙ@ L!@h Ҥ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p<~~ ?k֬nƹxq5Q%-T#=|$iȾ1/cgwzaV]w® 8=S35ᆚ2ԓ>o.'`(SE\0D쐉Q85O0{h Bv3~=,ԯ8y׆W?+ޡ'J;lre,COL"cDi3Ҷ~<l4<6w5 q;n<EBE>AXo7 w8dR4Ti,uA)^Kw鉚}2ۋ^HU%z~GYS*@^mOR1GY_HQ5Uߤr?Rgq[UMk7ez!?lRU[)S^U2y*&@ mj&& |4-=TގEwC>d 6qJ m' t |Ozj����IENDB`������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lolix/job.py���������������������������������������������������������������������0000664�0000000�0000000�00000001642�12657170273�0016570�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.job import BaseJobAdvert class LolixJobAdvert(BaseJobAdvert): @classmethod def id2url(cls, _id): return 'http://fr.lolix.org/search/offre/offre.php?id=%s' % _id ����������������������������������������������������������������������������������������������weboob-1.1/modules/lolix/module.py������������������������������������������������������������������0000664�0000000�0000000�00000014167�12657170273�0017311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import Value from weboob.capabilities.job import CapJob from .browser import LolixBrowser from .job import LolixJobAdvert __all__ = ['LolixModule'] class LolixModule(Module, CapJob): NAME = 'lolix' DESCRIPTION = u'Lolix French free software employment website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' VERSION = '1.1' BROWSER = LolixBrowser region_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '0': u'-- Indifférent --', '100000000': u'-- France entière', '100100000': u'-- France métropolitaine', '100100001': u'-- Alsace', '100100002': u'-- Auvergne', '100100003': u'-- Aquitaine', '100100004': u'-- Bourgogne', '100100005': u'-- Bretagne', '100100025': u'-- Centre', '100100027': u'-- Champagne-Ardenne', '100100030': u'-- Corse', '100100037': u'-- Franche-Comté', '100100040': u'-- Ile de France', '100100044': u'-- Languedoc-Roussillon', '100100048': u'-- Limousin', '100100051': u'-- Lorraine', '100100055': u'-- Midi-Pyrénées', '100100060': u'-- Nord-Pas-de-Calais', '100100073': u'-- Normandie', '100100076': u'-- Pays-de-Loire', '100100079': u'-- Picardie', '100100082': u'-- Poitou-Charentes', '100100085': u'-- Provence Alpes Cote d\'azur', '100100090': u'-- Rhône Alpes', '100200000': u'-- DOM et TOM', '100200001': u'-- Guadeloupe', '100200002': u'-- Guyane', '100200003': u'-- Martinique', '100200004': u'-- Réunion', '100200005': u'-- Saint-Pierre et Miquelon', '200000000': u'-- Etranger', }.iteritems())]) poste_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '0': u'-- Indifférent --', '100000000': u'-- Service Technique', '100005000': u'-- Administrateur base de données', '100004000': u'-- Admin. Système/Réseaux', '100004004': u'-- Administrateur système', '100004002': u'-- Administrateur réseaux', '100007000': u'-- Analyste', '100002000': u'-- Chef de projet', '100002001': u'-- Chef de projet junior', '100002002': u'-- Chef de projet senior', '100021000': u'-- Consultant', '100003000': u'-- Développeur', '100003001': u'-- Développeur junior', '100003002': u'-- Développeur senior', '100009000': u'-- Directeur technique', '100006000': u'-- Ingénieur d\'étude', '100011000': u'-- Ingénieur support', '100012000': u'-- Responsable R & D', '100010000': u'-- Technicien', '100010002': u'-- Technicien hotline', '100010003': u'-- Technicien maintenance', '100020000': u'-- Webmaster', '200000000': u'-- Service Commercial', '200300000': u'-- Commercial', '200200000': u'-- Directeur commercial', '200100000': u'-- Technico commercial', '400000000': u'-- Service Marketing', '400100000': u'-- Responsable Marketing', '300000000': u'-- Service qualité', '300100000': u'-- Assistant qualité', '300200000': u'-- Responsable qualité', '2000000': u'-- Fondateur', '7000000': u'-- Formateur', '6000000': u'-- Journaliste', '500100000': u'-- Assistant(e) de direction', '4000000': u'-- Stagiaire', '5000000': u'-- Traducteur', }.iteritems())]) ''' '000000' in order to display description in console question the rule is : len(key) > 5 or ' ' in key: ''' contrat_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '000000': u'-- Indifférent --', '6': u'Alternance', '5': u'Apprentissage', '2': u'CDD', '1': u'CDI', '4': u'Freelance', '3': u'Stage', }.iteritems())]) limit_date_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '2592000': u'30 jours', '5184000': u'60 jours', '7776000': u'90 jours', '0': u'Illimitée', }.iteritems())]) CONFIG = BackendConfig(Value('region', label=u'Région', choices=region_choices), Value('poste', label=u'Poste', choices=poste_choices), Value('contrat', label=u'Contrat', choices=contrat_choices), Value('limit_date', label=u'Date limite', choices=limit_date_choices)) def search_job(self, pattern=None): with self.browser: for job_advert in self.browser.advanced_search_job(pattern=pattern): yield job_advert def advanced_search_job(self): for advert in self.browser.advanced_search_job(region=self.config['region'].get(), poste=self.config['poste'].get(), contrat=int(self.config['contrat'].get()), limit_date=self.config['limit_date'].get()): yield advert def get_job_advert(self, _id, advert=None): with self.browser: return self.browser.get_job_advert(_id, advert) def fill_obj(self, advert, fields): self.get_job_advert(advert.id, advert) OBJECTS = {LolixJobAdvert: fill_obj} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lolix/pages.py�������������������������������������������������������������������0000664�0000000�0000000�00000006647�12657170273�0017127�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page import dateutil.parser import re from .job import LolixJobAdvert class AdvertPage(Page): def get_job_advert(self, url, advert): tables = self.document.getroot().xpath('//td[@class="Contenu"]/table') rows = self.parser.select(tables[2], 'tr') if not advert: advert = LolixJobAdvert(self.group_dict['id']) advert.url = url advert.society_name = u'%s' % self.parser.select(tables[3], 'tr/td/a', 1, method='xpath').text return self.fill_job_advert(rows, advert) def fill_job_advert(self, rows, advert): advert.title = u'%s' % self.parser.select(rows[0], 'td', 1).text_content() isDescription = False for row in rows: cols = self.parser.select(row, 'td') if isDescription: advert.description = u'%s' % cols[0].text_content() isDescription = False elif cols[0].text == u'Poste :': advert.job_name = u'%s' % cols[1].text_content() elif cols[0].text == u'Contrat :': advert.contract_type = u'%s' % cols[1].text_content() elif cols[0].text and cols[0].text.find(u'Rémunération :') != -1: advert.pay = u'%s' % cols[1].text_content() elif cols[0].text and cols[0].text.find(u'Région :') != -1: advert.place = u'%s' % cols[1].text_content() elif cols[0].text == u'Détails :': isDescription = True #else: # print cols[0].text return advert class SearchPage(Page): def iter_job_adverts(self, pattern): rows = self.document.getroot().xpath('//td[@class="Contenu"]/table/tr') for row in rows: cols = self.is_row_advert(row) if cols is not None: advert = self.create_job_advert(cols) if pattern: if pattern in advert.title: yield advert else: yield advert def is_row_advert(self, row): cols = self.parser.select(row, 'td') if len(cols) > 1: d = dict(cols[1].attrib) if 'class' in d.keys(): if 'ListeDark' == d['class'] or 'ListeLight' == d['class']: return cols def create_job_advert(self, cols): a = self.parser.select(cols[2], 'a')[0] advert = LolixJobAdvert(re.match(r'offre.php\?id=(.*)', a.attrib['href']).group(1)) advert.publication_date = dateutil.parser.parse(cols[0].text).date() advert.society_name = u'%s' % self.parser.select(cols[1], 'a')[0].text advert.title = u'%s' % a.text return advert �����������������������������������������������������������������������������������������weboob-1.1/modules/lolix/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000002122�12657170273�0016767�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class LolixTest(BackendTest): MODULE = 'lolix' def test_lolix_advanced_search(self): l = list(self.backend.advanced_search_job()) assert len(l) advert = self.backend.get_job_advert(l[0].id, l[0]) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lutim/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015444�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lutim/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000001430�12657170273�0017553�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import LutimModule __all__ = ['LutimModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lutim/browser.py�����������������������������������������������������������������0000664�0000000�0000000�00000003647�12657170273�0017513�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import math from urlparse import urljoin from StringIO import StringIO from weboob.browser import PagesBrowser, URL from .pages import ImagePage, UploadPage class LutimBrowser(PagesBrowser): BASEURL = 'https://lut.im' VERIFY = False # XXX SNI is not supported image_page = URL('/(?P<id>.+)', ImagePage) upload_page = URL('/', UploadPage) def __init__(self, base_url, *args, **kw): PagesBrowser.__init__(self, *args, **kw) self.base_url = self.BASEURL = base_url def fetch(self, paste): self.location(paste.id) assert self.image_page.is_here() paste.contents = unicode(self.page.contents.encode('base64')) paste.title = self.page.filename def post(self, paste, max_age=0): bin = paste.contents.decode('base64') name = paste.title or 'file' # filename is mandatory filefield = {'file': (name, StringIO(bin))} params = {'format': 'json'} if max_age: params['delete-day'] = math.ceil(max_age / 86400.) self.location('/', data=params, files=filefield) assert self.upload_page.is_here() info = self.page.fetch_info() paste.id = urljoin(self.base_url, info['short']) �����������������������������������������������������������������������������������������weboob-1.1/modules/lutim/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000001125�12657170273�0017576�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD���`>��� pHYs�� �� ����tIME�!&���tEXtComment�Created with GIMPW��IDATxQ0D!hmo$V6j"UMh^f j Q-B!;�F�ǽ F#¨�H.qZȫؼfXQ�oQ'b�@ �o m:ruA qSK.h؊ ,8`aJ�]` R{}yZ_ LZN@�ZV`N_Vg&@i7!H<O^z%NI5B[ pB8VZY[L8W|*TBR|">,ÛgDC#1 eqp˩x}C(G}�3 !ܘK�$n@^CCsA<(LkJ�{wuM�S0 @s渢3y:~ �@d7ꛗȀT[/,Z�0YA̓j綩GEE٫?يB =����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lutim/module.py������������������������������������������������������������������0000664�0000000�0000000�00000004744�12657170273�0017314�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from urlparse import urljoin from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.paste import CapPaste, BasePaste from weboob.tools.capabilities.paste import image_mime from weboob.tools.value import Value from .browser import LutimBrowser __all__ = ['LutimModule'] class LutimModule(Module, CapPaste): NAME = 'lutim' DESCRIPTION = u'lutim website' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = LutimBrowser CONFIG = BackendConfig(Value('base_url', label='Hoster base URL', default='https://lut.im/')) @property def base_url(self): url = self.config['base_url'].get() if not url.endswith('/'): url = url + '/' return url def create_default_browser(self): return self.create_browser(self.base_url) def can_post(self, contents, title=None, public=None, max_age=None): if public: return 0 elif max_age and max_age < 86400: return 0 # it cannot be shorter than one day elif re.search(r'[^a-zA-Z0-9=+/\s]', contents): return 0 # not base64, thus not binary else: mime = image_mime(contents, ('gif', 'jpeg', 'png')) return 20 * int(mime is not None) def get_paste(self, url): if not url.startswith('http'): url = urljoin(self.base_url, url) paste = self.new_paste(url) self.browser.fetch(paste) return paste def new_paste(self, _id): paste = LutimPaste(_id) return paste def post_paste(self, paste, max_age): return self.browser.post(paste, max_age) class LutimPaste(BasePaste): @classmethod def id2url(cls, id): return id ����������������������������weboob-1.1/modules/lutim/pages.py�������������������������������������������������������������������0000664�0000000�0000000�00000002421�12657170273�0017114�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.browser.pages import JsonPage, RawPage from weboob.capabilities.base import UserError class ImagePage(RawPage): @property def contents(self): return self.doc @property def filename(self): header = self.response.headers['content-disposition'] m = re.match('inline;filename="(.*)"', header) return unicode(m.group(1)) class UploadPage(JsonPage): def fetch_info(self): if not self.doc['success']: raise UserError(self.doc['msg']['msg']) return self.doc['msg'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/lutim/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000003233�12657170273�0016776�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class LutimTest(BackendTest): MODULE = 'lutim' # small gif file DATA = u'R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==\n' TITLE = u'foo.gif' def test_lutim(self): post = self.backend.new_paste(None) post.contents = self.DATA post.title = self.TITLE assert self.backend.can_post(post.contents, post.title) self.backend.post_paste(post, max_age=86400) assert post.id got = self.backend.get_paste(post.id) assert got assert got.title == self.TITLE assert got.contents == self.DATA # test with an empty name post.title = u'' self.backend.post_paste(post, max_age=86400) def test_invalid(self): post = self.backend.new_paste(None) post.contents = u'FAIL' post.title = self.TITLE assert not self.backend.can_post(post.contents, post.title) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mailinator/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016451�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mailinator/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000001442�12657170273�0020563�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MailinatorModule __all__ = ['MailinatorModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mailinator/browser.py������������������������������������������������������������0000664�0000000�0000000�00000005273�12657170273�0020515�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserBanned from weboob.tools.date import datetime from weboob.deprecated.browser.parsers.jsonparser import json import lxml.html import time import email __all__ = ['MailinatorBrowser'] class MailinatorBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'mailinator.com' ENCODING = 'utf-8' def __init__(self, *args, **kw): kw['parser'] = 'raw' Browser.__init__(self, *args, **kw) def _get_unicode(self, url): return self.get_document(self.openurl(url)).decode(self.ENCODING, 'replace') def _get_json(self, url): j = json.loads(self._get_unicode(url)) if 'rate' in j: # shit, we've been banned... raise BrowserBanned('Flood - Banned for today') return j def get_mails(self, boxid, after=None): mails = self._get_json('http://mailinator.com/api/webinbox?to=%s&time=%d' % (boxid, millis())) for mail in mails['messages']: d = {'id': mail['id'], 'from': mail['fromfull'], 'to': mail['to'], 'from_name': mail['from'], 'datetime': frommillis(mail['time']), 'subject': mail['subject'], 'read': mail['been_read'], 'box': boxid } yield d def get_mail_content(self, mailid): frame = self._get_unicode('http://mailinator.com/rendermail.jsp?msgid=%s&time=%s&text=true' % (mailid, millis())).strip() if not len(frame): # likely we're banned return '' doc = lxml.html.fromstring(frame) pre = doc.xpath('//pre')[0] msg = email.message_from_string(pre.text_content().strip().encode('utf-8')) if msg.is_multipart(): return msg.get_payload(0).get_payload() return msg.get_payload() def millis(): return int(time.time() * 1000) def frommillis(millis): return datetime.fromtimestamp(millis / 1000) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mailinator/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000001027�12657170273�0020604�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME )1ڒ}���tEXtComment�Created with GIMPW��IDATxY[0 kPpb}mb-M&;K8����� 'iX9&55ek>=*D7w$xg|᭢M&=sMj?Ye_LXvb"̙�)osÝvH%& {@G%u٬R]8ƖإjnV!.-Ee|l:5ymP]lD^*xKdK Pm_yV#�!һxJ6,@ ra]zJ* hݱkSpgN�cMK`1x"@B O# (#/d_. L{�k�r}����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mailinator/module.py�������������������������������������������������������������0000664�0000000�0000000�00000006212�12657170273�0020311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.messages import CapMessages, Thread, Message from weboob.tools.value import Value from .browser import MailinatorBrowser __all__ = ['MailinatorModule'] # There is only one thread per inbox, and the thread id is the inbox name # TODO but this can lead to bans if there are too many messages... class MailinatorModule(Module, CapMessages): NAME = 'mailinator' DESCRIPTION = u'mailinator temp mailbox' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = MailinatorBrowser CONFIG = BackendConfig(Value('inbox', label='Inbox', default='')) def iter_threads(self): inbox = self.config['inbox'].get() if not inbox: raise NotImplementedError() else: for d in self.browser.get_mails(inbox): thread = Thread(d['id']) thread.title = d['subject'] thread.flags = thread.IS_DISCUSSION msg = self.make_message(d, thread) if not msg.content: msg.content = self.browser.get_mail_content(msg.id) thread.root = msg yield thread def _get_messages_thread(self, inbox, thread): first = True for d in self.browser.get_mails(inbox): msg = self.make_message(d, thread) if not msg.content: msg.content = self.browser.get_mail_content(msg.id) if first: first = False thread.root = msg else: msg.parent = thread.root msg.parent.children.append(msg) def get_thread(self, _id): thread = Thread(_id) thread.title = 'Mail for %s' % _id thread.flags = thread.IS_DISCUSSION self._get_messages_thread(_id, thread) return thread def make_message(self, d, thread): msg = Message(thread, d['id']) msg.children = [] msg.sender = d['from'] msg.flags = 0 if not d.get('read', True): msg.flags = msg.IS_UNREAD msg.title = d['subject'] msg.date = d['datetime'] msg.receivers = [d['to']] return msg def fill_msg(self, msg, fields): if 'content' in fields: msg.content = self.browser.get_mail_content(msg.id) return msg OBJECTS = {Message: fill_msg} ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mailinator/test.py���������������������������������������������������������������0000664�0000000�0000000�00000002056�12657170273�0020005�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class MailinatorTest(BackendTest): MODULE = 'mailinator' def test_mailinator(self): t = self.backend.get_thread('qwerty') assert t assert t.root assert t.root.title assert t.root.date assert t.root.sender assert t.root.receivers ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangafox/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016112�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangafox/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001435�12657170273�0020226�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MangafoxModule __all__ = ['MangafoxModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangafox/module.py���������������������������������������������������������������0000664�0000000�0000000�00000002707�12657170273�0017757�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderModule, DisplayPage __all__ = ['MangafoxModule'] class MangafoxModule(GenericComicReaderModule): NAME = 'mangafox' DESCRIPTION = 'Manga Fox manga reading website' BROWSER_PARAMS = dict( img_src_xpath="//img[@id='image']/attribute::src", page_list_xpath="(//select[@onchange='change_page(this)'])[1]/option[text()!='Comments']/@value", page_to_location="%s.html") ID_REGEXP = r'[^/]+/[^/]+(?:/[^/]+)?' URL_REGEXP = r'.+mangafox.(?:com|me)/manga/(%s).*' % ID_REGEXP ID_TO_URL = 'http://www.mangafox.me/manga/%s' PAGES = {r'http://(?:.+\.)?mangafox.\w+/manga/[^/]+/[^/]+/([^/]+/)?(.+\.html)?': DisplayPage} ���������������������������������������������������������weboob-1.1/modules/mangafox/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000001733�12657170273�0017447�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreadertest import GenericComicReaderTest class MangafoxTest(GenericComicReaderTest): MODULE = 'mangafox' def test_download(self): return self._test_download('glass_no_kamen/v02/c000') �������������������������������������weboob-1.1/modules/mangago/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015723�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangago/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001434�12657170273�0020036�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MangagoModule __all__ = ['MangagoModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangago/module.py����������������������������������������������������������������0000664�0000000�0000000�00000002542�12657170273�0017565�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderModule, DisplayPage __all__ = ['MangagoModule'] class MangagoModule(GenericComicReaderModule): NAME = 'mangago' DESCRIPTION = 'Mangago manga reading site' DOMAIN = 'www.mangago.com' BROWSER_PARAMS = dict( img_src_xpath="//div[@id='pic_container']//img/@src", page_list_xpath="(//div[contains(@class,'page_select')]//select)[1]//@value") ID_REGEXP = r'(?:[^/]+/)+.+' URL_REGEXP = r'.+mangago.com/r/l_manga/(%s).+' % ID_REGEXP ID_TO_URL = 'http://www.mangago.com/r/l_manga/%s' PAGES = { URL_REGEXP: DisplayPage } ��������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangago/test.py������������������������������������������������������������������0000664�0000000�0000000�00000001751�12657170273�0017260�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreadertest import GenericComicReaderTest class MangagoTest(GenericComicReaderTest): MODULE = 'mangago' def test_download(self): return self._test_download('manga/love_scar/mh/manga/love_scar/c001/') �����������������������weboob-1.1/modules/mangahere/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016241�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangahere/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000001437�12657170273�0020357�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MangahereModule __all__ = ['MangahereModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangahere/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000020153�12657170273�0020375�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ����tIME ":L���tEXtComment�Created with GIMPW���bKGD������C��IDATx{y]u׷oop C,J-v+5v\5@ZYPhTKmbKMBn&V[cmI,$g}3wʮRw߽g97H>xQD2 M$RCQTb. ul{sc`׽?7sK1h*ǽTgDYj\Iޛ҂(B=?1#;/m^DpgD#%EeET=)<υ;:ZG?~LZJG}l4]͗\SPV"٨[[kr8mkcewkݲsUdN1͔("`yyE1G \[9Ͻ8x pCɁR*K9ahxR9?1Ċ  bm^Z?w.m ܿR0 E5EIVcIR8؀y:8]6 ڭZ\_h8Yy|X7ڟᑽО@qcz1/R2,[8ȇ!07wFm7ʥw[R[sbicz*UJiu#f6J(DItx"q]-ݬ9iΟz;7<GkN{45081P* iA\TM@!DHx#a&M3<%pYqͅS<<td:S*$8,cGxAQqJ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\_r#ײbk6ɬ˖�C v8=:%'q\2Y;|RȊYI$N@9煣OwK>vږ\[__/xK1vƑidc3jk:oV}iH|CO6 B4dd X!ѧ>Zpck ;Ԛeym]+l;=�EbGlZԵNHc.�_ɣE,x)|iYm4#5[k\ h(A~t@/bu 3 `FՇ8f>O= nm.~ B>=Ԅjy3#tWXSwg? wP`x\ :uo}y{S_ E�\x4GSlSt=GRS[ZX[^wk l  k>M9Wc{&!:[5VkT8ۏTw|6xZ _VzlQr C)xat=)xQ Ukj]hޣ:0ΏSDLFh*QȭhS2}RД)/sEYدg=ƣ]41o$<u����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangahere/module.py��������������������������������������������������������������0000664�0000000�0000000�00000002545�12657170273�0020106�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderModule, DisplayPage __all__ = ['MangahereModule'] class MangahereModule(GenericComicReaderModule): NAME = 'mangahere' DESCRIPTION = 'Manga Here manga reading website' DOMAIN = 'www.mangahere.com' BROWSER_PARAMS = dict( img_src_xpath="//img[@id='image']/@src", page_list_xpath="(//select[@onchange='change_page(this)'])[1]/option/@value") ID_REGEXP = r'[^/]+/[^/]+/[^/]+' URL_REGEXP = r'.+mangahere.com/manga/(%s).+' % ID_REGEXP ID_TO_URL = 'http://www.mangahere.com/manga/%s' PAGES = {URL_REGEXP: DisplayPage} �����������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangahere/test.py����������������������������������������������������������������0000664�0000000�0000000�00000001734�12657170273�0017577�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreadertest import GenericComicReaderTest class MangahereTest(GenericComicReaderTest): MODULE = 'mangahere' def test_download(self): return self._test_download('glass_no_kamen/v02/c000') ������������������������������������weboob-1.1/modules/mangareader/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016560�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangareader/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000001443�12657170273�0020673�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MangareaderModule __all__ = ['MangareaderModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangareader/module.py������������������������������������������������������������0000664�0000000�0000000�00000002554�12657170273�0020425�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderModule, DisplayPage __all__ = ['MangareaderModule'] class MangareaderModule(GenericComicReaderModule): NAME = 'mangareader' DESCRIPTION = 'MangaReader manga reading website' DOMAIN = 'www.mangareader.net' BROWSER_PARAMS = dict( img_src_xpath="//img[@id='img']/@src", page_list_xpath="//select[@id='pageMenu']/option/@value") ID_REGEXP = r'[^/]+/[^/]+' URL_REGEXP = r'.+mangareader.net/(%s).+' % ID_REGEXP ID_TO_URL = 'http://www.mangareader.net/%s' PAGES = {r'http://.+\.mangareader.net/.+': DisplayPage} # oh well ����������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mangareader/test.py��������������������������������������������������������������0000664�0000000�0000000�00000001725�12657170273�0020116�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreadertest import GenericComicReaderTest class MangareaderTest(GenericComicReaderTest): MODULE = 'mangareader' def test_download(self): return self._test_download('glass-mask/3') �������������������������������������������weboob-1.1/modules/mareeinfo/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016257�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mareeinfo/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0020367�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MareeinfoModule __all__ = ['MareeinfoModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mareeinfo/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000002212�12657170273�0020311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import IndexPage class MareeinfoBrowser(PagesBrowser): BASEURL = 'http://maree.info' harbor_page = URL('', '(?P<_id>.*)', IndexPage) def get_harbor_list(self, pattern): return self.harbor_page.go().get_harbor_list(pattern=pattern) def get_harbor_infos(self, gauge): return self.harbor_page.go(_id=gauge.id).get_harbor_infos(obj=gauge) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mareeinfo/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000001033�12657170273�0020407�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���gAMA�� a��� pHYs����(J���tEXtSoftware�paint.net 4.0.3P��IDATx^A Ѿg4F?L!;ĀAyRm؟qhIOG5Z-"O -6h@G }B% ݩJ.YNUz4tBwңKS }BБmh4|DiѰ#JU 4̖f 5h@*pd[Ehixv<ZZ;-֎GKkǣ2hK ߢ7Ё(?ޮ+VOћZz*O^Xw^?t.zCAX5aO^tWްrVtO󢻞n,tG{V1O-tVsZ >IZx>) MEjfv)`KUj4pT[z-8dk]Dn#����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mareeinfo/module.py��������������������������������������������������������������0000664�0000000�0000000�00000004572�12657170273�0020126�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.base import find_object from weboob.capabilities.gauge import CapGauge, Gauge, SensorNotFound from .browser import MareeinfoBrowser __all__ = ['MareeinfoModule'] class MareeinfoModule(Module, CapGauge): NAME = 'mareeinfo' DESCRIPTION = u'Un module qui permet d\' aller a la pêche aux moules totalement informé' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = MareeinfoBrowser def get_last_measure(self, sensor_id): gauge_id = sensor_id.split('-')[0] return find_object(self.iter_sensors(gauge_id), id=sensor_id, error=SensorNotFound).lastvalue def iter_gauge_history(self, sensor_id): gauge_id = sensor_id.split('-')[0] return find_object(self.iter_sensors(gauge_id), id=sensor_id, error=SensorNotFound).history def iter_gauges(self, pattern=None): for _gauge in self.browser.get_harbor_list(pattern): if pattern is not None: gauge = self.browser.get_harbor_infos(_gauge) yield gauge else: yield _gauge def iter_sensors(self, gauge, pattern=None): if not isinstance(gauge, Gauge): gauge = find_object(self.iter_gauges(), id=gauge, error=SensorNotFound) gauge = self.browser.get_harbor_infos(gauge) if pattern is None: for sensor in gauge.sensors: yield sensor else: lowpattern = pattern.lower() for sensor in gauge.sensors: if lowpattern in sensor.name.lower(): yield sensor ��������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mareeinfo/pages.py���������������������������������������������������������������0000664�0000000�0000000�00000020673�12657170273�0017740�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, DateTime, CleanDecimal, Regexp from weboob.browser.filters.html import Link, XPath from weboob.capabilities.gauge import Gauge, GaugeMeasure, GaugeSensor from datetime import timedelta import re class IndexPage(HTMLPage): @method class get_harbor_list(ListElement): item_xpath = "//a[@class='Port PP'] | //a[@class='Port PS']" class item(ItemElement): klass = Gauge obj_id = CleanText(Link('.'), replace=[('/', '')]) obj_name = CleanText('.') obj_city = CleanText('.') obj_object = u'Port' def validate(self, obj): if self.env['pattern']: return self.env['pattern'].lower() in obj.name.lower() return True @method class get_harbor_infos(ItemElement): klass = Gauge def _create_coef_sensor(self, gauge_id, AM=True): name = CleanText('//tr[@class="MJE"]/th[4]')(self) _name = 'matin' if AM else 'aprem' value = self._get_coef_value(AM=AM) if value: coef = GaugeSensor(u'%s-%s-%s' % (gauge_id, name, _name)) coef.name = '%s %s' % (name, _name) coef.lastvalue = value coef.gaugeid = gauge_id coef.history = [] for jour in range(0, 7): measure = self._get_coef_value(AM=AM, jour=jour) if measure: coef.history.append(measure) return coef def _get_coef_value(self, AM=True, jour=0): if AM: time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[1]' % jour))(self) value = CleanText('//tr[@id="MareeJours_%s"]/td[3]/b[1]' % jour)(self) else: time, value = None, None if len(XPath('//tr[@id="MareeJours_%s"]/td[1]/b' % jour)(self)) > 1: time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[2]' % jour))(self) value = CleanText('//tr[@id="MareeJours_%s"]/td[3]/b[2]' % jour)(self) if time and value: measure = GaugeMeasure() measure.level = float(value) measure.date = time + timedelta(days=jour) return measure def _create_high_tide(self, gauge_id, AM=True): name = CleanText('//tr[@class="MJE"]/th[3]')(self) _name = 'matin' if AM else 'aprem' value = self._get_high_tide_value(AM=AM) if value: tide = GaugeSensor(u'%s-%s-PM-%s' % (gauge_id, name, _name)) tide.name = u'Pleine Mer %s' % (_name) tide.unit = u'm' tide.lastvalue = value tide.gaugeid = gauge_id tide.history = [] for jour in range(0, 7): measure = self._get_high_tide_value(AM=AM, jour=jour) if measure: tide.history.append(measure) return tide def _get_high_tide_value(self, AM=True, jour=0): if AM: time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[1]' % jour))(self) value = CleanDecimal('//tr[@id="MareeJours_0"]/td[2]/b[1]', replace_dots=True)(self) else: time, value = None, None if len(XPath('//tr[@id="MareeJours_%s"]/td[1]/b' % jour)(self)) > 1: time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[2]' % jour), default=None)(self) value = CleanDecimal('//tr[@id="MareeJours_0"]/td[2]/b[2]', replace_dots=True, default=None)(self) if time and value: measure = GaugeMeasure() measure.level = float(value) measure.date = time + timedelta(days=jour) return measure def _create_low_tide(self, gauge_id, AM=True): name = CleanText('//tr[@class="MJE"]/th[3]')(self) _name = 'matin' if AM else 'aprem' value = self._get_low_tide_value(AM=AM) if value: tide = GaugeSensor(u'%s-%s-BM-%s' % (gauge_id, name, _name)) tide.name = u'Basse Mer %s' % (_name) tide.unit = u'm' tide.lastvalue = value tide.gaugeid = gauge_id tide.history = [] for jour in range(0, 7): measure = self._get_low_tide_value(AM=AM, jour=jour) if measure: tide.history.append(measure) return tide def _is_low_tide_first(self, jour): return XPath('//tr[@id="MareeJours_%s"]/td[1]' % jour)(self)[0].getchildren()[0].tag != 'b' def _get_low_tide_value(self, AM=True, jour=0): slow_tide_pos = 1 if self._is_low_tide_first(jour) else 2 m = re.findall('(\d{2}h\d{2})', CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour)(self)) re_time = '(\d{2}h\d{2}).*(\d{2}h\d{2}).*(\d{2}h\d{2})' re_value = '(.*)m(.*)m(.*)m' if len(m) > 3: re_time = '(\d{2}h\d{2}).*(\d{2}h\d{2}).*(\d{2}h\d{2}).*(\d{2}h\d{2})' re_value = '(.*)m(.*)m(.*)m(.*)m' if AM: time = DateTime(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour), re_time, '\\%s' % slow_tide_pos))(self) value = CleanDecimal(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[2]' % jour), re_value, '\\%s' % slow_tide_pos), replace_dots=True, default=None)(self) else: slow_tide_pos += 2 time, value = None, None if len(m) > slow_tide_pos - 1: time = DateTime(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour), re_time, '\\%s' % slow_tide_pos))(self) value = CleanDecimal(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[2]' % jour), re_value, '\\%s' % slow_tide_pos), replace_dots=True, default=None)(self) if time and value: measure = GaugeMeasure() measure.level = float(value) measure.date = time + timedelta(days=jour) return measure def obj_sensors(self): sensors = [] high_tide_PM = self._create_high_tide(self.obj.id) if high_tide_PM: sensors.append(high_tide_PM) high_tide_AM = self._create_high_tide(self.obj.id, AM=False) if high_tide_AM: sensors.append(high_tide_AM) low_tide_AM = self._create_low_tide(self.obj.id) if low_tide_AM: sensors.append(low_tide_AM) low_tide_PM = self._create_low_tide(self.obj.id, AM=False) if low_tide_PM: sensors.append(low_tide_PM) coef_AM = self._create_coef_sensor(self.obj.id) if coef_AM: sensors.append(coef_AM) coef_PM = self._create_coef_sensor(self.obj.id, AM=False) if coef_PM: sensors.append(coef_PM) return sensors ���������������������������������������������������������������������weboob-1.1/modules/mareeinfo/test.py����������������������������������������������������������������0000664�0000000�0000000�00000002322�12657170273�0017607�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class MareeinfoTest(BackendTest): MODULE = 'mareeinfo' def test_mareeinfo(self): l = list(self.backend.iter_gauges()) self.assertTrue(len(l) > 0) gauge = l[0] s = list(self.backend.iter_sensors(gauge)) self.assertTrue(len(s) > 0) sensor = s[0] self.assertTrue(self.backend.get_last_measure(sensor.id) is not None) self.assertTrue(len(self.backend.iter_gauge_history(sensor.id)) > 0) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/marmiton/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016140�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/marmiton/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001435�12657170273�0020254�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MarmitonModule __all__ = ['MarmitonModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/marmiton/browser.py��������������������������������������������������������������0000664�0000000�0000000�00000003030�12657170273�0020171�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.exceptions import BrowserHTTPNotFound from weboob.browser import PagesBrowser, URL from .pages import RecipePage, ResultsPage __all__ = ['MarmitonBrowser'] class MarmitonBrowser(PagesBrowser): BASEURL = 'http://www.marmiton.org/' search = URL('recettes/recherche.aspx\?aqt=(?P<pattern>.*)', ResultsPage) recipe = URL('recettes/recette_(?P<id>.*).aspx', RecipePage) def iter_recipes(self, pattern): return self.search.go(pattern=pattern).iter_recipes() def get_recipe(self, id, recipe=None): try: recipe = self.recipe.go(id=id).get_recipe(obj=recipe) comments = list(self.page.get_comments()) if comments: recipe.comments = comments return recipe except BrowserHTTPNotFound: return ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/marmiton/favicon.png�������������������������������������������������������������0000664�0000000�0000000�00000004173�12657170273�0020300�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME 6:m��IDATx{P\ǿMX� yGlXck715v4Ռ8R%&5:05:5Dq3q GB`eaeww ,ý9Bp _4`0�,s#\g�?xlnd"6|1Ko0>`ÓJ.9�3B !.L^{@2K Up-l*?=�!0�Y|HnP4<Rd\07*ѷe* tZ(Xw,,) y�u#ׁɭ�$|k=/ P4lw\d/ !`\- !wOˆv�kN�,uY\`YsX*6D !?hWALn)P,vv/]iݧ)Ñ 6O~e?Pͭ��n-J8?reypFh28}�z{+`M5(Z膳 hW$"ȡe,!y>ī6[1߿׃Hعm%Jwyj@$�0`V:yp ʾ�|K=gNIW,;][A.'^ ‡w�u*U*PD$23 @ }jۥ wb�4 88�KF69 $U 7hԳ;&E`r+eX#:OV#cߪi*tD C&BnDNM=*O t q J]`(w(;x 3A;bo u)8%H gv5Ɋմ �BVb-ρh(1�2b/v}2*ok@�ݭl(g622hwՏjwT/!fVhhHc�·^7R'F'W`L6o&Omt�>} ) ^ Bl4tDB<{ z!^iN(`&.~bl@�L�&�{͜'xߠvecR@�ln%7L}O�gZKAr02O,>ouY|fļ/\GsVp `Z߽/ZcDӭq+Pm 45ƀ뷀-\ʾR_;Gw"r,ioW{ly Qݧ1SZ�^P59uH՞ /oUnP1{= eX#| MMm·يGu0I >S19<:_.P wm߶7,˂x弼\wgkT8*zFQ>oqd;!iVrԘ9C͇AB|]`b g&ժ)LJybBBWβ'\*fy Qg.Sg�F5�QpEk�ZȱH 6;r%z(Q:XmrO�)n.�9�kY��T5jX`v#\#1iOY"9tV;Z �gm9ȰΟׂ9TH> ,lw qϬ@p B"#3;JJm $�*_<`?cDOjU)4EMC`Hʕ^10!|m'(xs�F:iX{߄z#3 $i  ݔz7MxΥT:HG۽/ijs۽o'<s t5�<c�+sLLȷيMIOAO$Nhv mh x(xSaRL4V>' :l0�Z;df����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/marmiton/module.py���������������������������������������������������������������0000664�0000000�0000000�00000003170�12657170273�0020000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.recipe import CapRecipe, Recipe from weboob.tools.backend import Module from .browser import MarmitonBrowser from urllib import quote_plus __all__ = ['MarmitonModule'] class MarmitonModule(Module, CapRecipe): NAME = 'marmiton' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = u'Marmiton French recipe website' LICENSE = 'AGPLv3+' BROWSER = MarmitonBrowser def get_recipe(self, id): return self.browser.get_recipe(id) def iter_recipes(self, pattern): return self.browser.iter_recipes(quote_plus(pattern.encode('utf-8'))) def fill_recipe(self, recipe, fields): if 'nb_person' in fields or 'instructions' in fields or 'thumbnail_url' in fields: recipe = self.browser.get_recipe(recipe.id, recipe) return recipe OBJECTS = { Recipe: fill_recipe, } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/marmiton/pages.py����������������������������������������������������������������0000664�0000000�0000000�00000007373�12657170273�0017623�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import Regexp, CleanText, Format, Env, Type from weboob.browser.filters.html import CleanHTML from weboob.capabilities.recipe import Recipe, Comment from weboob.capabilities.base import NotAvailable class ResultsPage(HTMLPage): """ Page which contains results as a list of recipies """ @pagination @method class iter_recipes(ListElement): item_xpath = '//div[has-class("recette_classique")]' def next_page(self): return CleanText('//a[@id="ctl00_cphMainContent_m_ctrlSearchEngine_m_ctrlSearchListDisplay_m_ctrlSearchPagination_m_linkNextPage"]/@href', default=None)(self) class item(ItemElement): klass = Recipe obj_id = Regexp(CleanText('./div/div[@class="m_titre_resultat"]/a/@href'), '/recettes/recette_(.*).aspx') obj_title = CleanText('./div/div[@class="m_titre_resultat"]/a') obj_short_description = Format('%s. %s', CleanText('./div/div[@class="m_detail_recette"]'), CleanText('./div/div[@class="m_texte_resultat"]')) class RecipePage(HTMLPage): """ Page which contains a recipe """ @method class get_recipe(ItemElement): klass = Recipe obj_id = Env('id') obj_title = CleanText('//h1[@class="m_title"]') obj_preparation_time = Type(CleanText('//span[@class="preptime"]'), type=int) obj_cooking_time = Type(CleanText('//span[@class="cooktime"]'), type=int) def obj_nb_person(self): nb_pers = Regexp(CleanText('//div[@class="m_content_recette_ingredients m_avec_substitution"]/span[1]'), '.*\(pour (\d+) personnes\)', default=0)(self) return [nb_pers] if nb_pers else NotAvailable def obj_ingredients(self): ingredients = CleanText('//div[@class="m_content_recette_ingredients m_avec_substitution"]', default='')(self).split('-') if len(ingredients) > 1: return ingredients[1:] return [] obj_instructions = CleanHTML('//div[@class="m_content_recette_todo"]') obj_thumbnail_url = CleanText('//a[@class="m_content_recette_illu"]/img/@src', default=NotAvailable) obj_picture_url = CleanText('//a[@class="m_content_recette_illu"]/img/@src', default=NotAvailable) @method class get_comments(ListElement): item_xpath = '//div[@class="m_commentaire_row"]' ignore_duplicate = True class item(ItemElement): klass = Comment obj_author = CleanText('./div[@class="m_commentaire_content"]/span[1]') obj_rate = CleanText('./div[@class="m_commentaire_note"]/span') obj_text = CleanText('./div[@class="m_commentaire_content"]/p[1]') obj_id = CleanText('./div[@class="m_commentaire_content"]/span[1]') ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/marmiton/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000002313�12657170273�0017470�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest import itertools class MarmitonTest(BackendTest): MODULE = 'marmiton' def test_recipe(self): recipes = list(itertools.islice(self.backend.iter_recipes('fondue'), 0, 20)) for recipe in recipes: full_recipe = self.backend.get_recipe(recipe.id) assert full_recipe.instructions assert full_recipe.ingredients assert full_recipe.title assert full_recipe.preparation_time ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mediawiki/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016255�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mediawiki/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000001443�12657170273�0020370�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MediawikiModule __all__ = ['MediawikiModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mediawiki/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000016174�12657170273�0020323�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from urlparse import urlsplit, urljoin import datetime import re from weboob.browser.browsers import DomainBrowser from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities.content import Revision __all__ = ['MediawikiBrowser'] class APIError(Exception): pass # Browser class MediawikiBrowser(DomainBrowser): ENCODING = 'utf-8' def __init__(self, url, apiurl, username, password, *args, **kwargs): url_parsed = urlsplit(url) self.PROTOCOL = url_parsed.scheme self.DOMAIN = url_parsed.netloc self.BASEPATH = url_parsed.path if self.BASEPATH.endswith('/'): self.BASEPATH = self.BASEPATH[:-1] self.apiurl = apiurl self.username = username self.password = password DomainBrowser.__init__(self, *args, **kwargs) def url2page(self, page): baseurl = self.PROTOCOL + '://' + self.DOMAIN + self.BASEPATH m = re.match('^' + urljoin(baseurl, 'wiki/(.+)$'), page) if m: return m.group(1) else: return page def get_wiki_source(self, page, rev=None): assert isinstance(self.apiurl, basestring) page = self.url2page(page) data = {'action': 'query', 'prop': 'revisions|info', 'titles': page, 'rvprop': 'content|timestamp|ids', 'rvlimit': '1', 'intoken': 'edit', } if rev: data['rvstartid'] = rev result = self.API_get(data) pageid = result['query']['pages'].keys()[0] if pageid == "-1": # Page does not exist return "" if 'revisions' not in repr(result['query']['pages'][str(pageid)]): raise APIError('Revision %s does not exist' % rev) if rev and result['query']['pages'][str(pageid)]['revisions'][0]['revid'] != int(rev): raise APIError('Revision %s does not exist' % rev) return result['query']['pages'][str(pageid)]['revisions'][0]['*'] def get_token(self, page, _type): ''' _type can be edit, delete, protect, move, block, unblock, email or import''' if len(self.username) > 0 and not self.is_logged(): self.login() data = {'action': 'query', 'prop': 'info', 'titles': page, 'intoken': _type, } result = self.API_get(data) pageid = result['query']['pages'].keys()[0] return result['query']['pages'][str(pageid)][_type + 'token'] def set_wiki_source(self, content, message=None, minor=False): if len(self.username) > 0 and not self.is_logged(): self.login() page = content.id token = self.get_token(page, 'edit') data = {'action': 'edit', 'title': page, 'token': token, 'text': content.content.encode('utf-8'), 'summary': message, } if minor: data['minor'] = 'true' self.API_post(data) def get_wiki_preview(self, content, message=None): data = {'action': 'parse', 'title': content.id, 'text': content.content.encode('utf-8'), 'summary': message, } result = self.API_post(data) return result['parse']['text']['*'] def is_logged(self): data = {'action': 'query', 'meta': 'userinfo', } result = self.API_get(data) return result['query']['userinfo']['id'] != 0 def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert isinstance(self.apiurl, basestring) data = {'action': 'login', 'lgname': self.username, 'lgpassword': self.password, } result = self.API_post(data) if result['login']['result'] == 'WrongPass': raise BrowserIncorrectPassword() if result['login']['result'] == 'NeedToken': data['lgtoken'] = result['login']['token'] self.API_post(data) def iter_wiki_revisions(self, page): """ Yield 'Revision' objects. """ if len(self.username) > 0 and not self.is_logged(): self.login() MAX_RESULTS = 50 results = MAX_RESULTS last_id = None while results == MAX_RESULTS: data = {'action': 'query', 'titles': page, 'prop': 'revisions', 'rvprop': 'ids|timestamp|comment|user|flags', 'rvlimit': str(MAX_RESULTS), } if last_id is not None: data['rvstartid'] = last_id result = self.API_get(data) pageid = str(result['query']['pages'].keys()[0]) results = 0 if pageid != "-1": for rev in result['query']['pages'][pageid]['revisions']: rev_content = Revision(str(rev['revid'])) rev_content.comment = rev['comment'] rev_content.author = rev['user'] rev_content.timestamp = datetime.datetime.strptime(rev['timestamp'], '%Y-%m-%dT%H:%M:%SZ') rev_content.minor = 'minor' in rev yield rev_content last_id = rev_content.id results += 1 def home(self): # We don't need to change location, we're using the JSON API here. pass def check_result(self, result): if 'error' in result: raise APIError(result['error']['info']) def API_get(self, data): """ Submit a GET request to the website The JSON data is parsed and returned as a dictionary """ data['format'] = 'json' result = self.open(self.apiurl, params=data).json() self.check_result(result) return result def API_post(self, data): """ Submit a POST request to the website The JSON data is parsed and returned as a dictionary """ data['format'] = 'json' result = self.open(self.apiurl, data=data).json() self.check_result(result) return result ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mediawiki/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000002223�12657170273�0020407�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME@~S���tEXtComment�Created with GIMPW��IDATx[UUxiCpC`xEA, / Ճ$2RY =(#"(# ރj ihV0֐FH8Xw9{ p8}{}[_;xmp8^C#~Z%Lc)0ԯ F1,`0H1%p`&p4X a*\5p;W��Fq$m0 @[4Ѱ(u h4|4COmG uK0zp1zO/9{@ݦdǗ]#z0R+ X&/Ǎ/o*GgM{0ROܿe0"yʪ ikFzwE]cKeװO=J.a4)}8%ZZ( 4Td%sj#Jx=$s 2�!#+WT*"XOL~VGpJe\H` <7*!q8yJ%/J>LIiNs|+w W,C4Jnk&Oe�%B{N`Vd5U ܗ{yDşJ@r~]>00R}C]Vk'\?*ސL2U~,M2wM"oJErC{A_ @9pPG~.m٤Y*73J^ǰ[ ﷁ'#{Z,R�YղC>msf"y>( PZVh%5%lH^*]SX[F+AUL)=0w7;9חYLO.'J%�2iDTV'dPd +SE[HU7M2GܷӸ_U.JդmpȭGMؼM񎹩Wr=nm����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mediawiki/module.py��������������������������������������������������������������0000664�0000000�0000000�00000005241�12657170273�0020116�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.content import CapContent, Content from weboob.tools.value import ValueBackendPassword, Value from .browser import MediawikiBrowser __all__ = ['MediawikiModule'] class MediawikiModule(Module, CapContent): NAME = 'mediawiki' MAINTAINER = u'Clément Schreiner' EMAIL = 'clemux@clemux.info' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'Wikis running MediaWiki, like Wikipedia' CONFIG = BackendConfig(Value('url', label='URL of the Mediawiki website', default='http://en.wikipedia.org/', regexp='https?://.*'), Value('apiurl', label='URL of the Mediawiki website\'s API', default='http://en.wikipedia.org/w/api.php', regexp='https?://.*'), Value('username', label='Login', default=''), ValueBackendPassword('password', label='Password', default='')) BROWSER = MediawikiBrowser def create_default_browser(self): username = self.config['username'].get() if len(username) > 0: password = self.config['password'].get() else: password = '' return self.create_browser(self.config['url'].get(), self.config['apiurl'].get(), username, password) def get_content(self, _id, revision=None): _id = _id.replace(' ', '_') content = Content(_id) page = _id rev = revision.id if revision else None data = self.browser.get_wiki_source(page, rev) content.content = data return content def iter_revisions(self, _id): return self.browser.iter_wiki_revisions(_id) def push_content(self, content, message=None, minor=False): self.browser.set_wiki_source(content, message, minor) def get_content_preview(self, content): return self.browser.get_wiki_preview(content) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/mediawiki/test.py����������������������������������������������������������������0000664�0000000�0000000�00000003143�12657170273�0017607�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from datetime import datetime class MediawikiTest(BackendTest): MODULE = 'mediawiki' def test_get_content(self): obj = self.backend.get_content(u"Project:Sandbox") assert len(obj.content) > 0 def test_iter_revisions(self): for rev in zip(range(10), self.backend.iter_revisions(u"Project:Sandbox")): pass def test_push_content(self): content = self.backend.get_content(u"Project:Sandbox") content.content = "test "+str(datetime.now()) self.backend.push_content(content, message="test weboob", minor=True) new_content = self.backend.get_content(u"Project:Sandbox") assert content.content == new_content.content def test_content_preview(self): content = self.backend.get_content(u"Project:Sandbox") self.backend.get_content_preview(content) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/meteofrance/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016602�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/meteofrance/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000001447�12657170273�0020721�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MeteofranceModule __all__ = ['MeteofranceModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/meteofrance/browser.py�����������������������������������������������������������0000664�0000000�0000000�00000002717�12657170273�0020646�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Cedric Defortis # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import WeatherPage, SearchCitiesPage __all__ = ['MeteofranceBrowser'] class MeteofranceBrowser(PagesBrowser): BASEURL = 'http://www.meteofrance.com' cities = URL('mf3-rpc-portlet/rest/lieu/facet/previsions/search/(?P<pattern>.*)', SearchCitiesPage) weather = URL('previsions-meteo-france/(?P<city_name>.*)/(?P<city_id>.*)', WeatherPage) def iter_city_search(self, pattern): return self.cities.go(pattern=pattern).iter_cities() def iter_forecast(self, city): return self.weather.go(city_id=city.id, city_name=city.name).iter_forecast() def get_current(self, city): return self.weather.go(city_id=city.id, city_name=city.name).get_current() �������������������������������������������������weboob-1.1/modules/meteofrance/favicon.png����������������������������������������������������������0000664�0000000�0000000�00000007055�12657170273�0020744�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���% ���sRGB���� pHYs�� �� ����tIME  #=<���tEXtComment�Created with GIMPW�� IDAThޭZoTͽ]{m`06BKcF%)|HQ!RHjP> V$j+EJ+P۴j miZT$)`o}yҖ+ vs93̡ 28}p\u@z_<W:s<܅C 1PKw 7DbO P0((>H`@7NyHL�J>h<swYp4 )$`$Ġʐ4YڐZ8cʋ06/@ k Wa�Eu5**JuA/X"?O:S+6]X~�]^ 8&r$PS@s+WfL G4ʓ 01}:�(}Dp4uק�w2Y K:V=qD`9?S^rGܘ٥G?{ ?L8& /y}(Bnq-Mj>ΫMG $VH{Nr/Ug_sk7z0bD8�3A3 XR$iF^237HX\S;N8ػ|JK MkW\k 1xc3% b7y|<͡r)0i(#,φ["�P_oY{wt|>{;|ÃI*Zbubђf{x EP 56fRo+-rY/$<Zp?WfTf,ȿW[-sZt\`S_QE!% Œx)̘j=wB,!7y:5/gv1sZJ^J4{wwmR!44`s%J�} oF(pGN,iCֱ5yo|8s30ZlGJU9)f8xITVFa�O…�NWKE`p�pϖxzg+7O޿`uZZKY7dE�բTPľt3?S �Pr}R)j~cnPS"07 g1̚x09N{of}#dX |H. y|p"M�GܷkOk6lT_|h%3f|2 y/gmGBHz�wǫRi ?�RY^6�039F9 졷26?Vpu}bـa2WO:|cjj \Se{p'W#, k@i:8NbcLk�ѯɰTnXGrbl/H�^kjɶ /= ]z{}oi 1;0׿nt:5$,v$r6-k/ &nܹb+;i ݈W0a"hi 5+qW{C523!L-L{dYBY][_+'dr5;!y,bqz$wvdgBdFF pj뮽&býZVe^*{[(פdʘUaȆvW]9n`m!R(dGfL] mlapvO{lƴ7w?+~W O`" "Gx$W8Ga/K/ndž꓇< |> Rd%]fa3Y䗷N9q`צ-*>ګ'G3}G]+ lUl\JMÌy~k *Ɠ>N\zw'wZωx-@ueÖbKIrC1IRaEK:a0[8m>*wkP u)? o7lt"i-YeRY$j(ߪɾ ޒWym*nt N/RE7@!W<:K@z%و<YQ kJ`FSV\X*vZר9?IA?%Հ8rR2C `Wie J1G@LɖItSl̜лjf?|I)X.TfX&qAf &$PKJP;4[,. [k?S$HV}J FFV8i5iլFYvXM- C`z&kj!TQm4X5jt-eYy! 1ⷵh#.R+Ȉ=L'Kgޭ7D5?Db^X@NT + {0Q<L3F(pE*rMl i̝#xwBEDG"(i]a0lZh[MRAy> B2jIEYܪj6XyJaBH$'sVJ2i<6 lRXV|EQ+ksBv2v[WZ3ʰ=GFh)x? yy4>%':=(U_PqM0yx%G%j *12Ozu}H9hĉic?k�xw8.a#fODM$fDEr"{fz 5bq OҘ,E_2U:N{{/vаԓO<tj%`})4/Ge<Qv,Du;w/9CE2"?+Gfu.Dz,ԞtQ"K]xiLLo6E=a KR%h8iTۃ;~LYD~PX[ 8e /A&*2GTFJztƮ7yנ"jRRJ&2Yj{ÌzLG!QEY {lsNm)tt`J,Z/'ZgH>0y2\/DO$#q3y᠈)yE5(+Fk':NY gÚp(l`2'5VC:t:<ko6vh&:j@6_C �]E]@y xx/<n̅jЕ4b33&X>I\“Ϯ%}"FGY GXu4I8"o5ݥ0Zw6U5.F*aػ:&"!of>)4t|IĢ"6.d 4rvm.R i>V+ج4sm&2x;����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/meteofrance/module.py������������������������������������������������������������0000664�0000000�0000000�00000003443�12657170273�0020445�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Cedric Defortis # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.weather import CapWeather, CityNotFound from weboob.tools.backend import Module from weboob.capabilities.base import find_object from .browser import MeteofranceBrowser __all__ = ['MeteofranceModule'] class MeteofranceModule(Module, CapWeather): NAME = 'meteofrance' MAINTAINER = u'Cedric Defortis' EMAIL = 'cedric@aiur.fr' VERSION = '1.1' DESCRIPTION = 'Get forecasts from the MeteoFrance website' LICENSE = 'AGPLv3+' BROWSER = MeteofranceBrowser def get_current(self, city_id): return self.browser.get_current(self.get_city(city_id)) def iter_forecast(self, city_id): return self.browser.iter_forecast(self.get_city(city_id)) def iter_city_search(self, pattern): return self.browser.iter_city_search(pattern) def get_city(self, _id): cities = list(self.iter_city_search(_id)) if len(cities) == 0: raise CityNotFound() try: return find_object(cities, id=_id, error=CityNotFound) except CityNotFound: return cities[0] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/meteofrance/pages.py�������������������������������������������������������������0000664�0000000�0000000�00000007450�12657170273�0020261�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ # -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Cedric Defortis # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import date from weboob.browser.pages import JsonPage, HTMLPage from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.capabilities.weather import Forecast, Current, City, Temperature from weboob.browser.filters.json import Dict from weboob.browser.filters.standard import CleanText, CleanDecimal, Regexp, Format class SearchCitiesPage(JsonPage): @method class iter_cities(DictElement): ignore_duplicate = True class item(ItemElement): klass = City def condition(self): return Dict('type')(self) == "VILLE_FRANCE" obj_id = Dict('codePostal') obj_name = Dict('slug') class WeatherPage(HTMLPage): @method class iter_forecast(ListElement): item_xpath = '//div[@class="group-days-summary"]/article' class item(ItemElement): klass = Forecast obj_id = CleanText('./header/h4') obj_date = CleanText('./header/h4') def obj_low(self): temp = CleanDecimal(Regexp(CleanText('./ul/li[@class="day-summary-temperature"]'), '(.*) / .*'))(self) unit = Regexp(CleanText('./ul/li[@class="day-summary-temperature"]'), u'.*\xb0(\w) Minimale / .*')(self) return Temperature(float(temp), unit) def obj_high(self): temp = CleanDecimal(Regexp(CleanText('./ul/li[@class="day-summary-temperature"]'), '.* / (.*)'))(self) unit = Regexp(CleanText('./ul/li[@class="day-summary-temperature"]'), u'.* / .*\xb0(\w).*')(self) return Temperature(float(temp), unit) obj_text = Format('%s - %s - %s - %s', CleanText('./ul/li[@class="day-summary-temperature"]'), CleanText('./ul/li[@class="day-summary-image"]'), CleanText('./ul/li[@class="day-summary-uv"]'), CleanText('./ul/li[@class="day-summary-wind"]')) @method class get_current(ItemElement): klass = Current obj_id = date.today() obj_date = date.today() obj_text = Format('%s - %s - %s - %s', CleanText('(//div[@class="group-days-summary"])[1]/article[1]/ul/li[@class="day-summary-temperature"]'), CleanText('(//div[@class="group-days-summary"])[1]/article[1]/ul/li[@class="day-summary-image"]'), CleanText('(//div[@class="group-days-summary"])[1]/article[1]/ul/li[@class="day-summary-uv"]'), CleanText('(//div[@class="group-days-summary"])[1]/article[1]/ul/li[@class="day-summary-wind"]')) def obj_temp(self): temp = CleanDecimal('//div[@id="detail-day-01"]/table/tr[@class="in-between"]/td[1]')(self) unit = Regexp(CleanText('//div[@id="detail-day-01"]/table/tr[@class="in-between"]/td[1]'), u'.*\xb0(\w)')(self) return Temperature(float(temp), unit) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/meteofrance/test.py��������������������������������������������������������������0000664�0000000�0000000�00000002470�12657170273�0020136�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class MeteoFranceTest(BackendTest): MODULE = 'meteofrance' def test_meteofrance(self): l = list(self.backend.iter_city_search('paris')) self.assertTrue(len(l) > 0) city = l[0] current = self.backend.get_current(city.id) self.assertTrue(current.temp.value > -20 and current.temp.value < 50) forecasts = list(self.backend.iter_forecast(city.id)) self.assertTrue(len(forecasts) > 0) forecast2 = list(self.backend.iter_forecast('blagnac')) self.assertTrue(len(forecast2) > 0) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016140�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000001522�12657170273�0020251�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"init of Newspaper20minutesModule" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import Newspaper20minutesModule __all__ = ['Newspaper20minutesModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000003163�12657170273�0020200�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"browser for 20minutes website" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .pages.article import ArticlePage from .pages.simple import SimplePage from weboob.deprecated.browser import Browser from .tools import id2url class Newspaper20minutesBrowser(Browser): "Newspaper20minutesBrowser class" ENCODING = None PAGES = { 'http://www.20minutes.fr/(?!preums|ledirect).+/?.*': ArticlePage, 'http://www.20minutes.fr/ledirect/?.*': SimplePage, 'http://www.20minutes.fr/preums/?.*': SimplePage } def is_logged(self): return False def login(self): pass def fillobj(self, obj, fields): pass def get_content(self, _id): "return page article content" try : url = id2url(_id) except ValueError: url = _id self.location(url) if self.page is not None: return self.page.get_article(_id) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000006127�12657170273�0020301�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD����`��� pHYs�� �� ����tIMEC���tEXtComment�Created with GIMPW�� IDATx[{L[]cl+<HKFiiTdYZu j+ݦlݴVjҦV{IAb%jy86�{~)ݑ{}\ Caw3|]e>zu� ->�u8UDk`ԩ�fUWŬ*:ކy\\P^`\.`' BwƏ)8P02vC#ݗjw� �z\�45᏿;d1ܤUL*BFȏw{{y X9cK4h[UlMC"x,0!'lεڊoY1k6GmE rނVGZ2r'a@Scʊ(+6dž^+B{><(/ْ(q @KWYmjß�|>|<*jO-k[ʸ{QVd`"E>x\$DhjCR oA8Ec�OSbfUQ*ޕzoIq=ېu8=xJ^D\L(|^HR!E <$Be*sJŎOo؄irFޮTEAV粝9p{o$49 y15=q4I/wd��D-SI %Yh>\Edi?/o~WPEQ1<ZNI' A<FM|(&Ǔ6'+-WX#w`=& �  pwm�CU`CrNEK\",=;1w ;#KjK56S\̰Sodw.x;AV$h>/�$K, d5 HgWΚvGz㇛) y52 pdlP(f$�RpvRBpan03=eƓDs j2R*@zt9UDAm 2S<4ߪ7q) APH^eYx<f� گn7H`�@Qh8]n/VmqWӪD1=wOK!_.+2zW.vl\ B|,CCp{f?r{a@gH<j#dvB`<ei2I#QU q 0?8~-& ._l otJgA,'\S|AV*E]e i\G1miޏ^<'m 1FgPW0ڀp8=$j5[p#fŕ�ʊ16iR5BG{ ƝUq4ڻ5`nl%�S?~[x坶hw'h">ʊ ˎEjw@Ts_\EbEhߝE0/c&ˊb_K@gIEK^J+nsh1YNfk�o0c賆F&q_5pK6*>"sTH9<:{l14Ev^z݃qn�:{mSQ7XU\?�?IP\49">` &4U۬uJVvBIPk�?gm(�R�J3E[f*ρQR!uȉ+ŪT,}wwD[םVy |Q!"ϣ? V U V]6<@@UyZyj^ҷ~'R!?AeYNt-/[ ZG,�E:oU<(ǘ_a�Dvp=J(b Ӌz@!{, pp_;E 3#R"MR!šNQBfcS")E|b5 ėHW&t{ֆ�T[cKZܳ9f+ebH:�WLj))&H%1Bb&Ź\-DBNRe5᭦iA IIAwNHF`lZٝ ,Oq{P_w�&C/]�~\$ 4,!4yToQFJ6D#N"ʤJE 2�$ ZM |>8-jߝ(�:)lD۔@k1 , epV̲UsAV .rq"/urw,Hnc㓛19Nz?&37TFx x!:�$F�B,r{s>2 0;E-zId yf?4Tf*ݣGi|0pjwbl³bqJ;u(�M<3*Qs{.ToC,2_LMO /P89 kdk &ɝ#6^t> B&bg%[qkt% 'p8nt]dM4' HWl+Y7N-4nL/R8Gq)b1` K1c'!!1=CScT|Saw^o{kG/h_ދlup8=a"4�" �V^cZh[⛒+h5Cw)BRE6iw#|5<3E`ԫV,&`W% LƤY?N|;7f]f@SAVr(\ґ  M °;~L8J3 Z*`W R=m[b#c굡ds n.WPl5tX3s?LV~^y #w8cw����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/module.py��������������������������������������������������������������0000664�0000000�0000000�00000002527�12657170273�0020005�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. "backend for http://20minutes.fr" from weboob.capabilities.messages import CapMessages from weboob.tools.capabilities.messages.GenericModule import GenericNewspaperModule from .browser import Newspaper20minutesBrowser from .tools import rssid class Newspaper20minutesModule(GenericNewspaperModule, CapMessages): MAINTAINER = u'Julien Hebert' EMAIL = 'juke@free.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' STORAGE = {'seen': {}} NAME = 'minutes20' DESCRIPTION = u'2 Minutes French newspaper website' BROWSER = Newspaper20minutesBrowser RSS_FEED = 'http://www.20minutes.fr/rss/une.xml' RSSID = rssid �������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/pages/�����������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017237�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/pages/__init__.py������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021336�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/pages/article.py�������������������������������������������������������0000664�0000000�0000000�00000003612�12657170273�0021236�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"ArticlePage object for minutes20" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.messages.genericArticle import NoAuthorElement, try_remove, NoneMainDiv from .simple import SimplePage class ArticlePage(SimplePage): "ArticlePage object for minutes20" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "h1" self.element_author_selector = "div.mna-signature" self.element_body_selector = "div[role=main], div.mna-body" def get_body(self): try: element_body = self.get_element_body() except NoneMainDiv: return None else: try_remove(self.parser, element_body, "div.mna-tools") try_remove(self.parser, element_body, "div.mna-comment-call") try_remove(self.parser, element_body, "ul[class^=content-related]") try_remove(self.parser, element_body, "ul[class^=content-related]") try_remove(self.parser, element_body, "p.author-sign") try: element_body.remove(self.get_element_author()) except NoAuthorElement: pass return self.parser.tostring(element_body) ����������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/pages/simple.py��������������������������������������������������������0000664�0000000�0000000�00000002174�12657170273�0021106�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"ArticlePage object for minutes20" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage class SimplePage(GenericNewsPage): "ArticlePage object for minutes20" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "h1" self.element_author_selector = "div.mna-signature" self.element_body_selector = "div.mna-body" ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/minutes20/test.py����������������������������������������������������������������0000664�0000000�0000000�00000001667�12657170273�0017503�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class Minutes20Test(BackendTest): MODULE = 'minutes20' def test_new_messages(self): for message in self.backend.iter_unread_messages(): pass �������������������������������������������������������������������������weboob-1.1/modules/minutes20/tools.py���������������������������������������������������������������0000664�0000000�0000000�00000002666�12657170273�0017664�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"common tools for 20minutes backend" # -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re def id2url(_id): "return an url from an id" regexp2 = re.compile("(\w+).([0-9]+).(.*$)") match = regexp2.match(_id) if match: return 'http://www.20minutes.fr/%s/%s/%s' % (match.group(1), match.group(2), match.group(3)) else: raise ValueError("id doesn't match") def url2id(url): "return an id from an url" regexp = re.compile("http://www.20minutes.fr/(\w+)/([0-9]+)/(.*$)") match = regexp.match(url) return '%s.%d.%s' % (match.group(1), int(match.group(2)), match.group(3)) def rssid(entry): return url2id(entry.id) ��������������������������������������������������������������������������weboob-1.1/modules/monster/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016001�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/monster/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001434�12657170273�0020114�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MonsterModule __all__ = ['MonsterModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/monster/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000004016�12657170273�0020037�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.browser import PagesBrowser, URL from .pages import SearchPage, AdvertPage, AdvertPage2 __all__ = ['MonsterBrowser'] class MonsterBrowser(PagesBrowser): BASEURL = 'http://offres.monster.fr/' advert = URL('http://offre-emploi.monster.fr/(?P<_id>.*).aspx', AdvertPage) advert2 = URL('http://offre-demploi.monster.fr/(?P<_id>.*)', AdvertPage2) search = URL('rechercher\?q=(?P<pattern>.*)', 'PowerSearch.aspx\?q=(?P<job_name>.*)&where=(?P<place>.*)&jt=(?P<contract>.*)&occ=(?P<job_category>.*)&tm=(?P<limit_date>.*)&indid=(?P<activity_domain>)', 'rechercher/.*', SearchPage) def search_job(self, pattern=None): return self.search.go(pattern=urllib.quote_plus(pattern)).iter_job_adverts() def advanced_search_job(self, job_name, place, contract, job_category, activity_domain, limit_date): return self.search.go(job_name=job_name, place=place, contract=contract, job_category=job_category, limit_date=limit_date, activity_domain=activity_domain).iter_job_adverts() def get_job_advert(self, _id, advert): splitted_id = _id.split('#') _page = self.advert2 if splitted_id[0] else self.advert return _page.go(_id=splitted_id[1]).get_job_advert(obj=advert) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/monster/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000040312�12657170273�0020134�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq��� pHYs�� �� ���� cHRM��z%��������u0��`��:��o_F��@PIDATx�@@X*������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������!*�jP��������������������������������������������������WoB�DW3��z������������������������������������������������������������������������������������������������������������������������������������������������������������������  �wZ�$� �Pf<�J^8�������������������������������������������������Mc:�Mc:� �&�wZ� �����������������������������������������������������������������������������������������������������������������������������������������������������������������Ma:� �Ƿ������<L-�������������������������������������������������<M.�����`�{� �La9��������������������������������������������������������������������������������������������������������������������������������������������������������������@R0�����������������������������������������������������������������������AS1��������������������������  ������������������������������������������������������������������������������������������������������*5 �  �����(�������������������������������������������������������������EX4������ �(3����������������������.;"��Lc:�����������������������������������������������������°�������������������������������������  �9H+���������wY�������������������������������������������������������� �^xG�������������6F*�������������������$�� � ����������������������������������������������������������6F)������������������������� �.;$�La9�",����������������������������������������������������� '�(2� ���������������������?P/��̿��������������~Z �2A&����������&/�'3������������������������������������������x�³������������������Nb;�AS0����������������������������������������������������������H[7�J`6���������������������������������������������X*���������������������������� �@Q0�G\6� ��������������������������������������^�����������c~J�3B&��������������������������������������������h���������������FX5�Nd;� ���������������������������������������������_����������,A�������������������������������4D(����������������������������������  �������/:$�gM�*6����������������������������������������#,�ȸ�������YpC�Qi=� �������������������������������������������ȹ������,A��������������������������������������*7���������������������������������������,7"�oT��ȷ�s���/=$�������������������������������  ����rU�>P.���v���"-����������������������������������ͽ�����������������������������������������������±�Lc7� ��������������������������������� �$�`{H� ����������[uD������������������������������ ��b|J�0?$�����e����������� �8H*���������������������������������",���,A�����������������������������������������1>&���������������������������������� )�DW3� �����������������BT1� ����������������������������� �>N/�4D'������������������������J_7���������������������������������������������������������������������������������������������������������������������� ����������������������������������������������������������&2�(5������������������������������������������������������������� � ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ʼ�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ò�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ������������������������������������²���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������̾�������������������������������������������������������������������������������������������������������������������������������������� ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������$����������������������������������������������������������������������� �������������������������������������������������������������������������� ���������<Ʈ����IENDB`����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/monster/module.py����������������������������������������������������������������0000664�0000000�0000000�00000016261�12657170273�0017646�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.job import CapJob, BaseJobAdvert from weboob.tools.value import Value from weboob.tools.ordereddict import OrderedDict from .browser import MonsterBrowser __all__ = ['MonsterModule'] class MonsterModule(Module, CapJob): NAME = 'monster' DESCRIPTION = u'monster website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = MonsterBrowser type_contrat_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '97': u'Interim ou CDD ou mission', '98': u'CDI', '99': u'Stage', '000100': u'Autres', '101': u'Indépendant/Freelance/Franchise', '102': u'Journalier', '103': u'Titulaire de la fonction publique', '104': u'Temps Partiel', '105': u'Temps Plein', }.iteritems())]) JobCategory_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'Choisir…', '78': u'Architecture, Création et Spectacle', '92': u'Autres', '76': u'BTP et second oeuvre', '95': u'Commercial / Vente', '72': u'Comptabilité et Finance', '80': u'Edition et Ecriture', '81': u'Formation / Education', '93': u'Gestion de projet / programme', '83': u'Hôtellerie, Restauration et Tourisme', '86': u'Informatique et Technologies', '82': u'Ingénierie', '85': u'Installation, Maintenance et Réparation', '87': u'Juridique', '88': u'Logistique, Approvisionnement et Transport', '90': u'Marketing', '89': u'Production et Opérations', '94': u'Qualité / Inspection', '75': u'Recherche et Analyses', '84': u'Ressources Humaines', '91': u'Santé', '96': u'Sécurité', '73': u'Services administratifs', '79': u'Services clientèle et aux particuliers', '77': u'Stratégie et Management', }.iteritems())]) activityDomain_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'Choisir…', '16': u'Aéronautique / Aérospatiale (civil et militaire)', '17': u'Agriculture / Sylviculture / Pêche / Chasse', '39': u'Agroalimentaire', '18': u'Architecture / Design et services associés', '53': u'Art / Culture / Loisirs', '51': u'Associations / Bénévolat', '43': u'Assurance et Mutualité', '23': u'Audiovisuel / Media / Diffusion Audio et Vidéo', '14': u'Audit / Comptabilité / Fiscalité', '20': u'Automobile - Vente, Maintenance et Réparations', '52': u'Autres', '24': u'Autres Services aux entreprises', '21': u'Banques / Organismes financiers', '32': u'Biens de consommation courante / Cosmétiques', '31': u'BTP / Construction - bâtiments commerciaux, habitations', '30': u'BTP / Construction - usines, infrastructures, TP', '45': u'Cabinets et Services Juridiques', '46': u'Cabinets conseils en Management et Stratégie', '25': u'Chimie', '67': u'Commerce de gros et Import/Export', '55': u'Edition / Imprimerie', '35': u'Energie et Eau', '33': u'Enseignement et Formation', '66': u'Gestion des déchêts et Recyclage', '59': u'Grande Distribution et Commerce de détail', '42': u'Hôtellerie', '56': u'Immobilier', '47': u'Industrie / Production, autres', '19': u'Industrie Automobile - Constructeurs / Équipementiers', '34': u'Industrie électronique', '22': u'Industrie pharmaceutique / Biotechnologies', '26': u'Industrie Textile, Cuir et Confection', '27': u'Informatique - Hardware', '29': u'Informatique - Services', '28': u'Informatique - Software', '36': u'Ingénierie et services associés', '44': u'Internet / e-commerce', '57': u'Location', '48': u'Marine / Aéronautique', '15': u'Marketing / Communication / Publicité / RP', '50': u'Métaux et Minéraux', '37': u'Parcs d attraction et salles de spectacles', '62': u'Recrutement / Intérim et bureaux de placement', '58': u'Restauration', '41': u'Santé', '49': u'Santé - Equipement et appareils', '40': u'Secteur Public', '60': u'Sécurité et Surveillance', '54': u'Services aux particuliers', '38': u'Services financiers', '61': u'Sport - Equipements et infrastructures', '63': u'Télécommunication', '65': u'Tourisme, voyages et transport de personnes', '64': u'Transport de marchandises, entreprosage, stockage', }.iteritems())]) date_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '-1': u'N importe quelle date', '000000': u'Aujourd hui', '1': u'2 derniers jours', '3': u'3 derniers jours', '7': u'Les 7 derniers jours', '14': u'Les 14 derniers jours', '30': u'30 derniers jours', }.iteritems())]) CONFIG = BackendConfig( Value('job_name', label='Job name', masked=False, default=''), Value('place', label='Place', masked=False, default=''), Value('contract', label=u'Contract', choices=type_contrat_choices, default='000100'), Value('job_category', label=u'Job Category', choices=JobCategory_choices, default=''), Value('activity_domain', label=u'Activity Domain', choices=activityDomain_choices, default=''), Value('limit_date', label=u'Date', choices=date_choices, default='-1'), ) def search_job(self, pattern=None): return self.browser.search_job(pattern) def advanced_search_job(self): return self.browser.advanced_search_job(job_name=self.config['job_name'].get(), place=self.config['place'].get(), contract=self.config['contract'].get(), job_category=self.config['job_category'].get(), activity_domain=self.config['activity_domain'].get(), limit_date=self.config['limit_date'].get()) def get_job_advert(self, _id, advert=None): return self.browser.get_job_advert(_id, advert) def fill_obj(self, advert, fields): return self.get_job_advert(advert.id, advert) OBJECTS = {BaseJobAdvert: fill_obj} �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/monster/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000010415�12657170273�0017453�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from datetime import datetime, time, timedelta from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import CleanText, Regexp, Filter, Env, BrowserURL, Join, Date, Format from weboob.browser.filters.html import Link, CleanHTML from weboob.capabilities.job import BaseJobAdvert from weboob.capabilities.base import NotAvailable class MonsterDate(Filter): def filter(self, date): now = datetime.now() number = re.search("\d+", date) if number: if 'heures' in date: date = now - timedelta(hours=int(number.group(0))) return datetime.combine(date, time()) elif 'jour' in date: date = now - timedelta(days=int(number.group(0))) return datetime.combine(date, time()) else: return datetime.combine(now, time.min) class SearchPage(HTMLPage): @pagination @method class iter_job_adverts(ListElement): item_xpath = '//table[@class="listingsTable"]/tbody/tr[@class="odd"] | //table[@class="listingsTable"]/tbody/tr[@class="even"]' def next_page(self): return Link('//a[@title="Suivant"]', default=None)(self) class item(ItemElement): klass = BaseJobAdvert obj_id = Regexp(Link('./td/div/div[@class="jobTitleContainer"]/a'), 'http://offre-(d?)emploi.monster.fr:80/(.*?)(.aspx|\?).*', '\\1#\\2') obj_society_name = CleanText('./td/div/div[@class="companyContainer"]/div/a') obj_title = CleanText('./td/div/div[@class="jobTitleContainer"]/a') obj_publication_date = MonsterDate(CleanText('td/div/div[@class="fnt20"]')) obj_place = CleanText('./td/div/div[@class="jobLocationSingleLine"]/a/@title', default=NotAvailable) class AdvertPage(HTMLPage): @method class get_job_advert(ItemElement): klass = BaseJobAdvert obj_id = Format('#%s', Env('_id')) obj_url = BrowserURL('advert', _id=Env('_id')) obj_title = CleanText('//div[@id="jobcopy"]/h1[@itemprop="title"]|//div[@itemprop="title"]/h1') obj_description = CleanHTML('//div[@id="jobBodyContent"]|//div[@itemprop="description"]') obj_contract_type = Join(u' ', '//dd[starts-with(@class, "multipledd")]') obj_society_name = CleanText('//dd[@itemprop="hiringOrganization"]') obj_place = CleanText('//span[@itemprop="jobLocation"]') obj_pay = CleanText('//span[@itemprop="baseSalary"]') obj_formation = CleanText('//span[@itemprop="educationRequirements"]') obj_experience = CleanText('//span[@itemprop="qualifications"]') class AdvertPage2(HTMLPage): @method class get_job_advert(ItemElement): klass = BaseJobAdvert obj_id = Format('d#%s', Env('_id')) obj_url = BrowserURL('advert2', _id=Env('_id')) obj_title = CleanText('//h3') obj_description = CleanHTML('//div[@id="jobBodyContent"]|//div[@itemprop="description"]') obj_contract_type = CleanHTML('//div[@class="jobview-section"]') obj_society_name = Regexp(CleanText('//h4[@class="company"]'), '.* : (.*) - .*') obj_place = Regexp(CleanText('//h4[@class="company"]'), '.* - (.*)') obj_publication_date = Date(Regexp(CleanText('//span[@class="postedDate"]'), '.* : (.*)'), dayfirst=True) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/monster/test.py������������������������������������������������������������������0000664�0000000�0000000�00000002655�12657170273�0017342�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import itertools from weboob.tools.test import BackendTest class MonsterTest(BackendTest): MODULE = 'monster' def test_monster_search(self): l = list(itertools.islice(self.backend.search_job(u'marketing'), 0, 20)) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) def test_monster_advanced_search(self): l = list(itertools.islice(self.backend.advanced_search_job(), 0, 20)) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) �����������������������������������������������������������������������������������weboob-1.1/modules/myhabit/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015747�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/myhabit/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001442�12657170273�0020061�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import MyHabitModule __all__ = ['MyHabitModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/myhabit/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000015336�12657170273�0020014�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from requests.exceptions import Timeout from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.browser import LoginBrowser, URL, need_login from weboob.browser.pages import HTMLPage from weboob.capabilities.base import Currency from weboob.capabilities.shop import OrderNotFound, Order, Payment, Item from weboob.exceptions import BrowserIncorrectPassword from datetime import datetime from decimal import Decimal __all__ = ['MyHabit'] class MyHabitPage(HTMLPage): @property def logged(self): return bool(self.doc.xpath('//a[text()="Sign Out"]')) class LoginPage(MyHabitPage): def login(self, username, password): form = self.get_form(name='signIn') form['email'] = username form['password'] = password form.submit() return self.browser.page class HistoryPage(MyHabitPage): def is_sane(self): # Occasionally MyHabit returns a page without this form. # In this case we must retry until correct page is retrieved. return bool(self.doc.xpath('//form[@id="viewOrdersHistory"]')) def to_year(self, year): form = self.get_form(xpath='//form[@id="viewOrdersHistory"]') form['orderRange'] = year form.submit() return self.browser.page def years(self): return self.doc.xpath('//option[contains(@value,"FULL_YEAR")]/@value') def iter_orders(self): return self.doc.xpath('//a[contains(@href,"ViewOrdersDetail")]/@href') class OrderPage(MyHabitPage): def order(self, url): order = Order(id=self.order_number()) order._url = url order.date = self.order_date() order.tax = self.tax() order.shipping = self.shipping() order.discount = self.discount() order.total = self.total() return order def payments(self): method = self.doc.xpath('//div[@class="creditCard"]/text()')[0].strip() pmt = Payment() pmt.date = self.order_date() pmt.method = unicode(method) pmt.amount = self.total() yield pmt def items(self): for span in self.doc.xpath('//div[@class="shipmentItems1"]' '/span[@class="item"]'): url = span.xpath('span[@class="itemLink"]/a/@href')[0] label = span.xpath('span[@class="itemLink"]/a/text()')[0] qty = span.xpath('span[@class="itemQuantity"]/text()')[0] price = span.xpath('span[@class="itemPrice"]/text()')[0] price = Decimal(qty)*AmTr.decimal_amount(price) item = Item() item.url = unicode(url) item.label = unicode(label) item.price = price yield item def order_date(self): date = self.doc.xpath(u'//span[text()="Order Placed:"]' '/following-sibling::span[1]/text()')[0].strip() return datetime.strptime(date, '%b %d, %Y') def order_number(self): return self.doc.xpath(u'//span[text()="MYHABIT Order Number:"]' '/following-sibling::span[1]/text()')[0].strip() def order_amount(self, which): return AmTr.decimal_amount((self.doc.xpath( '//tr[@class="%s"]/td[2]/text()' % which) or ['0'])[0]) def tax(self): return self.order_amount('tax') def shipping(self): return self.order_amount('shippingCharge') def discount(self): TAGS = ['discount', 'gc'] return sum(self.order_amount(t) for t in TAGS) def total(self): return self.order_amount('total') class MyHabit(LoginBrowser): BASEURL = 'https://www.myhabit.com' MAX_RETRIES = 10 login = URL(r'/signin', r'https://www.amazon.com/ap/signin.*$', LoginPage) order = URL(r'/vieworders\?.*appAction=ViewOrdersDetail.*', OrderPage) history = URL(r'/vieworders$', r'/vieworders\?.*appAction=ViewOrdersHistory.*', HistoryPage) unknown = URL(r'/.*$', r'http://www.myhabit.com/.*$', MyHabitPage) def get_currency(self): # MyHabit uses only U.S. dollars. return Currency.get_currency(u'$') @need_login def get_order(self, id_): # MyHabit requires dynamically generated token each time you # request order details, which makes it problematic to get an order # by id. Hence this slow and painful stub. for year in self.to_history().years(): hist = self.to_history().to_year(year) for url in hist.iter_orders(): if id_ in url: self.location(url) assert self.order.is_here() o = self.page.order(url) if o.id == id_: return o raise OrderNotFound() @need_login def iter_orders(self): for year in self.to_history().years(): hist = self.to_history().to_year(year) for url in hist.iter_orders(): self.location(url) assert self.order.is_here() yield self.page.order(url) @need_login def iter_payments(self, order): if self.url != self.BASEURL+order._url: self.location(order._url) assert self.order.is_here() return self.page.payments() @need_login def iter_items(self, order): if self.url != self.BASEURL+order._url: self.location(order._url) assert self.order.is_here() return self.page.items() @need_login def to_history(self): for i in xrange(self.MAX_RETRIES): if self.history.is_here() and self.page.is_sane(): return self.page self.history.go() def do_login(self): if not self.login.go().login(self.username, self.password).logged: raise BrowserIncorrectPassword() def location(self, *args, **kwargs): for i in xrange(self.MAX_RETRIES): try: return super(MyHabit, self).location(*args, **kwargs) except Timeout as e: pass raise e ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/myhabit/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000007206�12657170273�0020107�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���u:���gAMA�� a��� cHRM��z&���������u0��`��:��pQ<���bKGD X���tIME9#k;|^�� IDATxy\TW6 M75Ђ"AMh4(DPh&DPQHq f̸ &D}"@7}ɣG4uԩss ?v0� �K *4)Lnt2 ^*RH!ձ$ `Ѓt / $0VC@`CHы^hjD���(A $,XCM%|hy@O+ 2!sƀ1b*bv7ی5X5hCڴ>Z1A D+ʵr-,303D+aKKW4'q!bh[6 !t2ܣQ%}�#E. 1;|KOctA_$`9$$�MhB#=`A|JԎAN&SI$.{\)'jp.ԙ [GgDDDDGQdX?LD"Ȉܢy:阎:؀M|}?qҐ9KuBl˟ꇓ8s`40 L޸qnn憤I.sz444NW+ŕW>y*TOOOfMRSSyQi23Gfz{ziɈg-d!{؅=&bfD_",rB<g3$N0TdońX6w&.コ%. ٸ($nJ썸obmbKձfޛu42g:6m~[z?Z1lX1ŋ6mM[4gŒw/Z>*yWWعNu.v2;J]+gcFXFXFq+VĭgyֶֶZkڷok7wSZc1M49,,?(ߚ)U6'5:KSt"d qnqa;a<irX ەvgm iTsO_؟+9j^]ؕPRQԨjh4ٵ}nyxz#|;f:OoZ-/mְzZMz/櫓"qZmFcfrW%>38'@oH7{4{4{t*;ՁWZrj̧O3[ZZ\$.ㆣϏ>?RJ)/// 4[lb!! [S2go̱{] -l﫷^mvdiӡvC&X.;>oaefWn=y2ѧF9F_e9E]OLhؼ۱^u̜,3w~'RCy?5׹2 L8Q u:(Iʤ7oO:<1c===&M>1.c\8"*B*PmmmQR[R[R+--}R 8 =ŖD-7/O ɷG M.toP}l|îNZVٯ!to'~Kc,6[L o^T( Mͤ]&͊)ӤKbJbwqmm8zK_xb xx8SsLO*3:Iѐ@-R69C%#:f[TI=(lم.t kš&FFFY,YLQ(PxN9!~_}e.], - - Hs9TM&o Y,H&[([([ذagΈֈֈ־6RE*ȣfU妔5_׼S~t]M}@~]qm@IY\=H-}.:,l}ۑeUn[ڬvU;\89? nb@yTWzxӕq~_lcvq;kѬ#6dc6{?}6':Ex *{+?{p9�@ododo+WүwwwO.>ҾK.9>v|xR˥=Y=Y=Y?\r9qNcrcrcg$IpM&TIZJFЩ$"R`HC-�L CZ(r 5M%to0]'. ڧMgfWŒ@)w/y'۷'1c0FE jTuU|ſ̢mf+GYJv}qzq`�cOQzƗ[^oD E(B9Qb#ؘTTTq3K%Ow/y]οX&Ꮷl [p<J%ߕߕG x/7Ƌ 6\aa춑r�b2j/sԞd4l^7ꄡ Oz߱mid9ۼjMj^i*{=˞ pþú4ۆߝ3q;B? TrfؽKݙh2IPIK#F߉NjCk5^bB K$ $)m,a7o@h.zBiP]Lv1-?0?0?طط(@C1Ǹ:{;{;=h:W+lc^c^c?z^JPŠi]fNna6t ]Y*Ӕծ},{TYq7QxNV]ׅs]v'/TZKnfS>jzUĄ|FNuVumuԇwEwSAeoNM!'wS];6~\Ӕ:8ïd-YO(D!Wc5V!6 0Ή Ÿ7'NLB qqH( '| P9E$r8v?^~xpEn[ f.3KGOD"}FG"n. r + Z!A$ 2 >} mG5!w0L$2dL\kMq 1i<`QkbJ#FDP\ :%1>f9*WP뼦o! a'Ċ 1V'74vE@ (`smF`Fp4 |)'T U|o4΋k=c<#hF3^׺,`7ڸ"{=;Ё_:(%G�m:'9,`wo�9A3GZqx���%tEXtdate:create�2015-02-23T22:57:35-06:00ؓ���%tEXtdate:modify�2015-02-23T22:57:35-06:00`/����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/myhabit/module.py����������������������������������������������������������������0000664�0000000�0000000�00000003531�12657170273�0017610�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.shop import CapShop from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import MyHabit __all__ = ['MyHabitModule'] class MyHabitModule(Module, CapShop): NAME = 'myhabit' MAINTAINER = u'Oleg Plakhotniuk' EMAIL = 'olegus8@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'MYHABIT' CONFIG = BackendConfig( ValueBackendPassword('email', label='E-mail', masked=False), ValueBackendPassword('password', label='Password')) BROWSER = MyHabit def create_default_browser(self): return self.create_browser(self.config['email'].get(), self.config['password'].get()) def get_currency(self): return self.browser.get_currency() def get_order(self, id_): return self.browser.get_order(id_) def iter_orders(self): return self.browser.iter_orders() def iter_payments(self, order): return self.browser.iter_payments(order) def iter_items(self, order): return self.browser.iter_items(order) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/myhabit/test.py������������������������������������������������������������������0000664�0000000�0000000�00000002150�12657170273�0017276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class MyHabitTest(BackendTest): MODULE = 'myhabit' def test_history(self): """ Test that at least one item was ordered in the whole history. """ b = self.backend items = (i for o in b.iter_orders() for i in b.iter_items(o)) item = next(items, None) self.assertNotEqual(item, None) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nectarine/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016262�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nectarine/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000000103�12657170273�0020365�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import NectarineModule __all__ = ['NectarineModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nectarine/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000003164�12657170273�0020323�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# * -*- coding: utf-8 -*- # Copyright(C) 2013 Thomas Lecavelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser from .pages import LivePage, StreamsPage __all__ = ['NectarineBrowser'] class NectarineBrowser(Browser): DOMAIN = 'www.scenemusic.net' PROTOCOL = 'https' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['desktop_firefox'] PAGES = { 'https://www\.scenemusic\.net/demovibes/xml/streams/': StreamsPage, 'https://www\.scenemusic\.net/demovibes/xml/queue/': LivePage } def home(self): self.location('/demovibes/xml/streams/') assert self.is_on_page(StreamsPage) def iter_radios_list(self): self.location('/demovibes/xml/streams/') assert self.is_on_page(StreamsPage) return self.page.iter_radios_list() def get_current_emission(self): self.location('/demovibes/xml/queue/') assert self.is_on_page(LivePage) return self.page.get_current_emission() ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nectarine/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000003521�12657170273�0020416�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���tEXtSoftware�Adobe ImageReadyqe<��IDATxYlTUϝ;iC;B1*BR*  DƄ(<HD .A$B*cUZ^ذڙ2YlwfN4LL}]_s; h.09٦E]jǴ'}՜z~#8{%�k=C1 +,sȑqv< m6vpw4<:Vyi0qί zm!s(8K*@![`h}Ⱦ]\h:ygKmoFy)鹏҄03'٧+88# ,`; r-*˜yKy3&sL|ωwyo,d +Ć5WS[d!�@R@%Ea,H0E8Nv:&+~x8&\fsS'>k0#xUZ@Z`� *p^x1]ٳo+55O;#D1'3;$& Y%p3D=2ZMH,-0``6tU ܈p;�r/e^:qQ.0d!*Zbhm磪fm^O316S Q?K Y йͺ3q< ݘw:- ڵk Q6پlU\\ n<\x#puSnsΙ_\~0[cy`dB)K(d˗/D9MXkŋ'ORZ`h5B |I̬*/6~$- -`YHFfw 7L kh&ϚF[|9Fw=^v-x,MΣࠠx>ąNA ,lKͺ".Bs g餭K_&'+++m>jj5;hfi ̟*,ͿߨtA$[ ` eI�ٜ?Uy$^C%EeHZ՛]'[1tpS#4g?&בb_C6vӧa`X黉KR2�Wχc#Ăq4M#=xP:4]myVX5BGKϴ;zK 46iW![(,L?.7+-0;BC͙IK M1UrtuZYBZ5)⩿X w]9ޡuMa76 PO8n㼭ֳS*@`� + &OIoEWGHJS4F=g!Mf!c_B%z /ފwQ٪��w+EZVRojq,0?߄=9ysH=lh{Rbcl2@+#IZhް. lOAyf1\gǺƺ_\Gd�pWjW5s>avF>¦P:MpN!BIk0}B3yՌ/Q.lIE�*6a(jGmi1h39з5ˈMhv苰M F`7A\] ,ـwXoX9=>ivmr%Fq% p; 5^<t_ hnȆ5,$vZt:,Q]R-NnO�8ԿU>,X@m{LI��{#�\甌����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nectarine/module.py��������������������������������������������������������������0000664�0000000�0000000�00000004417�12657170273�0020127�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Thomas Lecavelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.collection import CapCollection from weboob.tools.backend import Module from .browser import NectarineBrowser __all__ = ['NectarineModule'] class NectarineModule(Module, CapRadio, CapCollection): NAME = 'nectarine' MAINTAINER = u'Thomas Lecavelier' EMAIL = 'thomas-weboob@lecavelier.name' VERSION = '1.1' DESCRIPTION = u'Nectarine Demoscene Radio' # License of your module LICENSE = 'AGPLv3+' BROWSER = NectarineBrowser def iter_resources(self, objs, split_path): if Radio in objs: self._restrict_level(split_path) for radio in self.browser.iter_radios_list(): self.browser.get_current_emission() radio.current = self.browser.get_current_emission() yield radio def iter_radios_search(self, pattern): for radio in self.browser.iter_radios_list(): if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower(): self.browser.get_current_emission() radio.current = self.browser.get_current_emission() yield radio def get_radio(self, radio): if not isinstance(radio, Radio): for rad in self.browser.iter_radios_list(): if rad.id == radio: return rad return None def fill_radio(self, radio, fields): if 'current' in fields: return self.get_radio(radio.id) return radio OBJECTS = {Radio: fill_radio} �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nectarine/pages.py���������������������������������������������������������������0000664�0000000�0000000�00000004021�12657170273�0017730�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# * -*- coding: utf-8 -*- # Copyright(C) 2013 Thomas Lecavelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page from weboob.capabilities.radio import Radio from weboob.capabilities.audiostream import BaseAudioStream from weboob.tools.capabilities.streaminfo import StreamInfo class StreamsPage(Page): def iter_radios_list(self): radio = Radio('necta') radio.title = u'Nectarine' radio.description = u'Nectarine Demoscene Radio' radio.streams = [] index = -1 for el in self.document.xpath('//stream'): index += 1 stream_url = unicode(el.findtext('url')) bitrate = el.findtext('bitrate') encode = unicode(el.findtext('type')) country = unicode(el.findtext('country')).upper() stream = BaseAudioStream(index) stream.bitrate = int(bitrate) stream.format = encode stream.title = ' '.join([radio.title, country, encode, unicode(bitrate), 'kbps']) stream.url = stream_url radio.streams.append(stream) yield radio class LivePage(Page): def get_current_emission(self): current = StreamInfo(0) current.who = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text) current.what = unicode(self.document.xpath('//playlist/now/entry/song')[0].text) return current ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nectarine/test.py����������������������������������������������������������������0000664�0000000�0000000�00000001677�12657170273�0017626�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Thomas Lecavelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class NectarineTest(BackendTest): MODULE = 'nectarine' def test_nectarine(self): l = list(self.backend.iter_radios_search('')) self.assertTrue(len(l) > 0) �����������������������������������������������������������������weboob-1.1/modules/nettokom/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016152�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nettokom/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001436�12657170273�0020267�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NettoKomModule __all__ = ['NettoKomModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nettokom/browser.py��������������������������������������������������������������0000664�0000000�0000000�00000006515�12657170273�0020216�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Fourcot Florent # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import HomePage, LoginPage, HistoryPage, DetailsPage, BillsPage __all__ = ['Nettokom'] class Nettokom(Browser): DOMAIN = 'konto.nettokom.de' PROTOCOL = 'https' ENCODING = None # refer to the HTML encoding PAGES = {'.*login.html.*': LoginPage, '.*start.html': HomePage, '.*guthabenverbrauch.html': DetailsPage, '.*/verbindungsnachweis/.*': HistoryPage, '.*verbindungsnachweis.html': BillsPage } def __init__(self, *args, **kwargs): Browser.__init__(self, *args, **kwargs) def home(self): self.location('/start.html') def is_logged(self): return not self.is_on_page(LoginPage) def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.username.isdigit() if not self.is_on_page(LoginPage): self.location('/login.html') self.page.login(self.username, self.password) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() def get_subscription_list(self): if not self.is_on_page(HomePage): self.location('/start.html') return self.page.get_list() def get_subscription(self, id): assert isinstance(id, basestring) if not self.is_on_page(HomePage): self.location('/start.html') l = self.page.get_list() for a in l: if a.id == id: return a return None def get_history(self): if not self.is_on_page(HistoryPage): self.location('/verbindungsnachweis/alle-verbindungen.html') return self.page.get_calls() def get_details(self): if not self.is_on_page(DetailsPage): self.location('/guthabenverbrauch.html') return self.page.get_details() def iter_bills(self, parentid): if not self.is_on_page(BillsPage): self.location('/verbindungsnachweis.html') return self.page.date_bills() def get_bill(self, id): assert isinstance(id, basestring) if not self.is_on_page(BillsPage): self.location('/verbindungsnachweis.html') l = self.page.date_bills() for a in l: if a.id == id: return a # Todo : url depends of file format # def download_bill(self, id): # assert isinstance(id, basestring) # date = id.split('.')[1] # # return self.readurl('/moncompte/ajax.php?page=facture&mode=html&date=' + date) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nettokom/module.py���������������������������������������������������������������0000664�0000000�0000000�00000005643�12657170273�0020021�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import CapBill, Subscription, SubscriptionNotFound, Detail from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Nettokom __all__ = ['NettoKomModule'] class NettoKomModule(Module, CapBill): NAME = 'nettokom' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'Nettokom website' CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID (phone number)', masked=False, regexp='^(\d{8,13}|)$'), ValueBackendPassword('password', label='Password') ) BROWSER = Nettokom def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): for subscription in self.browser.get_subscription_list(): yield subscription def get_subscription(self, _id): with self.browser: subscription = self.browser.get_subscription(_id) if subscription: return subscription else: raise SubscriptionNotFound() def iter_bills_history(self, subscription): with self.browser: for history in self.browser.get_history(): yield history # The subscription is actually useless, but maybe for the futur... def get_details(self, subscription): with self.browser: for detail in self.browser.get_details(): yield detail def get_balance(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) balance = Detail() balance.id = "%s-balance" % subscription.id balance.price = subscription._balance balance.label = u"Balance %s" % subscription.id balance.currency = u'EUR' return balance ���������������������������������������������������������������������������������������������weboob-1.1/modules/nettokom/pages/������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017251�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nettokom/pages/__init__.py�������������������������������������������������������0000664�0000000�0000000�00000001643�12657170273�0021366�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .homepage import HomePage from .history import HistoryPage, DetailsPage, BillsPage from .login import LoginPage __all__ = ['LoginPage', 'HomePage', 'HistoryPage', 'DetailsPage', 'BillsPage'] ���������������������������������������������������������������������������������������������weboob-1.1/modules/nettokom/pages/history.py��������������������������������������������������������0000664�0000000�0000000�00000005700�12657170273�0021326�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import datetime, date, time from decimal import Decimal from weboob.deprecated.browser import Page from weboob.capabilities.bill import Detail class DetailsPage(Page): def on_loaded(self): self.details = [] table = self.document.xpath('//table[@id="reportTable"]') if len(table) > 0: for tr in table[0].xpath('tbody/tr'): detail = Detail() # Skip global category if tr.find('td/a') is not None: continue if tr.attrib["class"] == "totalAmount": continue tds = tr.xpath('td') detail.label = unicode(tds[0].text.strip()) detail.infos = unicode(tds[1].text.strip()) detail.price = Decimal(tds[2].text.split(' ')[0].replace(',', '.')) self.details.append(detail) def get_details(self): return self.details def _get_date(detail): return detail.datetime class BillsPage(Page): def on_loaded(self): pass class HistoryPage(Page): def on_loaded(self): self.calls = [] for tr in self.document.xpath('//tr'): try: attrib = tr.attrib["class"] except: continue if attrib == "even" or attrib == "odd": label = u'' tddate = tr.find('td[@class="middle nowrap"]') for td in tr.xpath('td[@class="long"]'): label += unicode(td.text.strip()) + u' ' tdprice = tr.xpath('td[@class="price"]') label += u'(' + unicode(tdprice[0].text.strip()) + u')' price = Decimal(tdprice[1].text.strip().replace(',', '.')) detail = Detail() mydate = date(*reversed([int(x) for x in tddate.text.strip().split(' ')[0].split(".")])) mytime = time(*[int(x) for x in tddate.text.strip().split(' ')[1].split(":")]) detail.datetime = datetime.combine(mydate, mytime) detail.label = label detail.price = price self.calls.append(detail) def get_calls(self): return sorted(self.calls, key=_get_date, reverse=True) ����������������������������������������������������������������weboob-1.1/modules/nettokom/pages/homepage.py�������������������������������������������������������0000664�0000000�0000000�00000004234�12657170273�0021413�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import Subscription from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.deprecated.browser import Page from datetime import date from decimal import Decimal class HomePage(Page): def on_loaded(self): pass def get_list(self): l = [] divabo = self.document.xpath('//div[@id="accountSummary"]')[0] owner = divabo.xpath('a/h3')[0].text phone = divabo.xpath('dl/dd')[0].text credit = divabo.xpath('dl/dd')[1].text expiredate = divabo.xpath('dl/dd')[2].text phoneplan = divabo.xpath('dl/dd')[3].text self.browser.logger.debug('Found ' + owner + ' as subscriber') self.browser.logger.debug('Found ' + phone + ' as phone number') self.browser.logger.debug('Found ' + credit + ' as available credit') self.browser.logger.debug('Found ' + expiredate + ' as expire date ') self.browser.logger.debug('Found %s as subscription type', phoneplan) subscription = Subscription(phone) subscription.label = unicode(u'%s - %s - %s - %s' % (phone, credit, phoneplan, expiredate)) subscription.subscriber = unicode(owner) expiredate = date(*reversed([int(x) for x in expiredate.split(".")])) subscription.validity = expiredate subscription._balance = Decimal(FrenchTransaction.clean_amount(credit)) l.append(subscription) return l ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nettokom/pages/login.py����������������������������������������������������������0000664�0000000�0000000�00000002152�12657170273�0020733�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page class LoginPage(Page): def on_loaded(self): pass def login(self, login, password): self.browser.select_form(nr=0) self.browser.set_all_readonly(False) self.browser['number'] = login.encode('iso-8859-1') self.browser['password'] = password.encode('iso-8859-1') self.browser.submit(nologin=True) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nettokom/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000002710�12657170273�0017503�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class NettokomTest(BackendTest): MODULE = 'nettokom' def test_details(self): for subscription in self.backend.iter_subscription(): details = list(self.backend.get_details(subscription)) self.assertTrue(len(details) > 1, msg="Not enough details") def test_history(self): for subscription in self.backend.iter_subscription(): self.assertTrue(len(list(self.backend.iter_bills_history(subscription))) > 0) def test_list(self): """ Test listing of subscriptions. """ subscriptions = list(self.backend.iter_subscription()) self.assertTrue(len(subscriptions) > 0, msg="Account listing failed") ��������������������������������������������������������weboob-1.1/modules/newsfeed/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016112�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/newsfeed/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001446�12657170273�0020230�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NewsfeedModule __all__ = ['NewsfeedModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/newsfeed/favicon.png�������������������������������������������������������������0000664�0000000�0000000�00000006625�12657170273�0020256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ~���tIME  8(EH�� 'IDATxݛ{p\}?{W]OKe ۘ &dR -e:IKi-uȐ$iƱM@Rla6`[׻{9Ck{WFwFwwν}M;@B !Bp6mZkR�@;IH㥶gkZSPȌTV*)! aBʳ�J6x(h'v46m te]k[Lw<�Z=R) T65.+pIqT: m; @@ϳ#Y'^2 3C@?(ةT˟x�;4gwU65Q؀v\Cb@ș'rroc4A\fGifcj{MgaհZRC$pSIČ<'N Py-fA@ćGnᅮ)iG֮VeeĻIGѨs~:> !bbҺZ/h?#Դjj^hl$ݏ=z$0|*+Jݷ~~ʉF"ё^+*T'ni X5I~@켧z ZH1Gi*V4h%pj{8phFhug 2Ceex‡oYTA'FQ>Xx/B~B+855D;;T*iXY\U JMWfم=;xgN8ބЬ(5ZP EeF3`I N"P b.X`)�ݱ =M,)`D@(;)t|~N_uK1Š/NVpBZSa;MH0,C_w?;qv R^vl +VjB DkcJW%xFkVÅܗm71(,> zI=SgEy lb~ QTu'OoN�#rcaDa"X,D j##< ̰[%n9 !+0j/Ƭ`iE)-qww@9?uL0.:MDqڱ0uK1/\y*DlV˾�Շ&3k=/ŀ4n[?N~ԦQ}3/QE+V>5TiV(V~&CY3Ƨ@7֙BfĀ3ViTO;闾:t"" rDHq w_-DQ i+MNQh7j nnAPv~>y+F(iĺ^펟>ʙgO{QX,<cA؂:pVunV7-_<< 6wxu{]P7Qpz ׼uאj_yKّ;~sO "hKZP8[ u/+ȪKN~J f>~X9Fg-o4GPG~׸ց3 \YGvWy`8"X[:6/ס \Gsy<*�Q,q?k1 Y4gA03/ *斷QR' 7}uZ)(ZW!"GQ=o@|�ЈRs\*rp 5t(S\t ;ww@Zf$Hwwj0SG^Ge(,Xt5ƒȆ `xC{#Kmc/>6S[ 1kձ wV= -9b|=/l\?|_Уq=}}!Pu#`[w�?&t t]qKw7 X+<O4:1-.^+248+6n ?w 1g*1F~N&mJ<kߘ2I VVyl߈N=^B ޜqv|*[Zo*o([gQb̚Ox�ӄ2Vȡ]_\q#MP-d/o-D.Y(]J;^F{mzg*<zdܳUl:Eަ;ҍQVۀ]7W X3 !ADꐋV`z cUlH̸ٵR}¥+~f Rb޸ 2ͷ`\՜ LMoam"e}{{A UqNxAo7A6^. %{uHx'YX^UۧFEpInxrU<|c7GE+svo^A'cMmY w< ,[HuS l]۽ 2Vݽ'6=z50dwo;Iֵ}ޓ(RTgv!oTϩ(D|7o{=Α]K敋j{g;VM^KWᩎ:9ͳuƆc eY;6裇$2X ?&O>i!|孎/KZMrˣd̻oظc}>KbeY Ę"R!0R|zEt*q!BW#pߢŸw&J'' 3 �1'J!ձumຸqvT+6=[pNtp:YQĶ;yw=e%Ac;Z^_suK?#NޯAPwzljoI!hJox bv"]jN`Edby/ Iqs5hUY.vKH1ىR TF1 '&Qt28|">T[B(=$'vtu뱾>]|Eu vvrbh8-L˟<zf<6o,>14tPn*JZdX0׶=©-1,;{l`oC QҌ8NS.T[Lqs5Z(y,?YqdܡW PQv سNbw3<7*;eFg Nf78ÅJ(FzzF9!!mo?ʱŅ TzKaOCu=<II$FGI�A 0m?n*UmW"ĕl܄8b 6_Tg˯[U����IENDB`�����������������������������������������������������������������������������������������������������������weboob-1.1/modules/newsfeed/module.py���������������������������������������������������������������0000664�0000000�0000000�00000006020�12657170273�0017747�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.messages import CapMessages, Message, Thread from weboob.tools.newsfeed import Newsfeed from weboob.tools.value import Value __all__ = ['NewsfeedModule'] class NewsfeedModule(Module, CapMessages): NAME = 'newsfeed' MAINTAINER = u'Clément Schreiner' EMAIL = "clemux@clemux.info" VERSION = '1.1' DESCRIPTION = "Loads RSS and Atom feeds from any website" LICENSE = "AGPLv3+" CONFIG = BackendConfig(Value('url', label="Atom/RSS feed's url", regexp='https?://.*')) STORAGE = {'seen': []} def iter_threads(self): for article in Newsfeed(self.config['url'].get()).iter_entries(): yield self.get_thread(article.id, article) def get_thread(self, id, entry=None): if isinstance(id, Thread): thread = id id = thread.id else: thread = Thread(id) if entry is None: entry = Newsfeed(self.config['url'].get()).get_entry(id) if entry is None: return None flags = Message.IS_HTML if thread.id not in self.storage.get('seen', default=[]): flags |= Message.IS_UNREAD if len(entry.content) > 0: content = u"<p>Link %s</p> %s" % (entry.link, entry.content[0]) else: content = entry.link thread.title = entry.title thread.root = Message(thread=thread, id=0, title=entry.title, sender=entry.author, receivers=None, date=entry.datetime, parent=None, content=content, children=[], flags=flags) return thread def iter_unread_messages(self): for thread in self.iter_threads(): for m in thread.iter_all_messages(): if m.flags & m.IS_UNREAD: yield m def set_message_read(self, message): self.storage.get('seen', default=[]).append(message.thread.id) self.storage.save() def fill_thread(self, thread, fields): return self.get_thread(thread) OBJECTS = {Thread: fill_thread} ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/newsfeed/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000001665�12657170273�0017453�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class NewsfeedTest(BackendTest): MODULE = 'newsfeed' def test_newsfeed(self): for message in self.backend.iter_unread_messages(): pass ���������������������������������������������������������������������������weboob-1.1/modules/nihonnooto/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016504�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nihonnooto/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000000105�12657170273�0020611�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import NihonNoOtoModule __all__ = ['NihonNoOtoModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nihonnooto/browser.py������������������������������������������������������������0000664�0000000�0000000�00000003055�12657170273�0020544�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# * -*- coding: utf-8 -*- # Copyright(C) 2013 Thomas Lecavelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser from .pages import LivePage, ProgramPage __all__ = ['NihonNoOtoBrowser'] class NihonNoOtoBrowser(Browser): DOMAIN = 'www.nihon-no-oto.com' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['desktop_firefox'] PAGES = { 'http://www\.nihon-no-oto\.com/': LivePage, 'http://www\.nihon-no-oto\.com/app/playlist.php': ProgramPage, } def home(self): self.location('/') assert self.is_on_page(LivePage) def iter_radios_list(self): self.location('/') assert self.is_on_page(LivePage) return self.page.iter_radios_list() def get_current_emission(self): self.location('/app/playlist.php') assert self.is_on_page(ProgramPage) return self.page.get_current_emission() �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nihonnooto/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000016673�12657170273�0020654�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���tEXtSoftware�Adobe ImageReadyqe<��]IDATx{ t\^WJXl˶C ؄8l==Lf@Iϙ$CO/!3CO&a'}&d@bVcxwɋ$k*UzW%c;2&ӝ9<kU[w{WipYc4c�W�d|̷=� ? 9N$/X.� 8F8Q$ Vu9>Z7miti2 ۦqer~mA,M"jڨNa_2 *'|kOsEL\&]G� Lۖ;v5ֶ/~JCMq7h~�yec?/f϶7ߴLM@ ҾK.�?lF9d\eZ 0Z "Mw킓oJF}#/#p|!_S 庞%CkQs뙁W$m}p9S�{,'n9fXa|c;wbٿ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8},=0 o�qAӴ4$ #%sMPz̞1ZmZ֩jUy[vT{,VܰS`Gܬ#?~ut} =!BxElD|\#s�Vz`cz9h#9`%/6yd)Gi|S,Q"S< W\F7IT}-�r;=6Ӈ>�GKbLjΐU̻Xc|D k?7)M tuKN% mkک@Qm]uUѵlzn V8tD0+յZ3I\̡E�lFynS_겮FmPi5Tkc;D֞ak-=']ȗ7i3$kbZu?A*MEJ/M`�<X+����IENDB`���������������������������������������������������������������������weboob-1.1/modules/nihonnooto/module.py�������������������������������������������������������������0000664�0000000�0000000�00000004573�12657170273�0020354�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Thomas Lecavelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.collection import CapCollection from weboob.tools.backend import Module from .browser import NihonNoOtoBrowser __all__ = ['NihonNoOtoModule'] class NihonNoOtoModule(Module, CapRadio, CapCollection): NAME = 'nihonnooto' MAINTAINER = u'Thomas Lecavelier' EMAIL = 'thomas-weboob@lecavelier.name' VERSION = '1.1' DESCRIPTION = u'« Le son du Japon » french operated web radio, diffusing japanese music' # License of your module LICENSE = 'AGPLv3+' BROWSER = NihonNoOtoBrowser _RADIOS = {'nihonnooto': (u'Nihon no OTO', True) } def iter_resources(self, objs, split_path): if Radio in objs: self._restrict_level(split_path) for radio in self.browser.iter_radios_list(): self.browser.get_current_emission() radio.current = self.browser.get_current_emission() yield radio def iter_radios_search(self, pattern): for radio in self.browser.iter_radios_list(): if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower(): self.browser.get_current_emission() radio.current = self.browser.get_current_emission() yield radio def get_radio(self, radio): if not isinstance(radio, Radio): for rad in self.browser.iter_radios_list(): if rad.id == radio: return rad return None def fill_radio(self, radio, fields): if 'current' in fields: return self.get_radio(radio.id) return radio OBJECTS = {Radio: fill_radio} �������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nihonnooto/pages.py��������������������������������������������������������������0000664�0000000�0000000�00000004325�12657170273�0020161�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# * -*- coding: utf-8 -*- # Copyright(C) 2013 Thomas Lecavelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page from weboob.capabilities.radio import Radio from weboob.capabilities.audiostream import BaseAudioStream from weboob.tools.capabilities.streaminfo import StreamInfo class LivePage(Page): def iter_radios_list(self): radio = Radio('nihon') radio.title = u'Nihon no Oto' radio.description = u'Nihon no Oto: le son du Japon' radio.streams = [] index = -1 for el in self.document.xpath('//source'): index += 1 mime_type = unicode(el.attrib['type']) stream_url = unicode(el.attrib['src']) stream = BaseAudioStream(index) stream.bitrate = 128 if (mime_type == u'audio/mpeg'): stream.format = u'mp3' elif (mime_type == u'audio/ogg'): stream.format = u'vorbis' stream.title = radio.title + ' ' + mime_type stream.url = stream_url radio.streams.append(stream) yield radio class ProgramPage(Page): def get_current_emission(self): current = StreamInfo(0) two_or_more = unicode(self.document.xpath('//p')[0].text).split('/////')[0].split(' - ') # Consider that if String(' - ') appears it'll be in title rather in the artist name if len(two_or_more) > 2: current.who = two_or_more.pop(0) current.what = ' - '.join(two_or_more) else: current.who, current.what = two_or_more return current �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nihonnooto/test.py���������������������������������������������������������������0000664�0000000�0000000�00000001702�12657170273�0020035�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Thomas Lecavelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class NihonNoOtoTest(BackendTest): MODULE = 'nihonnooto' def test_nihonnooto(self): l = list(self.backend.iter_radios_search('')) self.assertTrue(len(l) > 0) ��������������������������������������������������������������weboob-1.1/modules/nolifetv/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016140�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nolifetv/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001433�12657170273�0020252�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NolifeTVModule __all__ = ['NolifeTVModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nolifetv/browser.py��������������������������������������������������������������0000664�0000000�0000000�00000007156�12657170273�0020206�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserIncorrectPassword import urllib from weboob.deprecated.browser.decorators import id2url from .video import NolifeTVVideo from .pages import VideoPage, VideoListPage, FamilyPage, AboPage, LoginPage, HomePage __all__ = ['NolifeTVBrowser'] class NolifeTVBrowser(Browser): USER_AGENT = Browser.USER_AGENTS['desktop_firefox'] DOMAIN = 'mobile.nolife-tv.com' PROTOCOL = 'http' PAGES = { r'http://mobile.nolife-tv.com/online/familles-\w+/': FamilyPage, r'http://mobile.nolife-tv.com/online/emission-(?P<id>\d+)/': VideoPage, 'http://mobile.nolife-tv.com/do.php': VideoListPage, 'http://mobile.nolife-tv.com/online/': VideoListPage, 'http://mobile.nolife-tv.com/abonnement/': AboPage, 'http://mobile.nolife-tv.com/login': LoginPage, 'http://mobile.nolife-tv.com/': HomePage, } AVAILABLE_VIDEOS = ['[Gratuit]'] def is_logged(self): return (self.username is None or (not self.is_on_page(HomePage)) or self.page.is_logged()) def login(self): if self.username is None: return if not self.is_on_page(LoginPage): self.location('/login', no_login=True) self.page.login(self.username, self.password) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() self.location('/abonnement/', no_login=True) assert self.is_on_page(AboPage) self.AVAILABLE_VIDEOS = self.page.get_available_videos() @id2url(NolifeTVVideo.id2url) def get_video(self, url, video=None): self.location(url) assert self.is_on_page(VideoPage) return self.page.get_video(video) def iter_family(self, type, sub): self.location('/online/familles-%s/' % type) assert self.is_on_page(FamilyPage) return self.page.iter_family(sub) def iter_category(self, type): self.location('/online/familles-%s/' % type) assert self.is_on_page(FamilyPage) return self.page.iter_category() def iter_video(self, family): data = { 'a': 'ge', 'famille': family, 'emissions': 0 } while True: self.location('/do.php', urllib.urlencode(data)) assert self.is_on_page(VideoListPage) if self.page.is_list_empty(): break for vid in self.page.iter_video(self.AVAILABLE_VIDEOS): yield vid data['emissions'] = data['emissions'] + 1 def get_latest(self): return self.iter_video(0) def search_videos(self, pattern): data = { 'search': pattern, 'submit': 'Rechercher' } self.location('/online/', urllib.urlencode(data)) assert self.is_on_page(VideoListPage) for vid in self.page.iter_video(self.AVAILABLE_VIDEOS): yield vid ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nolifetv/favicon.png�������������������������������������������������������������0000664�0000000�0000000�00000005145�12657170273�0020300�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������C��� pHYs�� �� ����tIME(yh���tEXtComment�Created with GIMPW�� IDATxYlSI!&KqHRBUH%6)mfQENUAtSVLȤ-"ai5Q-@5Yڊ`uB4ȏ q]fcvc;?bL}d{λ{y 2dȐ!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nJ�iɼN+FZ ~h`cE (F 6eȐ!C 2dȐ!C Qͦ(U����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nolifetv/module.py���������������������������������������������������������������0000664�0000000�0000000�00000012413�12657170273�0020000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound, Collection from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.backend import Module, BackendConfig from .browser import NolifeTVBrowser from .video import NolifeTVVideo import urllib import time from hashlib import md5 __all__ = ['NolifeTVModule'] class NolifeTVModule(Module, CapVideo, CapCollection): NAME = 'nolifetv' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'NolifeTV French video streaming website' LICENSE = 'AGPLv3+' BROWSER = NolifeTVBrowser CONFIG = BackendConfig(Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password', default=''), Value('quality', label='Quality', choices = { '1':'LQ', '2':'HQ', '3':'TV', '4':'720p', '5':'1080p' }, default = '5' )) def create_default_browser(self): username = self.config['username'].get() if username: password = self.config['password'].get() else: password = None return self.create_browser(username, password) def iter_resources(self, objs, split_path): with self.browser: if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield Collection([u'theme'], u'Par theme') yield Collection([u'type'], u'Par type') yield Collection([u'latest'], u'Latest NolifeTV videos') if collection.path_level == 1: if split_path[0] == 'latest': for vid in self.browser.get_latest(): yield vid else: for cat in self.browser.iter_category(split_path[0]): yield cat if collection.path_level == 2: for cat in self.browser.iter_family(split_path[0], split_path[1]): yield cat if collection.path_level == 3: for cat in self.browser.iter_video(split_path[2]): yield cat def validate_collection(self, objs, collection): if BaseVideo in objs: if collection.path_level == 0: return if collection.path_level == 1 and collection.split_path[0] in [u'theme', u'type', u'latest']: return if collection.path_level > 1: return raise CollectionNotFound(collection.split_path) def get_video(self, _id): with self.browser: return self.browser.get_video(_id) def fill_video(self, video, fields): with self.browser: self.browser.get_video(NolifeTVVideo.id2url(video.id), video) if 'thumbnail' in fields and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) if 'url' in fields: with self.browser: video.url = self.get_url(video.id, self.config['quality'].get()) return video def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): with self.browser: return self.browser.search_videos(pattern) OBJECTS = { NolifeTVVideo: fill_video } SALT = 'a53be1853770f0ebe0311d6993c7bcbe' def genkey(self): # This website is really useful to get info: http://www.showmycode.com/ timestamp = str(int(time.time())) skey = md5(md5(timestamp).hexdigest() + self.SALT).hexdigest() return skey, timestamp def get_url(self, id, quality): skey, timestamp = self.genkey() self.browser.readurl('http://online.nolife-tv.com/_nlfplayer/api/api_player.php', 'quality=%s&a=EML&skey=%s&id%%5Fnlshow=%s×tamp=%s' % (quality, skey, id, timestamp)) skey, timestamp = self.genkey() data = self.browser.readurl('http://online.nolife-tv.com/_nlfplayer/api/api_player.php', 'quality=%s&a=UEM%%7CSEM%%7CMEM%%7CCH%%7CSWQ&skey=%s&id%%5Fnlshow=%s×tamp=%s' % (quality, skey, id, timestamp)) values = dict([urllib.splitvalue(s) for s in data.split('&')]) if 'url' not in values: return None return unicode(values['url']) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nolifetv/pages.py����������������������������������������������������������������0000664�0000000�0000000�00000011460�12657170273�0017613�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.collection import Collection from weboob.capabilities.image import BaseImage from weboob.deprecated.browser import Page import re from datetime import datetime, timedelta from .video import NolifeTVVideo class VideoPage(Page): def get_video(self, video): if not video: video = NolifeTVVideo(self.group_dict['id']) els = self.document.getroot().xpath('//div[@data-role="content"]') if els and els[0] is not None: h3 = els[0].find('h3') if h3 is not None and h3.text: video.title = unicode(h3.text) h4 = els[0].find('h4') if h4 is not None and h4.text: video.title = video.title + u' - ' + h4.text thumb = els[0].find('p/img') if thumb is not None and thumb.get('src'): video.thumbnail = BaseImage(thumb.attrib['src']) video.thumbnail.url = video.thumbnail.id ps = els[0].findall('p') if len(ps) > 4: if ps[4].text: video.description = ps[4].text if ps[0].text and ps[0].text != u'∞': video.date = datetime.strptime(ps[0].text, '%d/%m/%Y').date() for text in ps[2].xpath('.//text()'): m = re.search(r'[^\d]*((\d+):)?(\d+)s?', text) if m: if m.group(2): minutes = int(m.group(2)) else: minutes = 0 video.duration = timedelta(minutes=minutes, seconds=int(m.group(3))) return video class VideoListPage(Page): def is_list_empty(self): return self.document.getroot() is None def iter_video(self, available_videos): for el in self.document.getroot().xpath('//li/a'): strongs = el.findall('p/strong') if len(strongs) > 3 and strongs[0].text not in ['Autopromo', 'Annonce'] and strongs[1].text in available_videos: m = re.search(r'emission-(\d+)', el.attrib['href']) if m and m.group(1): video = NolifeTVVideo(m.group(1)) h3 = el.find('h3') if h3 is not None and h3.text: video.title = unicode(h3.text) if strongs[3].text: video.title = video.title + ' - ' + strongs[3].text yield video class FamilyPage(Page): def iter_category(self): subs = list() for el in self.document.xpath('//ul/li[@data-role="list-divider"]'): if el.text not in subs: yield Collection([el.text], unicode(el.text)) subs.append(el.text) def iter_family(self, sub): for el in self.document.xpath('//ul/li[@data-role="list-divider"]'): if el.text != sub: continue while True: el = el.getnext() if el is None or el.get('data-role'): break h1 = el.find('.//h1') id = h1.getparent().attrib['href'] m = re.search(r'famille-(\d+)', id) if m and m.group(1): yield Collection([m.group(1)], unicode(h1.text)) class AboPage(Page): def get_available_videos(self): available = ['[Gratuit]'] for text in self.document.xpath('//div[@data-role="content"]/center/text()'): if 'Soutien' in text: available.append('[Archive]') available.append('[Standard]') if 'Standard' in text: available.append('[Standard]') return available class LoginPage(Page): def login(self, username, password): self.browser.select_form(name='login') self.browser['username'] = str(username) self.browser['password'] = str(password) self.browser.submit() class HomePage(Page): def is_logged(self): return len(self.document.xpath('//a[@href="deconnexion/"]')) == 1 ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nolifetv/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000002701�12657170273�0017471�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo class NolifeTVTest(BackendTest): MODULE = 'nolifetv' def test_search(self): l = list(self.backend.search_videos('nolife')) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) def test_latest(self): l = list(self.backend.iter_resources([BaseVideo], [u'latest'])) assert len(l) > 0 v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) ���������������������������������������������������������������weboob-1.1/modules/nolifetv/video.py����������������������������������������������������������������0000664�0000000�0000000�00000002026�12657170273�0017620�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo class NolifeTVVideo(BaseVideo): def __init__(self, *args, **kwargs): BaseVideo.__init__(self, *args, **kwargs) self.ext = u'mp4' @classmethod def id2url(cls, _id): return u'http://mobile.nolife-tv.com/online/emission-%s/' % _id ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nova/����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015255�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nova/__init__.py�����������������������������������������������������������������0000664�0000000�0000000�00000001423�12657170273�0017366�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NovaModule __all__ = ['NovaModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/nova/favicon.png�����������������������������������������������������������������0000664�0000000�0000000�00000000710�12657170273�0017406�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME/]���tEXtComment�Created with GIMPW��#IDATx1JA@ؤBZHeg!`6^iB+!N,N c6 fv0T;;ɼl6Y$I$I$I|X�/-02_)p9 8g)_o,8+x}Gp'؋  H@?jsɖӛ_P%V;|.9Q;`+nM� 6*C�'k w.;D OJZa(96^k~[�0 `��0 `�H9 ^����IENDB`��������������������������������������������������������weboob-1.1/modules/nova/module.py�������������������������������������������������������������������0000664�0000000�0000000�00000006731�12657170273�0017123�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from cStringIO import StringIO from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.audiostream import BaseAudioStream from weboob.tools.capabilities.streaminfo import StreamInfo from weboob.capabilities.collection import CapCollection from weboob.tools.backend import Module from weboob.deprecated.browser import StandardBrowser from weboob.deprecated.browser.parsers import get_parser __all__ = ['NovaModule'] class NovaModule(Module, CapRadio, CapCollection): NAME = 'nova' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'Nova French radio' LICENSE = 'AGPLv3+' BROWSER = StandardBrowser _RADIOS = {'nova': (u'Radio Nova', u'Radio nova', u'http://broadcast.infomaniak.net:80/radionova-high.mp3'), } def create_default_browser(self): return self.create_browser(parser='json') def iter_resources(self, objs, split_path): if Radio in objs: self._restrict_level(split_path) for id in self._RADIOS.iterkeys(): yield self.get_radio(id) def iter_radios_search(self, pattern): for radio in self.iter_resources((Radio, ), []): if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower(): yield radio def get_radio(self, radio): if not isinstance(radio, Radio): radio = Radio(radio) if radio.id not in self._RADIOS: return None title, description, url = self._RADIOS[radio.id] radio.title = title radio.description = description artist, title = self.get_current() current = StreamInfo(0) current.who = artist current.what = title radio.current = current stream = BaseAudioStream(0) stream.bitrate=128 stream.format=u'mp3' stream.title = u'128kbits/s' stream.url = url radio.streams = [stream] return radio def get_current(self): doc = self.browser.location('http://www.novaplanet.com/radionova/ontheair?origin=/') html = doc['track']['markup'] parser = get_parser()() doc = parser.parse(StringIO(html)) artist = u' '.join([txt.strip() for txt in doc.xpath('//div[@class="artist"]')[0].itertext()]) title = u' '.join([txt.strip() for txt in doc.xpath('//div[@class="title"]')[0].itertext()]) return unicode(artist).strip(), unicode(title).strip() def fill_radio(self, radio, fields): if 'current' in fields: if not radio.current: radio.current = StreamInfo(0) radio.current.who, radio.current.what = self.get_current() return radio OBJECTS = {Radio: fill_radio} ���������������������������������������weboob-1.1/modules/nova/test.py���������������������������������������������������������������������0000664�0000000�0000000�00000001737�12657170273�0016616�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.radio import Radio class NovaTest(BackendTest): MODULE = 'nova' def test_nova(self): l = list(self.backend.iter_resources((Radio, ), [])) self.assertTrue(len(l) > 0) ���������������������������������weboob-1.1/modules/okc/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015066�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/okc/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000001505�12657170273�0017200�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .browser import OkCBrowser from .module import OkCModule __all__ = ['OkCBrowser', 'OkCModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/okc/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000007305�12657170273�0017130�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012-2016 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import LoginBrowser, URL from weboob.exceptions import BrowserIncorrectPassword from weboob.tools.json import json __all__ = ['OkCBrowser'] def need_login(func): def inner(browser, *args, **kwargs): if not browser.access_token: browser.do_login() return func(browser, *args, **kwargs) return inner class OkCBrowser(LoginBrowser): BASEURL = 'https://www.okcupid.com' login = URL('/login') threads = URL('/messages') messages = URL('/apitun/messages/conversations/global_messaging') thread_delete = URL(r'/1/apitun/messages/conversations/(?P<thread_id>\d+)/delete') message_send = URL('/apitun/messages/send') quickmatch = URL(r'/quickmatch\?okc_api=1') like = URL(r'/1/apitun/profile/(?P<user_id>\d+)/like') profile = URL(r'/apitun/profile/(?P<user_id>\d+)') full_profile = URL(r'/profile/(?P<username>.*)\?okc_api=1') access_token = None me = None def do_login(self): r = self.login.go(data={'username': self.username, 'password': self.password, 'okc_api': 1}).json() if not 'oauth_accesstoken' in r: raise BrowserIncorrectPassword(r['status_str']) self.access_token = r['oauth_accesstoken'] self.me = {'userid': r['userid'], 'username': r['screenname'], } self.session.headers['X-OkCupid-Platform'] = 'DESKTOP' self.session.headers['X-Requested-With'] = 'XMLHttpRequest' self.session.headers['Authorization'] = 'Bearer %s' % self.access_token @need_login def get_threads_list(self, folder=1): return self.threads.go(params={'okc_api': 1, 'folder': folder, 'messages_dropdown_ajax': 1}).json() @need_login def get_thread_messages(self, thread_id): r = self.messages.go(params={'access_token': self.access_token, '_json': '{"userids":["%s"]}' % thread_id}).json() return r[thread_id] @need_login def post_message(self, thread_id, content): data = {'body': content, 'profile_tab': '', 'receiverid': thread_id, 'service': 'mailbox', 'source': 'desktop_global'} self.message_send.go(params={'access_token': self.access_token}, data=json.dumps(data)) @need_login def delete_thread(self, thread_id): self.thread_delete.go(method='POST', thread_id=thread_id) @need_login def find_match_profile(self): r = self.quickmatch.go().json() return r['tracking_userid'] @need_login def do_rate(self, user_id): self.like.go(method='POST', user_id=user_id) @need_login def get_username(self, user_id): return self.profile.go(user_id=user_id).json()['username'] @need_login def get_profile(self, username): if username.isdigit(): username = self.get_username(username) return self.full_profile.go(username=username).json() ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/okc/favicon.png������������������������������������������������������������������0000664�0000000�0000000�00000005032�12657170273�0017221�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� B(x���tIMEk���tEXtComment�Created with GIMPW�� uIDATxIoqHdQŶ+41D �9h X[uΗ(K@k1 ;%;^Id-4IqiZDrI ݞ>;g;vixxm|M�"w 0#oC�|?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B`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/okc/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000022516�12657170273�0016733�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012-2016 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import datetime from html2text import unescape from weboob.capabilities.contact import CapContact, ContactPhoto, Contact, ProfileNode from weboob.capabilities.dating import CapDating from weboob.capabilities.messages import CapMessages, CapMessagesPost, Message, Thread from weboob.tools.backend import Module, BackendConfig from weboob.tools.misc import to_unicode from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import Value, ValueBackendPassword from .browser import OkCBrowser from .optim.profiles_walker import ProfilesWalker __all__ = ['OkCModule'] class OkcContact(Contact): def set_profile(self, *args): section = self.profile for arg in args[:-2]: try: s = section[arg] except KeyError: s = section[arg] = ProfileNode(arg, arg.capitalize().replace('_', ' '), OrderedDict(), flags=ProfileNode.SECTION) section = s.value key = args[-2] value = args[-1] section[key] = ProfileNode(key, key.capitalize().replace('_', ' '), value) def __init__(self, profile): super(OkcContact, self).__init__(profile['userid'], profile['username'], self.STATUS_ONLINE if profile['is_online'] == '1' else self.STATUS_OFFLINE) self.url = 'https://www.okcupid.com/profile/%s' % self.name self.summary = profile.get('summary', '') self.status_msg = 'Last connection at %s' % profile['skinny']['last_online'] for no, photo in enumerate(profile['photos']): self.set_photo(u'image_%i' % no, url=photo['image_url'], thumbnail_url=photo['image_url']) self.profile = OrderedDict() self.set_profile('info', 'status', profile['status_str']) self.set_profile('info', 'orientation', profile['orientation_str']) self.set_profile('info', 'age', '%s yo' % profile['age']) self.set_profile('info', 'birthday', '%04d-%02d-%02d' % (profile['birthday']['year'], profile['birthday']['month'], profile['birthday']['day'])) self.set_profile('info', 'sex', profile['gender_str']) self.set_profile('info', 'location', profile['location']) self.set_profile('info', 'join_date', profile['skinny']['join_date']) self.set_profile('stats', 'match_percent', '%s%%' % profile['matchpercentage']) self.set_profile('stats', 'friend_percent', '%s%%' % profile['friendpercentage']) self.set_profile('stats', 'enemy_percent', '%s%%' % profile['enemypercentage']) for key, value in sorted(profile['skinny'].items()): self.set_profile('details', key, value or '-') for essay in profile['essays']: if len(essay['essay']) == 0: continue self.summary += '%s:\n' % essay['title'] self.summary += '-' * (len(essay['title']) + 1) self.summary += '\n' for text in essay['essay']: self.summary += text['rawtext'] self.summary += '\n\n' self.profile['info'].flags |= ProfileNode.HEAD self.profile['stats'].flags |= ProfileNode.HEAD class OkCModule(Module, CapMessages, CapContact, CapMessagesPost, CapDating): NAME = 'okc' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'OkCupid' CONFIG = BackendConfig(Value('username', label='Username'), ValueBackendPassword('password', label='Password')) STORAGE = {'profiles_walker': {'viewed': []}, 'sluts': {}, } BROWSER = OkCBrowser def create_default_browser(self): return self.create_browser(self.config['username'].get(), self.config['password'].get()) # ---- CapDating methods --------------------- def init_optimizations(self): self.add_optimization('PROFILE_WALKER', ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)) # ---- CapMessages methods --------------------- def fill_thread(self, thread, fields): return self.get_thread(thread) def iter_threads(self): threads = self.browser.get_threads_list() for thread in threads: t = Thread(thread['userid']) t.flags = Thread.IS_DISCUSSION t.title = u'Discussion with %s' % thread['user']['username'] t.date = datetime.fromtimestamp(thread['timestamp']) yield t def get_thread(self, thread): if not isinstance(thread, Thread): thread = Thread(thread) thread.flags = Thread.IS_DISCUSSION messages = self.browser.get_thread_messages(thread.id) contact = self.storage.get('sluts', thread.id, default={'lastmsg': datetime(1970,1,1)}) thread.title = u'Discussion with %s' % messages['fields']['username'] me = OkcContact(self.browser.get_profile(self.browser.me['userid'])) other = OkcContact(self.browser.get_profile(thread.id)) parent = None for message in messages['messages']['messages']: date = datetime.fromtimestamp(message['timestamp']) flags = 0 if contact['lastmsg'] < date: flags = Message.IS_UNREAD if message['from'] == thread.id: sender = other receiver = me else: receiver = other sender = me msg = Message(thread=thread, id=message['id'], title=thread.title, sender=sender.name, receivers=[receiver.name], date=date, content=to_unicode(unescape(message['body'])), children=[], parent=parent, signature=sender.get_text(), flags=flags) if parent: parent.children = [msg] else: thread.root = msg parent = msg return thread def iter_unread_messages(self): for thread in self.iter_threads(): contact = self.storage.get('sluts', thread.id, default={'lastmsg': datetime(1970,1,1)}) if thread.date <= contact['lastmsg']: continue thread = self.get_thread(thread) for message in thread.iter_all_messages(): if message.flags & message.IS_UNREAD: yield message def set_message_read(self, message): contact = self.storage.get('sluts', message.thread.id, default={'lastmsg': datetime(1970,1,1)}) if contact['lastmsg'] < message.date: contact['lastmsg'] = message.date self.storage.set('sluts', message.thread.id, contact) self.storage.save() # ---- CapMessagesPost methods --------------------- def post_message(self, message): self.browser.post_message(message.thread.id, message.content) # ---- CapContact methods --------------------- def fill_contact(self, contact, fields): if 'profile' in fields: contact = self.get_contact(contact) if contact and 'photos' in fields: for name, photo in contact.photos.iteritems(): if photo.url and not photo.data: data = self.browser.open(photo.url).content contact.set_photo(name, data=data) if photo.thumbnail_url and not photo.thumbnail_data: data = self.browser.open(photo.thumbnail_url).content contact.set_photo(name, thumbnail_data=data) def fill_photo(self, photo, fields): if 'data' in fields and photo.url and not photo.data: photo.data = self.browser.open(photo.url).content if 'thumbnail_data' in fields and photo.thumbnail_url and not photo.thumbnail_data: photo.thumbnail_data = self.browser.open(photo.thumbnail_url).content return photo def get_contact(self, user_id): if isinstance(user_id, Contact): user_id = user_id.id info = self.browser.get_profile(user_id) return OkcContact(info) def iter_contacts(self, status=Contact.STATUS_ALL, ids=None): threads = self.browser.get_threads_list() for thread in threads: c = self.get_contact(thread['user']['username']) if c and (c.status & status) and (not ids or c.id in ids): yield c OBJECTS = {Thread: fill_thread, Contact: fill_contact, ContactPhoto: fill_photo } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/okc/optim/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016216�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/okc/optim/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0020315�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/okc/optim/profiles_walker.py�����������������������������������������������������0000664�0000000�0000000�00000006341�12657170273�0021764�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2016 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from random import randint from weboob.capabilities.dating import Optimization from weboob.tools.log import getLogger from weboob.tools.value import Value, ValuesDict class ProfilesWalker(Optimization): CONFIG = ValuesDict(Value('first_message', label='First message to send to matched profiles', default='')) def __init__(self, sched, storage, browser): super(ProfilesWalker, self).__init__() self._sched = sched self._storage = storage self._browser = browser self._logger = getLogger('walker', browser.logger) self._config = storage.get('profile_walker', 'config', default=None) if self._config == {}: self._config = None self._view_cron = None self._visited_profiles = set(storage.get('profiles_walker', 'viewed')) self._logger.info(u'Loaded %d already visited profiles from storage.', len(self._visited_profiles)) def save(self): if self._config is None: return False self._storage.set('profiles_walker', 'viewed', list(self._visited_profiles)) self._storage.save() def start(self): self._view_cron = self._sched.schedule(randint(5, 10), self.view_profile) return True def stop(self): self._sched.cancel(self._view_cron) self._view_cron = None return True def is_running(self): return self._view_cron is not None def set_config(self, params): self._config = params self._storage.set('profile_walker', 'config', self._config) self._storage.save() def get_config(self): return self._config def view_profile(self): try: # Find a new profile user_id = self._browser.find_match_profile() if user_id in self._visited_profiles: return self._browser.do_rate(user_id) profile = self._browser.get_profile(user_id) if self._config['first_message'] != '': self._browser.post_message(user_id, self._config['first_message'] % {'name': profile['username']}) self._browser.delete_thread(user_id) self._logger.info(u'Visited profile of %s ', profile['username']) # do not forget that we visited this profile, to avoid re-visiting it. self._visited_profiles.add(user_id) self.save() finally: if self._view_cron is not None: self._view_cron = self._sched.schedule(randint(60, 120), self.view_profile) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/oney/����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015264�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/oney/__init__.py�����������������������������������������������������������������0000664�0000000�0000000�00000001424�12657170273�0017376�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Budget Insight # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import OneyModule __all__ = ['OneyModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/oney/browser.py������������������������������������������������������������������0000664�0000000�0000000�00000004423�12657170273�0017324�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Budget Insight # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.exceptions import BrowserIncorrectPassword from weboob.browser import LoginBrowser, URL, need_login from .pages import LoginPage, IndexPage, OperationsPage __all__ = ['OneyBrowser'] class OneyBrowser(LoginBrowser): BASEURL = 'https://www.oney.fr' VERIFY = False index = URL(r'/oney/client', IndexPage) login = URL(r'/oney/client', LoginPage) operations = URL(r'/oney/client', OperationsPage) card_page = URL(r'/oney/client\?task=Synthese&process=SyntheseMultiCompte&indexSelectionne=(?P<acc_num>/d)') def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.login.go() self.page.login(self.username, self.password) if not self.index.is_here(): raise BrowserIncorrectPassword() @need_login def get_accounts_list(self): return self.index.stay_or_go().iter_accounts() @need_login def iter_history(self, account): if account._num: self.card_page.go(acc_num=account._num) post = {'task': 'Synthese', 'process': 'SyntheseCompte', 'taskid': 'Releve'} self.operations.go(data=post) return self.page.iter_transactions(seen=set()) @need_login def iter_coming(self, account): if account._num: self.card_page.go(acc_num=account._num) post = {'task': 'OperationRecente', 'process': 'OperationRecente', 'taskid': 'OperationRecente'} self.operations.go(data=post) return self.page.iter_transactions(seen=set()) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/oney/favicon.png�����������������������������������������������������������������0000664�0000000�0000000�00000005377�12657170273�0017433�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD��N�cQ��� pHYs�� �� ����tIME  %[}���tEXtComment�Created with GIMPW�� gIDATx[klf絳k.8!*PDe*$i+5i" E+G(Qd`(HچWU( jR+1k{mcfgfyɮ]xSZ;9{MiF]B8�K�4`Z�!�B6@@@'�N8FQ^rBՄC3VB�8A#uBHT><{2go%7ZoOo'&=,!Nd۶=n"�n{!K($N)ϏxDXE+X T1`w]m0 IdY~qΰ'Sh$ض M I% )] OEQt3BcTz( 4Meم'OlSKS7',R)(QD.^B xg!Ey|>x t{0`,>rb\;ƿq? 5D@zR~.K'C|ۃ(`h^)(U�Myy~e!(4x�. à|E^ &3h9m~Fqaَ;{mSjG{|j=XMӠiNc<̃/tJBTpb^p1;톅C �7#`�X?w⿲./VL5C̵p֣)t?>|t_~<7kxGAX`w&޺wf;;17oyp6�i�:7^k{Gx7{�@-7 3/_�5�`{Ww@ԣT oGy /ͮ | 4[Er6"$ j˖O_ .�މ~2 �2,beg#�{ê-ItURNhwgO܌'fnvpp{o$Ճ2vnHpAmrY[j�(]_> Ւ��K? s@�bz{b0uY7EE`<_%WVpUtԕ]cMe(c+I])Mr ?)�� 1P>�~jJPdM<#ds3b|=R,18V݆R"dzf| ��472LƞMYy=QknoŬɋٕlUİ~ُhZ5;ЗяOăͺi"*�i( s0|R\rp9ݗ_ȺbFg4�K懃�TqXU;>F>IDiB �!Vnx?S<q5a<TlA ߶B=X U\-V?SjF04XTX^+Lt jV?k L|C!l!D%R44( (0.^SO=(:K};϶mCuiZg8[2T6۶a6,˂iPU,G)|0`&LӄH$p mGa J9+I@IG !`6LӄPUB#۶mG[:`v<P *p ÀiV$֮iiZƾ}gsDeHdE"Q (*aYN/IJa@QX9{*W$AE |F7PVV!IT*MӠKD)H_4W(bpppo[[[G��˲u],0Me);,B'IX,+WlιfBMMͅT*Qe(0ܪ*s $8O$7KrV=ܹs'8[ qhv27 nT}̅(Dwwk֬YwxXլi%˲"S 7B #; /H`hhuwTϟߡX x@prd~$X,tww?u֎ўSn?B!yw>3,wH85xwG"tuu=ҲˣG %8wو^$8wfvN‹H$7P3CL0 2Ddz]%.b[~b=߿?A8<xƉyYH$܄M,˘]o7,=,t 8Rwæ:SNc``_~c,8vj^_UU嬨eYnE�n8NmH$7nذBԫ:?  z8 12.c"goOO;w^o'4Moٲ14WVV>hA ^oOUe8dw<YڊI7o۶c|]k}>ʪ`p40zz`NsK'ޓ$TU䑡H}Ϟ=u/9y x<�B!]IiFM )X,v*۷o_Mici:p}����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/oney/module.py�������������������������������������������������������������������0000664�0000000�0000000�00000004127�12657170273�0017127�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Budget Insight # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import OneyBrowser __all__ = ['OneyModule'] class OneyModule(Module, CapBank): NAME = 'oney' MAINTAINER = u'Vincet Paredes' EMAIL = 'vparedes@budget-insight.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'Oney' CONFIG = BackendConfig(ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Mot de passe')) BROWSER = OneyBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): for account in self.browser.get_accounts_list(): yield account def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_history(self, account): # To prevent issues in calcul of actual balance and coming one, all # operations are marked as debited. for tr in self.browser.iter_coming(account): yield tr for tr in self.browser.iter_history(account): yield tr �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/oney/pages.py��������������������������������������������������������������������0000664�0000000�0000000�00000022713�12657170273�0016742�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Budget Insight # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from cStringIO import StringIO import requests from weboob.capabilities.bank import Account from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.captcha.virtkeyboard import MappedVirtKeyboard, VirtKeyboardError from weboob.browser.pages import HTMLPage, LoggedPage, pagination from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import Env, CleanDecimal, CleanText, Field, Format from weboob.browser.filters.html import Attr from weboob.exceptions import ParseError class Transaction(FrenchTransaction): PATTERNS = [(re.compile(ur'^(?P<text>Retrait .*?) - traité le \d+/\d+$'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(ur'^(?P<text>Prélèvement .*?) - traité le \d+/\d+$'), FrenchTransaction.TYPE_ORDER), (re.compile(ur'^(?P<text>.*?) - traité le \d+/\d+$'), FrenchTransaction.TYPE_CARD)] class VirtKeyboard(MappedVirtKeyboard): # XXX it will be necessary to do something to fix that shit. symbols={'0':('069f9dd5e75d8419476b18f1551e59ce','4d3d5662b2a85ab7f0dc33b234eeaa12','9dbc8f4af61329c68cb53f62570ab213', 'c375d0349a6b097ac2708cc12736651a','15997d39cbdceecf8fc3050f86811ded','65cf69050c47fd044dc6866b0771665a', '53998518eef3c5be42290bca46288094', 'f152068e6057f5ef07ead676e8e1006f',), '1':('ddc9036ea2ae1bdfbb15616a0e3a0d90',), '2':('27638b6ebedf6a23149990495ef4c1c5','f602ee70136eb2331275a8ac8cd636de','ff1f44c05a5eab4569bef7bde84e5b66', '3b0795e3fc0af85c4838279847cb87f7','ac27be9df781cc8756f999d61f7a46f3', 'c5d2d4e03ca49cd698ffe971a286aa7c',), '3':('45101362592c07bc94f8449a1f4479f1','b24990f89de3454038b7c7940bc1053f','bf0d6bd4f13ea9b57a72f76c6dad0b41', '743762655b13c97908b17ce7b36a1f5a','53f9b643c228e99723c384fe12390a0e','f206adf0be6f3c6613452c19a7b0babe', 'f206adf0be6f3c6613452c19a7b0babe','f80d52e8776e0825954cc3477e3c4d95','4ed9ae4d6ed821da16156ed9c31c6609', '9b9a760b46320848ca48593f43dc22d7','e0896e80bea559f8d1ec02ba38489715','4452c4b1a1247462fbefdcb53903c401', '658158105933251a7960358b298ed79c','c2f37f9291e643f8ca3437da7dd29c94','802ab1c4b6514b894cc1057f658d26b6',), '4':('9d5d871b405465218cc892dc015ea6d8','fed023bedd046b9f4d169c6ab12f6d4c','5069a391893fb107fbc39923a9d108ef',), '5':('5ef102b78f5dc642ee98e9bdcf42a02e','496418730424d7f40d2b137d56bcbfe8','139186da206acf5344362ed86da42a7f', 'e080cd4fbda1493034f1444eae484887','fa7679409453ed56b8e1d13f5c0987bc'), '6':('ab1fff097099fb395fe73470f7afcae0','70c64ac427435d40d2713128e8735b4d','bbb6fc3d0f23fa5104e2ea602ecc2d18', '5d8c50960dd1f50457697fd8a8d5622e','96106ac2caa33e2a9025efcb21277a3c','780831d18940564f96e3ed6636038911'), '7':('30f11190e1772dd0f93740190aaa7608','ef5477640cf97de373e49e13caef8f5c','05dfb006e2668d7dfd210b2fdf74fef8', '8efb472abef04ac9bcd1ba02b49ed6a5','30f11190e1772dd0f93740190aaa7608'), '8':('8a8258f63f816888b550d704f4c6a068','69cade726c4d6c8e6a72e96df059c8c7','675972437c7733747146a0851bbb5727', '01ce8b70eb0761b7f4047c365faa9cf5','08e6113ad8ac2f74d104c156047819a8','c2278d5c10b9903aff14f1a6516a583b', 'bbba856f115bf8a45ef944a5e41ee436','f365fa7628ef15f172d40f07e54c327a','ed9b97a0cf393832ea75263d9bdd8004', 'ee281ac9d1c20a510fcaf4dc37d5450a'), '9':('bf8e09357cd69275cbc6fdef42610ea0','212af59d8bc81dff176e02c0f001aa81','a3bc28250187c34a46757f2ab01e436b', '9c0ab75a491e6a64dca57543efe5012c','62bedc16830a5602e26d9a050b13d2df','2b79fff64f55c027d23895baa5d2c66b', '9d5d871b405465218cc892dc015ea6d8',), } color=(0,0,0) def __init__(self, page): img = page.doc.find("//img[@usemap='#cv']") res = page.browser.open(img.attrib['src']) MappedVirtKeyboard.__init__(self, StringIO(res.content), page.doc, img, self.color, 'href', convert='RGB') self.check_symbols(self.symbols, page.browser.responses_dirname) def check_color(self, pixel): for p in pixel: if p >= 200: return False return True def get_symbol_code(self, md5sum_list): for md5sum in md5sum_list: try: code = MappedVirtKeyboard.get_symbol_code(self,md5sum) except VirtKeyboardError: continue else: return ''.join(re.findall(r"'(\d+)'", code)[-2:]) raise VirtKeyboardError('Symbol not found') def get_string_code(self, string): code = '' for c in string: code += self.get_symbol_code(self.symbols[c]) return code class LoginPage(HTMLPage): is_here ="//form[@id='formulaire-login']" def login(self, login, password): vk = VirtKeyboard(self) form = self.get_form('//form[@id="formulaire-login"]') code = vk.get_string_code(password) assert len(code)==10, ParseError("Wrong number of character.") form['identifiant'] = login form['codePinpad'] = code form['task'] = 'Login' form['process'] = 'Login' form['eventid'] = 'suivant' form['modeCodeSecret'] = 'pinpad' form['personneIdentifiee'] = 'N' form.submit() class IndexPage(LoggedPage, HTMLPage): is_here = "//div[@id='situation']" @method class iter_accounts(ListElement): item_xpath = '//div[@id="situation"]//div[@class="synthese-produit"]' class item(ItemElement): klass = Account obj_currency = u'EUR' obj_type = Account.TYPE_CARD obj_label = Env('label') obj__num = Env('_num') obj_id = Env('id') obj_balance = Env('balance') def parse(self, el): self.env['label'] = CleanText('./h3/a')(self) or u'Carte Oney' self.env['_num'] = Attr('%s%s%s' % ('//option[contains(text(), "', Field('label')(self).replace('Ma ', ''), '")]'), 'value', default=u'')(self) self.env['id'] = Format('%s%s' % (self.page.browser.username, Field('_num')(self)))(self) # On the multiple accounts page, decimals are separated with dots, and separated with commas on single account page. amount_due = CleanDecimal('./p[@class = "somme-due"]/span[@class = "synthese-montant"]', default=None)(self) if amount_due is None: amount_due = CleanDecimal('./div[@id = "total-sommes-dues"]/p[contains(text(), "sommes dues")]/span[@class = "montant"]', replace_dots=True)(self) self.env['balance'] = - amount_due class OperationsPage(LoggedPage, HTMLPage): is_here = "//div[@id='releve-reserve-credit'] | //div[@id='operations-recentes'] | //select[@id='periode']" @pagination @method class iter_transactions(ListElement): item_xpath = '//table[@class="tableau-releve"]/tbody/tr[not(node()//span[@class="solde-initial"])]' flush_at_end = True def flush(self): # As transactions are unordered on the page, we flush only at end # the sorted list of them. return sorted(self.objects.itervalues(), key=lambda tr: tr.rdate, reverse=True) def store(self, obj): # It stores only objects with an ID. To be sure it works, use the # uid of transaction as object ID. obj.id = obj.unique_id(seen=self.env['seen']) return ListElement.store(self, obj) class credit(ItemElement): klass = Transaction obj_type = Transaction.TYPE_CARD obj_date = Transaction.Date('./td[1]') obj_raw = Transaction.Raw('./td[2]') obj_amount = Env('amount') def condition(self): self.env['amount'] = Transaction.Amount('./td[3]')(self.el) return self.env['amount'] > 0 class debit(ItemElement): klass = Transaction obj_type = Transaction.TYPE_CARD obj_date = Transaction.Date('./td[1]') obj_raw = Transaction.Raw('./td[2]') obj_amount = Env('amount') def condition(self): self.env['amount'] = Transaction.Amount('', './td[4]')(self.el) return self.env['amount'] < 0 def next_page(self): options = self.page.doc.xpath('//select[@id="periode"]//option[@selected="selected"]/preceding-sibling::option[1]') if options: data = {'numReleve':options[0].values(),'task':'Releve','process':'Releve','eventid':'select','taskid':'','hrefid':'','hrefext':''} return requests.Request("POST", self.page.url, data=data) �����������������������������������������������������weboob-1.1/modules/opacwebaloes/��������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016756�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opacwebaloes/__init__.py���������������������������������������������������������0000664�0000000�0000000�00000001433�12657170273�0021070�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import AloesModule __all__ = ['AloesModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opacwebaloes/browser.py����������������������������������������������������������0000664�0000000�0000000�00000005311�12657170273�0021013�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages import LoginPage, HomePage, RentedPage, HistoryPage, BookedPage __all__ = ['AloesBrowser'] # Browser class AloesBrowser(Browser): PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['desktop_firefox'] #DEBUG_HTTP = True DEBUG_HTTP = False PAGES = { 'http://.*/index.aspx': LoginPage, 'http://.*/index.aspx\?IdPage=1': HomePage, 'http://.*/index.aspx\?IdPage=45': RentedPage, 'http://.*/index.aspx\?IdPage=429': HistoryPage, 'http://.*/index.aspx\?IdPage=44': BookedPage } def __init__(self, baseurl, *args, **kwargs): self.BASEURL = baseurl Browser.__init__(self, *args, **kwargs) def is_logged(self): return self.page \ and not self.page.document.getroot().xpath('//input[contains(@id, "ctl00_ContentPlaceHolder1_ctl00_ctl08_ctl00_TextSaisie")]') #return True def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(HomePage): self.location('%s://%s/index.aspx' % (self.PROTOCOL, self.BASEURL), no_login=True) if not self.page.login(self.username, self.password) or \ not self.is_logged() or \ (self.is_on_page(LoginPage) and self.page.is_error()): raise BrowserIncorrectPassword() def get_rented_books_list(self): if not self.is_on_page(RentedPage): self.location('%s://%s/index.aspx?IdPage=45' % (self.PROTOCOL, self.BASEURL) ) return self.page.get_list() def get_booked_books_list(self): if not self.is_on_page(BookedPage): self.location('%s://%s/index.aspx?IdPage=44' % (self.PROTOCOL, self.BASEURL)) return self.page.get_list() �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opacwebaloes/favicon.png���������������������������������������������������������0000664�0000000�0000000�00000004763�12657170273�0021123�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME 9") ���DtEXtComment�CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality Gul�� #IDATx[[lxu06vTQqZJ QLb"U.yI ^Z+JQ)Aj4Q8Ę $-{awg߇왙3]̜ws`1O!�`'-Ͻ*[mCRju=omz 2{!X(/{?鶍%*z쇢:)p<^U,D:{Kz+n :ojj‘#0%09"[\5b:[õ)\Nv@Uh1fPҲ""w8ۇ?8+1=<9i`񙍓3v N:?.ǬYNǁ 0gFp{q? \YD\XG aIELZї~X1"=&71sysѲfp466btt admfdJ!$e)κ\+ھ WG CZ8'q5s׏ s=Z$uvu&rܹw10/ݳر}' `W;@tBCC ޯLHа4XFk' BcQwɂ qK3B.É'd0u/;[I$蘜|&sHC~jCO>�d2_ XCb,3Q cْ%/,co 8TX ;~Ifbm (}J'J Io.$mܰ)$I9 l问9l߾*K'}$+W fJJvd 1%nD21v΁X+V&Iշ'ޮ+O""@QG|ٽhim19y^0FˋK9`dJR~(œ?.{Ty&w*Sx#b;Zۻ1D nJ֥U[nuMMt7444`h @DqJR Xaqw^Ư(nPC-C+$ݢCt; A%XU\~ x@ď!46:Ή04۷>S/a/t}T-4ꬎ (gVO/E:曧eC5U`SLߌgg/}t,{I"¿mDD5 2Nyc^3B@g\XNV<!ߣNrZ[۰B?m[tnݲ9AlVl^lٝ"i2F{c DGGGW}/<tyTe<lPSUI?}v=^-f܉͘C譎0 ?\XyӕߠXJJ%E &k)WjS|J:mVՠNbH؉u@46&ce;O.%?رj22E(f=sj\@*qZ]!tC4dٚ)FQʞvkK0e2xP"(掀qA }uj nꍔXq0 ,YQ,}X(/um!,sÅΡѾ68rUoꌜs "BG Z۰o}3Pv{u yp]rlS:uYZZµk<f"™`-b-:??o#^[[k$G@ Ah �*ڃXmܻW@> k3{Nd!A:uo:-U &7Ut]`ݶ;X] S`i�`cMի#iSU$%.,,` ֮[t]wi~~実YFM 59"y{?Rd5dvX{} ##/Tت)s$~<\~=V[jP 0{ /bx9+FA_  똞jȪ cϖǶ8nyEŃ00q;{{_N�N�ȝEYٗ0pH8.|LӴ bvAF|r_бbG+_9KU#)`#Ձbq(ArP_c|42\֦!L����IENDB`�������������weboob-1.1/modules/opacwebaloes/module.py�����������������������������������������������������������0000664�0000000�0000000�00000004252�12657170273�0020620�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.library import CapBook from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import AloesBrowser __all__ = ['AloesModule'] class AloesModule(Module, CapBook): NAME = 'opacwebaloes' MAINTAINER = u'Jeremy Monnet' EMAIL = 'jmonnet@gmail.com' VERSION = '1.1' DESCRIPTION = 'Aloes Library software' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('login', label='Account ID', regexp='^\d{1,8}\w$'), ValueBackendPassword('password', label='Password of account'), Value('baseurl', label='Base URL') ) BROWSER = AloesBrowser def create_default_browser(self): return self.create_browser(self.config['baseurl'].get(), self.config['login'].get(), self.config['password'].get()) def get_rented(self): for book in self.browser.get_rented_books_list(): yield book def get_booked(self): for book in self.browser.get_booked_books_list(): yield book def iter_books(self): for book in self.get_booked(): yield book for book in self.get_rented(): yield book def get_book(self, _id): raise NotImplementedError() def search_books(self, _string): raise NotImplementedError() ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opacwebaloes/pages.py������������������������������������������������������������0000664�0000000�0000000�00000012517�12657170273�0020435�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import date from weboob.capabilities.library import Book from weboob.deprecated.browser import Page, BrowserUnavailable from weboob.deprecated.mech import ClientForm class SkipPage(Page): pass class HomePage(Page): pass def txt2date(s): return date(*reversed([int(x) for x in s.split(' ')[-1].split('/')])) class RentedPage(Page): # TODO, table limited to 20 items, need to use pagination def get_list(self): for book in self.iter_books('//tr[contains(@id, "ctl00_ContentPlaceHolder1_ctl00_ctl07_COMPTE_PRET_1_1_GrillePrets_ctl00__")]', 1): book.late = False yield book for book in self.iter_books('//tr[contains(@id, "ctl00_ContentPlaceHolder1_ctl00_ctl08_COMPTE_RETARD_0_1_GrilleRetards_ctl00__")]', 0): book.late = True yield book def iter_books(self, el, start): for tr in self.document.getroot().xpath(el): book = Book(tr[start].text) book.name = tr[start+3].text book.author = tr[start+4].text book.date = txt2date(tr[start+5].text) yield book class HistoryPage(Page): pass class BookedPage(Page): # TODO, table limited to 20 items, need to use pagination def get_list(self): for tr in self.document.getroot().xpath('//tr[contains(@id, "ctl00_ContentPlaceHolder1_ctl00_ctl09_COMPTE_INFOS_0_GrilleInfos_ctl00__0")]'): username=tr[1].text+"_"+tr[0].text for i, tr in enumerate(self.document.getroot().xpath('//tr[contains(@id, "ctl00_ContentPlaceHolder1_ctl00_ctl10_COMPTE_RESA_1_1_GrilleResas_ctl00__")]')): book = Book('%s%d' % (username, i)) # if all the books booked are available, there are only 7 columns. # if (at least ?) one book is still not available, yous can cancel, and the first column does contain the checkbox. So 8 columns. if (len(tr) == 7): start = 2 if (len(tr) == 8): start = 3 book.name = tr[start].text book.author = tr[start+1].text book.date = txt2date(tr[start+3].text) book.late = False yield book class LoginPage(Page): def login(self, login, passwd): self.browser.select_form(predicate=lambda x: x.attrs.get('id','')=='aspnetForm') self.browser.form.set_all_readonly(False) self.browser['ctl00$ContentPlaceHolder1$ctl00$ctl04$ctl00$TextSaisie'] = login self.browser['ctl00$ContentPlaceHolder1$ctl00$ctl04$ctl00$TextPass'] = passwd self.browser['ctl00_ScriptManager1_TSM']="%3B%3BSystem.Web.Extensions%2C%20Version%3D1.0.61025.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D31bf3856ad364e35%3Afr-FR%3A1f0f78f9-0731-4ae9-b308-56936732ccb8%3Aea597d4b%3Ab25378d2%3BTelerik.Web.UI%2C%20Version%3D2009.3.1314.20%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D121fae78165ba3d4%3Afr-FR%3Aec1048f9-7413-49ac-913a-b3b534cde186%3A16e4e7cd%3Aed16cbdc%3Af7645509%3A24ee1bba%3A19620875%3A874f8ea2%3A33108d14%3Abd8f85e4" self.browser.controls.append(ClientForm.TextControl('text', 'RadAJAXControlID', {'value': ''})) self.browser['RadAJAXControlID']="ctl00_ContentPlaceHolder1_ctl00_ctl04_ctl00_RadAjaxPanelConnexion" self.browser.controls.append(ClientForm.TextControl('text', 'ctl00$ScriptManager1', {'value': ''})) self.browser['ctl00$ScriptManager1']="ctl00$ContentPlaceHolder1$ctl00$ctl04$ctl00$ctl00$ContentPlaceHolder1$ctl00$ctl04$ctl00$RadAjaxPanelConnexionPanel|" self.browser.controls.append(ClientForm.TextControl('text', '__EVENTTARGET', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', '__EVENTARGUMENT', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', 'ctl00$ContentPlaceHolder1$ctl00$ctl04$ctl00$btnImgConnexion.x', {'value': ''})) self.browser['ctl00$ContentPlaceHolder1$ctl00$ctl04$ctl00$btnImgConnexion.x']="76" self.browser.controls.append(ClientForm.TextControl('text', 'ctl00$ContentPlaceHolder1$ctl00$ctl04$ctl00$btnImgConnexion.y', {'value': ''})) self.browser['ctl00$ContentPlaceHolder1$ctl00$ctl04$ctl00$btnImgConnexion.y']="10" try: self.browser.submit() except BrowserUnavailable: # Login is not valid return False return True def is_error(self): for text in self.document.find('body').itertext(): text=text.strip() # Login seems valid, but password does not needle='Echec lors de l\'authentification' if text.startswith(needle.decode('utf-8')): return True return False ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opacwebaloes/test.py�������������������������������������������������������������0000664�0000000�0000000�00000001550�12657170273�0020310�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class AloestTest(BackendTest): MODULE = 'aloes' def test_aloes(self): pass ��������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opensubtitles/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017212�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opensubtitles/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000001447�12657170273�0021331�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import OpensubtitlesModule __all__ = ['OpensubtitlesModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opensubtitles/browser.py���������������������������������������������������������0000664�0000000�0000000�00000004130�12657170273�0021245�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from weboob.applications.suboob.suboob import LANGUAGE_CONV from .pages import SubtitlesPage, SearchPage, SubtitlePage __all__ = ['OpensubtitlesBrowser'] class OpensubtitlesBrowser(Browser): DOMAIN = 'www.opensubtitles.org' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.opensubtitles.org.*search2/sublanguageid.*moviename.*': SearchPage, 'http://www.opensubtitles.org.*search/sublanguageid.*idmovie.*': SubtitlesPage, 'http://www.opensubtitles.org.*search/imdbid.*/sublanguageid.*/moviename.*': SubtitlesPage, 'http://www.opensubtitles.org.*subtitles/[0-9]*/.*': SubtitlePage } def iter_subtitles(self, language, pattern): lang = LANGUAGE_CONV[language] self.location('http://www.opensubtitles.org/search2/sublanguageid-%s/moviename-%s' % ( lang, pattern.encode('utf-8'))) assert self.is_on_page(SearchPage) or self.is_on_page(SubtitlesPage) or self.is_on_page(SubtitlePage) return self.page.iter_subtitles() def get_subtitle(self, id): try: self.location('http://www.opensubtitles.org/subtitles/%s' % id) except BrowserHTTPNotFound: return if self.is_on_page(SubtitlePage): return self.page.get_subtitle() ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opensubtitles/favicon.png��������������������������������������������������������0000664�0000000�0000000�00000005567�12657170273�0021362�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME!m�� IDATxypU?s_^ŽIXQV"u\h:ک3mqcHY8cbTpP#Nk[ť,Z-A^K}y!I!g&r=QUf[7��\-p1 Q@b&clwA h4`8Ʝh^H6~=g�9o8V$~ԑlEPCG. �<ȡf`D9CU} W-HowU˳I;S%&3oL -5Mv*1 oY&b>H@$ ( Yhf\zdzi1d;Geh! &UƊ.CN+tH~hjK1S~b"n$Z/||mY-iɚVҀ#]Npohtoxӓ',}'vni5٣d1|9r8gS/nk:Rk˶7a cS"8/qIȑ&7/AV;4 �-.bd$o'/GdMJ͝Wzt3? xِQ2sdʼ)cyhxӲR8C_S}n0ݟJnw evYHls@M�⡨}0ɺ[G9c1Жv ]rs)2i^pq@9I^1WM|/3|!XXXIơ17�Jn?%2: Mp~`] 75ԓ6 |AS+4ml=^O7/Wɴz-~x% V dDŸ:>ѽ] _:kPz"H `T᜛}P-?إ5 a6 i:imn@~ne.TY\ ʃ٣p4ɫx#Jѿ%xʜ{g9doeCl׆]EQ)&*Qk7??-N$x1_�_:3뒍7G_壵5z1|-m{ Eu۷}"8XMG/K�8eO^}io^!t?$BG؟詧.O�ekΚ$M_4_80iOoJé"{C>h_+h;pܛL;Gű~z= AMf-g4ǰ4{#MC+x9[\icڅ 3Cyh[ծʏ] Ѐ5KRd!Ap vKIg\lNGs1A${.iE&eP31Ӈ@D*!:52$v<P(_yhb|P;eD0u \W++<1^Pnp0V-$�䊐 ܺF*By|سF�=`;;̪$Sp_m7R6QV ǻ+p`ϸף88O|N LXx5t�z?VyP#T$[mLVVCEXb"$gn\9㰳 �4s0? 8;Wl*#Dӓ_p"`y3<Q X[J|oU]qKl4-q(p%Ka�V-q8vca" Ƈ #Ҝ9FYyQC?][- S@?[b `;N6WgV9kb ǁz:Jx)+Rr܉U6uVP*He< <o,J [lU7aj)C:BmZq6„a kY$3[,'hֱj@ag_QRBK V8#^]o<MG*k>Fv2CEڈ%qu:�RإJBk1<9�vm6n۶d;Ʈ$Rŕ�.n�[ jp;J[Xa]I>]Y#W;T kvu4NkKՃJ!AS%*@eܖ k^x 7#^D_R<PoNpx �8}iAӀPkLwym L:Fy]#³.c$鶀HEDyI<-ˬi7烵6>'OC-"۷~u3fO;P9 k*Ϻ3n]wT�#>^}cxV{:<Po /` 4F4X$߈@eX籤]-N06[΋6O~t.FS Fx=r?jFu WQ B&pcD9EprQ{U8*O:Jܗ,`*wˍȬ4 ٶnj�B/5,;pr;C+kԊ>ʭ+ \yi&3F-eEj[Nw6O׽o�I5j�ԦV PЫ?BD+3\fOli5LdnV*k>wSY#C>Wg-2ʻTrZ8� E G�4e'5}Qa7ʂm(g[ОNG;Hj=޺Hn� O<����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opensubtitles/module.py����������������������������������������������������������0000664�0000000�0000000�00000004052�12657170273�0021052�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.subtitle import CapSubtitle, LanguageNotSupported, Subtitle from weboob.applications.suboob.suboob import LANGUAGE_CONV from weboob.tools.backend import Module from .browser import OpensubtitlesBrowser from urllib import quote_plus __all__ = ['OpensubtitlesModule'] class OpensubtitlesModule(Module, CapSubtitle): NAME = 'opensubtitles' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'Opensubtitles subtitle website' LICENSE = 'AGPLv3+' BROWSER = OpensubtitlesBrowser def get_subtitle(self, id): return self.browser.get_subtitle(id) def get_subtitle_file(self, id): subtitle = self.browser.get_subtitle(id) if not subtitle: return None return self.browser.openurl(subtitle.url.encode('utf-8')).read() def iter_subtitles(self, language, pattern): if language not in LANGUAGE_CONV.keys(): raise LanguageNotSupported() return self.browser.iter_subtitles(language, quote_plus(pattern.encode('utf-8'))) def fill_subtitle(self, subtitle, fields): if 'description' in fields: sub = self.get_subtitle(subtitle.id) subtitle.description = sub.description return subtitle OBJECTS = { Subtitle: fill_subtitle, } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opensubtitles/pages.py�����������������������������������������������������������0000664�0000000�0000000�00000013442�12657170273�0020667�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.subtitle import Subtitle from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page from weboob.applications.suboob.suboob import LANGUAGE_CONV class SearchPage(Page): """ Page which contains results as a list of movies """ def iter_subtitles(self): tabresults = self.parser.select(self.document.getroot(), 'table#search_results') if len(tabresults) > 0: table = tabresults[0] # for each result line, explore the subtitle list page to iter subtitles for line in self.parser.select(table, 'tr'): links = self.parser.select(line, 'a') if len(links) > 0: a = links[0] url = a.attrib.get('href', '') if "ads2.opensubtitles" not in url: self.browser.location("http://www.opensubtitles.org%s" % url) assert self.browser.is_on_page(SubtitlesPage) or self.browser.is_on_page(SubtitlePage) # subtitles page does the job for subtitle in self.browser.page.iter_subtitles(): yield subtitle class SubtitlesPage(Page): """ Page which contains several subtitles for a single movie """ def iter_subtitles(self): tabresults = self.parser.select(self.document.getroot(), 'table#search_results') if len(tabresults) > 0: table = tabresults[0] # for each result line, get the data # why following line doesn't work all the time (for example 'search fr sopranos guy walks' ? # for line in self.parser.select(table,'tr'): for line in table.getiterator('tr'): # some tr are useless, specially ads if line.attrib.get('id', '').startswith('name'): yield self.get_subtitle_from_line(line) def get_subtitle_from_line(self, line): cells = self.parser.select(line, 'td') if len(cells) > 0: links = self.parser.select(line, 'a') a = links[0] name = u" ".join(a.text.strip().split()) first_cell = cells[0] spanlist = self.parser.select(first_cell, 'span') if len(spanlist) > 0: long_name = spanlist[0].attrib.get('title', '') else: texts = first_cell.itertext() long_name = texts.next() long_name = texts.next() if "Download at 25" in long_name: long_name = "---" name = "%s (%s)" % (name, long_name) second_cell = cells[1] link = self.parser.select(second_cell, 'a', 1) lang = link.attrib.get('href', '').split('/')[-1].split('-')[-1] for lshort, llong in LANGUAGE_CONV.items(): if lang == llong: lang = unicode(lshort) break nb_cd = int(cells[2].text.strip().lower().replace('cd', '')) cell_dl = cells[4] href = self.parser.select(cell_dl, 'a', 1).attrib.get('href', '') url = unicode('http://www.opensubtitles.org%s' % href) id = href.split('/')[-1] subtitle = Subtitle(id, name) subtitle.url = url subtitle.language = lang subtitle.nb_cd = nb_cd subtitle.description = NotLoaded return subtitle class SubtitlePage(Page): """ Page which contains a single subtitle for a movie """ def get_subtitle(self): desc = NotAvailable a = self.parser.select(self.document.getroot(), 'a#bt-dwl', 1) id = a.attrib.get('rel', '').split('/')[-1] m = re.match('Download \((\w+)\)', self.parser.tocleanstring(a)) if m: ext = m.group(1) else: ext = u'zip' url = unicode('http://www.opensubtitles.org/subtitleserve/sub/%s' % id) link = self.parser.select(self.document.getroot(), 'link[rel=bookmark]', 1) title = unicode(link.attrib.get('title', '')) nb_cd = int(title.lower().split('cd')[0].split()[-1]) lang = unicode(title.split('(')[1].split(')')[0]) file_names = self.parser.select(self.document.getroot(), "img[title~=filename]") if len(file_names) > 0: file_name = file_names[0].getparent().text_content() file_name = ' '.join(file_name.split()) desc = u'files :' for f in file_names: desc_line = f.getparent().text_content() desc += '\n'+' '.join(desc_line.split()) name = unicode('%s (%s)' % (title, file_name)) subtitle = Subtitle(id, name) subtitle.url = url subtitle.ext = ext for lshort, llong in LANGUAGE_CONV.items(): if lang == llong: lang = unicode(lshort) break subtitle.language = lang subtitle.nb_cd = nb_cd subtitle.description = desc return subtitle def iter_subtitles(self): yield self.get_subtitle() ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/opensubtitles/test.py������������������������������������������������������������0000664�0000000�0000000�00000002452�12657170273�0020546�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from random import choice class OpensubtitlesTest(BackendTest): MODULE = 'opensubtitles' def test_subtitle(self): lsub = [] subtitles = self.backend.iter_subtitles('fr', 'spiderman') for i in range(5): subtitle = subtitles.next() lsub.append(subtitle) assert subtitle.url.startswith('http') assert (len(lsub) > 0) # get the file of a random sub if len(lsub): subtitle = choice(lsub) self.backend.get_subtitle_file(subtitle.id) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/��������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015565�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/__init__.py���������������������������������������������������������������0000664�0000000�0000000�00000000075�12657170273�0017700�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import OrangeModule __all__ = ['OrangeModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/bill/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016507�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/bill/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0020606�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/bill/browser.py�����������������������������������������������������������0000664�0000000�0000000�00000003651�12657170273�0020551�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, BillsPage __all__ = ['OrangeBillBrowser'] class OrangeBillBrowser(LoginBrowser): loginpage = URL('https://id.orange.fr/auth_user/bin/auth_user.cgi', LoginPage) billspage = URL('https://m.espaceclientv3.orange.fr/\?page=factures-archives', 'https://.*.espaceclientv3.orange.fr/\?page=factures-archives', BillsPage) def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.loginpage.stay_or_go().login(self.username, self.password) self.billspage.go() if self.loginpage.is_here(): raise BrowserIncorrectPassword() def get_nb_remaining_free_sms(self): raise NotImplementedError() def post_message(self, message, sender): raise NotImplementedError() @need_login def get_subscription_list(self): return self.billspage.stay_or_go().get_list() @need_login def iter_bills(self, subscription): return self.billspage.stay_or_go().get_bills(subid=subscription.id) ���������������������������������������������������������������������������������������weboob-1.1/modules/orange/bill/pages/���������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017606�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/bill/pages/__init__.py����������������������������������������������������0000664�0000000�0000000�00000001477�12657170273�0021730�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .login import LoginPage from .bills import BillsPage __all__ = ['LoginPage', BillsPage] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/bill/pages/bills.py�������������������������������������������������������0000664�0000000�0000000�00000004167�12657170273�0021275�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.browser.pages import HTMLPage from weboob.capabilities.bill import Subscription from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanDecimal, CleanText, Env, Format, Date from weboob.browser.filters.html import Attr from weboob.capabilities.bill import Bill class BillsPage(HTMLPage): @method class get_list(ListElement): class item(ItemElement): klass = Subscription obj_label = CleanText('(//li[@class="n1 menuUsage toHighlight"])[1]') obj_subscriber = CleanText('//div[@class="blocCompte blocPrincipal"]//h2/a') obj_id = Env('id') def parse(self, el): self.env['id'] = re.sub(r'[^\d\-\.]', '', el.xpath('(//li[@class="n1 menuUsage toHighlight"])[1]//a')[0].text) @method class get_bills(ListElement): item_xpath = '//ul[@class="liste fe_clearfix factures"]/li' class item(ItemElement): klass = Bill obj__url = Attr('.//span[@class="telecharger pdf"]/a', 'href') obj_id = Format('%s.%s', Env('subid'), CleanDecimal(CleanText('.//span[@class="date magic_gras magic_font13"]'))) obj_date = Date(CleanText('.//span[@class="date magic_gras magic_font13"]')) obj_format = u"pdf" obj_price = CleanDecimal('span[@class="montant"]', replace_dots=True) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/bill/pages/login.py�������������������������������������������������������0000664�0000000�0000000�00000001753�12657170273�0021276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage class LoginPage(HTMLPage): def login(self, login, password): form = self.get_form(xpath='//form[@id="AuthentForm"]') form['credential'] = login form['password'] = password form.submit() ���������������������weboob-1.1/modules/orange/browser.py����������������������������������������������������������������0000664�0000000�0000000�00000005276�12657170273�0017634�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. #~ from .pages.compose import ClosePage, ComposePage, ConfirmPage, SentPage #~ from .pages.login import LoginPage from .pages import LoginPage, ComposePage, ConfirmPage from weboob.deprecated.browser import Browser, BrowserIncorrectPassword __all__ = ['OrangeBrowser'] class OrangeBrowser(Browser): DOMAIN = 'orange.fr' PAGES = { 'http://id.orange.fr/auth_user/bin/auth_user.cgi.*': LoginPage, 'http://id.orange.fr/auth_user/bin/auth0user.cgi.*': LoginPage, 'https://id.orange.fr/auth_user/bin/auth_user.cgi.*': LoginPage, 'https://id.orange.fr/auth_user/bin/auth0user.cgi.*': LoginPage, 'https://authweb.orange.fr/auth_user/bin/auth_user.cgi.*': LoginPage, 'https://authweb.orange.fr/auth_user/bin/auth0user.cgi.*': LoginPage, 'http://smsmms1.orange.fr/./Sms/sms_write.php.*' : ComposePage, 'http://smsmms1.orange.fr/./Sms/sms_write.php?command=send' : ConfirmPage, 'https://smsmms1.orange.fr/./Sms/sms_write.php.*' : ComposePage, 'https://smsmms1.orange.fr/./Sms/sms_write.php?command=send' : ConfirmPage, } def get_nb_remaining_free_sms(self): self.location("http://smsmms1.orange.fr/M/Sms/sms_write.php") return self.page.get_nb_remaining_free_sms() def home(self): self.location("http://smsmms1.orange.fr/M/Sms/sms_write.php") def is_logged(self): self.location("http://smsmms1.orange.fr/M/Sms/sms_write.php", no_login=True) return not self.is_on_page(LoginPage) def login(self): if not self.is_on_page(LoginPage): self.location('https://authweb.orange.fr/auth_user/bin/auth_user.cgi?url=http://www.orange.fr', no_login=True) self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() def post_message(self, message, sender): if not self.is_on_page(ComposePage): self.home() self.page.post_message(message, sender) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000002216�12657170273�0017721�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ����tIME  ɲ���tEXtComment�Created with GIMPW��IDATxklUm-jb0񁦑JVh(hXdnTRJAC4[A#4hR,$QQR)-Kqvvs=sߞ{ͬO#Xr�P� @(��P� @(��P� @(��P� @(��P�W\uٯ _gڿ al]`-0yO�5pn־N= ǜ6,=L P MqѰ#] ƧΓѳ^ xSխ@�j U[`Vs.fMԗLUQh 1ˡ�sg�T;e/x C Kk ѐ,{7ڋ/,BDelODl{ tpjomwM$?g_/5E&csI<}, =,ފv a}O'<qxdw#iZi/.} r\RS]o֟yCuO^޳h9դ'K߰y]ޗwvA0=Y'Eo ~^&R�L,sF{é3aI数x0>s.݁ [<#``Ez!Pig~؝f>m }sPw^Za@QYf#rEDDdcFh:/bǛb4]"vr9dFG2%ϱ;nx6l'cpdd':Lz`A{_K"#﷧6_ԑqgK[~{ O`50;ojіo7KiCMVqk8B~X8ďHdhH= :EV{,n˲:V~ V_ zaOexi1� Ȍs����IENDB`����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000010306�12657170273�0017424�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import CapBill, Subscription, Bill, SubscriptionNotFound, BillNotFound from weboob.capabilities.messages import CantSendMessage, CapMessages, CapMessagesPost from weboob.capabilities.base import find_object from weboob.capabilities.account import CapAccount, StatusField from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import OrangeBrowser from .bill.browser import OrangeBillBrowser __all__ = ['OrangeModule'] # We need to have a switcher, CapMessages use a browser1 and # CapBill use a browser2 # This will be remove when CapMessages use a browser2 def browser_switcher(b): def set_browser(func): def func_wrapper(*args, **kwargs): self = args[0] if self._browser is None or type(self._browser) != b: self.BROWSER = b try: self._browser = self._browsers[b] except KeyError: self._browsers[b] = self.create_default_browser() self._browser = self._browsers[b] return func(*args, **kwargs) return func_wrapper return set_browser class OrangeModule(Module, CapAccount, CapMessages, CapMessagesPost, CapBill): NAME = 'orange' MAINTAINER = u'Lucas Nussbaum' EMAIL = 'lucas@lucas-nussbaum.net' VERSION = '1.1' DESCRIPTION = 'Orange French mobile phone provider' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('login', label='Login'), ValueBackendPassword('password', label='Password'), Value('phonenumber', label='Phone number', default='') ) ACCOUNT_REGISTER_PROPERTIES = None BROWSER = OrangeBrowser def __init__(self, *args, **kwargs): self._browsers = dict() super(OrangeModule, self).__init__(*args, **kwargs) def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) @browser_switcher(OrangeBrowser) def get_account_status(self): return (StatusField('nb_remaining_free_sms', 'Number of remaining free SMS', self.browser.get_nb_remaining_free_sms()),) @browser_switcher(OrangeBrowser) def post_message(self, message): if not message.content.strip(): raise CantSendMessage(u'Message content is empty.') self.browser.post_message(message, self.config['phonenumber'].get()) @browser_switcher(OrangeBillBrowser) def iter_subscription(self): return self.browser.get_subscription_list() @browser_switcher(OrangeBillBrowser) def get_subscription(self, _id): return find_object(self.iter_subscription(), id=_id, error=SubscriptionNotFound) @browser_switcher(OrangeBillBrowser) def get_bill(self, _id): subid = _id.split('.')[0] subscription = self.get_subscription(subid) return find_object(self.iter_bills(subscription), id=_id, error=BillNotFound) @browser_switcher(OrangeBillBrowser) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_bills(subscription) @browser_switcher(OrangeBillBrowser) def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) return self.browser.open(bill._url).content ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/pages/��������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016664�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/pages/__init__.py���������������������������������������������������������0000664�0000000�0000000�00000001543�12657170273�0021000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .login import LoginPage from .compose import ComposePage, ConfirmPage __all__ = ['LoginPage', 'ComposePage', 'ConfirmPage'] �������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/pages/compose.py����������������������������������������������������������0000664�0000000�0000000�00000004237�12657170273�0020711�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.messages import CantSendMessage from weboob.deprecated.browser import Page class ConfirmPage(Page): def on_loaded(self): pass class ComposePage(Page): phone_regex = re.compile('^(\+33|0033|0)(6|7)(\d{8})$') def on_loaded(self): # Deal with bad encoding... for ie6... response = self.browser.response() response.set_data(response.get_data().decode('utf-8', 'ignore')) self.browser.set_response(response) def get_nb_remaining_free_sms(self): return "0" def post_message(self, message, sender): receiver = message.thread.id if self.phone_regex.match(receiver) is None: raise CantSendMessage(u'Invalid receiver: %s' % receiver) listetel = ",," + receiver #Fill the form self.browser.select_form(name="formulaire") self.browser.new_control("hidden", "autorize", {'value': ''}) self.browser.set_all_readonly(False) self.browser["corpsms"] = message.content.encode('utf-8') self.browser["pays"] = "33" self.browser["listetel"] = listetel self.browser["reply"] = "2" self.browser["typesms"] = "2" self.browser["produit"] = "1000" self.browser["destToKeep"] = listetel self.browser["NUMTEL"] = sender self.browser["autorize"] = "1" self.browser["msg"] = message.content.encode('utf-8') self.browser.submit() �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/orange/pages/login.py������������������������������������������������������������0000664�0000000�0000000�00000004052�12657170273�0020347�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page import urllib class LoginPage(Page): def on_loaded(self): pass def login(self, user, pwd): post_data = {"credential" : str(user), "password" : str(pwd), "save_user": "false", "save_pwd" : "false", "save_TC" : "true", "action" : "valider", "usertype" : "", "service" : "", "url" : "http://www.orange.fr", "case" : "", "origin" : "", } post_data = urllib.urlencode(post_data) self.browser.addheaders = [('Referer', 'http://id.orange.fr/auth_user/template/auth0user/htm/vide.html'), ("Content-Type" , 'application/x-www-form-urlencoded') ] self.browser.open(self.browser.geturl(), data=post_data) #~ print "LOGIN!!!" #~ self.browser.select_form(predicate=lambda form: "id" in form.attrs and form.attrs["id"] == "authentication_form" ) #~ user_control = self.browser.find_control(id="user_credential") #~ user_control.value = user #~ pwd_control = self.browser.find_control(id="user_password") #~ pwd_control.value = pwd #~ self.browser.submit() ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ouifm/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015431�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ouifm/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000001432�12657170273�0017542�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import OuiFMModule __all__ = ['OuiFMModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ouifm/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000007574�12657170273�0017601�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME  66K���tEXtComment�Created with GIMPW��IDATxy|TUǿUedB�\"Hb#! B"#("#(4N#`KЀHF[XCVB%3WK Tpz˭wY.Mi$f.,pd ʼnC' jj:\nkr&=�|tɄVU"0dWh>%L0.0%ش5_h^.8~]d70Tm' @<�;7Afp}`Ji!�p%ChL1-c�́nm@yK ^KUǜ,1_U�Bz0/}'!7~7 Р%\U:oFL/һwƢ++UdUF{tm0)T VEBzW0Vj`3 ?Zu�sn#aғ( N%i(_@W \-[1Fl~<mՄ0j ӏ"hTq |;� mw d|Ďu[xJ2L�gaO֡$ nX1,Zjs r&Np2DqHQ-Eh!BsDh&BSIjŞQ̘ 17l4he ߶X3bb==.-3}sT)#Urh,iޜ~;'�~? = I*nm鄕` Ъ,zޛEEQ0.8v #pL#ڤWtu;IX_)dL#""ykHWѺB̓bv-fD }CYsv1f,/s$ښq{1ybF Tq*R MdՙBK@&Ly NϻCjS n nY;棼}!)^Sَ 6 Ǘo$Z @h j �,!4X٢;ySߒ@Yt`fT 5KGHxtdhċO:21 meY[R\qȄhp{jVצ4NvġG0r>9l Z8#"*;3nTyH9t�hW1!`GaG"P ?  ϳE5tJ>@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l}Jo),>w4ͮ˻כCQ))QhAL [i'SY#[Ż(qPV: 2% !E?BhAz3NK>EEe8 '-gyh԰$Dp0AM`Zt/A8xbdi|z_1z'cmh7KӀ)8B#[r1,_jڥvU9t2����IENDB`������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ouifm/module.py������������������������������������������������������������������0000664�0000000�0000000�00000007731�12657170273�0017300�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.audiostream import BaseAudioStream from weboob.tools.capabilities.streaminfo import StreamInfo from weboob.capabilities.collection import CapCollection from weboob.tools.backend import Module from weboob.deprecated.browser import StandardBrowser from weboob.tools.misc import to_unicode __all__ = ['OuiFMModule'] class OuiFMModule(Module, CapRadio, CapCollection): NAME = 'ouifm' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = u'OÜI FM French radio' LICENSE = 'AGPLv3+' BROWSER = StandardBrowser _RADIOS = {'general': (u"OÜI FM", u'OÜI FM', u'http://ouifm.ice.infomaniak.ch/ouifm-high.mp3', 128), 'alternatif': (u"OÜI FM Alternatif", u'OÜI FM - L\'Alternative Rock', u'http://ouifm.ice.infomaniak.ch/ouifm2.mp3', 128), 'classicrock': (u"OÜI FM Classic Rock", u'OÜI FM - Classic Rock', u'http://ouifm.ice.infomaniak.ch/ouifm3.mp3', 160), 'bluesnrock': (u"OÜI FM Blues'n'Rock", u'OÜI FM - Blues\'n\'Rock', u'http://ouifm.ice.infomaniak.ch/ouifm4.mp3', 128), 'rockinde': (u"OÜI FM Rock Indé", u'OÜI FM - Rock Indé', u'http://ouifm.ice.infomaniak.ch/ouifm5.mp3', 128), } def create_default_browser(self): return self.create_browser(parser='json') def iter_resources(self, objs, split_path): if Radio in objs: self._restrict_level(split_path) for id in self._RADIOS.iterkeys(): yield self.get_radio(id) def iter_radios_search(self, pattern): for radio in self.iter_resources((Radio, ), []): if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower(): yield radio def get_current(self, radio): document = self.browser.location('http://www.ouifm.fr/onair.json') rad = '' if radio == 'general': rad = 'rock' else: rad = radio last = document[rad][0] artist = to_unicode(last.get('artist', '').strip()) title = to_unicode(last.get('title', '').strip()) return artist, title def get_radio(self, radio): if not isinstance(radio, Radio): radio = Radio(radio) if radio.id not in self._RADIOS: return None title, description, url, bitrate = self._RADIOS[radio.id] radio.title = title radio.description = description artist, title = self.get_current(radio.id) current = StreamInfo(0) current.who = artist current.what = title radio.current = current stream = BaseAudioStream(0) stream.bitrate=bitrate stream.format=u'mp3' stream.title = u'%skbits/s' % (stream.bitrate) stream.url = url radio.streams = [stream] return radio def fill_radio(self, radio, fields): if 'current' in fields: if not radio.current: radio.current = StreamInfo(0) radio.current.who, radio.current.what = self.get_current(radio.id) return radio OBJECTS = {Radio: fill_radio} ���������������������������������������weboob-1.1/modules/ouifm/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000001747�12657170273�0016773�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.radio import Radio class OuiFMTest(BackendTest): MODULE = 'ouifm' def test_ouifm(self): l = list(self.backend.iter_resources((Radio, ), [])) self.assertTrue(len(l) > 0) �������������������������weboob-1.1/modules/ovh/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015106�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovh/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000001432�12657170273�0017217�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import OvhModule __all__ = ['OvhModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovh/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000004172�12657170273�0017147�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, HomePage, ApiAuthPage, ProfilePage, BillsPage class OvhBrowser(LoginBrowser): BASEURL = 'https://www.ovh.com' login = URL('/manager/web/login/', LoginPage) home = URL('/manager/web/index.html.*', HomePage) api_auth = URL('/manager/dedicated/api/auth/loginSessionidV6', ApiAuthPage) profile = URL('/manager/dedicated/api/proxypass/me', ProfilePage) billspage = URL('/manager/web/api/billing/bills', BillsPage) def open(self, *args, **kwargs): if not 'headers' in kwargs: kwargs['headers'] = {} try: kwargs['headers']['X-Csid'] = self.csid except AttributeError: pass return super(OvhBrowser, self).open(*args, **kwargs) def do_login(self): self.login.go() self.page.login(self.username, self.password) if not self.home.is_here(): raise BrowserIncorrectPassword self.location('https://www.ovh.com/manager/dedicated/api/auth/loginSessionidV6', method="POST") self.csid = self.page.get_csid() @need_login def get_subscription_list(self): return self.profile.stay_or_go().get_list() @need_login def iter_bills(self, subscription): return self.billspage.stay_or_go().get_bills(subid=subscription.id) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovh/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000004505�12657170273�0016751�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import CapBill, Subscription, Bill, SubscriptionNotFound, BillNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import OvhBrowser __all__ = ['OvhModule'] class OvhModule(Module, CapBill): NAME = 'ovh' DESCRIPTION = u'ovh website' MAINTAINER = u'Vincent Paredes' EMAIL = 'vparedes@budget-insight.com' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(Value('login', label='Account ID'), ValueBackendPassword('password', label='Password')) BROWSER = OvhBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): return self.browser.get_subscription_list() def get_subscription(self, _id): return find_object(self.iter_subscription(), id=_id, error=SubscriptionNotFound) def get_bill(self, _id): subid = _id.split('.')[0] subscription = self.get_subscription(subid) return find_object(self.iter_bills(subscription), id=_id, error=BillNotFound) def iter_bills(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.iter_bills(subscription) def download_bill(self, bill): if not isinstance(bill, Bill): bill = self.get_bill(bill) return self.browser.open(bill._url).content �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovh/pages.py���������������������������������������������������������������������0000664�0000000�0000000�00000004434�12657170273�0016564�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import Bill, Subscription from weboob.browser.pages import HTMLPage, LoggedPage, JsonPage from weboob.browser.filters.standard import CleanDecimal, CleanText, Env, Format, Date from weboob.browser.filters.json import Dict from weboob.browser.elements import ListElement, ItemElement, method, DictElement class LoginPage(HTMLPage): def login(self, login, password): form = self.get_form('//form[@class="pagination-centered"]') form[self.doc.xpath('//input[@placeholder="Account ID"]/@id')[0]] = login form[self.doc.xpath('//input[@placeholder="Password"]/@id')[0]] = password form.submit() class HomePage(HTMLPage, LoggedPage): pass class ProfilePage(JsonPage, LoggedPage): @method class get_list(ListElement): class item(ItemElement): klass = Subscription obj_label = CleanText(Dict('nichandle')) obj_subscriber = Format("%s %s", CleanText(Dict('firstname')), CleanText(Dict('name'))) obj_id = CleanText(Dict('nichandle')) class ApiAuthPage(JsonPage, LoggedPage): def get_csid(self): return self.doc['csid'] class BillsPage(JsonPage, LoggedPage): @method class get_bills(DictElement): item_xpath = 'list/results' class item(ItemElement): klass = Bill obj_id = Format('%s.%s', Env('subid'), Dict('orderId')) obj_date = Date(Dict('billingDate')) obj_format = u"pdf" obj_price = CleanDecimal(Dict('priceWithTax/value')) obj__url = Dict('pdfUrl') ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovh/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000001572�12657170273�0016444�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Vincent Paredes # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class OvhTest(BackendTest): MODULE = 'ovh' def test_ovh(self): raise NotImplementedError() ��������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovs/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015121�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovs/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000001424�12657170273�0017233�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import OvsModule __all__ = ['OvsModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovs/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000011270�12657170273�0017157�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.deprecated.browser.parsers.iparser import IParser import BeautifulSoup from .pages import PagePrivateThreadsList, PagePrivateThread, PageLogin, PageIndex, DummyPage, PageUserProfile, PageCityList __all__ = ['OvsBrowser'] class SoupParser(IParser): def parse(self, data, encoding=None): return BeautifulSoup.BeautifulSoup(data.read().decode(encoding or 'utf-8'), convertEntities=BeautifulSoup.BeautifulStoneSoup.ALL_ENTITIES) class OvsBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'paris.onvasortir.com' ENCODING = 'cp1252' def __init__(self, city, username, password, *a, **kw): self.DOMAIN = '%s.onvasortir.com' % city self.PAGES = { '%s://%s/' % (self.PROTOCOL, self.DOMAIN): PageIndex, r'%s://%s/message_read.php\?Id=.+' % (self.PROTOCOL, self.DOMAIN): PagePrivateThread, '%s://%s/vue_messages_recus.php' % (self.PROTOCOL, self.DOMAIN): PagePrivateThreadsList, '%s://%s/vue_messages_envoyes.php' % (self.PROTOCOL, self.DOMAIN): PagePrivateThreadsList, '%s://%s/page_action_connect.php' % (self.PROTOCOL, self.DOMAIN): PageLogin, r'%s://%s/\?Langue=EN' % (self.PROTOCOL, self.DOMAIN): DummyPage, '%s://%s/page_action_boost.php' % (self.PROTOCOL, self.DOMAIN): DummyPage, '%s://%s/vue_profil_all.php.php' % (self.PROTOCOL, self.DOMAIN): DummyPage, r'%s://%s/message_msg_envoi_ok.php\?.*' % (self.PROTOCOL, self.DOMAIN): DummyPage, '%s://%s/message_action_envoi.php' % (self.PROTOCOL, self.DOMAIN): DummyPage, r'%s://%s/profil_read.php\?.+' % (self.PROTOCOL, self.DOMAIN): PageUserProfile, 'http://www.onvasortir.com/?': PageCityList, 'http://www.urbeez.com/?': PageCityList, } kw['parser'] = SoupParser() Browser.__init__(self, username, password, *a, **kw) self.city = city def iter_threads_list(self): self.location('/vue_messages_recus.php') assert self.is_on_page(PagePrivateThreadsList) for thread in self.page.iter_threads_list(): yield thread self.location('/vue_messages_envoyes.php') assert self.is_on_page(PagePrivateThreadsList) for thread in self.page.iter_threads_list(): yield thread def get_thread(self, _id): self.location('/message_read.php?Id=%s&AffMsg=all' % _id) assert self.is_on_page(PagePrivateThread) return self.page.get_thread(_id) def login(self): assert not self.is_logged() self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() self.location('/?Langue=EN') self.location('/page_action_boost.php') self.location('/') def is_logged(self): return (self.is_on_page(DummyPage) or self.page.is_logged()) def post_to_thread(self, thread_id, subject, body): self.location('/message_read.php?Id=%s' % thread_id.encode(self.ENCODING)) # FIXME assert self.is_on_page(PagePrivateThread) self.page.post_to_thread(thread_id, subject, body) def create_thread(self, recipient, subject, body): self.location('/profil_read.php?%s' % recipient.encode(self.ENCODING)) # FIXME assert self.is_on_page(PageUserProfile) self.page.create_thread(recipient, subject, body) def get_contact(self, id): self.location('/profil_read.php?%s' % id.encode(self.ENCODING)) # FIXME assert self.is_on_page(PageUserProfile) return self.page.get_contact() def get_french_cities(self): self.location('http://www.onvasortir.com') assert self.is_on_page(PageCityList) return self.page.get_cities('onvasortir.com') def get_world_cities(self): self.location('http://www.urbeez.com') assert self.is_on_page(PageCityList) return self.page.get_cities('urbeez.com') ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovs/favicon.png������������������������������������������������������������������0000664�0000000�0000000�00000006231�12657170273�0017256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD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1*+!L2ZQ2˴lYK`_ Ty.ז `kpIZ` ,F0 %gbی"Z)1d@πl`x6du!*wrp�#m;NzRsΤYQ`GV+IZF�[0Zc;SY's0Qna_> $̰NpxnN؂tURn@(_óФfZ\R0L¨\ELK^o2ڐJWySsJ,FZn3Qc_L LRAZR?ܟ NxO]X;-3'KS|Ë(=i*([P#+�^JZ:\BG[r i�n 8Yh` ԄȦ7x-{rq`B `tT] <!EIy1di˙2>W$g[:e$DZau\JD n|rjdzBrn$�v! P]ׇ鍉2jjJ]gP#t i<qwrKr,eUZ'}=(\|3 lˡqCA0[)pOdf@b,D8{P^e%!?0R뤷̒!ĘFi F_@R+-Z&s#4SGQch:R(O"Yx~QKB6$@JGϻ+[M*?̀^n ,$k^[,0{Ak9�Т >  Q�j�8؅r+>ڬ.h8�6!#fVS[?G����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovs/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000015312�12657170273�0016762�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.deprecated.browser import BrowserForbidden from weboob.tools.value import Value, ValueBackendPassword from weboob.capabilities.messages import CapMessages, CapMessagesPost, Message from weboob.capabilities.contact import CapContact from .browser import OvsBrowser __all__ = ['OvsModule'] CITIES = {u'agen': u'Agen', u'ajaccio': u'Ajaccio', u'albi': u'Albi', u'amiens': u'Amiens', u'angers': u'Angers', u'angouleme': u'Angoul\xeame', u'annecy': u'Annecy', u'aurillac': u'Aurillac', u'auxerre': u'Auxerre', u'avignon': u'Avignon', u'bastia': u'Bastia', u'beauvais': u'Beauvais', u'belfort': u'Belfort', u'bergerac': u'Bergerac', u'besancon': u'Besan\xe7on', u'beziers': u'B\xe9ziers', u'biarritz': u'Biarritz', u'blois': u'Blois', u'bordeaux': u'Bordeaux', u'bourg-en-bresse': u'M\xe2con', u'bourges': u'Bourges', u'brest': u'Brest', u'brive-la-gaillarde': u'Brive', u'bruxelles': u'Bruxelles', u'caen': u'Caen', u'calais': u'Boulogne', u'carcassonne': u'Carcassonne', u'chalon-sur-saone': u'Chalon', u'chambery': u'Albertville', u'chantilly': u'Chantilly', u'charleroi': u'Charleroi', u'charleville-mezieres': u'Charleville', u'chartres': u'Chartres', u'chateauroux': u'Ch\xe2teauroux', u'cherbourg': u'Cherbourg', u'cholet': u'Cholet', u'clermont-ferrand': u'Clt-Ferrand', u'compiegne': u'Compi\xe8gne', u'dieppe': u'Dieppe', u'dijon': u'Dijon', u'dunkerque': u'Dunkerque', u'evreux': u'Evreux', u'frejus': u'Fr\xe9jus', u'gap': u'Gap', u'geneve': u'Gen\xe8ve', u'grenoble': u'Grenoble', u'la-roche-sur-yon': u'La Roche/Yon', u'la-rochelle': u'La Rochelle', u'lausanne': u'Lausanne', u'laval': u'Laval', u'le-havre': u'Le Havre', u'le-mans': u'Alen\xe7on', u'liege': u'Li\xe8ge', u'lille': u'Lille', u'limoges': u'Limoges', u'lorient': u'Lorient', u'luxembourg': u'Luxembourg', u'lyon': u'Lyon', u'marseille': u'Aix', u'metz': u'Metz', u'mons': u'Mons', u'mont-de-marsan': u'Mont de Marsan', u'montauban': u'Montauban', u'montlucon': u'Montlu\xe7on', u'montpellier': u'Montpellier', u'mulhouse': u'Colmar', u'namur': u'Namur', u'nancy': u'Nancy', u'nantes': u'Nantes', u'nevers': u'Nevers', u'nice': u'Cannes', u'nimes': u'N\xeemes', u'niort': u'Niort', u'orleans': u'Orl\xe9ans', u'paris': u'PARIS', u'pau': u'Pau', u'perigueux': u'P\xe9rigueux', u'perpignan': u'Perpignan', u'poitiers': u'Poitiers', u'quimper': u'Quimper', u'reims': u'Reims', u'rennes': u'Rennes', u'roanne': u'Roanne', u'rodez': u'Rodez', u'rouen': u'Rouen', u'saint-brieuc': u'St-Brieuc', u'saint-etienne': u'St-Etienne', u'saint-malo': u'St-Malo', u'saint-nazaire': u'St-Nazaire', u'saint-quentin': u'St-Quentin', u'saintes': u'Saintes', u'strasbourg': u'Strasbourg', u'tarbes': u'Tarbes', u'toulon': u'Toulon', u'toulouse': u'Toulouse', u'tours': u'Tours', u'troyes': u'Troyes', u'valence': u'Mont\xe9limar', u'vannes': u'Vannes', u'zurich': u'Zurich'} class OvsModule(Module, CapMessages, CapMessagesPost, CapContact): NAME = 'ovs' DESCRIPTION = u'OnVaSortir website. Handles private messages only' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' VERSION = '1.1' CONFIG = BackendConfig(Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password', default=''), Value('city', label='City (subdomain)', default='paris', choices=CITIES)) BROWSER = OvsBrowser STORAGE = {'seen': {}} def create_default_browser(self): return self.create_browser(self.config['city'].get(), self.config['username'].get(), self.config['password'].get(), parser='raw') # CapMessages def iter_threads(self): with self.browser: for thread in self.browser.iter_threads_list(): yield thread def get_thread(self, id): with self.browser: thread = self.browser.get_thread(id) messages = [thread.root] + thread.root.children for message in messages: if not self.storage.get('seen', message.full_id, default=False): message.flags |= Message.IS_UNREAD return thread def iter_unread_messages(self): with self.browser: for thread in self.iter_threads(): # TODO reuse thread object? thread2 = self.get_thread(thread.id) messages = [thread2.root] + thread2.root.children for message in messages: if message.flags & Message.IS_UNREAD: yield message # TODO implement more efficiently by having a "last weboob seen" for # a thread and query a thread only if "last activity" returned by web # is later than "last weboob seen" def set_message_read(self, message): self.storage.set('seen', message.full_id, True) self.storage.save() # CapMessagesPost def post_message(self, message): if not self.browser.username: raise BrowserForbidden() with self.browser: thread = message.thread if message.parent: # ovs.<threadid>@* self.browser.post_to_thread(thread.id, message.title, message.content) else: # ovs.<recipient>@* self.browser.create_thread(thread.id, message.title, message.content) # CapContact def get_contact(self, id): return self.browser.get_contact(id) # FIXME known bug: parsing is done in "boosted mode" which is automatically disable after some time, the "boosted mode" should be re-toggled often # TODO support outing comments, forum messages # TODO make an CapOuting? ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovs/ovsparse.py������������������������������������������������������������������0000664�0000000�0000000�00000006231�12657170273�0017337�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import BeautifulSoup def nearest_parent(node, expected): return node.findParent(expected) while node and node.name != expected: node = node.parent return node def all_text_recursive(node): return ''.join(node.findAll(text=True)) def all_next_siblings(node): ret = [] while node: ret.append(node) node = node.nextSibling return ret def image_to_text(src): smileys = {'chat/e/grin.gif': ':D', 'chat/e/unsure.gif': ':s', 'chat/e/smile.gif': ':)', 'chat/e/shocked.gif': ':|', 'chat/e/sad.gif': ':(', 'chat/e/huh.gif': ':h', 'chat/e/suprised.gif': ':o', 'chat/e/cool.gif': 'B)', 'chat/e/redface.gif': ':red', 'chat/e/confused.gif': ':=', 'chat/e/razz.gif': ':p', 'chat/e/wink.gif': ';)', 'chat/e/mad.gif': ':x', 'chat/e/rolleyes.gif': ':b', 'chat/e/lol.gif': ':lol', 'chat/e/wub.gif': ':$', 'chat/e/bouche.gif': ':K', 'chat/e/sick.gif': '+o('} return smileys.get(src) def html_message_to_text(nodes): parts = [] for node in nodes: if isinstance(node, BeautifulSoup.NavigableString): parts.append(unicode(node).replace('\r', '')) elif node.name == 'img': parts.append(image_to_text(node['src'])) elif node.name == 'a': parts.append(node['href']) elif node.name == 'br': parts.append('\n') else: assert not ('%s not supported' % node.name) return ''.join(parts) def create_unique_id(proposed_id, used_ids): if proposed_id not in used_ids: return proposed_id def make_id(base, index): return '%s-%s' % (base, index) index = 1 while make_id(proposed_id, index) in used_ids: index += 1 return make_id(proposed_id, index) # public def private_message_form_fields(document): ret = {} form = document.find('form', attrs={'name': 'envoimail'}) def set_if_present(name): item = form.find('input', attrs={'name': name}) if item: ret[name] = item['value'] set_if_present('Pere') set_if_present('Sortie') set_if_present('Dest') set_if_present('Titre') return ret def is_logged(document): return (not document.find('form', attrs={'name': 'connection'})) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovs/pages.py���������������������������������������������������������������������0000664�0000000�0000000�00000023140�12657170273�0016572�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import datetime import re import urllib from urlparse import urlsplit from weboob.deprecated.browser import Page from weboob.capabilities.messages import Message, Thread from weboob.capabilities.contact import Contact, ProfileNode from weboob.tools.date import parse_french_date from . import ovsparse class OvsPage(Page): def is_logged(self): return ovsparse.is_logged(self.document) def login(self, username, password): self.browser.select_form(name='connection') self.browser['Pseudo'] = username.encode(self.browser.ENCODING) self.browser['Password'] = password.encode(self.browser.ENCODING) self.browser['Retenir'] = ['ok'] self.browser.submit(nologin=True) class PagePrivateThreadsList(OvsPage): def iter_threads_list(self): # site is sorted from latest to oldest for message_a in reversed(self.document.findAll('a', href=re.compile(r'message_read.php\?'))): ovs_id = re.search(r'Id=(\d+)', message_a["href"]).group(1) id_ = ovs_id thread = Thread(id_) thread.title = ovsparse.all_text_recursive(message_a) thread.flags = Thread.IS_DISCUSSION #~ parent_tr = message_a.findParent('tr') #~ username = all_text_recursive(parent_tr.find('a', href=re.compile(r'profil_read.php\?.*'))) #~ notread_self = (parent_tr.get('class') == 'newmails') #~ notread_other = (parent_tr.find('span', **{'class': 'new_sortiepartenaire'}) is not None) yield thread class PagePrivateThread(OvsPage): def get_thread(self, _id): thread = Thread(_id) thread.title = self.document.find('div', 'PADtitreBlanc_txt').find('center').string thread.flags = Thread.IS_DISCUSSION root = True for message in self._get_messages(thread): if root: message.children = [] thread.root = message thread.date = message.date message.title = thread.title root = False else: message.title = 'Re: %s' % thread.title message.children = [] message.parent = thread.root thread.root.children.append(message) return thread def _get_messages(self, thread): thread_div = self.document.find(True, 'PADpost_txt') used_ids = set() rcpt = self.document.find('input', attrs={'type': 'hidden', 'name': 'Dest'})['value'] sender_to_receiver = {rcpt: self.browser.username, self.browser.username: rcpt} # site is sorted from latest to oldest message for message_table in reversed(thread_div.findAll('table')): for td in message_table.findAll('td'): profile_a = td.find('a', href=re.compile(r'profil_read.php\?.*')) if not profile_a: continue first_br = td.find('br') assert first_br.nextSibling.name == 'br' text_nodes = ovsparse.all_next_siblings(first_br.nextSibling.nextSibling) # TODO #~ print text_nodes # date will be used as id sitedate = profile_a.findParent('div').find(text=re.compile(',.*')).replace(', ', '') sysdate = parse_french_date(sitedate) compactdate = datetime.datetime.strftime(sysdate, '%Y%m%dT%H%M%S') # but make it unique msg_id = ovsparse.create_unique_id(compactdate, used_ids) used_ids.add(msg_id) message = Message(thread, msg_id) message.sender = re.search(r'\?(.+)', profile_a['href']).group(1) message.receivers = [sender_to_receiver[message.sender]] message.date = sysdate message.content = ovsparse.html_message_to_text(text_nodes) notread_self = bool(td.find('span', 'ColorSurligne')) notread_other = bool(td.find('span', 'new_sortiepartenaire')) if notread_other or notread_self: message.flags |= Message.IS_NOT_RECEIVED else: message.flags |= Message.IS_RECEIVED yield message def post_to_thread(self, thread_id, subject, body): form = ovsparse.private_message_form_fields(self.document) recode_dict(form, self.browser.ENCODING) form['Message'] = body.encode(self.browser.ENCODING) self.browser.location('/message_action_envoi.php', urllib.urlencode(form)) # html code is so broken that mechanize won't parse the forms #~ self.browser.select_form('envoimail') #~ self.browser['Message'] = body.encode(self.browser.ENCODING) #~ self.browser['Pere'] = thread_id.encode(self.browser.ENCODING) #~ self.browser['Titre'] = subject.encode(self.browser.ENCODING) #~ self.browser.submit() class PageLogin(Page): pass class PageIndex(OvsPage): pass class DummyPage(Page): pass class PagePostMessage(OvsPage): pass class PageUserProfile(OvsPage): def create_thread(self, recipient, subject, body): form = ovsparse.private_message_form_fields(self.document) recode_dict(form, self.browser.ENCODING) form['Message'] = body.encode(self.browser.ENCODING) form['Titre'] = subject.encode(self.browser.ENCODING) self.browser.location('/message_action_envoi.php', urllib.urlencode(form)) #~ self.browser.select_form('envoimail') #~ self.browser['Titre'] = subject.encode(self.browser.ENCODING) #~ self.browser['Message'] = body.encode(self.browser.ENCODING) #~ self.browser.submit() def get_contact(self): profile_a = self.document.find('a', href=re.compile(r'profil_read.php\?.*')) _id = re.search(r'\?(.*)', profile_a['href']).group(1) # not available in the 'boosted' version contact = Contact(_id, _id, Contact.STATUS_OFFLINE) contact.url = self.url contact.profile = {} thumbnail_url = 'http://photos.onvasortir.com/%s/photos/%s_resize.png' % (self.browser.city, _id) if self.document.find('img', attrs={'src': thumbnail_url}): photo_url = thumbnail_url.replace('_resize', '') contact.set_photo('main', thumbnail_url=thumbnail_url, url=photo_url, hidden=False) location_a = self.document.find('a', href=re.compile(r'vue_profil_carte\.php\?')) if location_a: lat = float(re.search(r'Lat=([\d.]+)', location_a['href']).group(1)) self._set_profile(contact, 'latitude', lat) lng = float(re.search(r'Lng=([\d.]+)', location_a['href']).group(1)) self._set_profile(contact, 'longitude', lng) div = self.document.find('div', attrs={'class': 'PADtitreBlanc_txt'}, text=re.compile('Personal Info')) td = div.findParent('tr').findNextSibling('tr').td infos_text = td.getText(separator='\n').strip() it = iter(infos_text.split('\n')) infos = dict(zip(it, it)) if infos['Sex :'] == 'Man': self._set_profile(contact, 'sex', 'M') elif infos['Sex :'] == 'Woman': self._set_profile(contact, 'sex', 'F') if infos['Birthday :'] != 'Unknown': self._set_profile(contact, 'birthday', parse_french_date(re.search(r'(\d+ \w+ \d+)', infos['Birthday :']).group(1))) self._try_attr(contact, infos, 'First Name :', 'first_name') self._try_attr(contact, infos, 'Status :', 'marriage') self._try_attr(contact, infos, 'Area :', 'area') div = self.document.find('div', attrs={'class': 'PADtitreBlanc_txt'}, text=re.compile('A few words')) td = div.findParent('tr').findNextSibling('tr').td summary = td.getText(separator='\n').strip() if summary == 'Unknown': contact.summary = u'' else: contact.summary = summary div = self.document.find('div', style=re.compile('dashed')) if div: # TODO handle html, links and smileys contact.status_msg = div.getText() else: contact.status_msg = u'' return contact def _set_profile(self, contact, key, value): contact.profile[key] = ProfileNode(key, key.capitalize(), value) def _try_attr(self, contact, infos, html_attr, obj_attr): if infos[html_attr] != 'Unknown': self._set_profile(contact, obj_attr, infos[html_attr].strip()) class PageCityList(DummyPage): def get_cities(self, master_domain='onvasortir.com'): cities = {} for home_a in self.document.findAll('a', href=re.compile(r'http://(.*)\.%s/?' % master_domain)): hostname = urlsplit(home_a['href']).hostname code = hostname.split('.')[0] if code == 'www': continue name = home_a.text cities[name] = {'code': code, 'hostname': hostname} return cities def recode_dict(dict_, encoding): for k in dict_: dict_[k] = dict_[k].encode(encoding) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ovs/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000001564�12657170273�0016460�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class OvsTest(BackendTest): MODULE = 'ovs' def test_ovs(self): raise NotImplementedError() ��������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pap/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015072�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pap/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000000067�12657170273�0017206�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import PapModule __all__ = ['PapModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pap/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000005464�12657170273�0017140�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.browser import PagesBrowser, URL from weboob.capabilities.housing import Query, TypeNotSupported from .pages import SearchResultsPage, HousingPage, CitiesPage __all__ = ['PapBrowser'] class PapBrowser(PagesBrowser): BASEURL = 'http://www.pap.fr' search_page = URL('annonce/.*', SearchResultsPage) housing = URL('annonces/(?P<_id>.*)', HousingPage) cities = URL('index/ac-geo2\?q=(?P<pattern>.*)', CitiesPage) def search_geo(self, pattern): return self.cities.open(pattern=pattern).iter_cities() TYPES = {Query.TYPE_RENT: 'location', Query.TYPE_SALE: 'vente'} RET = {Query.HOUSE_TYPES.HOUSE: 'maison', Query.HOUSE_TYPES.APART: 'appartement', Query.HOUSE_TYPES.LAND: 'terrain', Query.HOUSE_TYPES.PARKING: 'garage-parking', Query.HOUSE_TYPES.OTHER: 'divers'} def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types): if type not in self.TYPES: raise TypeNotSupported() self.session.headers.update({'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}) data = {'geo_objets_ids': ','.join(cities), 'surface[min]': area_min or '', 'surface[max]': area_max or '', 'prix[min]': cost_min or '', 'prix[max]': cost_max or '', 'produit': self.TYPES.get(type, 'location'), 'recherche': 1, 'nb_resultats_par_page': 40, } if nb_rooms: data['nb_pieces[min]'] = nb_rooms data['nb_pieces[max]'] = nb_rooms ret = [] for house_type in house_types: if house_type in self.RET: ret.append(self.RET.get(house_type)) _data = '%s%s%s' % (urllib.urlencode(data), '&typesbien%5B%5D=', '&typesbien%5B%5D='.join(ret)) return self.search_page.go(data=_data).iter_housings() def get_housing(self, _id, housing=None): return self.housing.go(_id=_id).get_housing(obj=housing) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pap/favicon.png������������������������������������������������������������������0000664�0000000�0000000�00000001511�12657170273�0017223�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME .���tEXtComment�Created with GIMPW��IDATxOEܮx) #,!KqYR. QAE]T;CmUmta6 ?.h ]1`-z{Μ6»xg!      +*#YW=8 ,^S؊ </k|+Q€ĞftlA?slpbLΕQʀuqM_f6gr m!>bz8WM`v=;bM`^­MxϷ=6my|Ot3Kgp%:9[8uڛ߲t'[?RPG#C٢/^CܣYùYc6;K(izZŖ v۰OϽ#lC(a,册8}zT,V%(VU3~ "Ycq=<N,=ØwEﻖ~6K E<f?~;Klf_uw5%ƒW}0Y;bgO`Gft:‘SGG1ˎy8o9<-[ Xko#ϸLWد;KUp>LK }/=װeulEG,?eNAAAAA����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pap/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000004405�12657170273�0016734�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.housing import CapHousing, Housing, HousingPhoto from weboob.tools.backend import Module from .browser import PapBrowser __all__ = ['PapModule'] class PapModule(Module, CapHousing): NAME = 'pap' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'French housing website' LICENSE = 'AGPLv3+' BROWSER = PapBrowser def search_housings(self, query): cities = ['%s' % c.id for c in query.cities if c.backend == self.name] if len(cities) == 0: return list() return self.browser.search_housings(query.type, cities, query.nb_rooms, query.area_min, query.area_max, query.cost_min, query.cost_max, query.house_types) def get_housing(self, housing): if isinstance(housing, Housing): id = housing.id else: id = housing housing = None return self.browser.get_housing(id, housing) def search_city(self, pattern): return self.browser.search_geo(pattern) def fill_housing(self, housing, fields): return self.browser.get_housing(housing.id, housing) def fill_photo(self, photo, fields): if 'data' in fields and photo.url and not photo.data: photo.data = self.browser.open(photo.url).content return photo OBJECTS = {Housing: fill_housing, HousingPhoto: fill_photo, } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pap/pages.py���������������������������������������������������������������������0000664�0000000�0000000�00000012515�12657170273�0016547�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from decimal import Decimal from weboob.tools.date import parse_french_date from weboob.browser.pages import HTMLPage, JsonPage, pagination from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.browser.filters.standard import CleanText, CleanDecimal, Regexp, Env, BrowserURL, Format from weboob.browser.filters.html import Link, XPath, CleanHTML from weboob.browser.filters.json import Dict from weboob.capabilities.base import NotAvailable from weboob.capabilities.housing import Housing, City, HousingPhoto class CitiesPage(JsonPage): @method class iter_cities(DictElement): class item(ItemElement): klass = City obj_id = Dict('id') obj_name = Dict('name') class SearchResultsPage(HTMLPage): @pagination @method class iter_housings(ListElement): item_xpath = '//li[@class="annonce"]' def next_page(self): return Link('//ul[@class="pagination"]/li[@class="next"]/a')(self) class item(ItemElement): klass = Housing def condition(self): return Regexp(Link('./div[@class="header-annonce"]/a'), '/annonces/(.*)', default=None)(self) obj_id = Regexp(Link('./div[@class="header-annonce"]/a'), '/annonces/(.*)') obj_title = CleanText('./div[@class="header-annonce"]/a') obj_area = CleanDecimal(Regexp(CleanText('./div[@class="header-annonce"]/a/span[@class="desc"]'), '(.*?)(\d*) m\xb2(.*?)', '\\2'), default=NotAvailable) obj_cost = CleanDecimal(CleanText('./div[@class="header-annonce"]/a/span[@class="prix"]'), replace_dots=(',', '.'), default=Decimal(0)) obj_currency = Regexp(CleanText('./div[@class="header-annonce"]/a/span[@class="prix"]'), '.*([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') def obj_date(self): _date = Regexp(CleanText('./div[@class="header-annonce"]/span[@class="date"]'), '.* / (.*)')(self) return parse_french_date(_date) obj_station = CleanText('./div/div/div[@cladd=metro]', default=NotAvailable) obj_location = CleanText('./div[@class="clearfix"]/div/a/span/img/@alt') obj_text = CleanText('./div[@class="clearfix"]/div[@class="description clearfix"]/p') def obj_photos(self): photos = [] for img in XPath('//div[@class="vignette-annonce"]/a/span/img/@src')(self): photos.append(HousingPhoto(u'%s' % img)) return photos class HousingPage(HTMLPage): @method class get_housing(ItemElement): klass = Housing obj_id = Env('_id') obj_title = CleanText('//h1[@class="desc clearfix"]/span[@class="title"]') obj_cost = CleanDecimal('//h1[@class="desc clearfix"]/span[@class="prix"]') obj_currency = Regexp(CleanText('//h1[@class="desc clearfix"]/span[@class="prix"]'), '.*([%s%s%s])' % (u'€', u'$', u'£'), default=u'€') obj_area = CleanDecimal(Regexp(CleanText('//h1[@class="desc clearfix"]/span[@class="title"]'), '(.*?)(\d*) m\xb2(.*?)', '\\2'), default=NotAvailable) obj_location = CleanText('//div[@class="text-annonce"]/h2') obj_text = CleanText(CleanHTML('//div[@class="text-annonce-container"]/p')) obj_station = CleanText('//div[@class="metro"]') obj_phone = CleanText('(//span[@class="telephone hide-tel"])[1]') obj_url = BrowserURL('housing', _id=Env('_id')) def obj_details(self): details = dict() for item in XPath('//div[@class="footer-descriptif"]/ul/li')(self): key = CleanText('./span[@class="label"]')(item) value = CleanText('.', replace=[(key, '')])(item) if value and key: details[key] = value key = CleanText('//div[@class="classe-energie-content"]/div/div/span')(self) value = Format('%s(%s)', CleanText('//div[@class="classe-energie-content"]/div/div/p'), CleanText('//div[@class="classe-energie-content"]/div/@class', replace=[('-', ' ')]))(self) if value and key: details[key] = value return details def obj_photos(self): photos = [] for img in XPath('//div[@class="showcase-thumbnail"]/img/@src')(self): photos.append(HousingPhoto(u'%s' % img)) return photos �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pap/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000002462�12657170273�0016427�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.housing import Query from weboob.tools.test import BackendTest class PapTest(BackendTest): MODULE = 'pap' def test_pap(self): query = Query() query.area_min = 20 query.cost_max = 900 query.type = Query.TYPE_RENT query.cities = [] for city in self.backend.search_city('paris'): city.backend = self.backend.name query.cities.append(city) results = list(self.backend.search_housings(query)) self.assertTrue(len(results) > 0) self.backend.fillobj(results[0], 'phone') ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pariskiwi/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016314�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pariskiwi/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0020424�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import ParisKiwiModule __all__ = ['ParisKiwiModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pariskiwi/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000003556�12657170273�0020362�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser from .pages import PageList, PageList2, PageEvent __all__ = ['ParisKiwiBrowser'] class ParisKiwiBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'pariskiwi.org' ENCODING = 'utf-8' PAGES = { 'http://pariskiwi.org/~parislagrise/mediawiki/index.php/Agenda': PageList, 'http://pariskiwi.org/~parislagrise/mediawiki/index.php/Agenda/Detruire_Ennui_Paris/.+': PageEvent, r'http://pariskiwi.org/~parislagrise/mediawiki/api.php\?action=query&list=allpages.*': PageList2, } def __init__(self, *a, **kw): kw['parser'] = 'raw' Browser.__init__(self, *a, **kw) def list_events_all(self): self.location('http://pariskiwi.org/~parislagrise/mediawiki/api.php?action=query&list=allpages&apprefix=Agenda%2FDetruire_Ennui_Paris&aplimit=500&format=json') assert self.is_on_page(PageList2) return self.page.list_events() def get_event(self, _id): self.location('http://pariskiwi.org/~parislagrise/mediawiki/index.php/Agenda/Detruire_Ennui_Paris/%s' % _id) assert self.is_on_page(PageEvent) return self.page.get_event() ��������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pariskiwi/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000001634�12657170273�0020453�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD�c�=�Xw��� pHYs�� �� ����tIME 6 '���tEXtComment�Created with GIMPW��IDATxZKNA@"eaqPv [#rYs΀@bkl&iVzơKiޫWjJӢE-Z|ڀ G~~2H{'Lo3wz &{P ~,U2? ]Pa s._H*0w}ȐnT)Wo!M~,0) /XOյD$LH$X),z6_^bm=Pd/ 5IE :D�n $ !{IxEDߏF8�oSLbG~͑c_^Q0-g?vm*X`j64T)?@5CX)kf9Cp,&(ZÌ_NaAHciR2$u?:[a=b㎓An}!Jן0: /� 5Ԯ@" @+M-R +n=`}n6gmhm7ԶHm%-KD ;s d̛]^q%#$k!R$r z@ wmg܆)qw Xw bW7AN9pdOn0Qjuf;TY>(V GC?<^d�Fr05!lL/tC0"uT�5 /ꪌ2Ǜۧ( y)_,% f,Ir@/MM*q2-Zhq rZN����IENDB`����������������������������������������������������������������������������������������������������weboob-1.1/modules/pariskiwi/module.py��������������������������������������������������������������0000664�0000000�0000000�00000005716�12657170273�0020164�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.calendar import CapCalendarEvent, BaseCalendarEvent, CATEGORIES, TRANSP, STATUS from datetime import datetime, time from .browser import ParisKiwiBrowser __all__ = ['ParisKiwiModule'] class ParisKiwiModule(Module, CapCalendarEvent): NAME = 'pariskiwi' DESCRIPTION = u'ParisKiwi website' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = ParisKiwiBrowser ASSOCIATED_CATEGORIES = [CATEGORIES.CONCERT] def search_events(self, query): if self.has_matching_categories(query): return self.list_events(query.start_date, query.end_date or None) def list_events(self, date_from, date_to=None): for d in self.browser.list_events_all(): if self.matches_date(d, date_from, date_to): event = self.get_event(d['id']) if event is not None: yield event def get_event(self, _id): d = self.browser.get_event(_id) if not d: return None return self._make_event(d) def _make_event(self, d): event = BaseCalendarEvent(d['id']) event.city = u'Paris' event.url = d['url'] event.start_date = d['datetime'] event.end_date = datetime.combine(d['datetime'].date(), time.max) event.summary = d['summary'] event.category = CATEGORIES.CONCERT event.description = d['description'] event.status = STATUS.CONFIRMED event.transp = TRANSP.OPAQUE if 'price' in d: event.price = d['price'] if 'address' in d: event.location = d['address'] return event def _make_false_event(self): event = BaseCalendarEvent('0') event.start_date = event.end_date = datetime.utcfromtimestamp(0) event.summary = u'NON EXISTING EVENT' event.status = STATUS.CANCELLED event.category = CATEGORIES.CONCERT event.transp = TRANSP.OPAQUE return event def matches_date(self, d, date_from, date_to): if date_from and d['date'] < date_from: return False if date_to and d['date'] > date_from: return False return True ��������������������������������������������������weboob-1.1/modules/pariskiwi/pages.py���������������������������������������������������������������0000664�0000000�0000000�00000010027�12657170273�0017765�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page from datetime import datetime, time import json import lxml.html import re def date_from_id(_id): textdate = _id.split('_')[0] return datetime.strptime(textdate, '%m-%d-%Y') def id_from_path(title): return title.replace(' ', '_').split('/')[-1] def combine(dt, t): return datetime(dt.year, dt.month, dt.day, t.hour, t.minute) class PageList(Page): def get_events(self): raise NotImplementedError() class PageList2(Page): def list_events(self): events = list(self.unsorted_list()) events.sort(key=lambda d: (d['date'], d['id'])) return events def unsorted_list(self): # TODO paginate when there are >500 events for jpage in json.loads(self.document)['query']['allpages']: d = {} d['id'] = id_from_path(jpage['title']) d['date'] = date_from_id(d['id']) yield d class PageEvent(Page): def get_event(self): d = {} d['id'] = id_from_path(self.url) d['date'] = date_from_id(d['id']) d['datetime'] = date_from_id(d['id']) d['url'] = self.url html = lxml.html.fromstring(self.document) for div in html.iter('div'): if div.get('id') == 'bodyContent': break tags = [t for t in div if not callable(t.tag) and not t.get('id') and 'footer' not in t.get('class', '')] parts = [t.text_content().strip().replace('\n', ' ') for t in tags] description = '\n'.join(parts) summary = description.split('\n', 1)[0] self.div = div if not summary: return None d['summary'] = summary d['description'] = description for n, p in enumerate(parts): match = re.search(r'\b(\d\d?)h(\d\d)?\b', p) if match: d['hour'] = time(int(match.group(1)), int(match.group(2) or '0')) d['datetime'] = combine(d['date'], d['hour']) parts[n] = p[:match.start(0)] + p[match.end(0):] break for n, p in enumerate(parts): match = re.search(ur'\b(\d+([,.]\d+)?)\s*(euros\b|euro\b|€)', p) if match: d['price'] = float(match.group(1).replace(',', '.')) parts[n] = p[:match.start(0)] + p[match.end(0):] break address = [] for n, p in enumerate(parts): match = re.search(r'\d+[\s,]+(rue|boulevard|avenue)\s+.+', p, re.I) if match: address.append(match.group(0)) p = parts[n] = p[:match.start(0)] + p[match.end(0):] match = re.search(r'\b(75|92|93|94|78|77|95|91)\d\d\d\b.*', p) if match: address.append(match.group(0)) p = parts[n] = p[:match.start(0)] + p[match.end(0):] match = re.search(r'\b(m.tro|rer)\b.*', p, re.I) if match: address.append(match.group(0)) p = parts[n] = p[:match.start(0)] + p[match.end(0):] match = re.search(r'@\s+\w+(\s+[^.]+.*)?', p) # refuse '@foo' or '@ foo . plop' if match: address.append(match.group(0)) p = parts[n] = p[:match.start(0)] + p[match.end(0):] if address: d['address'] = ' '.join(address) return d ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pariskiwi/test.py����������������������������������������������������������������0000664�0000000�0000000�00000002661�12657170273�0017652�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from datetime import datetime class ParisKiwiTest(BackendTest): MODULE = 'pariskiwi' def test_pariskiwi_event(self): event = self.backend.get_event('11-9-2013_-Event_2') assert event assert event.location assert event.price assert event.summary assert event.url == 'http://pariskiwi.org/~parislagrise/mediawiki/index.php/Agenda/Detruire_Ennui_Paris/11-9-2013_-Event_2' assert event.start_date == datetime(2013, 11, 9, 20, 30) def test_pariskiwi_list(self): it = self.backend.list_events(datetime.now()) ev = it.next() assert ev is not None assert ev.start_date >= datetime.now() �������������������������������������������������������������������������������weboob-1.1/modules/parolesmania/��������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016765�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmania/__init__.py���������������������������������������������������������0000664�0000000�0000000�00000001446�12657170273�0021103�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import ParolesmaniaModule __all__ = ['ParolesmaniaModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmania/browser.py����������������������������������������������������������0000664�0000000�0000000�00000004175�12657170273�0021031�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import SongResultsPage, SonglyricsPage, ArtistResultsPage, ArtistSongsPage __all__ = ['ParolesmaniaBrowser'] class ParolesmaniaBrowser(Browser): DOMAIN = 'www.parolesmania.com' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.parolesmania.com/recherche.php\?c=title.*': SongResultsPage, 'http://www.parolesmania.com/recherche.php\?c=artist.*': ArtistResultsPage, 'http://www.parolesmania.com/paroles.*[0-9]*/paroles.*': SonglyricsPage, 'http://www.parolesmania.com/paroles[^/]*.html': ArtistSongsPage, } def iter_lyrics(self, criteria, pattern): crit = 'artist' if criteria != 'artist': crit = 'title' self.location('http://www.parolesmania.com/recherche.php?c=%s&k=%s' % (crit, pattern)) assert self.is_on_page(SongResultsPage) or self.is_on_page(ArtistResultsPage)\ or self.is_on_page(ArtistSongsPage) for lyr in self.page.iter_lyrics(): yield lyr def get_lyrics(self, id): ids = id.split('|') try: self.location('http://www.parolesmania.com/paroles_%s/paroles_%s.html' % (ids[0], ids[1])) except BrowserHTTPNotFound: return if self.is_on_page(SonglyricsPage): return self.page.get_lyrics(id) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmania/favicon.png���������������������������������������������������������0000664�0000000�0000000�00000012143�12657170273�0021121�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME5w~s��IDATx՛itu3,͒˶dY6%6+! %Є4 -Iڐ&) mB 큞' YZI Iz�oF6b.:, 1̝y̝6۶ Ð+{!{q[i\?<t|.yⷥ[ͺKX~w�_޲W:5(-߽�'-Ν[OٳҸpa5p\JJ$k/iz̹f)3h`ႅOI+UhY-SLN�f!ďr$WQ_W.̙ں5{'H'?�mQS倎P ̘QU_1&� q0 TZ#c$;` ׸~B*+R 4FV]or̙qa%%`N;(xU)`;)\5W-?KSַn];#q0F!@ �!� ]4;8WGRVSxfW YIaуhO#>lقgGG(� ¯D^GQiE>R� 0ZfA-[u͍0WZ#Lcsp�,>`$1\gg|5p)C{K)]'i ;=p{,u遇Oٍ][tqsa]N[S4OoTQa%sůR5:*5#ů5sJ,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QYr/ee^[oz/ȑg1D{s?lYrN9յɖ3uj鏹 e:47p٥+R჻0;n?2 cF&f›:A;GԩS 4n߳rbH@\I)J :_?5s]-hH%<DD(o0 <.!FZ y}_!6G}}~}>n$7|J^# " | Yo�'Q Bĕ=H: tٺd=?Pgbeq=e(2<bCJYHSb$qlc$RZDFHXeyd):՜E硣$2JJKReYhmc RFQGc"PU&]P(6Yqn<5RqI)%BČ1Da`b@*>, i9DGttQ[{ ,F:f4;wvо|<h1_0/R @('1�J/3]F#b ##l{,pQ(h\sbfㆍ g�X/@ Bu@L,�v(Y @1& PBZ}zf ,XL2QŲC&a``; 5 FhF1\ ijj 2cD%m'PƇ?x%D CG)xX{njJJ " a`I q�'"˜ꕋV]ǯqF1yO32:B*Uʂ-L1l|E܄1\GwÍ7 ~(X[!,Q !mB"#2S@`.rÇ.eղVΙD9MEy!r8Jz H2C̮/W.r-� )8V:,JtIMMV%^ X|UIscH7B.< Il>\3n%ֱ{w'Me'sXAԤ:x|˺?=H$S_ƥR(&?0(!Ҋi$K*شu7Ǻ$Zū[;6JkYFvY@_>ʳn'& <6>aźUh4mٺm'q?#C";:º;l~ qNE)sL40/}^^f]N8x\fϫ̎Pȱ>VK?Eg`T!m:OrޫFiU.򵠆WKA{8i8 :2!x:Q5|n)Ncs)%TV'y*y_h:ZڝfC>8qF8OG̥Ru*]HS ЏBǰ1qD?V?2ժ9N+nw3JV-{a\^E87h5ȐD1s;]AϢb!Schu?V0??Fp} M}0X!؆8M`qh$)g +. +Pw\q�Idd䒱ZN('EFe,�B3d$GLYc>1TWASt%BF['.Bˈ5LTXc{8lIVm@;*|"B[3F}$:IVP=MD9ŚOkgxq>sRlq8!{cAmA5}FqTFa(ON3~-nl/C _����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmania/module.py�����������������������������������������������������������0000664�0000000�0000000�00000003223�12657170273�0020624�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.lyrics import CapLyrics, SongLyrics from weboob.tools.backend import Module from .browser import ParolesmaniaBrowser from urllib import quote_plus __all__ = ['ParolesmaniaModule'] class ParolesmaniaModule(Module, CapLyrics): NAME = 'parolesmania' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'Paroles Mania lyrics website' LICENSE = 'AGPLv3+' BROWSER = ParolesmaniaBrowser def get_lyrics(self, id): return self.browser.get_lyrics(id) def iter_lyrics(self, criteria, pattern): return self.browser.iter_lyrics(criteria, quote_plus(pattern.encode('utf-8'))) def fill_songlyrics(self, songlyrics, fields): if 'content' in fields: sl = self.get_lyrics(songlyrics.id) songlyrics.content = sl.content return songlyrics OBJECTS = { SongLyrics: fill_songlyrics } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmania/pages.py������������������������������������������������������������0000664�0000000�0000000�00000007114�12657170273�0020441�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.lyrics import SongLyrics from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page class ArtistResultsPage(Page): def iter_lyrics(self): for link in self.parser.select(self.document.getroot(), 'div#albums > h1 a'): artist = unicode(link.text_content()) href = link.attrib.get('href', '') if href.startswith('/paroles'): self.browser.location('http://www.parolesmania.com%s' % href) assert self.browser.is_on_page(ArtistSongsPage) for lyr in self.browser.page.iter_lyrics(artist): yield lyr class ArtistSongsPage(Page): def iter_lyrics(self, artist=None): if artist is None: artist = self.parser.select(self.document.getroot(), 'head > title', 1).text.replace('Paroles ', '') for link in self.parser.select(self.document.getroot(), 'div#albums a'): href = link.attrib.get('href', '') titleattrib = link.attrib.get('title', '') if href.startswith('/paroles') and not href.endswith('alpha.html') and titleattrib.startswith('Paroles '): title = unicode(link.text) ids = href.replace('/', '').replace('.html', '').split('paroles_') id = '%s|%s' % (ids[1], ids[2]) songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = NotLoaded yield songlyrics class SongResultsPage(Page): def iter_lyrics(self): for link in self.parser.select(self.document.getroot(), 'div#albums a'): artist = NotAvailable title = unicode(link.text.split(' - ')[0]) href = link.attrib.get('href', '') if href.startswith('/paroles') and not href.endswith('alpha.html'): ids = href.replace('/', '').replace('.html', '').split('paroles_') id = '%s|%s' % (ids[1], ids[2]) artist = unicode(link.text.split(' - ')[1]) songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = NotLoaded yield songlyrics class SonglyricsPage(Page): def get_lyrics(self, id): content = NotAvailable artist = NotAvailable title = NotAvailable lyrdiv = self.parser.select(self.document.getroot(), 'div#songlyrics_h') if len(lyrdiv) > 0: content = unicode(lyrdiv[0].text_content().strip()) infos = self.parser.select(self.document.getroot(), 'head > title', 1).text artist = unicode(infos.split(' - ')[1]) title = unicode(infos.split(' - ')[0].replace('Paroles ', '')) songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = content return songlyrics ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmania/test.py�������������������������������������������������������������0000664�0000000�0000000�00000003243�12657170273�0020320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.base import NotLoaded class ParolesmaniaTest(BackendTest): MODULE = 'parolesmania' def test_search_song_n_get(self): l_lyrics = list(self.backend.iter_lyrics('song', 'chien')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded full_lyr = self.backend.get_lyrics(songlyrics.id) assert full_lyr.id assert full_lyr.title assert full_lyr.artist assert full_lyr.content is not NotLoaded def test_search_artist(self): l_lyrics = list(self.backend.iter_lyrics('artist', 'boris')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmusique/������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017370�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmusique/__init__.py�������������������������������������������������������0000664�0000000�0000000�00000000115�12657170273�0021476�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import ParolesmusiqueModule __all__ = ['ParolesmusiqueModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmusique/browser.py��������������������������������������������������������0000664�0000000�0000000�00000003665�12657170273�0021437�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import SongResultsPage, SonglyricsPage, ArtistResultsPage, ArtistSongsPage, HomePage __all__ = ['ParolesmusiqueBrowser'] class ParolesmusiqueBrowser(Browser): DOMAIN = 'www.paroles-musique.com' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.paroles-musique.com': HomePage, 'http://www.paroles-musique.com/lyrics-paroles-0-.*,0.php': SongResultsPage, 'http://www.paroles-musique.com/lyrics-paroles-.*-0,0.php': ArtistResultsPage, 'http://www.paroles-musique.com/paroles-.*p[0-9]*': SonglyricsPage, 'http://www.paroles-musique.com/paroles-.*-lyrics,a[0-9]*': ArtistSongsPage, } def iter_lyrics(self, criteria, pattern): self.location('http://www.paroles-musique.com') assert self.is_on_page(HomePage) return self.page.iter_lyrics(criteria, pattern) def get_lyrics(self, id): try: self.location('http://www.paroles-musique.com/paroles-%s' % id) except BrowserHTTPNotFound: return if self.is_on_page(SonglyricsPage): return self.page.get_lyrics(id) ���������������������������������������������������������������������������weboob-1.1/modules/parolesmusique/favicon.png�������������������������������������������������������0000664�0000000�0000000�00000003213�12657170273�0021522�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME/=yO�� IDATx{ebjEyK^: k0aR'*/e],9bڍB [ii㺌AcE%**>úgI{`ywo}ߙYPt)d& H�:յK8m :G`:#Cu��L@{`J=Svk]_8ϱ:9=VYp"�VS$ 9e,PG&g@_#vCEjgw`):'2lՆR)RwC:6&#?kЩL"�k.Ճ[Wt:%ŎEXG h�<+R cc^90X ^h - @/{K&}X? V\ke�56V/ 2FJ-~[Mn@J`Q'>b�}fSnjɣn|.RhiYŸ~#A B:T s4O(nV5p l&m-9w]oElٴqM9!0 Ƈ><T�Dv: I;ZEB/Չ)l_-n1pqDa&e˶1oR`6;pA3y |XkD!覕E3%ˀJV'\#V�RpX:~�8,B xXxUA#M<^];E0MIn [uZMǾv(:Ϩvtd*}g~[kU2QK$>׋{ke.IכI@il%7X3 [7tMJ~@i�%" l;y;DL�ZWcў:%S*4U%S2G59-߫16%8ZbJ^ߺFN(8E2t긶;`@E4ǸxTBGvslIM2u$y}'SQj^hE˒tK)IUԀ1VwlTzS:yFZC+2jl |t2n*xCIgg/ϧg*4}rn091|UsTEP C P))@6#B3Y-s*JMXa|-6(G!MhjƨT-pjY2*0#M)IF6T;E97S,B3|/1PLHL`荵6ԣ6N(-zy{T5# |oklW"45?hcG*}LQ;R&I=ښ)0;^>Eq)i{r1˹?H~N$S(4#Eu]QN ]zti; & q]{/Ŋ"@7B`aaaaaaaaaaaaq9SM����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmusique/module.py���������������������������������������������������������0000664�0000000�0000000�00000003164�12657170273�0021233�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.lyrics import CapLyrics, SongLyrics from weboob.tools.backend import Module from .browser import ParolesmusiqueBrowser __all__ = ['ParolesmusiqueModule'] class ParolesmusiqueModule(Module, CapLyrics): NAME = 'parolesmusique' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'paroles-musique lyrics website' LICENSE = 'AGPLv3+' BROWSER = ParolesmusiqueBrowser def get_lyrics(self, id): return self.browser.get_lyrics(id) def iter_lyrics(self, criteria, pattern): return self.browser.iter_lyrics(criteria, pattern.encode('utf-8')) def fill_songlyrics(self, songlyrics, fields): if 'content' in fields: sl = self.get_lyrics(songlyrics.id) songlyrics.content = sl.content return songlyrics OBJECTS = { SongLyrics: fill_songlyrics } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesmusique/pages.py����������������������������������������������������������0000664�0000000�0000000�00000006674�12657170273�0021056�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.lyrics import SongLyrics from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page class HomePage(Page): def iter_lyrics(self, criteria, pattern): self.browser.select_form(name='rechercher') if criteria == 'artist': self.browser['termes_a'] = pattern else: self.browser['termes_t'] = pattern self.browser.submit() assert self.browser.is_on_page(SongResultsPage) or self.browser.is_on_page(ArtistResultsPage) for lyr in self.browser.page.iter_lyrics(): yield lyr class ArtistResultsPage(Page): def iter_lyrics(self): for link in self.parser.select(self.document.getroot(), 'div.cont_cat table a.std'): artist = unicode(link.text_content()) self.browser.location('http://www.paroles-musique.com%s' % link.attrib.get('href', '')) assert self.browser.is_on_page(ArtistSongsPage) for lyr in self.browser.page.iter_lyrics(artist): yield lyr class ArtistSongsPage(Page): def iter_lyrics(self, artist): for link in self.parser.select(self.document.getroot(), 'div.cont_catA div.art_scroll a'): href = link.attrib.get('href', '') if href.startswith('./paroles'): title = unicode(link.text) id = href.replace('./paroles-', '') songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = NotLoaded yield songlyrics class SongResultsPage(Page): def iter_lyrics(self): first = True for tr in self.parser.select(self.document.getroot(), 'div.cont_cat table tr'): if first: first = False continue artist = NotAvailable links = self.parser.select(tr, 'a.std') title = unicode(links[0].text) id = links[0].attrib.get('href', '').replace('/paroles-', '') artist = unicode(links[1].text) songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = NotLoaded yield songlyrics class SonglyricsPage(Page): def get_lyrics(self, id): artist = NotAvailable title = NotAvailable content = unicode(self.parser.select(self.document.getroot(), 'div#lyr_scroll', 1).text_content().strip()) infos = self.parser.select(self.document.getroot(), 'h2.lyrics > font') artist = unicode(infos[0].text) title = unicode(infos[1].text) songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = content return songlyrics ��������������������������������������������������������������������weboob-1.1/modules/parolesmusique/test.py�����������������������������������������������������������0000664�0000000�0000000�00000003247�12657170273�0020727�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.base import NotLoaded class ParolesmusiqueTest(BackendTest): MODULE = 'parolesmusique' def test_search_song_n_get(self): l_lyrics = list(self.backend.iter_lyrics('song', 'chien')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded full_lyr = self.backend.get_lyrics(songlyrics.id) assert full_lyr.id assert full_lyr.title assert full_lyr.artist assert full_lyr.content is not NotLoaded def test_search_artist(self): l_lyrics = list(self.backend.iter_lyrics('artist', 'boris')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesnet/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016466�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesnet/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000000105�12657170273�0020573�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import ParolesnetModule __all__ = ['ParolesnetModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesnet/browser.py������������������������������������������������������������0000664�0000000�0000000�00000003322�12657170273�0020523�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import ResultsPage, SonglyricsPage, ArtistSongsPage, HomePage __all__ = ['ParolesnetBrowser'] class ParolesnetBrowser(Browser): DOMAIN = 'www.paroles.net' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.paroles.net': HomePage, 'http://www.paroles.net/search': ResultsPage, 'http://www.paroles.net/.*/paroles-.*': SonglyricsPage, 'http://www.paroles.net/[a-z\-]*': ArtistSongsPage } def iter_lyrics(self, criteria, pattern): self.location('http://www.paroles.net') assert self.is_on_page(HomePage) return self.page.iter_lyrics(criteria, pattern) def get_lyrics(self, id): try: self.location('http://www.paroles.net/%s' % id) except BrowserHTTPNotFound: return if self.is_on_page(SonglyricsPage): return self.page.get_lyrics(id) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesnet/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000002574�12657170273�0020631�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME  *'h(��IDATx[VU,S(gl`f3 Jbf]^Pm" */TD,Rbd+ 8i53(~c˷ٗ^ksq&es݀@);qKr& }+`q"q0<@ `,p8`P:7p?+֠yTiPm?Pks)XgRf0\ �js4}&`]"2A(@O`|"j7G@W`0;ٝ:WՔ.ѱKDC@܅ Im ҉q.0<!l`1 x1s Թ|NVhjƭv3{l TaN2 Xn|ViUf{uKZc^ךx<unV`0�hsD1un(�Chnچl-2vC99&"s95m&"z-RB�%";SW QHNz} Y]Ve&0}lHpX_ ŒL[}Ԩ}XZo�$unLnLgrW"T,tIM ϶cVkLۖ?�끥FDԹ-i:̋�{<#1S5{Xv?wiγwk |ssƷok)PV&/ ҀuDdB۲Lqm({C�|ʺ[p 0xU˝@5CsE@"�땈щJ:I끚D)y\�{�] x`F"!R})X὿]|wyKO`_P/% *=-p~+}5'81 Xoow6) �{e!!z9_B:}Y!@Qb~Fj=Lי z!.Eūf1UkN?o{Ú!۩^N7@g]v#{`yG׳I@&W!Yϱ~5{[=pSG�{A/{BKϐB•7ߞd0-9*}=-ȉ}t=u#""""""""""""""""""[\W8f����IENDB`������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesnet/module.py�������������������������������������������������������������0000664�0000000�0000000�00000003134�12657170273�0020326�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.lyrics import CapLyrics, SongLyrics from weboob.tools.backend import Module from .browser import ParolesnetBrowser __all__ = ['ParolesnetModule'] class ParolesnetModule(Module, CapLyrics): NAME = 'parolesnet' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'paroles.net lyrics website' LICENSE = 'AGPLv3+' BROWSER = ParolesnetBrowser def get_lyrics(self, id): return self.browser.get_lyrics(id) def iter_lyrics(self, criteria, pattern): return self.browser.iter_lyrics(criteria, pattern.encode('utf-8')) def fill_songlyrics(self, songlyrics, fields): if 'content' in fields: sl = self.get_lyrics(songlyrics.id) songlyrics.content = sl.content return songlyrics OBJECTS = { SongLyrics: fill_songlyrics } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/parolesnet/pages.py��������������������������������������������������������������0000664�0000000�0000000�00000006647�12657170273�0020154�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.lyrics import SongLyrics from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page class HomePage(Page): def iter_lyrics(self, criteria, pattern): self.browser.select_form(nr=0) self.browser['search'] = pattern self.browser.submit() assert self.browser.is_on_page(ResultsPage) for lyr in self.browser.page.iter_lyrics(criteria): yield lyr class ResultsPage(Page): def iter_lyrics(self, criteria): for link in self.parser.select(self.document.getroot(), 'div.box-content td.song-name a'): href = link.attrib.get('href','') if criteria == 'artist': if len(href.split('/')) != 4: continue else: self.browser.location('%s' % href) assert self.browser.is_on_page(ArtistSongsPage) or self.browser.is_on_page(SonglyricsPage) for lyr in self.browser.page.iter_lyrics(): yield lyr else: if len(href.split('/')) != 5: continue else: artist = unicode(self.parser.select(link.getparent().getparent().getparent(), 'td.song-artist > p', 1).text.strip()) title = unicode(link.text) id = unicode(link.attrib.get('href', '').replace('http://www.paroles.net/','')) lyr = SongLyrics(id, title) lyr.artist = artist yield lyr class ArtistSongsPage(Page): def iter_lyrics(self): artist = unicode(self.parser.select(self.document.getroot(), 'span[itemprop=name]', 1).text) for link in self.parser.select(self.document.getroot(), 'td.song-name > p[itemprop=name] > a[itemprop=url]'): href = unicode(link.attrib.get('href', '')) title = unicode(link.text) id = href.replace('http://www.paroles.net/', '') songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = NotLoaded yield songlyrics class SonglyricsPage(Page): def get_lyrics(self, id): artist = NotAvailable title = NotAvailable content = unicode(self.parser.select(self.document.getroot(), 'div.song-text', 1).text_content().strip()) artist = unicode(self.parser.select(self.document.getroot(), 'span[property$=artist]', 1).text) title = unicode(self.parser.select(self.document.getroot(), 'span[property$=name]', 1).text) songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = content return songlyrics �����������������������������������������������������������������������������������������weboob-1.1/modules/parolesnet/test.py���������������������������������������������������������������0000664�0000000�0000000�00000003237�12657170273�0020024�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.base import NotLoaded class ParolesnetTest(BackendTest): MODULE = 'parolesnet' def test_search_song_n_get(self): l_lyrics = list(self.backend.iter_lyrics('song', 'chien')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded full_lyr = self.backend.get_lyrics(songlyrics.id) assert full_lyr.id assert full_lyr.title assert full_lyr.artist assert full_lyr.content is not NotLoaded def test_search_artist(self): l_lyrics = list(self.backend.iter_lyrics('artist', 'boris')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastealacon/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016604�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastealacon/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000001445�12657170273�0020721�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import PastealaconModule __all__ = ['PastealaconModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastealacon/browser.py�����������������������������������������������������������0000664�0000000�0000000�00000007226�12657170273�0020650�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.paste import BasePaste, PasteNotFound from weboob.browser.filters.standard import CleanText, DateTime, Env, RawText, Regexp from weboob.browser.pages import HTMLPage from weboob.browser.browsers import PagesBrowser from weboob.browser.url import URL from weboob.browser.elements import ItemElement, method from weboob.exceptions import BrowserHTTPNotFound class Spam(Exception): def __init__(self): super(Spam, self).__init__("Detected as spam and unable to handle the captcha") class PastealaconPaste(BasePaste): # all pastes are public public = True # TODO perhaps move this logic elsewhere, remove this and id2url from capability # (page_url is required by pastoob) @property def page_url(self): return '%s%s' % (PastealaconBrowser.BASEURL, self.id) class PastePage(HTMLPage): @method class fill_paste(ItemElement): klass = PastealaconPaste obj_id = Env('id') obj_title = Regexp(CleanText('id("content")/h3'), r'Posted by (.+) on .+ \(') obj__date = DateTime(Regexp(CleanText('id("content")/h3'), r'Posted by .+ on (.+) \(')) obj_contents = RawText('//textarea[@id="code"]') def parse(self, el): # there is no 404, try to detect if there really is a content if len(el.xpath('id("content")/div[@class="syntax"]//ol')) != 1: raise PasteNotFound() class CaptchaPage(HTMLPage): pass class PostPage(HTMLPage): def post(self, paste, expiration=None): form = self.get_form(name='editor') form['code2'] = paste.contents form['poster'] = paste.title if expiration: form['expiry'] = expiration form.submit() class PastealaconBrowser(PagesBrowser): BASEURL = 'http://paste.alacon.org/' paste = URL(r'(?P<id>\d+)', PastePage) captcha = URL(r'%s' % re.escape('pastebin.php?captcha=1'), CaptchaPage) raw = URL(r'%s(?P<id>\d+)' % re.escape('pastebin.php?dl=')) post = URL(r'$', PostPage) @paste.id2url def get_paste(self, url): url = self.absurl(url, base=True) m = self.paste.match(url) if m: return PastealaconPaste(m.groupdict()['id']) def fill_paste(self, paste): """ Get as much as information possible from the paste page """ self.paste.stay_or_go(id=paste.id) return self.page.fill_paste(paste) def get_contents(self, _id): """ Get the contents from the raw URL This is the fastest and safest method if you only want the content. Returns unicode. """ try: return self.raw.open(id=_id).text except BrowserHTTPNotFound: raise PasteNotFound() def post_paste(self, paste, expiration=None): self.post.stay_or_go().post(paste, expiration=expiration) if self.captcha.is_here(): raise Spam() self.page.fill_paste(paste) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastealacon/favicon.png����������������������������������������������������������0000664�0000000�0000000�00000004633�12657170273�0020745�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME7Uk���tEXtComment�Created with GIMPW��IDATx{T?;ٙ]XV\Qb.T j`F4GӐj1ilS[Fcc"ES1EQ4Z>hQ`]>f1gu2e7Mn2|={5PC 5PC GJA0P�: @ ,~|d G*`+PtZ_a`NUHGT,$|8`` cӋDz:z׊ <:? Pb` WŮLKUF| *x~V1̈́L56?>D(>2^<V_S1?dk2q>27c#vNP& ,?5D87"ij# =�dHL�HV3Y \Xύ9d(\W l !(xB�B&S&0B\qG+{4L/ld Upk8�`-Bϟ2zBU�flI4cg {mZ{{g/vA*{8�a_Zy{9S~=/_43ob}Wڶfo''CpgQv`۴aUypwBt;�כ<{Ułsύ 3|g u(-A t? -b`$yg"* M$O{Yk57ds m7IgW\xv3Å�'Qr},o!|u\+x{*?v€S`Ό545&x^.nk}HD"Dlw{p ht/IvNsِ4�],<bρ, `V&B׀diѪSZ\ew0aM-F+sE)zĥm,fvOI>0+]cAAklK=QEl2=oE6ś窼C87TG0dԓgk�c q.Ho(޻t^Ztt|#@X!'_79'hqNx rI+vudO_xj |l#4;|Ȝ|ޮ| <oKuؒŭٜG2a ):='�[h;h/c6Q[rCi'�@]ڂ(Ncf&ƌoI+MkO$imQFwu 18wЍ%oە~k�`; \K%C!@ I`BPn97ƭyjxkZ �qNf9z 㢯iM!x3?U N)h+} +a!:@y9/t_]E #hEO U4BZH+=Vvߊf AhFH I5k>wZ � N!d^+\B{QH +nv?v@ϿaTP,{Va#+H+~@N6|·:sP~gZ+4" !$*Ru'/} )@h5+ղvhKSZt$rra%R�;+h]*~^Oʇ;*hNy�^ؕjY=t 09teZAInf�`淓s.kDv)G!v\JMkY洫<Q"|�8][ړW�KB?!-AZqh@1ٗ��[Zִig!#a0Ғdg2f89AAɟ*Ϲ/ :p/{:�!$wnph^~5Nnb i'2Ri3{ ~:ޔ/C[k^)\5Fe'2H(/v<0z. JnQ^B&/ȑw[7{yPu*(b \OMK�z^]A9b~oxʗѐmw5#\ N%{|^6U`44ui5 t_x/<tjjj8.@=����IENDB`�����������������������������������������������������������������������������������������������������weboob-1.1/modules/pastealacon/module.py������������������������������������������������������������0000664�0000000�0000000�00000005271�12657170273�0020450�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.tools.capabilities.paste import BasePasteModule from weboob.tools.backend import Module from weboob.capabilities.base import NotLoaded from .browser import PastealaconBrowser, PastealaconPaste class PastealaconModule(Module, BasePasteModule): NAME = 'pastealacon' MAINTAINER = u'Laurent Bachelier' EMAIL = 'laurent@bachelier.name' VERSION = '1.1' DESCRIPTION = u'Paste à la con text sharing tool' LICENSE = 'AGPLv3+' BROWSER = PastealaconBrowser EXPIRATIONS = { 24 * 3600: 'd', 24 * 3600 * 30: 'm', False: 'f', } def new_paste(self, *args, **kwargs): return PastealaconPaste(*args, **kwargs) def can_post(self, contents, title=None, public=None, max_age=None): try: contents.encode('ISO-8859-1') except UnicodeEncodeError: return 0 if public is False: return 0 if max_age is not None: if self.get_closest_expiration(max_age) is None: return 0 # the "title" is filtered (does not even accepts dots) if not title or re.match('^\w+$', title) and len(title) <= 24: return 2 return 1 def get_paste(self, _id): return self.browser.get_paste(_id) def fill_paste(self, paste, fields): # if we only want the contents if fields == ['contents']: if paste.contents is NotLoaded: contents = self.browser.get_contents(paste.id) paste.contents = contents # get all fields elif fields is None or len(fields): self.browser.fill_paste(paste) return paste def post_paste(self, paste, max_age=None): if max_age is not None: expiration = self.get_closest_expiration(max_age) else: expiration = None self.browser.post_paste(paste, expiration=self.EXPIRATIONS.get(expiration)) OBJECTS = {PastealaconPaste: fill_paste} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastealacon/test.py��������������������������������������������������������������0000664�0000000�0000000�00000007506�12657170273�0020145�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.base import NotLoaded from weboob.capabilities.paste import PasteNotFound from .browser import Spam class PastealaconTest(BackendTest): MODULE = 'pastealacon' def _get_paste(self, _id): # html method p = self.backend.get_paste(_id) self.backend.fillobj(p, ['title']) assert p.title == u'ouiboube' assert p.page_url.startswith('http://paste.alacon.org/') assert u'héhéhé' in p.contents assert p.public is True # raw method p = self.backend.get_paste(_id) self.backend.fillobj(p, ['contents']) assert p.title is NotLoaded assert p.page_url.startswith('http://paste.alacon.org/') assert u'héhéhé' in p.contents assert p.public is True def test_post(self): p = self.backend.new_paste(None, title=u'ouiboube', contents=u'Weboob Test héhéhé') self.backend.post_paste(p, max_age=3600*24) assert p.id self.backend.fill_paste(p, ['title']) assert p.title == 'ouiboube' assert p.id in p.page_url assert p.public is True # test all get methods from the Paste we just created self._get_paste(p.id) # same but from the full URL self._get_paste('http://paste.alacon.org/'+p.id) def test_spam(self): p = self.backend.new_paste(None, title=u'viagra', contents=u'http://example.com/') self.assertRaises(Spam, self.backend.post_paste, p) def test_notfound(self): for _id in ('424242424242424242424242424242424242', 'http://paste.alacon.org/424242424242424242424242424242424242'): # html method p = self.backend.get_paste(_id) self.assertRaises(PasteNotFound, self.backend.fillobj, p, ['title']) # raw method p = self.backend.get_paste(_id) self.assertRaises(PasteNotFound, self.backend.fillobj, p, ['contents']) def test_checkurl(self): # call with an URL we can't handle with this backend assert self.backend.get_paste('http://pastebin.com/nJG9ZFG8') is None # same even with correct domain (IDs are numeric) assert self.backend.get_paste('http://paste.alacon.org/nJG9ZFG8') is None assert self.backend.get_paste('nJG9ZFG8') is None def test_can_post(self): assert 0 == self.backend.can_post(u'hello', public=False) assert 1 <= self.backend.can_post(u'hello', public=True) assert 0 == self.backend.can_post(u'hello', public=True, max_age=600) assert 1 <= self.backend.can_post(u'hello', public=True, max_age=3600*24) assert 1 <= self.backend.can_post(u'hello', public=True, max_age=3600*24*3) assert 1 <= self.backend.can_post(u'hello', public=True, max_age=False) assert 1 <= self.backend.can_post(u'hello', public=None, max_age=False) assert 1 <= self.backend.can_post(u'hello', public=True, max_age=3600*24*40) assert 1 <= self.backend.can_post(u'héhé', public=True) assert 0 == self.backend.can_post(u'hello ♥', public=True) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastebin/������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016117�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastebin/__init__.py�������������������������������������������������������������0000664�0000000�0000000�00000001437�12657170273�0020235�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import PastebinModule __all__ = ['PastebinModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastebin/browser.py��������������������������������������������������������������0000664�0000000�0000000�00000016517�12657170273�0020166�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.paste import BasePaste, PasteNotFound from weboob.browser import LoginBrowser, need_login, URL from weboob.browser.pages import HTMLPage, RawPage from weboob.browser.elements import ItemElement, method from weboob.browser.filters.standard import Base, CleanText, DateTime, Env, Filter, FilterError, RawText from weboob.browser.filters.html import Attr from weboob.exceptions import BrowserHTTPNotFound, BrowserIncorrectPassword, BrowserUnavailable class PastebinPaste(BasePaste): # TODO perhaps move this logic elsewhere, remove this and id2url from capability # (page_url is required by pastoob) @classmethod def id2url(cls, _id): return '%s%s' % (PastebinBrowser.BASEURL, _id) class BasePastebinPage(HTMLPage): @property def logged(self): for link in self.doc.xpath('//div[@id="header_bottom"]/ul[@class="top_menu"]//ul/li/a'): if link.text == 'logout': return True if link.text == 'login': return False raise BrowserUnavailable('Unable to determine login state') class LoginPage(BasePastebinPage): def login(self, username, password): form = self.get_form('myform') form['user_name'] = username form['user_password'] = password form.submit() class CleanVisibility(Filter): def filter(self, txt): if txt.startswith('Public'): return True if txt.startswith('Unlisted') or txt.startswith('Private'): return False return self.default_or_raise(FilterError('Unable to get the paste visibility')) class PastePage(BasePastebinPage): @method class fill_paste(ItemElement): klass = PastebinPaste def parse(self, el): self.env['header'] = el.find('//div[@id="content_left"]//div[@class="paste_box_info"]') obj_id = Env('id') obj_title = Base(Env('header'), CleanText('.//div[@class="paste_box_line1"]//h1')) obj_contents = RawText('//textarea[@id="paste_code"]') obj_public = Base( Env('header'), CleanVisibility(Attr('.//div[@class="paste_box_line1"]//img', 'title'))) obj__date = Base( Env('header'), DateTime(Attr('.//div[@class="paste_box_line2"]/span[1]', 'title'))) class PostPage(BasePastebinPage): def post(self, paste, expiration=None): form = self.get_form(name='myform') form['paste_code'] = paste.contents form['paste_name'] = paste.title if paste.public is True: form['paste_private'] = '0' elif paste.public is False: form['paste_private'] = '1' if expiration: form['paste_expire_date'] = expiration form.submit() class WarningPage(BasePastebinPage): def __init__(self, *args, **kwargs): raise LimitExceeded() class UserPage(BasePastebinPage): pass class BadAPIRequest(BrowserUnavailable): pass class LimitExceeded(BrowserUnavailable): pass class PastebinBrowser(LoginBrowser): BASEURL = 'http://pastebin.com/' warning = URL('warning\.php\?p=(?P<id>\d+)', WarningPage) api = URL('api/api_post\.php', RawPage) apilogin = URL('api/api_login\.php', RawPage) login = URL('login', LoginPage) userprofile = URL('u/(?P<username>.+)', UserPage) postpage = URL('$', PostPage) paste = URL('(?P<id>\w+)', PastePage) raw = URL('raw\.php\?i=(?P<id>\w+)', RawPage) def __init__(self, api_key, *args, **kwargs): super(PastebinBrowser, self).__init__(*args, **kwargs) self.api_key = api_key self.user_key = None # being connected is optionnal at the module level, so require # login only if an username is configured if self.username: self.post = need_login(self.post_paste) def fill_paste(self, paste): """ Get as much as information possible from the paste page """ try: return self.paste.stay_or_go(id=paste.id).fill_paste(paste) except BrowserHTTPNotFound: raise PasteNotFound() @paste.id2url def get_paste(self, url): m = self.paste.match(url) if m: return PastebinPaste(m.groupdict()['id']) def get_contents(self, _id): """ Get the contents from the raw URL This is the fastest and safest method if you only want the content. Returns unicode. """ try: return self.raw.open(id=_id).response.text except BrowserHTTPNotFound: raise PasteNotFound() def post_paste(self, paste, expiration=None): self.postpage.stay_or_go().post(paste, expiration=expiration) # We cannot call fill_paste because we often have a captcha # anti-spam page, and do not detect it. paste.id = self.page.params['id'] def api_post_paste(self, paste, expiration=None): data = {'api_dev_key': self.api_key, 'api_option': 'paste', 'api_paste_code': paste.contents} if self.password: data['api_user_key'] = self.api_login() if paste.public is True: data['api_paste_private'] = '0' elif paste.public is False: data['api_paste_private'] = '1' if paste.title: data['api_paste_name'] = paste.title if expiration: data['api_paste_expire_date'] = expiration res = self.open(self.api.build(), data=data, data_encoding='utf-8').text self._validate_api_response(res) paste.id = self.paste.match(res).groupdict()['id'] def api_login(self): # "The api_user_key does not expire." # TODO store it on disk if self.user_key: return self.user_key data = {'api_dev_key': self.api_key, 'api_user_name': self.username, 'api_user_password': self.password} res = self.open(self.apilogin.build(), data=data, data_encoding='utf-8').text try: self._validate_api_response(res) except BadAPIRequest as e: if str(e) == 'invalid login': raise BrowserIncorrectPassword() else: raise e self.user_key = res return res # TODO make it into a Page? def _validate_api_response(self, res): matches = re.match('Bad API request, (?P<error>.+)', res) if matches: raise BadAPIRequest(matches.groupdict().get('error')) def do_login(self): self.login.stay_or_go().login() self.page.login(self.username, self.password) if not self.page.logged: raise BrowserIncorrectPassword() ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastebin/favicon.png�������������������������������������������������������������0000664�0000000�0000000�00000004163�12657170273�0020256�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������C��� pHYs����od���tIME9 O ��IDATxMl\7o潱'2N*RG�"PYD 6:BeQ؄n*6,`Y  %$$nZ06I1|yg1@y3:ͻw |Iׯ�e`(@uttw9V?dÇURAA$c1F.WB`n lK%C(lFF[ot].FyꩧĚ>`ff)s%Iسl ls98s>}W/yiX⯼:tD)A>�l,G-Q8 YOWWxܠl#r=044$V<jtt>R$K6;E v킞`NK }w H6 <twof``3]]fff\.{墳{U+k}ǁlTuxYDॗbC2 q,k3رB!ϋ/cǎH$V PJ!|Ϗ6"vL&^:;]ˌy4R8nL$JQ(s^ XAP >qؾ}Qw�MlpQmL&d2XR"||ɵke ]J0`G0*LNBg)%B-Rja ZZ R4ssyFFh4x�FpmກeEH&cD"r龫>}۶16m`h7rpWӠ >@h4<om.&IR RJL@b`YQ:;;)8@)HH$u RuoTՐ /Yuq ]1MR0\HyffL�', Mߺ0]im0 )mLS =%ybICJ<ku6ͦxxDlr Q*8 |_13csȗWXIm\ԋuMv:u?^?4z… l|ޣZҨV% ضu&}6 /|PJQLO<޽ 4#RXIb�owx͓ I=.Ś@`B!}=RR1  ر19"U&'=^)45֯Oqc{)$vʖ-]4 Hllض8OiZN$7f8wnݻPm<x>f`gyݷ3J%xg~}/B 'N311O6[ʕYΜi~ڷĄD�K|\xbdbQU6lݝfbb+WJ4eb5Ν˳<�}4-B[[ݴ NgH&GI&'vpIWn�UmiR- @$/:G8mH䓿z$w {oL|;0 HDʉj[_;aPebMF!52.g.G)M 2n%`Æv 7e"t]'P(JK4VO,L GbR`6]Ks|D2oj"mFgg'r9|_2\WqrZ4XV˂hTbD"7)XyȈ8xzW)˚#^ Ccvb4C4'{c{CiSdP.WI[o)~gl~w@2AP/&X߰+_ P/ݲ:￟B];CLO(?~9a čuZٴ9{K71C طi<:BDH0V*CS*qR+ hx<ccǡ옂����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastebin/module.py���������������������������������������������������������������0000664�0000000�0000000�00000006376�12657170273�0017772�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.base import NotLoaded from weboob.tools.backend import BackendConfig, Module from weboob.tools.capabilities.paste import BasePasteModule from weboob.tools.value import Value, ValueBackendPassword from .browser import PastebinBrowser, PastebinPaste class PastebinModule(Module, BasePasteModule): NAME = 'pastebin' MAINTAINER = u'Laurent Bachelier' EMAIL = 'laurent@bachelier.name' VERSION = '1.1' DESCRIPTION = 'Pastebin text sharing service' LICENSE = 'AGPLv3+' BROWSER = PastebinBrowser CONFIG = BackendConfig( Value('username', label='Optional username', default=''), ValueBackendPassword('password', label='Optional password', default=''), ValueBackendPassword('api_key', label='Optional API key', default='', noprompt=True), ) EXPIRATIONS = { 600: '10M', 3600: '1H', 3600 * 24: '1D', 3600 * 24 * 30: '1M', False: 'N', } def create_default_browser(self): username = self.config['username'].get() if username: password = self.config['password'].get() else: password = None return self.create_browser(self.config['api_key'].get() or None, username, password) def new_paste(self, *args, **kwargs): return PastebinPaste(*args, **kwargs) def can_post(self, contents, title=None, public=None, max_age=None): if max_age is not None: if self.get_closest_expiration(max_age) is None: return 0 if not title or len(title) <= 60: return 2 return 1 def get_paste(self, _id): return self.browser.get_paste(_id) def fill_paste(self, paste, fields): # if we only want the contents if fields == ['contents']: if paste.contents is NotLoaded: paste.contents = self.browser.get_contents(paste.id) # get all fields elif fields is None or len(fields): self.browser.fill_paste(paste) return paste def post_paste(self, paste, max_age=None, use_api=True): if max_age is not None: expiration = self.get_closest_expiration(max_age) else: expiration = None if use_api and self.config.get('api_key').get(): self.browser.api_post_paste(paste, expiration=self.EXPIRATIONS.get(expiration)) else: self.browser.post_paste(paste, expiration=self.EXPIRATIONS.get(expiration)) OBJECTS = {PastebinPaste: fill_paste} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pastebin/test.py�����������������������������������������������������������������0000664�0000000�0000000�00000010764�12657170273�0017460�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.base import NotLoaded from weboob.capabilities.paste import PasteNotFound from weboob.tools.test import BackendTest, SkipTest from .browser import LimitExceeded class PastebinTest(BackendTest): MODULE = 'pastebin' def test_get_paste(self): for _id in ('7HmXwzyt', 'http://pastebin.com/7HmXwzyt'): # html method p = self.backend.get_paste(_id) self.backend.fillobj(p, ['title']) assert p.title == u'plop' assert p.page_url == 'http://pastebin.com/7HmXwzyt' assert p.contents == u'prout' assert p.public is True assert p._date.year == 2011 # raw method p = self.backend.get_paste(_id) self.backend.fillobj(p, ['contents']) assert p.title is NotLoaded assert p.page_url == 'http://pastebin.com/7HmXwzyt' assert p.contents == u'prout' assert p.public is NotLoaded def test_post(self): # we cannot test public pastes, as the website sometimes forces them as private # there seems to be a very low post per day limit, even when logged in p = self.backend.new_paste(None, title=u'ouiboube', contents=u'Weboob Test', public=False) try: self.backend.post_paste(p, max_age=600) except LimitExceeded: raise SkipTest("Limit exceeded") assert p.id assert not p.id.startswith('http://') self.backend.fill_paste(p, ['title']) assert p.title == u'ouiboube' assert p.id in p.page_url assert p.public is False def test_specialchars(self): # post a paste and get the contents through the HTML response p1 = self.backend.new_paste(None, title=u'ouiboube', contents=u'Weboob <test>¿¡', public=False) try: self.backend.post_paste(p1, max_age=600) except LimitExceeded: raise SkipTest("Limit exceeded") assert p1.id # not related to testing special chars, but check if the paste is # really private since test_post() tests the contrary assert p1.public is False # this should use the raw method to get the contents p2 = self.backend.get_paste(p1.id) self.backend.fillobj(p2, ['contents']) assert p2.contents == p1.contents assert p2.public is NotLoaded def test_notfound(self): for _id in ('weboooooooooooooooooooooooooob', 'http://pastebin.com/weboooooooooooooooooooooooooob'): # html method p = self.backend.get_paste(_id) self.assertRaises(PasteNotFound, self.backend.fillobj, p, ['title']) # raw method p = self.backend.get_paste(_id) self.assertRaises(PasteNotFound, self.backend.fillobj, p, ['contents']) def test_checkurl(self): # call with an URL we can't handle with this backend assert self.backend.get_paste('http://pastealacon.com/1') is None def test_can_post(self): assert self.backend.can_post(u'hello', public=None) > 0 assert self.backend.can_post(u'hello', public=True) > 0 assert self.backend.can_post(u'hello', public=False) > 0 assert self.backend.can_post(u'hello', public=True, max_age=600) > 0 assert self.backend.can_post(u'hello', public=True, max_age=3600*24) > 0 assert self.backend.can_post(u'hello', public=True, max_age=3600*24*3) > 0 assert self.backend.can_post(u'hello', public=True, max_age=False) > 0 assert self.backend.can_post(u'hello', public=None, max_age=False) > 0 assert self.backend.can_post(u'hello', public=True, max_age=3600*24*40) > 0 assert self.backend.can_post(u'héhé', public=True) > 0 assert self.backend.can_post(u'hello ♥', public=True) > 0 ������������weboob-1.1/modules/paypal/��������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015600�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/paypal/__init__.py���������������������������������������������������������������0000664�0000000�0000000�00000001441�12657170273�0017711�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import PaypalModule __all__ = ['PaypalModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/paypal/browser.py����������������������������������������������������������������0000664�0000000�0000000�00000020367�12657170273�0017645�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib import datetime from dateutil.relativedelta import relativedelta from weboob.exceptions import BrowserHTTPError, BrowserIncorrectPassword from weboob.browser.browsers import LoginBrowser, need_login from weboob.browser.url import URL from .pages import PromoPage, LoginPage, AccountPage, UselessPage, HomePage, ProHistoryPage, PartHistoryPage, HistoryDetailsPage, HistoryPaybackPage, ErrorPage __all__ = ['Paypal'] class Paypal(LoginBrowser): BASEURL = 'https://www.paypal.com' login = URL('https://\w+.paypal.com/signin/.*', '/cgi-bin/webscr\?cmd=_login-submit.+$', LoginPage) useless = URL('/cgi-bin/webscr\?cmd=_login-processing.+$', '/cgi-bin/webscr\?cmd=_account.*$', '/cgi-bin/webscr\?cmd=_login-done.+$', UselessPage) home = URL('/cgi-bin/webscr\?cmd=_home&country_lang.x=true$', 'https://\w+.paypal.com/webapps/business/\?country_lang.x=true', 'https://\w+.paypal.com/myaccount/\?nav=0.0', 'https://\w+.paypal.com/webapps/business/\?nav=0.0', 'https://\w+.paypal.com/myaccount/$', HomePage) error = URL('/auth/validatecaptcha$', ErrorPage) history_details = URL('https://\w+.paypal.com/cgi-bin/webscr\?cmd=_history-details-from-hub&id=[\-A-Z0-9]+$', 'https://\w+.paypal.com/myaccount/transaction/details/[\-A-Z0-9]+$', HistoryDetailsPage) history_payback = URL('https://history.paypal.com/fr/cgi-bin/webscr\?cmd=_history-details.*', HistoryPaybackPage) promo = URL('https://www.paypal.com/fr/webapps/mpp/clickthru/paypal-app-promo-2.*', PromoPage) account = URL('https://www.paypal.com/businessexp/money', AccountPage) pro_history = URL('https://\w+.paypal.com/webapps/business/activity\?.*', 'https://\w+.paypal.com/businessexp/summary', ProHistoryPage) part_history = URL('https://\w+.paypal.com/myaccount/activity/.*', PartHistoryPage) TIMEOUT = 180.0 BEGINNING = datetime.date.today() - relativedelta(months=24) account_type = None def find_account_type(self): try: self.location('https://www.paypal.com/myaccount/') self.account_type = "perso" except: self.account_type = "pro" def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.login.is_here(): self.location('/signin/') response = self.open(self.page.get_script_url()) token, csrf = self.page.get_token_and_csrf(response.text) data = {} data['ads_token_js'] = token data['_csrf'] = csrf data = urllib.urlencode(data) self.open('/auth/verifychallenge', data=data) res = self.page.login(self.username, self.password) if 'LoginFailed' in res.content or 'Sorry, we can\'t log you in' in res.content or self.login.is_here() or self.error.is_here(): raise BrowserIncorrectPassword() self.find_account_type() @need_login def get_accounts(self): self.account.stay_or_go() return self.page.get_accounts() @need_login def get_account(self, _id): self.account.stay_or_go() return self.page.get_account(_id) @need_login def get_personal_history(self, account): s = self.BEGINNING.strftime('%Y-%m-%d') e = datetime.date.today().strftime('%Y-%m-%d') data = {'transactionType': 'ALL', 'timeFrame': '90', 'nextPageToken': '', 'freeTextSearch': '', 'startDate': s, 'endDate': e, } # The response is sometimes not the one we expect. for i in xrange(3): try: self.location('https://www.paypal.com/myaccount/activity/filter?%s' % urllib.urlencode(data), headers={'Accept' : 'application/json, text/javascript, */*; q=0.01'}) if self.page.transaction_left(): return self.page.iter_transactions(account) return iter([]) except KeyError as e: self.logger.warning("retrying to get activity ...") raise e @need_login def get_download_history(self, account, step_min=None, step_max=None): if self.account_type == "perso": for i in self.get_personal_history(account): yield i else: if step_min is None and step_max is None: step_min = 30 step_max = 180 def fetch_fn(start, end): if self.download_history(start, end): return self.page.iter_transactions(account) return iter([]) assert step_max <= 365*2 # PayPal limitations as of 2014-06-16 try: for i in self.smart_fetch(beginning=self.BEGINNING, end=datetime.date.today(), step_min=step_min, step_max=step_max, fetch_fn=fetch_fn): yield i except BrowserHTTPError: self.logger.warning("Paypal timeout") def smart_fetch(self, beginning, end, step_min, step_max, fetch_fn): """ Fetches transactions in small chunks to avoid request timeouts. Time period of each requested chunk is adjusted dynamically. """ FACTOR = 1.5 step = step_min while end > beginning: start = end - datetime.timedelta(step) chunk = list(fetch_fn(start, end)) end = start - datetime.timedelta(1) if len(chunk) > 40: # If there're too much transactions in current period, decrease # the period. step = max(step_min, step/FACTOR) else: # If there's no transactions, or only a bit, in current period, # increase the period. step = min(step_max, step*FACTOR) for trans in chunk: yield trans def download_history(self, start, end): """ Download history. However, it is not normalized, and sometimes the download is refused and sent later by mail. """ s = start.strftime('%d/%m/%Y') e = end.strftime('%d/%m/%Y') # Settings a big magic number so we hope to get all transactions for the period LIMIT = '9999' self.location('https://www.paypal.com/webapps/business/activity?fromdate=' + s + '&todate=' + e + '&transactiontype=ALL_TRANSACTIONS¤cy=ALL_TRANSACTIONS_CURRENCY&limit=' + LIMIT + '&archive=true', headers={'X-Requested-With': 'XMLHttpRequest'}) return self.page.transaction_left() def transfer(self, from_id, to_id, amount, reason=None): raise NotImplementedError() def convert_amount(self, account, trans, link): self.location(link) if self.history_details.is_here(): cc = self.page.get_converted_amount(account) return cc def check_for_payback(self, trans, link): self.location(link) if self.history_details.is_here(): url = self.page.get_payback_url() if url: self.location(url) if self.history_payback.is_here(): return self.page.get_payback() return None, None, None, None �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/paypal/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000003335�12657170273�0017737�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq��IDATxYh\Uٗd5tbMi.Z "ڇOQ(>ЈTD#҅. QEVLifL&Üi朙;DAȽ{|߁EZ5i~ �Zۀ@ P L! |@pׯ]ru@t@0?4hb%;#702|`� @K��"<6�^{vkmX>St�21C3@:*wϱ x@U 2tUKF 2k6�[\rR0Z�tH�WfrJ$ sz:L';$&6;L3==URlWո6uݣ#cv'O0=B}SH. Ԩp8oΤ'f7.U߹/(Htߞ>aCdz;͹UsgYY_(p �4N4  HX۝>ӗ<f$ GH/ðuO%g׆BT` LɤcB="Pm*B�͌gP${EZ!09>ӎJTx/d g&Urӗ<�| |9&ғEiCV {sJ�KRN;shfs$b; lJoB�ZU8$v٩ׂ Zm t*B1ie*d�"͔.|N%g�NO(+2Q% ê]:1\VI@ <P'Y {UEH*� &ÖdTa^BIT�hUa #"#-*p(-*�tQYe**-hYF*�:v]=u GD)ҥ{ݰ&ݽkUK薶D(D%~k:4Ѷr5_V5xQ�".[g~^J$g ~Ea DžiTQlv;V7 *#*0nD]Y% ⇽؀!$ Ee4Zr=O%UeKյKذ95w"a\1�t:QUбa*F/yPM,^_S̷\|O ]PtXձyt_d91r{6fm^#?y>^ OM7< �,LuLӴqӅ`H?\)\WQYE]C øq\9Sqa`&U5u=^e+x|7HU~_T}�SQέk$Qz8 ktX{c%HvXr  :,bz�_�2. *1A@ ]Q-^/>j2�H˵=�Nc7jq@.'־+bCçI"$uT6F]m~'m/v:e*`f,GSlO%5Y�NΙ"�g% Bg!p8*Hv}�Q{,s.9х{O oiy#`"�R@wo۹qF_"-"/y Q6i����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/paypal/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000003613�12657170273�0017442�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import Paypal __all__ = ['PaypalModule'] class PaypalModule(Module, CapBank): NAME = 'paypal' MAINTAINER = u'Laurent Bachelier' EMAIL = 'laurent@bachelier.name' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'PayPal' CONFIG = BackendConfig(ValueBackendPassword('login', label='E-mail', masked=False), ValueBackendPassword('password', label='Password')) BROWSER = Paypal def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts().itervalues() def get_account(self, _id): account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): for history in self.browser.get_download_history(account): yield history ���������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/paypal/pages.py������������������������������������������������������������������0000664�0000000�0000000�00000024427�12657170273�0017262�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from decimal import Decimal import re from weboob.capabilities.bank import Account from weboob.capabilities.base import NotAvailable, Currency from weboob.exceptions import BrowserUnavailable from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage from weboob.browser.filters.standard import CleanText from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.date import parse_french_date from weboob.tools.js import Javascript class PromoPage(LoggedPage, HTMLPage): def on_load(self): # We land sometimes on this page, it's better to raise an unavailable browser # than an Incorrect Password raise BrowserUnavailable('Promo Page') class LoginPage(HTMLPage): def get_token_and_csrf(self, code): code1 = re.search('(function .*)\(function\(\)', code).group(1) # Another victory for the scrapper team # CommitStrip Data Wars code1 = re.sub('return typeof document!="undefined"&&typeof document.createAttribute!="undefined"', '1==1', code1) # now it checks if some browsers-only builtin variables are defined: # e+=function(e,t){return typeof navigator!="undefined"?e:t} js = Javascript('var navigator = {}; ' + code1) func_name = re.search(r'function (\w+)\(\)', code1).group(1) token = str(js.call(func_name)) csrf = re.search(r'csrf="\+encodeURIComponent\("(.*?)"\)', code).group(1) return token, csrf def login(self, login, password): #Paypal use this to check if we accept cookie self.browser.session.cookies.set('cookie_check', 'yes') form = self.get_form(name='login') form['login_email'] = login form['login_password'] = password return form.submit(headers={'X-Requested-With': 'XMLHttpRequest'}) def get_script_url(self): list1 = self.doc.xpath('//script') for s in list1: if 'src' in s.attrib and 'challenge' in s.attrib['src']: return s.attrib['src'] class ErrorPage(HTMLPage): pass class UselessPage(LoggedPage, HTMLPage): pass class HomePage(LoggedPage, HTMLPage): pass class AccountPage(LoggedPage, HTMLPage): def get_account(self, _id): return self.get_accounts().get(_id) def get_accounts(self): accounts = {} content = self.doc.xpath('//div[@id="moneyPage"]')[0] # Primary currency account primary_account = Account() primary_account.type = Account.TYPE_CHECKING try: balance = CleanText('.')(content.xpath('//div[contains(@class, "col-md-6")][contains(@class, "available")]')[0]) except IndexError: primary_account.id = 'EUR' primary_account.currency = u'EUR' primary_account.balance = NotAvailable primary_account.label = u'%s' % (self.browser.username) else: primary_account.currency = Account.get_currency(balance) primary_account.id = unicode(primary_account.currency) primary_account.balance = Decimal(FrenchTransaction.clean_amount(balance)) primary_account.label = u'%s %s*' % (self.browser.username, primary_account.currency) accounts[primary_account.id] = primary_account return accounts class HistoryPage(LoggedPage): def iter_transactions(self, account): for trans in self.parse(account): yield trans def parse(self, account): transactions = list() transacs = self.get_transactions() for t in transacs: for trans in self.parse_transaction(t, account): transactions.append(trans) for t in transactions: yield t def format_amount(self, amount, is_credit): """ This function takes a textual amount to convert it to Decimal. It tries to guess what is the decimal separator (, or .). """ if not isinstance(amount, Decimal): m = re.search(r"\D", amount[::-1]) amount = Decimal(re.sub(r'[^\d]', '', amount))/Decimal((10 ** m.start())) if is_credit: return abs(amount) else: return -abs(amount) class ProHistoryPage(HistoryPage, JsonPage): def transaction_left(self): return len(self.doc['data']['transactions']) > 0 def get_transactions(self): return self.doc['data']['transactions'] def parse_transaction(self, transaction, account): trans = [] if transaction['transactionStatus'] in [u'Créé', u'Annulé', u'Suspendu', u'Mis à jour', u'Actif', u'Payé', u'En attente', u'Rejeté', u'Expiré', \ u'Created']: return [] if transaction['transactionDescription'].startswith(u'Offre de remboursement') or transaction['transactionDescription'].startswith(u'Commande à'): return [] t = FrenchTransaction(transaction['transactionId']) if not transaction['transactionAmount']['currencyCode'] == account.currency: cc = self.browser.convert_amount(account, transaction, 'https://www.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=' + transaction['transactionId']) if not cc: return [] t.original_amount = Decimal('%.2f' % transaction['transactionAmount']['currencyDoubleValue']) t.original_currency = u'' + transaction['transactionAmount']['currencyCode'] t.amount = abs(cc) if not transaction['debit'] else -abs(cc) else: t.amount = Decimal('%.2f' % transaction['net']['currencyDoubleValue']) date = parse_french_date(transaction['transactionTime']) raw = transaction['transactionDescription'] if raw.startswith(u'Paiement \xe0') or raw.startswith('Achat de'): payback_id, payback_raw, payback_amount, payback_currency = self.browser.check_for_payback(transaction, 'https://www.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=' + transaction['transactionId']) if payback_id and payback_raw and payback_amount and payback_currency: t_payback = FrenchTransaction(payback_id) t_payback.amount = payback_amount t_payback.original_currency = payback_currency t_payback.type = FrenchTransaction.TYPE_TRANSFER t_payback.parse(date=date, raw=u'Prélèvement pour %s' % raw) trans.append(t_payback) t.commission = Decimal('%.2f' % transaction['fee']['currencyDoubleValue']) t.parse(date=date, raw=raw) trans.append(t) return trans class PartHistoryPage(HistoryPage, JsonPage): def transaction_left(self): return self.doc['data']['activity']['hasTransactionsCompleted'] or self.doc['data']['activity']['hasTransactionsPending'] def get_transactions(self): return self.doc['data']['activity']['transactions'] def parse_transaction(self, transaction, account): t = FrenchTransaction(transaction['id']) if not transaction['isPrimaryCurrency']: cc = self.browser.convert_amount(account, transaction, transaction['detailsLink']) if not cc: return [] t.original_amount = self.format_amount(transaction['amounts']['net']['value'], transaction["isCredit"]) t.original_currency = u'' + transaction['amounts']['txnCurrency'] t.amount = self.format_amount(cc, transaction['isCredit']) else: t.amount = self.format_amount(transaction['amounts']['net']['value'], transaction['isCredit']) date = parse_french_date(transaction['date']['formattedDate'] + ' ' + transaction['date']['year']) raw = transaction.get('counterparty', transaction['displayType']) t.parse(date=date, raw=raw) return [t] class HistoryDetailsPage(LoggedPage, HTMLPage): def get_converted_amount(self, account): find_td = self.doc.xpath('//td[contains(text(),"' + account.currency + '")] | //dd[contains(text(),"' + account.currency + '")]') if len(find_td) > 0 : # In case text is "12,34 EUR = 56.78 USD" or "-£115,62 GBP soit -€163,64 EUR" for text in re.split('=|soit', CleanText().filter(find_td[0])): if account.currency in text: return Decimal(FrenchTransaction.clean_amount(text.split(account.currency)[0])) return False def get_payback_url(self): if not self.doc.xpath(u'//td[contains(text(), "Transaction associée")]'): return None url = self.doc.xpath(u'//tr[td[contains(text(),"Approvisionnement à")]]//a[contains(text(), "Détails")]/@href') if len(url) == 1: return url[0] return None class HistoryPaybackPage(LoggedPage, HTMLPage): def get_payback(self): if not self.doc.xpath(u'//td[contains(text(), "Transaction associée")]'): return None, None, None, None tr = self.doc.xpath(u'//tr[td[contains(text(),"Approvisionnement à")]]') td_id = self.doc.xpath(u'//td[span[contains(text(),"Approvisionnement à")]]') if len(tr) > 0 and len(td_id)>0: tr = tr[0] m = re.search(u'Nº de transaction unique ([a-zA-Z0-9_]*)', CleanText().filter(td_id[0])) if m: id = m.group(1) raw = CleanText().filter(tr.xpath('./td[2]')[0]) amount = Decimal(FrenchTransaction.clean_amount(CleanText().filter(tr.xpath('./td[5]')[0]))) currency = Currency.get_currency(CleanText().filter(tr.xpath('./td[5]')[0])) return id, raw, amount, currency return None, None, None, None �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/paypal/test.py�������������������������������������������������������������������0000664�0000000�0000000�00000002034�12657170273�0017130�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class PaypalTest(BackendTest): MODULE = 'paypal' def test_balance(self): for account in self.backend.iter_accounts(): balance = sum(t.amount for t in self.backend.iter_history(account)) self.assertEqual(balance, account.balance) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015405�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000001477�12657170273�0017527�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .browser import PhpBB from .module import PhpBBModule __all__ = ['PhpBB', 'PhpBBModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/browser.py�����������������������������������������������������������������0000664�0000000�0000000�00000015025�12657170273�0017445�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re import urllib from urlparse import urlsplit from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.capabilities.messages import CantSendMessage from .pages.index import LoginPage from .pages.forum import ForumPage, TopicPage, PostingPage from .tools import id2url, url2id __all__ = ['PhpBB'] # Browser class PhpBB(Browser): PAGES = {'https?://.*/index.php': ForumPage, 'https?://.*/': ForumPage, 'https?://.*/viewforum.php\?f=(\d+)': ForumPage, 'https?://.*/search.php\?.*': ForumPage, 'https?://.*/viewtopic.php\?.*': TopicPage, 'https?://.*/posting.php\?.*': PostingPage, 'https?://.*/ucp.php\?mode=login.*': LoginPage, } last_board_msg_id = None def __init__(self, url, *args, **kwargs): self.url = url v = urlsplit(url) self.PROTOCOL = v.scheme self.DOMAIN = v.netloc self.BASEPATH = v.path[:v.path.rfind('/')] Browser.__init__(self, *args, **kwargs) def absurl(self, rel): return Browser.absurl(self, '%s/%s' % (self.BASEPATH, rel)) def home(self): self.location(self.url) def is_logged(self): return not self.page or self.page.is_logged() def login(self): data = {'login': 'Connexion', 'username': self.username, 'password': self.password, } self.location('%s/ucp.php?mode=login' % self.BASEPATH, urllib.urlencode(data), no_login=True) assert self.is_on_page(LoginPage) if not self.page.is_logged(): raise BrowserIncorrectPassword(self.page.get_error_message()) def get_root_feed_url(self): self.home() return self.page.get_feed_url() def iter_links(self, url): if url: self.location(url) else: self.home() assert self.is_on_page(ForumPage) return self.page.iter_links() def iter_posts(self, id, stop_id=None): if id.startswith('http'): self.location(id) else: self.location('%s/%s' % (self.BASEPATH, id2url(id))) assert self.is_on_page(TopicPage) parent = 0 while True: for post in self.page.iter_posts(): if stop_id and post.id >= stop_id: return post.parent = parent yield post parent = post.id if self.page.cur_page == self.page.tot_pages: return self.location(self.page.next_page_url()) def riter_posts(self, id, stop_id=None): if id.startswith('http'): self.location(id) else: self.location('%s/%s' % (self.BASEPATH, id2url(id))) assert self.is_on_page(TopicPage) child = None while True: for post in self.page.riter_posts(): if child: child.parent = post.id yield child if post.id <= stop_id: return child = post if self.page.cur_page == 1: if child: yield child return self.location(self.page.prev_page_url()) def get_post(self, id): if id.startswith('http'): self.location(id) id = url2id(id) else: self.location('%s/%s' % (self.BASEPATH, id2url(id))) assert self.is_on_page(TopicPage) post = self.page.get_post(int(id.split('.')[-1])) if not post: return None if post.parent == 0 and self.page.cur_page > 1: self.location(self.page.prev_page_url()) post.parent = self.page.get_last_post_id() return post def get_forums(self): self.home() return dict(self.page.iter_all_forums()) def post_answer(self, forum_id, topic_id, title, content): if topic_id == 0: if not forum_id: forums = self.get_forums() forums_prompt = 'Forums list:\n%s' % ('\n'.join(['\t- %s' % f for f in forums.itervalues()])) m = re.match('\[(.*)\] (.*)', title or '') if not m: raise CantSendMessage('Please enter a title formatted like that:\n\t"[FORUM] SUBJECT"\n\n%s' % forums_prompt) forum_id = None for k,v in forums.iteritems(): if v.lower() == m.group(1).lower(): forum_id = k break if not forum_id: raise CantSendMessage('Forum "%s" not found.\n\n%s' % (m.group(1), forums_prompt)) self.location('%s/posting.php?mode=post&f=%d' % (self.BASEPATH, forum_id)) assert self.is_on_page(PostingPage) self.page.post(title, content) assert self.is_on_page(PostingPage) error = self.page.get_error_message() if error: raise CantSendMessage(u'Unable to send message: %s' % error) else: self.location('%s/%s' % (self.BASEPATH, id2url(topic_id))) assert self.is_on_page(TopicPage) self.page.go_reply() assert self.is_on_page(PostingPage) # Don't send title because it isn't needed in real use case # and with monboob title is something like: # Re: [Forum Name] Re: Topic Name if title is not None and title.startswith('Re:'): title = None self.page.post(title, content) assert self.is_on_page(PostingPage) error = self.page.get_error_message() if error: raise CantSendMessage(u'Unable to send message: %s' % error) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000006620�12657170273�0017544�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME", T���tEXtComment�Created with GIMPW�� IDATxZk]u>{̝?xa#4&5UDiT%V͟JW\)i~PRUV JH>PJZ$ Nll#۱/=s{3csU%]\{5{}{ַeQeQeQeQeQ+Uq<~CDf �of "k#^_+]RLLa|Rzb1�*��8#"9$*§ 2̄Q(}DZK)�"�C[3p.aMwG6ƣ4.:�>JurmU?uVC0L`v r�g "A4)R. ca+@@d&3p tXcw_5604nA g'[^PJCP{DPZ-ܯɁؖ@;dZo}C'V\ֿj";gdAd@d{ ?Eo=ZP:R JgDOr1]$YٓO|a'&W]׋ `Y8g@i/qZX*%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^N ]L nw�f_B2 _z$/'`v0Nk~К/WPn1oe&k|<gDv;w&sܘ%,mf]?}&5d4mmH nu6GzDM&sCm5I6eY*^WLi24m"M^OnJsw�5LgcWrC,6_}3=,m +iGiwtv<n};]� g{|I>y64&YOdM$s;#3F�ݤɺU&_X\EYEYEY"cz����IENDB`����������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/module.py������������������������������������������������������������������0000664�0000000�0000000�00000016065�12657170273�0017254�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.tools.newsfeed import Newsfeed from weboob.tools.value import Value, ValueInt, ValueBackendPassword from weboob.tools.misc import limit from weboob.capabilities.messages import CapMessages, CapMessagesPost, Message, Thread, CantSendMessage from .browser import PhpBB from .tools import rssid, url2id, id2url, id2topic __all__ = ['PhpBBModule'] class PhpBBModule(Module, CapMessages, CapMessagesPost): NAME = 'phpbb' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = "phpBB forum" CONFIG = BackendConfig(Value('url', label='URL of forum', regexp='https?://.*'), Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password', default=''), ValueInt('thread_unread_messages', label='Limit number of unread messages to retrieve for a thread', default=500) ) STORAGE = {'seen': {}} BROWSER = PhpBB def create_default_browser(self): username = self.config['username'].get() if len(username) > 0: password = self.config['password'].get() else: password = None return self.create_browser(self.config['url'].get(), username, password) #### CapMessages ############################################## def _iter_threads(self, root_link=None): with self.browser: links = list(self.browser.iter_links(root_link.url if root_link else None)) for link in links: if link.type == link.FORUM: link.title = '%s[%s]' % (root_link.title if root_link else '', link.title) for thread in self._iter_threads(link): yield thread if link.type == link.TOPIC: thread = Thread(url2id(link.url)) thread.title = ('%s ' % root_link.title if root_link else '') + link.title thread.date = link.date thread.flags = thread.IS_DISCUSSION yield thread def iter_threads(self): return self._iter_threads() def get_thread(self, id): thread = None parent = None if isinstance(id, Thread): thread = id id = thread.id thread_id = url2id(id, nopost=True) or id try: last_seen_id = self.storage.get('seen', default={})[id2topic(thread_id)] except KeyError: last_seen_id = 0 with self.browser: for post in self.browser.iter_posts(id): if not thread: thread = Thread(thread_id) thread.title = post.title m = self._post2message(thread, post) m.parent = parent if last_seen_id < post.id: m.flags |= Message.IS_UNREAD if parent: parent.children = [m] else: thread.root = m parent = m return thread def _post2message(self, thread, post): signature = post.signature if signature: signature += '<br />' signature += 'URL: %s' % self.browser.absurl(id2url('%s.%s' % (thread.id, post.id))) return Message(thread=thread, id=post.id, title=post.title, sender=post.author, receivers=None, date=post.date, parent=None, content=post.content, signature=signature, children=[], flags=Message.IS_HTML) def iter_unread_messages(self): with self.browser: url = self.browser.get_root_feed_url() for article in Newsfeed(url, rssid).iter_entries(): id = url2id(article.link) thread = None try: last_seen_id = self.storage.get('seen', default={})[id2topic(id)] except KeyError: last_seen_id = 0 child = None iterator = self.browser.riter_posts(id, last_seen_id) if self.config['thread_unread_messages'].get() > 0: iterator = limit(iterator, self.config['thread_unread_messages'].get()) for post in iterator: if not thread: thread = Thread('%s.%s' % (post.forum_id, post.topic_id)) message = self._post2message(thread, post) if child: message.children.append(child) child.parent = message if post.parent: message.parent = Message(thread=thread, id=post.parent) else: thread.root = message yield message def set_message_read(self, message): try: last_seen_id = self.storage.get('seen', default={})[id2topic(message.thread.id)] except KeyError: last_seen_id = 0 if message.id > last_seen_id: self.storage.set('seen', id2topic(message.thread.id), message.id) self.storage.save() def fill_thread(self, thread, fields): return self.get_thread(thread) #### CapMessagesReply ######################################### def post_message(self, message): assert message.thread forum = 0 topic = 0 if message.thread: try: if '.' in message.thread.id: forum, topic = [int(i) for i in message.thread.id.split('.', 1)] else: forum = int(message.thread.id) except ValueError: raise CantSendMessage('Thread ID must be in form "FORUM_ID[.TOPIC_ID]".') with self.browser: return self.browser.post_answer(forum, topic, message.title, message.content) OBJECTS = {Thread: fill_thread} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/pages/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016504�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/pages/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0020603�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/pages/forum.py�������������������������������������������������������������0000664�0000000�0000000�00000017657�12657170273�0020226�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from time import sleep from urlparse import urlsplit, parse_qs from weboob.deprecated.browser import BrokenPageError from .index import PhpBBPage from ..tools import parse_date class Link(object): (FORUM, TOPIC) = xrange(2) def __init__(self, type, url): self.type = type self.url = url self.title = u'' self.date = None class ForumPage(PhpBBPage): def iter_links(self): for li in self.parser.select(self.document.getroot(), 'ul.forums li.row'): title = li.cssselect('a.forumtitle')[0] link = Link(Link.FORUM, title.attrib['href']) link.title = title.text.strip() yield link for li in self.parser.select(self.document.getroot(), 'ul.topics li.row'): title = li.cssselect('a.topictitle')[0] link = Link(Link.TOPIC, title.attrib['href']) link.title = title.text.strip() for a in li.find('dl').find('dt').findall('a'): for text in (a.text, a.tail): if text is None: continue try: link.date = parse_date(text.strip(u'» \r\n')) except ValueError: continue else: break yield link def iter_all_forums(self): for option in self.parser.select(self.document.getroot(), 'select#f', 1).findall('option'): value = int(option.attrib['value']) if value < 0 or not option.text: continue yield value, option.text.strip(u'» \xa0\n\r') class Post(object): def __init__(self, forum_id, topic_id, id): self.id = int(id) self.forum_id = forum_id self.topic_id = topic_id self.title = u'' self.author = u'' self.date = None self.content = u'' self.signature = u'' self.parent = 0 class TopicPage(PhpBBPage): def on_loaded(self): div = self.document.getroot().cssselect('div.pagination')[0] strongs = div.cssselect('strong') self.cur_page = int(strongs[0].text.strip()) self.tot_pages = int(strongs[1].text.strip()) try: url = self.document.xpath('//h2/a')[-1].attrib['href'] except BrokenPageError: url = self.url v = urlsplit(url) args = parse_qs(v.query) self.topic_id = int(args['t'][0]) self.forum_id = int(args['f'][0]) if 'f' in args else 0 self.forum_title = u'' nav = self.parser.select(self.document.getroot(), 'li.icon-home') if len(nav) > 0: text = nav[0].findall('a')[-1].text.strip() if len(text) >= 20: text = text[:20] + u'…' self.forum_title = '[%s] ' % text def go_reply(self): self.browser.follow_link(url_regex='posting\.php') def next_page_url(self): try: return self.parser.select(self.document.getroot(), 'a.right-box', 1).attrib['href'] except BrokenPageError: a_list = self.parser.select(self.document.getroot(), 'div.pagination', 1).findall('a') if self.cur_page == self.tot_pages: return '#' return a_list[-1].attrib['href'] def prev_page_url(self): try: return self.parser.select(self.document.getroot(), 'a.left-box', 1).attrib['href'] except BrokenPageError: a_list = self.parser.select(self.document.getroot(), 'div.pagination', 1).findall('a') if self.cur_page == self.tot_pages: a = a_list[-1] else: a = a_list[-2] return a.attrib['href'] def iter_posts(self): for div in self.parser.select(self.document.getroot(), 'div.post'): yield self._get_post(div) def riter_posts(self): for div in reversed(self.parser.select(self.document.getroot(), 'div.post')): yield self._get_post(div) def get_post(self, id): parent = 0 for div in self.parser.select(self.document.getroot(), 'div.post'): if div.attrib['id'] == 'p%d' % id: post = self._get_post(div) post.parent = parent return post else: parent = int(div.attrib['id'][1:]) def _get_post(self, div): body = div.cssselect('div.postbody')[0] profile = div.cssselect('dl.postprofile')[0] id = div.attrib['id'][1:] post = Post(self.forum_id, self.topic_id, id) title_tags = body.xpath('//h3/a') if len(title_tags) == 0: title_tags = self.document.xpath('//h2/a') if len(title_tags) == 0: title = u'' self.logger.warning('Unable to parse title') else: title = title_tags[-1].text.strip() post.title = self.forum_title + title for a in profile.cssselect('dt a'): if a.text: post.author = a.text.strip() p_tags = body.cssselect('p.author') if len(p_tags) == 0: p_tags = body.find('p') if len(p_tags) == 0: post.date = None self.logger.warning('Unable to parse datetime') else: p = p_tags[0] text = p.find('strong') is not None and p.find('strong').tail if not text: text = p.text[4:] text = text.strip(u'» \n\r') try: post.date = parse_date(text) except ValueError: self.logger.warning(u'Unable to parse datetime "%s"' % text) post.content = self.parser.tostring(body.cssselect('div.content')[0]) signature = body.cssselect('div.signature') if len(signature) > 0: post.signature = self.parser.tostring(signature[0]) return post def get_last_post_id(self): id = 0 for div in self.parser.select(self.document.getroot(), 'div.post'): id = int(div.attrib['id'][1:]) return id class PostingPage(PhpBBPage): def post(self, title, content): self.browser.select_form(predicate=lambda form: form.attrs.get('id', '') == 'postform') self.browser.set_all_readonly(False) if title: self.browser['subject'] = title.encode('utf-8') self.browser['message'] = content.encode('utf-8') # This code on phpbb: # if ($cancel || ($current_time - $lastclick < 2 && $submit)) # { # /* ... */ # redirect($redirect); # } # To prevent that shit because weboob is too fast, we simulate # a value of lastclick 10 seconds before. self.browser['lastclick'] = str(int(self.browser['lastclick']) - 10) # Likewise for create_time, with this check: # $diff = time() - $creation_time; # // If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)... # if ($diff && ($diff <= $timespan || $timespan === -1)) # But as the form_token depends on the create_time value, I can't # change it. But I can wait a second before posting... sleep(1) self.browser.submit(name='post') ���������������������������������������������������������������������������������weboob-1.1/modules/phpbb/pages/index.py�������������������������������������������������������������0000664�0000000�0000000�00000002505�12657170273�0020167�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page class PhpBBPage(Page): def is_logged(self): return len(self.document.getroot().cssselect('li.icon-register')) == 0 def get_feed_url(self): links = self.document.getroot().cssselect('link[type="application/atom+xml"]') return links[-1].attrib['href'] def get_error_message(self): errors = [] for div in self.parser.select(self.document.getroot(), 'div.error,p.error'): if div.text: errors.append(div.text.strip()) return ', '.join(errors) class LoginPage(PhpBBPage): pass �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000002022�12657170273�0016732�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class PhpBBTest(BackendTest): MODULE = 'phpbb' def testthreads(self): for thread in self.backend.iter_threads(): pass def test_unread_messages(self): for message in self.backend.iter_unread_messages(): pass ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/phpbb/tools.py�������������������������������������������������������������������0000664�0000000�0000000�00000004401�12657170273�0017116�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from dateutil.parser import parse as _parse_dt from urlparse import urlsplit, parse_qs from weboob.tools.date import local2utc def url2id(url, nopost=False): v = urlsplit(url) pagename = v.path.split('/')[-1] args = parse_qs(v.query) if pagename == 'viewforum.php': return '%d' % int(args['f'][0]) if pagename == 'viewtopic.php': if 'f' in args: s = '%d' % int(args['f'][0]) else: s = '0' s += '.%d' % int(args['t'][0]) if 'p' in args and not nopost: s += '.%d' % int(args['p'][0]) return s return None def id2url(id): v = id.split('.') if len(v) == 1: return 'viewforum.php?f=%d' % int(v[0]) if len(v) == 2: return 'viewtopic.php?f=%d&t=%d' % (int(v[0]), int(v[1])) if len(v) == 3: return 'viewtopic.php?f=%d&t=%d&p=%d#p%d' % (int(v[0]), int(v[1]), int(v[2]), int(v[2])) def id2topic(id): try: return int(id.split('.')[1]) except IndexError: return None def rssid(id): return id def parse_date(s): s = s.replace(u'Fév', 'Feb') \ .replace(u'Avr', 'Apr') \ .replace(u'Mai', 'May') \ .replace(u'Juin', 'Jun') \ .replace(u'Juil', 'Jul') \ .replace(u'Aoû', 'Aug') \ .replace(u'Ao\xfbt', 'Aug') \ .replace(u'Déc', 'Dec') return local2utc(_parse_dt(s)) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016272�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000000103�12657170273�0020375�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import PiratebayModule __all__ = ['PiratebayModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000004471�12657170273�0020335�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2015 Julien Veyssier, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import random import urllib from urlparse import urlsplit from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages.index import IndexPage from .pages.torrents import TorrentPage, TorrentsPage __all__ = ['PiratebayBrowser'] class PiratebayBrowser(Browser): ENCODING = 'utf-8' DOMAINS = ['thepiratebay.se'] def __init__(self, url, *args, **kwargs): url = url or 'https://%s/' % random.choice(self.DOMAINS) url_parsed = urlsplit(url) self.PROTOCOL = url_parsed.scheme self.DOMAIN = url_parsed.netloc self.PAGES = { '%s://%s/' % (self.PROTOCOL, self.DOMAIN): IndexPage, '%s://%s/search/.*/0/7/0' % (self.PROTOCOL, self.DOMAIN): TorrentsPage, '%s://%s/torrent/.*' % (self.PROTOCOL, self.DOMAIN): TorrentPage } Browser.__init__(self, *args, **kwargs) def iter_torrents(self, pattern): self.location('%s://%s/search/%s/0/7/0' % (self.PROTOCOL, self.DOMAIN, urllib.quote_plus(pattern.encode('utf-8')))) assert self.is_on_page(TorrentsPage) return self.page.iter_torrents() def get_torrent(self, _id): try: self.location('%s://%s/torrent/%s/' % (self.PROTOCOL, self.DOMAIN, _id)) except BrowserHTTPNotFound: return if self.is_on_page(TorrentPage): return self.page.get_torrent(_id) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000003066�12657170273�0020432�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME  QML��IDATx{Tu?w\gGY4tA>? D#6% Ң!(B a%aVdaQJiCuݝUgݹ?;3wvfv~a߽;{!D!B"H?Onmlg-ow.Op`具�>_23qK1L}dB V9H|Ȁ5AP��*;ǘ=@DB p�x h4p7GZ `γX tTC] &oYwW{pHyk?9H3�,!"&RqpP 4 N%,hkRsj`h: Ӗ}1#L^> aX o&xL3H`sEp=LRW( 𒞢K)Eᙚ>Ee}[4gmSPdj 66,NrU}*^ w%<QӉ824Ά@9PSSr4͗97 h'Jl 5�ӁM9lYc74`*[bDm.ɷwx@0 8iy^sVǞQ�0(EՏX#z=Ijc@G<t{Siw {5�C(\f^?G3bVvϽ=Oo=yg sՌt6𨇟N-n Fe-p47�Q]FWsib3F` M4�cM2pa Pw�3=|4*91ȣb]zہMGPՆQgsD㿊yHz08 `[>{0h2vp&0N| a\َuCM-2EK7O \{3`E!^eU+đ�Z4L 1LFZӀ"a pTG)>m6Ł]F6]mi`GhY4?57m/ha ?L3+LEx/P#`9gR| < ,_ k6gfbFYjQ򍆤#nqNs%x).3i1G"r%L*Y̯t�Ձ5{W.-I}ϵlSχ]M7{p"Zt0xzpq}I2 ]ɡt6 y'f3KEB3OO-q^iqnnKTy7pr:$pZCͽw\PS۔I*O@<Br v.Zln2}Y"ih%Y ,Yh�FK5D{P}Jr1>Ѧ܋L,p.eZ&Y ϰa,BucDT 1A}֮A߯p(!B"D!B8*Z؛����IENDB`��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/module.py��������������������������������������������������������������0000664�0000000�0000000�00000004524�12657170273�0020136�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.torrent import CapTorrent, MagnetOnly, Torrent from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value from weboob.capabilities.base import NotAvailable from .browser import PiratebayBrowser __all__ = ['PiratebayModule'] class PiratebayModule(Module, CapTorrent): NAME = 'piratebay' MAINTAINER = u'Laurent Bachelier' EMAIL = 'laurent@bachelier.name' VERSION = '1.1' DESCRIPTION = 'The Pirate Bay BitTorrent tracker' LICENSE = 'AGPLv3+' BROWSER = PiratebayBrowser CONFIG = BackendConfig(Value('proxybay', label='Use a Proxy Bay', regexp=r'https?://.*', default='', required=False)) def create_default_browser(self): return self.create_browser(self.config['proxybay'].get()) def get_torrent(self, id): return self.browser.get_torrent(id) def get_torrent_file(self, id): torrent = self.browser.get_torrent(id) if not torrent: return None if torrent.url is NotAvailable and torrent.magnet: raise MagnetOnly(torrent.magnet) return self.browser.openurl(torrent.url.encode('utf-8')).read() def iter_torrents(self, pattern): return self.browser.iter_torrents(pattern.replace(' ', '+')) def fill_torrent(self, torrent, fields): if 'description' in fields or 'files' in fields: tor = self.get_torrent(torrent.id) torrent.description = tor.description torrent.magnet = tor.magnet torrent.files = tor.files torrent.url = tor.url return torrent OBJECTS = {Torrent: fill_torrent} ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/pages/�����������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017371�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/pages/__init__.py������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021470�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/pages/index.py���������������������������������������������������������0000664�0000000�0000000�00000001570�12657170273�0021055�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page class IndexPage(Page): def is_logged(self): return 'id' in self.document.find('body').attrib ����������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/pages/torrents.py������������������������������������������������������0000664�0000000�0000000�00000011152�12657170273�0021623�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Julien Veyssier, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page,BrokenPageError from weboob.capabilities.torrent import Torrent from weboob.capabilities.base import NotAvailable, NotLoaded from html2text import unescape class TorrentsPage(Page): def unit(self, n, u): m = {'B': 1, 'KB': 1024, 'MB': 1024 * 1024, 'GB': 1024 * 1024 * 1024, 'TB': 1024 * 1024 * 1024 * 1024, } return float(n * m[u]) def iter_torrents(self): try: table = self.parser.select(self.document.getroot(), 'table#searchResult', 1) except BrokenPageError: return first = True for tr in table.getiterator('tr'): if first: first = False continue if tr.get('class', '') != "header": td = tr.getchildren()[1] div = td.getchildren()[0] link = div.find('a').attrib['href'] title = unicode(unescape(div.find('a').text)) idt = link.split('/')[2] a = td.getchildren()[1] url = unicode(a.attrib['href']) size = td.find('font').text.split(',')[1].strip() u = size.split(' ')[1].split(u'\xa0')[1].replace('i', '') size = size.split(' ')[1].split(u'\xa0')[0] seed = tr.getchildren()[2].text leech = tr.getchildren()[3].text torrent = Torrent(idt, title) torrent.url = url torrent.size = self.unit(float(size), u) torrent.seeders = int(seed) torrent.leechers = int(leech) torrent.description = NotLoaded torrent.files = NotLoaded torrent.magnet = NotLoaded yield torrent class TorrentPage(Page): def get_torrent(self, id): url = NotAvailable magnet = NotAvailable for div in self.document.getiterator('div'): if div.attrib.get('id', '') == 'title': title = unicode(unescape(div.text.strip())) elif div.attrib.get('class', '') == 'download': for link in self.parser.select(div, 'a'): href = link.attrib.get('href', '') # https fails on the download server, so strip it if href.startswith('https://'): href = href.replace('https://', 'http://', 1) if href.startswith('magnet:'): magnet = unicode(href) elif len(href): url = unicode(href) elif div.attrib.get('id', '') == 'details': size = float(div.getchildren()[0].getchildren()[5].text.split('(')[1].split('Bytes')[0]) if len(div.getchildren()) > 1 \ and div.getchildren()[1].attrib.get('class', '') == 'col2': child_to_explore = div.getchildren()[1] else: child_to_explore = div.getchildren()[0] prev_child_txt = "none" seed = "-1" leech = "-1" for ch in child_to_explore.getchildren(): if prev_child_txt == "Seeders:": seed = ch.text if prev_child_txt == "Leechers:": leech = ch.text prev_child_txt = ch.text elif div.attrib.get('class', '') == 'nfo': description = unicode(div.getchildren()[0].text_content().strip()) torrent = Torrent(id, title) torrent.url = url or NotAvailable torrent.magnet = magnet torrent.size = size torrent.seeders = int(seed) torrent.leechers = int(leech) torrent.description = description torrent.files = NotAvailable return torrent ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/piratebay/test.py����������������������������������������������������������������0000664�0000000�0000000�00000003155�12657170273�0017627�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Julien Veyssier, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.torrent import MagnetOnly from random import choice class PiratebayTest(BackendTest): MODULE = 'piratebay' def test_torrent(self): # try something popular so we sometimes get a magnet-only torrent l = list(self.backend.iter_torrents('ubuntu linux')) if len(l): torrent = choice(l) full_torrent = self.backend.get_torrent(torrent.id) assert torrent.name assert full_torrent.name == torrent.name # I assume descriptions can be empty assert isinstance(full_torrent.description, basestring) try: assert self.backend.get_torrent_file(torrent.id) except MagnetOnly as e: assert e.magnet.startswith('magnet:') assert e.magnet == full_torrent.magnet �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pixtoilelibre/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017165�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pixtoilelibre/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000001450�12657170273�0021276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import PixtoilelibreModule __all__ = ['PixtoilelibreModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pixtoilelibre/browser.py���������������������������������������������������������0000664�0000000�0000000�00000003612�12657170273�0021224�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser from weboob.tools.capabilities.paste import image_mime from StringIO import StringIO from .pages import PageHome, PageImage, PageError __all__ = ['PixtoilelibreBrowser'] class PixtoilelibreBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'pix.toile-libre.org' ENCODING = None PAGES = {'%s://%s/' % (PROTOCOL, DOMAIN): PageHome, r'%s://%s/\?action=upload': PageError, r'%s://%s/\?img=(.+)' % (PROTOCOL, DOMAIN): PageImage} def post_image(self, filename, contents, private=False, description=''): self.location('/') assert self.is_on_page(PageHome) mime = image_mime(contents.encode('base64')) self.select_form(nr=0) self.form.find_control('private').items[0].selected = private self.form['description'] = description or '' self.form.find_control('img').add_file(StringIO(contents), filename=filename, content_type=mime) self.submit() assert self.is_on_page(PageImage) return self.page.get_info() def get_contents(self, id): return self.readurl('%s://%s/upload/original/%s' % (self.PROTOCOL, self.DOMAIN, id)) ����������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pixtoilelibre/favicon.png��������������������������������������������������������0000664�0000000�0000000�00000006517�12657170273�0021331�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs��@��@[���tIME 1 ?F�� IDATx}t?7I RP!T:<,]Zf@J7 30tbe=G9jOG=rBUhe]_Ӝn&2G"JTl5$yd0='$^wy_ș |( 4Xx @eX T759Sv <J99Oe%HVIY_Θq\ɓO݊.]Y(N,veu5X6XV4->%O~,־|#NYo"4⺮>q0@iU2 ֧\ִ]b׮çD".@U-h.mxAH |Hઊxe>2:cu@1?|8+rI&"1=(d@Dΰ8B 93 � @$}c'0qSr 0gu�/-%FeKQ}DD& ]o&>K\A>HRcpQ:s@$}p܆km~?6ܹ6rJq]c@߹>^;vT[[Drj�طoՈȝ"f8�޸�_zmf7o*Z[;7{O"ȏK<�~8]Hdk0=+,  oy:Q LJBقx@}y9O�ph4dHcnZn]Gl1)D&`�*@yYx3aYWaӦeOfߨǛo:u ]t-п{UUUꕪ31 m3gQ47[HaOtYϋ.嶶T&w 6%zbόoHh4J8^ہM"nF_dŹ@RUr'ԭ1c"X6`uMK [~d466D@}1^VՊkjjZY(c֪h4zU[{gQ"jcub8Ei\9P 1\YSSӘ+J"RcT>?'u.5PaQ{zR>@[sl5�Fdyf/_Kߕ%G'"*8""`#^)`[[ h)̠�n6z!W)guQ�<]g<}Y)D~_`JYgv7 l(-D" 3qU]F䩧:lܹtvvkm'"רNsPUk5kTX,m_R٪uu1Z7xr<<y7+gtRjjjBWX73^mFߎD"8sm?n (uL:hT>_x/|QU`A }ݻlW(߶-#JKFkkf&xbx "W)2?r�w�%y`ƌc1 0[U+Ej=[D~ԴB+  +%%lׇGP8'"U+"iM;&せ,X{|5Gp*yK.i//S&NDzz~{þ}˺`<~s眃\vYNQ;urtI$8C8fԨQ1+:txT= |UfΜISS ~?ݻHuz{'4wcT+?x8L3մs7a޽/R"'ocL&{WyUߛܜJ/NN68cƌ1fz]ss黹 /_ǿ9"ow`kYg(PAsى!"۷eekk{`YIUmulY_?HUD+BPSDe`<�o{@`Z6mɂ>g#I6O>{.cQw�vzU}/_�TǞ{R@2oos|+/p>;C`pgmG�[^VV6A9]&MSߋ-6�vsswس- DďxM^x@?_xhR*zs]GGGHWyw`ĉIR+STufNŋ8H$֥RZuր<0kرWaUFaaH$gYf ˖-Tm�Bk)�UuE4}%ρe^Plt' 0{쑉Dbpm֩w>Ŕ/W&$lSuuu˗/G�"PO`<iYQSS@̙3#+ lbm|>~-"Ezt}QjcL2bm&X R yXFw{L'`ǎ5ece?DOH1$=` P9\T[[=[n)H&uXX)((;wN6kY>}^ӨX,v#RZ3(҂<O ל(�DPDO${Ӫ%8B zH/v� i'W |f^nU`kjw$�\e*/_qRƘ -uuu!2Gj"H>><#rX]]8ۀ3N%Kԭ^E;}hYO'!mcv7ź}Nuvv{?7j|ƘD2nd=m.m{m[lVgmhtl@KI,X,m_A -Xp$o_ض]3@AX̍b9$ xIm#pJ_ޥ c/8A@&�Sτ/�Q$I �r֧ [l@,rgB kWKJJj@gbԙp^.))9Ei׬X,ёmI!#mxq>lb%K|$="f>mW',����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pixtoilelibre/module.py����������������������������������������������������������0000664�0000000�0000000�00000004267�12657170273�0021035�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.paste import CapPaste, BasePaste from weboob.tools.capabilities.paste import image_mime import re from .browser import PixtoilelibreBrowser __all__ = ['PixtoilelibreModule'] class PixPaste(BasePaste): @classmethod def id2url(cls, id): return 'http://pix.toile-libre.org/?img=%s' % id class PixtoilelibreModule(Module, CapPaste): NAME = 'pixtoilelibre' DESCRIPTION = u'toile-libre image hosting website' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = PixtoilelibreBrowser def can_post(self, contents, title=None, public=None, max_age=None): if re.search(r'[^a-zA-Z0-9=+/\s]', contents): return 0 elif max_age: return 0 # expiration is not possible else: mime = image_mime(contents, ('gif', 'jpeg', 'png')) return 20 * int(mime is not None) def get_paste(self, id): paste = PixPaste(id) contents = self.browser.get_contents(id) if contents: paste.contents = contents.encode('base64') return paste def new_paste(self, *a, **kw): return PixPaste(*a, **kw) def post_paste(self, paste, max_age=None): d = self.browser.post_image(paste.title or '-', paste.contents.decode('base64'), private=(not paste.public), description=paste.title) paste.id = d['id'] return paste �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/pixtoilelibre/pages.py�����������������������������������������������������������0000664�0000000�0000000�00000001752�12657170273�0020643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page import re class PageHome(Page): pass class PageImage(Page): def get_info(self): id = re.search(r'img=([^&]+)', self.url).group(1) return {'url': self.url, 'id': id} class PageError(Page): pass ����������������������weboob-1.1/modules/pixtoilelibre/test.py������������������������������������������������������������0000664�0000000�0000000�00000002512�12657170273�0020516�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class PixtoilelibreTest(BackendTest): MODULE = 'pixtoilelibre' # small gif file DATA = 'R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==\n' def test_pixtoilelibre(self): assert self.backend.can_post(self.DATA, max_age=0) post = self.backend.new_paste(None) post.contents = self.DATA post.public = True self.backend.post_paste(post, max_age=0) assert post.id got = self.backend.get_paste(post.id) assert got assert got.contents.decode('base64') == self.DATA.decode('base64') ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/playme/��������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015601�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/playme/__init__.py���������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0017711�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import PlayMeModule __all__ = ['PlayMeModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/playme/browser.py����������������������������������������������������������������0000664�0000000�0000000�00000012273�12657170273�0017643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.browser import DomainBrowser from weboob.browser.exceptions import ClientError from weboob.browser.pages import HTMLPage from weboob.browser.profiles import Profile from weboob.exceptions import BrowserIncorrectPassword from weboob.tools.json import json __all__ = ['PlayMeBrowser', 'FacebookBrowser'] class NoCredits(Exception): pass class FacebookBrowser(DomainBrowser): BASEURL = 'https://graph.facebook.com' CLIENT_ID = "149987128492319" access_token = None info = None def login(self, username, password): self.location('https://www.facebook.com/dialog/oauth?client_id=%s&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=email,user_birthday,user_friends,public_profile,user_photos,user_likes&response_type=token' % self.CLIENT_ID) page = HTMLPage(self, self.response) form = page.get_form('//form[@id="login_form"]') form['email'] = username form['pass'] = password form['persistent'] = 1 form.submit(allow_redirects=False) if 'Location' not in self.response.headers: raise BrowserIncorrectPassword() self.location(self.response.headers['Location']) m = re.search('access_token=([^&]+)&', self.url) if m: self.access_token = m.group(1) self.info = self.request('/me') def request(self, url, *args, **kwargs): url += '?access_token=' + self.access_token r = self.location(self.absurl(url, base=True), *args, **kwargs) return json.loads(r.content) class IPhoneClient(Profile): def setup_session(self, session): session.headers["Accept-Language"] = "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5" session.headers["Accept"] = "*/*" session.headers["User-Agent"] = "PlayMe/3.0.2 (iPhone; iOS 7.1; Scale/2.00)" session.headers["Accept-Encoding"] = "gzip, deflate" session.headers["Content-Type"] = "application/json" class PlayMeBrowser(DomainBrowser): BASEURL = 'https://api2.goplayme.com/' PROFILE = IPhoneClient() VERIFY = False recs = [] def __init__(self, facebook, *args, **kwargs): super(PlayMeBrowser, self).__init__(*args, **kwargs) self.facebook = facebook profile_picture = 'http%3A%2F%2Fgraph.facebook.com%2F' + facebook.info['id'] + '%2Fpicture%3Fwidth%3D600%26height%3D600' me = self.request('/auth/facebook/callback?access_token=%s&profile_picture=%s' % (facebook.access_token, profile_picture)) self.session.headers['Authorization'] = 'Token token="%s"' % me['token'] self.my_id = me['id'] self.my_name = me['name'] self.credits = me['credits']['count'] def get_threads(self): r = self.request('/users/%s/contacts' % self.my_id) if 'status' in r: return [] return reversed(r) def get_thread_messages(self, contact_id): return self.request('/messages/%s' % contact_id) def get_user(self, contact_id): return self.request('/users/%s' % contact_id) def post_message(self, contact_id, content): self.request('/messages', data={'id': contact_id, 'msg': content}) def request(self, *args, **kwargs): if 'data' in kwargs: kwargs['data'] = json.dumps(kwargs['data']) r = self.location(*args, **kwargs) return json.loads(r.content) def find_users(self, lat, lon): r = self.request('/users/?lat=%s&lon=%s&type=full' % (lat, lon)) return r['pending'] + r['history'] def get_theme(self): r = self.request('/questions') for t in r: if t['theme']['is_vip']: continue return t def challenge(self, user_id): try: r = self.request('/users/%s/challenge/%s' % (self.my_id, user_id)) except ClientError as e: r = json.loads(e.response.content) self.credits = r['credits']['count'] raise NoCredits(r['credits']['next_restore_in_seconds']) if isinstance(r, list) and 'questions' in r[0]: t = r[0] else: t = self.get_theme() self.credits = r['credits']['count'] data = {} data['theme'] = {'id': t['theme']['id'], 'is_vip': 0} data['questions'] = [q['id'] for q in t['questions']][:5] data['answers'] = [{'duration': 1000, 'result': 1} for q in t['questions'][:5]] self.request('/users/%s/challenge/%s' % (self.my_id, user_id), data=data) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/playme/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000002135�12657170273�0017735�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq��� pHYs�� �� ����tIME 5 X ���tEXtComment�Created with GIMPW��IDATx[kUߛFViD" EkP+/1ȗP b66QLK$ͩx5q43μ4{翟Zk)RHbFTZσXU̡\ѝo+ƪ}&J`.E [\$TS 7cO,uD�gYU\ ?@kY p,~W8:WTnV�Nc 3XF�;c%D_\13WjU�A\q ?Mb.+)@9fH"y,4s4p6tmi| .6#e}0a܎[ZeLFn_G}1%wݿ9V\p<nB�Xڧ ;q/Q<яt(ABh d؃x �7f֤#pp2+Y( :;Ѓ;q�/'F#Ǥ X爚+z\$˧@ {�OlT4=Pi1t4DS4ܱsKwmin(pAwCx/Q]w⵨Pw+܃ǣVx6>QL!|WCx-nAmPx s�wpW8Uud$q.+Y(: |5,> �6'C!|dfmDc~+mr�ގ3ۤݞ C!|G[@�՛^B EF#NY}glu`$o�=Mj`49#aZB?QFB@!ͯԝ8۳r|FQ /bYD�5(v3m~ǧ>Hj˝xLtshw6$?yvxǿv%"4fm*Iu&X#H� H� H� H"E)Wh7q3p����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/playme/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000017051�12657170273�0017444�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import datetime from weboob.capabilities.messages import CapMessages, CapMessagesPost, Thread, Message from weboob.capabilities.dating import CapDating, Optimization from weboob.capabilities.account import CapAccount, StatusField from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.date import local2utc from weboob.tools.log import getLogger from .browser import PlayMeBrowser, FacebookBrowser, NoCredits __all__ = ['PlayMeModule'] class ProfilesWalker(Optimization): def __init__(self, sched, storage, browser): super(ProfilesWalker, self).__init__() self._sched = sched self._storage = storage self._browser = browser self._logger = getLogger('walker', browser.logger) self._view_cron = None def start(self): self._view_cron = self._sched.schedule(1, self.view_profile) return True def stop(self): self._sched.cancel(self._view_cron) self._view_cron = None return True def set_config(self, params): pass def is_running(self): return self._view_cron is not None def view_profile(self): delay = 900 try: challenged = self._storage.get('challenged', default=[]) for user in self._browser.find_users(48.883989, 2.367168): if user['id'] in challenged: continue try: self._browser.challenge(user['id']) except NoCredits as e: delay = int(str(e)) self._logger.info('No more credits (next try in %d minutes)', (delay/60)) else: self._logger.info('Challenged %s', user['name']) challenged.append(user['id']) self._storage.set('challenged', challenged) self._storage.save() break finally: if self._view_cron is not None: self._view_cron = self._sched.schedule(delay, self.view_profile) class PlayMeModule(Module, CapMessages, CapMessagesPost, CapDating, CapAccount): NAME = 'playme' DESCRIPTION = u'PlayMe dating mobile application' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(Value('username', label='Facebook email'), ValueBackendPassword('password', label='Facebook password')) BROWSER = PlayMeBrowser STORAGE = {'contacts': {}, 'challenged': [], } def create_default_browser(self): facebook = FacebookBrowser() facebook.login(self.config['username'].get(), self.config['password'].get()) return self.create_browser(facebook) # ---- CapDating methods ----------------------- def init_optimizations(self): self.add_optimization('PROFILE_WALKER', ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)) # ---- CapMessages methods --------------------- def fill_thread(self, thread, fields): return self.get_thread(thread) def iter_threads(self): for thread in self.browser.get_threads(): t = Thread(thread['id']) t.flags = Thread.IS_DISCUSSION t.title = u'Discussion with %s' % thread['name'] t.date = local2utc(datetime.datetime.fromtimestamp(thread['last_message']['utc_timestamp'])) yield t def get_thread(self, thread): if not isinstance(thread, Thread): thread = Thread(thread) thread.flags = Thread.IS_DISCUSSION user = self.browser.get_user(thread.id) thread.title = u'Discussion with %s' % user['name'] contact = self.storage.get('contacts', thread.id, default={'lastmsg': 0}) signature = u'Age: %s' % user['age'] signature += u'\nLast online: %s' % user['last_online'] signature += u'\nPhotos:\n\t%s' % '\n\t'.join([user['photo_host'] + photo['large'] for photo in user['photos']]) child = None for msg in self.browser.get_thread_messages(thread.id): flags = 0 if int(contact['lastmsg']) < msg['utc_timestamp']: flags = Message.IS_UNREAD if msg['type'] == 'msg': content = unicode(msg['msg']) elif msg['type'] == 'new_challenge': content = u'A new challenge has been proposed!' elif msg['type'] == 'serie': content = u"I've played" elif msg['type'] == 'end_game': content = u'%s is the winner! (%s VS %s)' % (self.browser.my_name if msg['score']['w'] == self.browser.my_id else user['name'], msg['score']['s'][0], msg['score']['s'][1]) else: content = u'Unknown action: %s' % msg['type'] msg = Message(thread=thread, id=msg['utc_timestamp'], title=thread.title, sender=unicode(self.browser.my_name if msg['from'] == self.browser.my_id else user['name']), receivers=[unicode(self.browser.my_name if msg['from'] != self.browser.my_id else user['name'])], date=local2utc(datetime.datetime.fromtimestamp(msg['utc_timestamp'])), content=content, children=[], parent=None, signature=signature if msg['from'] != self.browser.my_id else u'', flags=flags) if child: msg.children.append(child) child.parent = msg child = msg thread.root = child return thread def iter_unread_messages(self): for thread in self.iter_threads(): thread = self.get_thread(thread) for message in thread.iter_all_messages(): if message.flags & message.IS_UNREAD: yield message def set_message_read(self, message): contact = self.storage.get('contacts', message.thread.id, default={'lastmsg': 0}) if int(contact['lastmsg']) < int(message.id): contact['lastmsg'] = int(message.id) self.storage.set('contacts', message.thread.id, contact) self.storage.save() # ---- CapMessagesPost methods --------------------- def post_message(self, message): self.browser.post_message(message.thread.id, message.content) # ---- CapAccount methods --------------------- def get_account_status(self): return (StatusField(u'myname', u'My name', unicode(self.browser.my_name)), StatusField(u'credits', u'Credits', unicode(self.browser.credits)), ) OBJECTS = {Thread: fill_thread, } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/playme/test.py�������������������������������������������������������������������0000664�0000000�0000000�00000001646�12657170273�0017141�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class PlayMeTest(BackendTest): MODULE = 'playme' def test_playme(self): for m in self.backend.iter_unread_messages(): pass ������������������������������������������������������������������������������������������weboob-1.1/modules/podnapisi/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016300�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/podnapisi/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000001437�12657170273�0020416�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import PodnapisiModule __all__ = ['PodnapisiModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/podnapisi/browser.py�������������������������������������������������������������0000664�0000000�0000000�00000003520�12657170273�0020335�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import SearchPage, SubtitlePage, LANGUAGE_NUMBERS __all__ = ['PodnapisiBrowser'] class PodnapisiBrowser(Browser): DOMAIN = 'www.podnapisi.net' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.podnapisi.net/fr/ppodnapisi/search\?sJ=[0-9]*&sK=.*&sS=downloads&sO=desc': SearchPage, 'http://www.podnapisi.net/fr/ppodnapisi/podnapis/i/[0-9]*': SubtitlePage } def iter_subtitles(self, language, pattern): nlang = LANGUAGE_NUMBERS[language] self.location('http://www.podnapisi.net/fr/ppodnapisi/search?sJ=%s&sK=%s&sS=downloads&sO=desc' % (nlang, pattern.encode('utf-8'))) assert self.is_on_page(SearchPage) return self.page.iter_subtitles(unicode(language)) def get_subtitle(self, id): try: self.location('http://www.podnapisi.net/fr/ppodnapisi/podnapis/i/%s' % id) except BrowserHTTPNotFound: return if self.is_on_page(SubtitlePage): return self.page.get_subtitle(id) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/podnapisi/favicon.png������������������������������������������������������������0000664�0000000�0000000�00000003101�12657170273�0020426�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME  )P˞���tEXtComment�Created with GIMPW��IDATxkTU6>j^b5JtfIYr44%")#B_JC_&J{#´@L4Au{5v\Gvsf̘1w΂ag^{@N9SN9ԨuD|h#ޘM @! +rƥ0\n t݀X�Iw4(֓񣯔jq}/�}�ڀg䚁'{ˀNJ9(@+5XiLPv�_|Pb6`1:G-Wz.c &,IIQSJ^Ѿ.B_I5N6s?0VX_gLpʘj|7u3&XmL|3`zL֘1NjbAS c60?߳4N�0&+ g8Еx@C></4}gR[0"7Ăf9*J'�',^S~ӿ+aU] �{c@K} l^6&X2zg9AӘ̃a5yA 0D}Ί]lro2 82792og2)c"/N~�8ILcքMϨL;0Řh]y/ZcPi�-�nuZ ֤GCl0&r "-`LЦ�<Gq/b>0Ę`ULO:zG+G`X-~zP(tG^,q$65B#sx""?[N ? 3EY+iEvZV+nEZ׭Hϸ.m"~+rŠ"f1h>`AB|%Nו1@wOsf]t2ޘf qH˴]W/wݤ/(�.@q;.Ҍ,�)Zi�XiZXݗ:scQ#^npw)�|hV �/mX.H֔v}[T"}6^u4y!*r`cj XQ ﵭ\R tvxaO9Uv/ j78(vmjػX/ ߎ: Cԋ8]3὎We@ߊLO 1_aW/ za8Y<KΊL;a_qY<$E/9+ҬF7�75y9}� ) )Ȭu[2O �ZKlo ˁG++Pe}U2ѯˉ�taA,{?�Nujd=JW?5 r_�Y{�j5 XA/NF5<r)r5}9j%����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/podnapisi/module.py��������������������������������������������������������������0000664�0000000�0000000�00000004135�12657170273�0020142�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.subtitle import CapSubtitle, LanguageNotSupported, Subtitle from weboob.applications.suboob.suboob import LANGUAGE_CONV from weboob.tools.backend import Module from .browser import PodnapisiBrowser from urllib import quote_plus __all__ = ['PodnapisiModule'] class PodnapisiModule(Module, CapSubtitle): NAME = 'podnapisi' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'Podnapisi movies and tv series subtitle website' LICENSE = 'AGPLv3+' BROWSER = PodnapisiBrowser def get_subtitle(self, id): return self.browser.get_subtitle(id) def get_subtitle_file(self, id): subtitle = self.browser.get_subtitle(id) if not subtitle: return None return self.browser.openurl(subtitle.url.encode('utf-8')).read() def iter_subtitles(self, language, pattern): if language not in LANGUAGE_CONV.keys(): raise LanguageNotSupported() return self.browser.iter_subtitles(language, quote_plus(pattern.encode('utf-8'))) def fill_subtitle(self, subtitle, fields): if 'description' in fields or 'url' in fields: sub = self.get_subtitle(subtitle.id) subtitle.description = sub.description subtitle.url = sub.url return subtitle OBJECTS = { Subtitle: fill_subtitle, } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/podnapisi/pages.py���������������������������������������������������������������0000664�0000000�0000000�00000010010�12657170273�0017741�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.subtitle import Subtitle from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page LANGUAGE_NUMBERS = { 'sq': '29', 'de': '5', 'en': '2', 'ar': '12', 'bn': '59', 'be': '50', 'bg': '33', 'ca': '53', 'zh': '17', 'ko': '4', 'hr': '38', 'da': '24', 'es': '28', 'et': '20', 'fi': '31', 'fr': '8', 'gr': '16', 'hi': '42', 'nl': '23', 'hu': '15', 'iw': '22', 'id': '54', 'ga': '49', 'is': '6', 'it': '9', 'ja': '11', 'lv': '21', 'lt': '19', 'mk': '35', 'ms': '55', 'no': '3', 'pl': '26', 'pt': '32', 'ro': '13', 'ru': '27', 'sr': '36', 'sk': '37', 'sl': '1', 'sv': '25', 'cz': '7', 'th': '44', 'tr': '30', 'uk': '46', 'vi': '51' } class SearchPage(Page): """ Page which contains results as a list of movies """ def iter_subtitles(self, language): linksresults = self.parser.select(self.document.getroot(), 'a.subtitle_page_link') for link in linksresults: id = unicode(link.attrib.get('href', '').split('-p')[-1]) name = unicode(link.text_content()) tr = link.getparent().getparent().getparent() cdtd = self.parser.select(tr, 'td')[4] nb_cd = int(cdtd.text) description = NotLoaded subtitle = Subtitle(id, name) subtitle.nb_cd = nb_cd subtitle.language = language subtitle.description = description yield subtitle class SubtitlePage(Page): """ Page which contains a single subtitle for a movie """ def get_subtitle(self, id): language = NotAvailable url = NotAvailable nb_cd = NotAvailable links_info = self.parser.select(self.document.getroot(), 'fieldset.information a') for link in links_info: href = link.attrib.get('href', '') if '/fr/ppodnapisi/kategorija/jezik/' in href: nlang = href.split('/')[-1] for lang, langnum in LANGUAGE_NUMBERS.items(): if str(langnum) == str(nlang): language = unicode(lang) break desc = u'' infos = self.parser.select(self.document.getroot(), 'fieldset.information') for info in infos: for p in self.parser.select(info, 'p'): desc += '%s\n' % (u' '.join(p.text_content().strip().split())) spans = self.parser.select(info, 'span') for span in spans: if span.text is not None and 'CD' in span.text: nb_cd = int(self.parser.select(span.getparent(), 'span')[1].text) title = unicode(self.parser.select(self.document.getroot(), 'head title', 1).text) name = title.split(' - ')[0] dllinks = self.parser.select(self.document.getroot(), 'div.footer > a.download') for link in dllinks: href = link.attrib.get('href', '') if id in href: url = u'http://www.podnapisi.net%s' % href subtitle = Subtitle(id, name) subtitle.url = url subtitle.language = language subtitle.nb_cd = nb_cd subtitle.description = desc return subtitle ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/podnapisi/test.py����������������������������������������������������������������0000664�0000000�0000000�00000002524�12657170273�0017634�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from random import choice class PodnapisiTest(BackendTest): MODULE = 'podnapisi' def test_subtitle(self): lsub = [] subtitles = self.backend.iter_subtitles('fr', 'spiderman') for i in range(5): subtitle = subtitles.next() lsub.append(subtitle) assert (len(lsub) > 0) # get the file of a random sub if len(lsub): subtitle = choice(lsub) self.backend.get_subtitle_file(subtitle.id) ss = self.backend.get_subtitle(subtitle.id) assert ss.url.startswith('http') ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/poivy/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015460�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/poivy/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000001435�12657170273�0017574�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import PoivyModule __all__ = ['PoivyModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/poivy/browser.py�����������������������������������������������������������������0000664�0000000�0000000�00000003375�12657170273�0017525�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Fourcot Florent # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import HomePage, LoginPage, HistoryPage, BillsPage, ErrorPage __all__ = ['PoivyBrowser'] class PoivyBrowser(LoginBrowser): BASEURL = 'https://www.poivy.com' login = URL('/login', LoginPage) homepage = URL('/buy_credit.*', HomePage) history = URL('/recent_calls', HistoryPage) bills = URL('/purchases', BillsPage) warning = URL('/warning.*', ErrorPage) def do_login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) self.login.stay_or_go() self.page.login(self.username, self.password) if self.login.is_here() or self.warning.is_here(): raise BrowserIncorrectPassword() @need_login def get_subscription_list(self): return self.homepage.stay_or_go().get_list() @need_login def get_history(self): self.history.stay_or_go() return self.page.get_calls() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/poivy/module.py������������������������������������������������������������������0000664�0000000�0000000�00000005344�12657170273�0017325�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bill import CapBill, Subscription, SubscriptionNotFound, Detail from weboob.capabilities.base import find_object from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import PoivyBrowser __all__ = ['PoivyModule'] class PoivyModule(Module, CapBill): NAME = 'poivy' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = 'Poivy website' CONFIG = BackendConfig(ValueBackendPassword('login', label='login', masked=False), ValueBackendPassword('password', label='Password') ) BROWSER = PoivyBrowser def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_subscription(self): return self.browser.get_subscription_list() def get_subscription(self, _id): return find_object(self.iter_subscription(), id=_id, error=SubscriptionNotFound) def iter_bills_history(self, subscription): # Try if we have a real subscription before to load the history if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) return self.browser.get_history() # No details on the website def get_details(self, subscription): raise NotImplementedError() def get_balance(self, subscription): if not isinstance(subscription, Subscription): subscription = self.get_subscription(subscription) balance = Detail() balance.id = "%s-balance" % subscription.id balance.price = subscription._balance balance.label = u"Balance %s" % subscription.id balance.currency = u'EUR' return balance ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/poivy/pages.py�������������������������������������������������������������������0000664�0000000�0000000�00000005767�12657170273�0017150�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.exceptions import BrowserBanned from weboob.browser.pages import HTMLPage, LoggedPage, pagination from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, CleanDecimal, Field, DateTime, Format from weboob.browser.filters.html import Attr, Link from weboob.capabilities.bill import Subscription, Detail class ErrorPage(HTMLPage): pass class LoginPage(HTMLPage): def login(self, login, password): captcha = self.doc.xpath('//label[@class="label_captcha_input"]') if len(captcha) > 0: raise BrowserBanned('Too many connections from you IP address: captcha enabled') xpath_hidden = '//form[@id="newsletter_form"]/input[@type="hidden"]' hidden_id = Attr(xpath_hidden, "value")(self.doc) hidden_name = Attr(xpath_hidden, "name")(self.doc) form = self.get_form(xpath="//form[@class='form-detail']") form['login[username]'] = login form['login[password]'] = password form[hidden_name] = hidden_id form.submit() class HomePage(LoggedPage, HTMLPage): @method class get_list(ListElement): item_xpath = '.' class item(ItemElement): klass = Subscription obj_id = CleanText('//span[@class="welcome-text"]/b') obj__balance = CleanDecimal(CleanText('//span[contains(@class, "balance")]'), replace_dots=False) obj_label = Format(u"Poivy - %s - %s €", Field('id'), Field('_balance')) class HistoryPage(LoggedPage, HTMLPage): @pagination @method class get_calls(ListElement): item_xpath = '//table/tbody/tr' next_page = Link("//div[@class='date-navigator center']/span/a[contains(text(), 'Previous')]", default=None) class item(ItemElement): klass = Detail obj_id = None obj_datetime = DateTime(CleanText('td[1] | td[2]')) obj_price = CleanDecimal('td[7]', replace_dots=False, default=0) obj_currency = u'EUR' obj_label = Format(u"%s from %s to %s - %s", CleanText('td[3]'), CleanText('td[4]'), CleanText('td[5]'), CleanText('td[6]')) #TODO class BillsPage(HTMLPage): pass ���������weboob-1.1/modules/poivy/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000002764�12657170273�0017022�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Fourcot Florent # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class PoivyTest(BackendTest): MODULE = 'poivy' def test_list(self): """ Test listing of subscriptions . No support of multi-account on the website, we could assume to have only one subscription. Check the balance if the subscription is ok. """ subscriptions = list(self.backend.iter_subscription()) self.assertTrue(len(subscriptions) == 1, msg="Account listing failed") self.assertTrue(self.backend.get_balance(subscriptions[0]) > 0, msg="Get balance failed") def test_history(self): for subscription in self.backend.iter_subscription(): self.assertTrue(len(list(self.backend.iter_bills_history(subscription))) > 0) ������������weboob-1.1/modules/popolemploi/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016651�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/popolemploi/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000001444�12657170273�0020765�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import PopolemploiModule __all__ = ['PopolemploiModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/popolemploi/browser.py�����������������������������������������������������������0000664�0000000�0000000�00000005427�12657170273�0020716�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .pages import SearchPage, AdvertPage from weboob.browser import PagesBrowser, URL from urllib import quote_plus, quote __all__ = ['PopolemploiBrowser'] class PopolemploiBrowser(PagesBrowser): BASEURL = 'https://candidat.pole-emploi.fr/' advert = URL('candidat/rechercheoffres/detail/(?P<id>.*)', AdvertPage) search = URL('candidat/rechercheoffres/resultats/(?P<search>.*?)', 'https://offre.pole-emploi.fr/resultat\?offresPartenaires=true&libMetier=(?P<pattern>.*?)', SearchPage) decode_salary = { 'FOURCHETTE1': u'|15000|A', 'FOURCHETTE2': u'15000|18000|A', 'FOURCHETTE3': u'18000|21000|A', 'FOURCHETTE4': u'21000|24000|A', 'FOURCHETTE5': u'24000|36000|A', 'FOURCHETTE6': u'36000|60000|A', 'FOURCHETTE7': u'60000||A', } def search_job(self, pattern=None): return self.search.go(pattern=quote_plus(pattern)).iter_job_adverts() def advanced_search_job(self, metier='', place=None, contrat=None, salary=None, qualification=None, limit_date=None, domain=None): splitted_place = place.split('|') _domain = "%s-" % domain if domain else "" if salary in self.decode_salary: salary_time = self.decode_salary.get(salary).split('|')[2] salary_low = self.decode_salary.get(salary).split('|')[0] salary_hight = self.decode_salary.get(salary).split('|')[1] else: salary_time = "" salary_low = "" salary_hight = "" search = "A_%s_%s_%s__%s_P_%s_%s_%s_____________________%s_%s_%s_______" % ( quote(metier.encode('utf-8')).replace('%', '$00'), splitted_place[1], splitted_place[2], contrat, _domain, salary_time, qualification, limit_date, salary_low, salary_hight) return self.search.go(search=search).iter_job_adverts() def get_job_advert(self, id, advert): return self.advert.go(id=id).get_job_advert(obj=advert) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/popolemploi/favicon.png����������������������������������������������������������0000664�0000000�0000000�00000012576�12657170273�0021017�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� Ǡ���tIME$kX�� IDATxyxUչ?k}>sNNf$H2(R^ŁrkQ?^jQk-`2 99>b˽?/Yϳd'{~}DC|@?~��W+j#24*0>.Fc Ci˩8 Z)ஓ<\Iawg{8@QMw1/ g( fn:@T aT` 7��GN:Og")<gKRC(�,i+Jex(gBaWD߷SvA[rE|? �i3N=)%*m�XsN[ōH?b`Z=5'2:= NvšT-AZ?+"di}jit+AMq%Lh&=X`Mcd7�G!7�`q-6 4lt $$R.$;"jI0ɸ qkkO+zRp"nJ0cf=1d$Ldhط]MZJskbc#N,?ƛ;P�q[p8q "XbÃ>4+C%HOIzI)EAqO|#VgsK&;KU՚$DqP?& e2/zC@@iЦEg6Z.YL?Xix5'Ϗ#N3ayȃf~M@5H*PHX_V $Y$Jf@YNir!YF<@@rq g|vL"B5e<q>w^܆6p"ҡ0А( QT)7~l,]Rg6ySc-Kl!v ν; _1Xi (M)t/X^?A0S~4ۋpy8J'jgp}$z.g+fǧXLFRswT z& Lb}E <3'?衑X.K'X7|sE<I56Q|a)5්<b N&{\ + OWm6+Ns;#°zC+Nj 砦O,V@ H O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al܂1"*&JY]3jx1HQ5 3A"ąHh�> 2j-)ڃ^#|Uue":"�<t'>^tf7G:Z00: nw ق`T Fy!,BO|Dqa Q'h!b5%)"sH.,s'K}YAG?n�/0sʗz{X,l(dTzGvP �"^VI$@"BmXJʭE=BAgA՘,ЅE.WvWE;BkC H) !|"!NIxț}_RCx .[*vXיH6cȐ[3?nU|ϛ19giM.B n7"D9 ׺e&1 11U~9 H�UK~B% q?:�5e!t? @ɥh;&AGXl#Zy}38p-15wMƮtkvoqSDX]]I9DYjپ|S1�ti 8*23F7@%\Rw'p~Ə|gdZY%ՓOr-˞EL~aYJKtܿV΍K#!kgCY Nx0epǠ)>Ȥ[gϦspRV5s2wXf9]DS%q5C~u6]o-Z8gN:Y}-qػy.Y0[ bfB4a/`ȷEHrȟGO.{~/]O^O+}GZZ"~J8t'|_yz&z]-7C2jn>yWqU{9\Vرe;%g4Β.z6u)ݦ3%oZܭ9\{`lqFW8vTi!?|<$?Gw<s^ֹIvwޟoϦݝ< h.OaZ +|5\2V{\?$]pxD y?L<C=Ib3fRm-MoE2E$i%qDCimMD"06L6BMbɃ'Sh3DS0ƏV6ZαK0:�ߑn@iH ]'p"wq1c8}:-LԠ{<=k�;G$S+?cp?"Ά3g$vۮ}5I|B Q/Ly*F[ۺP}۱ #8۱}^=a4Vz=r1 c;y542í< 8g}!�T++_|d׬6[�,p>d _;h3W+MnqО;@=lHKZ R!|~qdNv>Tn@%tnbk(xݙ뼑M4̄;6zǡgo3?\"R18R{TLōr."xCrPx)Cl^B\*L+IxIBx4, P !aᢳa\7aADT!$xzjw![xFNE$YTh#aAsO re"^:9-~C+1#e.jR[a u /u ay�aHxKk)~L HC'+ʐT!F>DQ_?@?~��q#3=> Z����IENDB`����������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/popolemploi/module.py������������������������������������������������������������0000664�0000000�0000000�00000037310�12657170273�0020514�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.job import BaseJobAdvert from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.job import CapJob from weboob.tools.value import Value from weboob.tools.ordereddict import OrderedDict from .browser import PopolemploiBrowser __all__ = ['PopolemploiModule'] class PopolemploiModule(Module, CapJob): NAME = 'popolemploi' DESCRIPTION = u'Pole Emploi website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' VERSION = '1.1' BROWSER = PopolemploiBrowser places_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '100|PAYS|01': u'France entière', '102|REGION|42': u'Alsace', '103|DEPARTEMENT|67': u'-- Rhin (Bas) (67)', '104|DEPARTEMENT|68': u'-- Rhin (Haut) (68)', '105|REGION|72': u'Aquitaine', '106|DEPARTEMENT|24': u'-- Dordogne (24)', '107|DEPARTEMENT|33': u'-- Gironde (33)', '108|DEPARTEMENT|40': u'-- Landes (40)', '109|DEPARTEMENT|47': u'-- Lot et Garonne (47)', '110|DEPARTEMENT|64': u'-- Pyrénées Atlantiques (64)', '111|REGION|83': u'Auvergne', '112|DEPARTEMENT|03': u'-- Allier (03)', '113|DEPARTEMENT|15': u'-- Cantal (15)', '114|DEPARTEMENT|43': u'-- Loire (Haute) (43)', '115|DEPARTEMENT|63': u'-- Puy de Dôme (63)', '116|REGION|26': u'Bourgogne', '117|DEPARTEMENT|21': u'-- Côte d\'Or (21)', '118|DEPARTEMENT|58': u'-- Nièvre (58)', '119|DEPARTEMENT|71': u'-- Saône et Loire (71)', '120|DEPARTEMENT|89': u'-- Yonne (89)', '121|REGION|53': u'Bretagne', '122|DEPARTEMENT|22': u'-- Côtes d\'Armor (22)', '123|DEPARTEMENT|29': u'-- Finistère (29)', '124|DEPARTEMENT|35': u'-- Ille et Vilaine (35)', '125|DEPARTEMENT|56': u'-- Morbihan (56)', '126|REGION|24': u'Centre', '127|DEPARTEMENT|18': u'-- Cher (18)', '128|DEPARTEMENT|28': u'-- Eure et Loir (28)', '129|DEPARTEMENT|36': u'-- Indre (36)', '130|DEPARTEMENT|37': u'-- Indre et Loire (37)', '131|DEPARTEMENT|41': u'-- Loir et Cher (41)', '132|DEPARTEMENT|45': u'-- Loiret (45)', '133|REGION|21': u'Champagne Ardenne', '134|DEPARTEMENT|08': u'-- Ardennes (08)', '135|DEPARTEMENT|10': u'-- Aube (10)', '136|DEPARTEMENT|51': u'-- Marne (51)', '137|DEPARTEMENT|52': u'-- Marne (Haute) (52)', '138|REGION|94': u'Corse', '139|DEPARTEMENT|2A': u'-- Corse du Sud (2A)', '140|DEPARTEMENT|2B': u'-- Haute Corse (2B)', '141|REGION|43': u'Franche Comté', '142|DEPARTEMENT|90': u'-- Belfort (Territoire de) (90)', '143|DEPARTEMENT|25': u'-- Doubs (25)', '144|DEPARTEMENT|39': u'-- Jura (39)', '145|DEPARTEMENT|70': u'-- Saône (Haute) (70)', '146|REGION|11': u'Ile de France', '147|DEPARTEMENT|91': u'-- Essonne (91)', '148|DEPARTEMENT|92': u'-- Hauts de Seine (92)', '149|DEPARTEMENT|75': u'-- Paris (Dept.) (75)', '150|DEPARTEMENT|93': u'-- Seine Saint Denis (93)', '151|DEPARTEMENT|77': u'-- Seine et Marne (77)', '152|DEPARTEMENT|95': u'-- Val d\'Oise (95)', '153|DEPARTEMENT|94': u'-- Val de Marne (94)', '154|DEPARTEMENT|78': u'-- Yvelines (78)', '155|REGION|91': u'Languedoc Roussillon', '156|DEPARTEMENT|11': u'-- Aude (11)', '157|DEPARTEMENT|30': u'-- Gard (30)', '158|DEPARTEMENT|34': u'-- Hérault (34)', '159|DEPARTEMENT|48': u'-- Lozère (48)', '161|DEPARTEMENT|66': u'-- Pyrénées Orientales (66)', '162|REGION|74': u'Limousin', '163|DEPARTEMENT|19': u'-- Corrèze (19)', '164|DEPARTEMENT|23': u'-- Creuse (23)', '165|DEPARTEMENT|87': u'-- Vienne (Haute) (87)', '166|REGION|41': u'Lorraine', '167|DEPARTEMENT|54': u'-- Meurthe et Moselle (54)', '168|DEPARTEMENT|55': u'-- Meuse (55)', '169|DEPARTEMENT|57': u'-- Moselle (57)', '170|DEPARTEMENT|88': u'-- Vosges (88)', '171|REGION|73': u'Midi Pyrénées', '172|DEPARTEMENT|09': u'-- Ariège (09)', '173|DEPARTEMENT|12': u'-- Aveyron (12)', '174|DEPARTEMENT|31': u'-- Garonne (Haute) (31)', '175|DEPARTEMENT|32': u'-- Gers (32)', '176|DEPARTEMENT|46': u'-- Lot (46)', '177|DEPARTEMENT|65': u'-- Pyrénées (Hautes) (65)', '178|DEPARTEMENT|81': u'-- Tarn (81)', '179|DEPARTEMENT|82': u'-- Tarn et Garonne (82)', '180|REGION|31': u'Nord Pas de Calais', '181|DEPARTEMENT|59': u'-- Nord (59)', '182|DEPARTEMENT|62': u'-- Pas de Calais (62)', '183|REGION|25': u'Normandie (Basse)', '184|DEPARTEMENT|14': u'-- Calvados (14)', '185|DEPARTEMENT|50': u'-- Manche (50)', '186|DEPARTEMENT|61': u'-- Orne (61)', '187|REGION|23': u'Normandie (Haute)', '188|DEPARTEMENT|27': u'-- Eure (27)', '189|DEPARTEMENT|76': u'-- Seine Maritime (76)', '190|REGION|52': u'Pays de la Loire', '191|DEPARTEMENT|44': u'-- Loire Atlantique (44)', '192|DEPARTEMENT|49': u'-- Maine et Loire (49)', '193|DEPARTEMENT|53': u'-- Mayenne (53)', '194|DEPARTEMENT|72': u'-- Sarthe (72)', '195|DEPARTEMENT|85': u'-- Vendée (85)', '196|REGION|22': u'Picardie', '197|DEPARTEMENT|02': u'-- Aisne (02)', '198|DEPARTEMENT|60': u'-- Oise (60)', '199|DEPARTEMENT|80': u'-- Somme (80)', '200|REGION|54': u'Poitou Charentes', '201|DEPARTEMENT|16': u'-- Charente (16)', '202|DEPARTEMENT|17': u'-- Charente Maritime (17)', '203|DEPARTEMENT|79': u'-- Sèvres (Deux) (79)', '204|DEPARTEMENT|86': u'-- Vienne (86)', '205|REGION|93': u'Provence Alpes Côte d\'Azur', '206|DEPARTEMENT|05': u'-- Alpes (Hautes) (05)', '207|DEPARTEMENT|06': u'-- Alpes Maritimes (06)', '208|DEPARTEMENT|04': u'-- Alpes de Haute Provence (04)', '209|DEPARTEMENT|13': u'-- Bouches du Rhône (13)', '210|DEPARTEMENT|83': u'-- Var (83)', '211|DEPARTEMENT|84': u'-- Vaucluse (84)', '212|REGION|82': u'Rhône Alpes', '213|DEPARTEMENT|01': u'-- Ain (01)', '214|DEPARTEMENT|07': u'-- Ardèche (07)', '215|DEPARTEMENT|26': u'-- Drôme (26)', '216|DEPARTEMENT|38': u'-- Isère (38)', '217|DEPARTEMENT|42': u'-- Loire (42)', '218|DEPARTEMENT|69': u'-- Rhône (69)', '219|DEPARTEMENT|73': u'-- Savoie (73)', '220|DEPARTEMENT|74': u'-- Savoie (Haute) (74)', '221|REGION|03': u'Région Antilles / Guyane', '222|DEPARTEMENT|971': u'-- Guadeloupe (971)', '223|DEPARTEMENT|973': u'-- Guyane (973)', '224|DEPARTEMENT|972': u'-- Martinique (972)', '225|DEPARTEMENT|977': u'-- Saint Barthélémy (977)', '226|DEPARTEMENT|978': u'-- Saint Martin (978)', '227|REGION|98': u'Région Atlantique Nord', '228|DEPARTEMENT|975': u'-- Saint Pierre et Miquelon (975)', '229|REGION|95': u'Région Pacifique', '230|DEPARTEMENT|989': u'-- Ile de Clipperton (989)', '231|DEPARTEMENT|988': u'-- Nouvelle Calédonie (988)', '232|DEPARTEMENT|987': u'-- Polynésie française (987)', '233|DEPARTEMENT|984': u'-- Terres australes/antarctiques (984)', '234|DEPARTEMENT|986': u'-- Wallis et Futuna (986)', '235|REGION|97': u'Région Réunion / Mayotte', '236|DEPARTEMENT|976': u'-- Mayotte (976)', '237|DEPARTEMENT|974': u'-- Réunion (974)', }.iteritems())]) type_contrat_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'Tous types de contrats', '11': u'CDI tout public', '14': u'CDI alternance', '13': u'CDI insertion', '12': u'CDD tout public', '16': u'CDD alternance', '15': u'CDD insertion', '10': u'CDD Senior', '3': u'Mission d\'intérim', '4': u'Contrat de travail saisonnier', '5': u'Contrat de travail intermittent', '8': u'Franchise', '7': u'Profession libérale', '9': u'Reprise d\'entreprise', '6': u'Profession commerciale', }.iteritems())]) salary_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'Tout salaire annuel', 'FOURCHETTE1': u'Moins de 15000', 'FOURCHETTE2': u'Compris entre 15000 et 18000', 'FOURCHETTE3': u'Compris entre 18000 et 21000', 'FOURCHETTE4': u'Compris entre 21000 et 24000', 'FOURCHETTE5': u'Compris entre 24000 et 36000', 'FOURCHETTE6': u'Compris entre 36000 et 60000', 'FOURCHETTE7': u'Supérieur à 60000', }.iteritems())]) qualification_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'Toute Qualification', '1': u'Manoeuvre', '2': u'Ouvrier spécialisé', '3': u'Ouvrier qualifié (P1,P2)', '4': u'Ouvrier qualifié (P3,P4,OHQ)', '5': u'Employé non qualifié', '6': u'Employé qualifié', '7': u'Technicien', '8': u'Agent de maîtrise', '9': u'Cadre', }.iteritems())]) limit_date_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'Aucune limite', '1': u'Hier', '3': u'3 jours', '7': u'1 semaine', '14': u'2 semaines', '31': u'1 mois', '93': u'3 mois', }.iteritems())]) domain_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'Tout secteur d\'activité', '88': u'Action sociale sans hebergt', '82': u'Activ.admin/soutien entreprise', '66': u'Activ. auxiliaire finance/assu', '90': u'Activ. crea/artistiq/spectacle', '77': u'Activ. de loc. et loc.-bail', '70': u'Activ. siege soc/conseil gest.', '93': u'Activ. sportive/recreat/loisir', '69': u'Activite juridique/comptable', '94': u'Activite organisations assoc.', '86': u'Activite pr la sante humaine', '53': u'Activites de poste/courrier', '64': u'Activite services financiers', '68': u'Activites immobilieres', '62': u'Activites informatiques', '78': u'Activites liees a l\'emploi', '75': u'Activites veterinaires', '84': u'Administration publiq/defense', '79': u'Agences voyage/activ. liees', '71': u'Archi/ing/control/analyse tech', '65': u'Assurance', '32': u'Autre industrie manufacturiere', '74': u'Autres activ.spe scientif/tech', '08': u'Autres industries extractives', '91': u'Biblio/ musée/ activ. culturel', '36': u'Captage/traitement/distrib.eau', '19': u'Cokefaction et raffinage', '37': u'Collecte/traitement eaux usees', '38': u'Collecte/traitnt/elimin dechet', '45': u'Commerce/reparation auto/moto', '47': u'Commerce detail sauf auto/moto', '46': u'Commerce gros sauf auto/moto', '41': u'Construction de batiments', '01': u'Cult./prod. animale, chasse', '39': u'Depollution/autre gest. dechet', '58': u'Edition', '80': u'Enquetes et securite', '85': u'Enseignement', '52': u'Entreposage/sce auxil. transp', '06': u'Extraction d\'hydrocarbures', '05': u'Extraction houille/ lignite', '07': u'Extraction minerais metalliq.', '26': u'Fab. prod. info/electro/optiq', '22': u'Fabr. prod. caoutchouc/plastiq', '30': u'Fabric. autre materiel transp.', '23': u'Fabric.autre produit non metal', '28': u'Fabric. autres machines/equip.', '27': u'Fabric. d\'equip. electriques', '31': u'Fabrication de meubles', '12': u'Fabrication produit base tabac', '25': u'Fabrication produits metalliq', '42': u'Genie civil', '55': u'Hebergement', '87': u'Hebergt médico-social/ social', '18': u'Imprimerie/reprod. enregistre.', '00': u'Indetermine', '29': u'Industrie automobile', '20': u'Industrie chimique', '14': u'Industrie de l\'habillement', '11': u'Industrie des boissons', '15': u'Industrie du cuir/la chaussure', '17': u'Industrie du papier/du carton', '21': u'Industrie pharmaceutique', '10': u'Industries alimentaires', '13': u'Industrie textile', '24': u'Metallurgie', '92': u'Orga. jeux hasard/argent', '99': u'Organisations et organismes', '03': u'Peche et aquaculture', '35': u'Prod./distrib.elec/gaz/vap/air', '59': u'Prod film cine/video/tv/musiq', '98': u'Production menage bien propre', '60': u'Programmation et diffusion', '73': u'Publicite et etudes de marche', '72': u'Rech.-dev. scientifique', '33': u'Repar./instal. machines/equip.', '95': u'Repar.pc/biens perso/domestiq', '56': u'Restauration', '97': u'Sce domestique pr particuliers', '81': u'Services bat/amenagnt paysager', '63': u'Services d\'information', '96': u'Services personnels', '09': u'Soutien industries extractives', '02': u'Sylvicult./exploit. forestiere', '61': u'Telecommunications', '51': u'Transports aeriens', '50': u'Transports par eau', '49': u'Transports terrestres', '16': u'Travail bois/fab. article bois', '43': u'Travaux constr.specialises', }.iteritems())]) CONFIG = BackendConfig(Value('metier', label='Job name', masked=False, default=''), Value('place', label=u'Place', choices=places_choices, default='100|FRANCE|01'), Value('contrat', label=u'Contract', choices=type_contrat_choices, default=''), Value('salary', label=u'Salary', choices=salary_choices, default=''), Value('qualification', label=u'Qualification', choices=qualification_choices, default=''), Value('limit_date', label=u'Date limite', choices=limit_date_choices, default=''), Value('domain', label=u'Domain', choices=domain_choices, default='')) def search_job(self, pattern=None): return self.browser.search_job(pattern=pattern) def advanced_search_job(self): return self.browser.advanced_search_job(metier=self.config['metier'].get(), place=self.config['place'].get(), contrat=self.config['contrat'].get(), salary=self.config['salary'].get(), qualification=self.config['qualification'].get(), limit_date=self.config['limit_date'].get(), domain=self.config['domain'].get()) def get_job_advert(self, _id, advert=None): return self.browser.get_job_advert(_id, advert) def fill_obj(self, advert, fields): return self.get_job_advert(advert.id, advert) OBJECTS = {BaseJobAdvert: fill_obj} ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/popolemploi/pages.py�������������������������������������������������������������0000664�0000000�0000000�00000005514�12657170273�0020327�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.job import BaseJobAdvert from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import Regexp, CleanText, Date, Env, BrowserURL from weboob.browser.filters.html import Link, CleanHTML class SearchPage(HTMLPage): @method class iter_job_adverts(ListElement): item_xpath = '//table[@class="definition-table ordered"]/tbody/tr' class item(ItemElement): klass = BaseJobAdvert obj_id = Regexp(Link('td[@headers="offre"]/a'), '.*detailoffre/(.*?)(?:\?|;).*') obj_contract_type = CleanText('td[@headers="contrat"]') obj_title = CleanText('td[@headers="offre"]/a') obj_society_name = CleanText('td/div/p/span[@class="company"]/span', default='') obj_place = CleanText('td[@headers="lieu"]') obj_publication_date = Date(CleanText('td[@headers="dateEmission"]')) class AdvertPage(HTMLPage): @method class get_job_advert(ItemElement): klass = BaseJobAdvert obj_id = Env('id') obj_url = BrowserURL('advert', id=Env('id')) obj_title = CleanText('//div[@id="offre-body"]/h4[@itemprop="title"]') obj_job_name = CleanText('//div[@id="offre-body"]/h4[@itemprop="title"]') obj_description = CleanHTML('//div[@id="offre-body"]/p[@itemprop="description"]') obj_society_name = CleanText('//div[@id="offre-body"]/div[@class="vcard"]/p[@class="title"]/span', default='') obj_contract_type = CleanText('//div[@id="offre-body"]/dl/dd/span[@itemprop="employmentType"]') obj_place = CleanText('//div[@id="offre-body"]/dl/dd/ul/li[@itemprop="addressRegion"]') obj_formation = CleanText('//div[@id="offre-body"]/dl/dd/span[@itemprop="qualifications"]') obj_pay = CleanText('//div[@id="offre-body"]/dl/dd/span[@itemprop="baseSalary"]') obj_experience = CleanText('//div[@id="offre-body"]/dl/dd/span[@itemprop="experienceRequirements"]') obj_publication_date = Date(CleanText('//span[@itemprop="datePosted"]')) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/popolemploi/test.py��������������������������������������������������������������0000664�0000000�0000000�00000002576�12657170273�0020214�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class PopolemploiTest(BackendTest): MODULE = 'popolemploi' def test_popolemploi_search(self): l = list(self.backend.search_job('infographiste')) assert len(l) advert = self.backend.get_job_advert(l[0].id, l[0]) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) def test_popolemploi_advanced_search(self): l = list(self.backend.advanced_search_job()) assert len(l) advert = self.backend.get_job_advert(l[0].id, l[0]) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) ����������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016521�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000001526�12657170273�0020636�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"NewspaperPresseuropModule init" # -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NewspaperPresseuropModule __all__ = ['NewspaperPresseuropModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/browser.py������������������������������������������������������������0000664�0000000�0000000�00000004204�12657170273�0020556�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"browser for presseurop website" # -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import date, datetime, time from .pages.article import PresseuropPage, CartoonPage, DailySinglePage,\ DailyTitlesPage from weboob.deprecated.browser import Browser from weboob.tools.ordereddict import OrderedDict class NewspaperPresseuropBrowser(Browser): "NewspaperPresseuropBrowser class" PAGES = OrderedDict(( ("http://www.voxeurop.eu/.*/news-brief/.*", DailySinglePage), ("http://www.voxeurop.eu/.*/today/.*", DailyTitlesPage), ("http://www.voxeurop.eu/.*/cartoon/.*", CartoonPage), ("http://www.voxeurop.eu/.*", PresseuropPage), )) def is_logged(self): return False def login(self): pass def fillobj(self, obj, fields): pass def get_content(self, _id): "return page article content" self.location(_id) return self.page.get_article(_id) def get_daily_date(self, _id): self.location(_id) return self.page.get_daily_date() def get_daily_infos(self, _id): url = "http://www.voxeurop.eu/fr/today/" + _id self.location(url) title = self.page.get_title() article_date = date(*[int(x) for x in _id.split('-')]) article_time = time(0, 0, 0) article_datetime = datetime.combine(article_date, article_time) return url, title, article_datetime ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000000553�12657170273�0020657�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���XGl���sRGB����PLTEnE�]y$~4��� pHYs�� �� ����tIME(S���IDATHŕa 0e7ExWjB[%ݠ{+>-(%XO�0I5'U1Z!�+@N9 aYUf�f\'�;�H : SzI- �|͊�\s)%7LŲBc l%|%ۀCrUIMH/XL }],Ea^VWo!l����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/module.py�������������������������������������������������������������0000664�0000000�0000000�00000006027�12657170273�0020365�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. "backend for http://www.presseurop.eu" from weboob.capabilities.messages import CapMessages, Thread from weboob.tools.capabilities.messages.GenericModule import GenericNewspaperModule from weboob.tools.backend import BackendConfig from weboob.tools.value import Value from .browser import NewspaperPresseuropBrowser from .tools import rssid, url2id from weboob.tools.newsfeed import Newsfeed class NewspaperPresseuropModule(GenericNewspaperModule, CapMessages): MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' STORAGE = {'seen': {}} NAME = 'presseurop' DESCRIPTION = u'Presseurop website' BROWSER = NewspaperPresseuropBrowser RSSID = staticmethod(rssid) URL2ID = staticmethod(url2id) RSSSIZE = 300 CONFIG = BackendConfig(Value('lang', label='Lang of articles', choices={'fr': 'fr', 'de': 'de', 'en': 'en', 'cs': 'cs', 'es': 'es', 'it': 'it', 'nl': 'nl', 'pl': 'pl', 'pt': 'pt', 'ro': 'ro'}, default='fr')) def __init__(self, *args, **kwargs): GenericNewspaperModule.__init__(self, *args, **kwargs) self.RSS_FEED = 'http://www.voxeurop.eu/%s/rss.xml' % self.config['lang'].get() def iter_threads(self): daily = [] for article in Newsfeed(self.RSS_FEED, self.RSSID).iter_entries(): if "/news-brief/" in article.link: day = self.browser.get_daily_date(article.link) if day and (day not in daily): localid = url2id(article.link) daily.append(day) id, title, date = self.browser.get_daily_infos(day) id = id + "#" + localid thread = Thread(id) thread.title = title thread.date = date yield(thread) elif day is None: thread = Thread(article.link) thread.title = article.title thread.date = article.datetime yield(thread) else: thread = Thread(article.link) thread.title = article.title thread.date = article.datetime yield(thread) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/pages/����������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017620�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/pages/__init__.py�����������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021717�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/pages/article.py������������������������������������������������������0000664�0000000�0000000�00000006402�12657170273�0021617�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"ArticlePage object for presseurope" # -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage,\ try_drop_tree, clean_relativ_urls class PresseuropPage(GenericNewsPage): "PresseuropPage object for presseurop" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "title" self.element_author_selector = "div[id=content-author]>a" self.element_body_selector = "div.block, div.panel, div.bodytext" def get_body(self): element_body = self.get_element_body() try_drop_tree(self.parser, element_body, "li.button-social") try_drop_tree(self.parser, element_body, "div.sharecount") clean_relativ_urls(element_body, "http://presseurop.eu") return self.parser.tostring(element_body) def get_title(self): title = GenericNewsPage.get_title(self) title = title.split('|')[0] return title def get_author(self): author = GenericNewsPage.get_author(self) try: source = self.document.getroot().xpath( "//span[@class='sourceinfo']/a")[0] source = source.text author = author + " | " + source return author except: return author class DailyTitlesPage(PresseuropPage): def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "title" self.element_author_selector = "div[id=content-author]>a" self.element_body_selector = "div.bodytext" def get_body(self): element_body = self.get_element_body() try_drop_tree(self.parser, element_body, "li.button-social") try_drop_tree(self.parser, element_body, "aside.articlerelated") try_drop_tree(self.parser, element_body, "div.sharecount") clean_relativ_urls(element_body, "http://presseurop.eu") return self.parser.tostring(element_body) class DailySinglePage(PresseuropPage): def get_daily_date(self): plink = self.document.getroot().xpath("//p[@class='w200']") if len(plink) > 0: link = plink[0].xpath('a')[0] date = link.attrib['href'].split('/')[3] return date return None class CartoonPage(PresseuropPage): "CartoonPage object for presseurop" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "title" self.element_author_selector = "div.profilecartoontext>p>a" self.element_body_selector = "div.bodytext" ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/presseurop/test.py���������������������������������������������������������������0000664�0000000�0000000�00000001665�12657170273�0020062�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class PresseuropTest(BackendTest): MODULE = 'presseurop' def test_new_messages(self): for message in self.backend.iter_unread_messages(): pass ���������������������������������������������������������������������������weboob-1.1/modules/presseurop/tools.py��������������������������������������������������������������0000664�0000000�0000000�00000002025�12657170273�0020232�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"tools for presseurop backend" # -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re def url2id(url): "return an id from an url" if "/today/" in url: return url.split("#")[1] else: regexp = re.compile(".*/([0-9]+)-.*") id = regexp.match(url).group(1) return id def rssid(entry): return url2id(entry.link) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/prixcarburants/������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017361�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/prixcarburants/__init__.py�������������������������������������������������������0000664�0000000�0000000�00000000115�12657170273�0021467�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import PrixCarburantsModule __all__ = ['PrixCarburantsModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/prixcarburants/browser.py��������������������������������������������������������0000664�0000000�0000000�00000004701�12657170273�0021420�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.deprecated.browser import Browser from .pages import IndexPage, ComparisonResultsPage, ShopInfoPage __all__ = ['PrixCarburantsBrowser'] class PrixCarburantsBrowser(Browser): TOKEN = None PROTOCOL = 'http' DOMAIN = 'www.prix-carburants.economie.gouv.fr' ENCODING = 'iso-8859-15' PAGES = { 'http://www.prix-carburants.economie.gouv.fr': IndexPage, 'http://www.prix-carburants.economie.gouv.fr/recherche/': ComparisonResultsPage, 'http://www.prix-carburants.economie.gouv.fr/itineraire/infos/\d+': ShopInfoPage, } def iter_products(self): if not self.is_on_page(IndexPage): self.location("%s://%s" % (self.PROTOCOL, self.DOMAIN)) assert self.is_on_page(IndexPage) return self.page.iter_products() def get_token(self): if not self.is_on_page(IndexPage): self.location("%s://%s" % (self.PROTOCOL, self.DOMAIN)) assert self.is_on_page(IndexPage) self.TOKEN = self.page.get_token() def iter_prices(self, zipcode, product): if self.TOKEN is None: self.get_token() data = { '_recherche_recherchertype[localisation]': '%s' % zipcode, '_recherche_recherchertype[choix_carbu]': '%s' % product.id, '_recherche_recherchertype[_token]': '%s' % self.TOKEN, } self.location('%s://%s' % (self.PROTOCOL, self.DOMAIN), urllib.urlencode(data)) assert self.is_on_page(ComparisonResultsPage) return self.page.iter_results(product) def get_shop_info(self, id): self.location('%s://%s/itineraire/infos/%s' % (self.PROTOCOL, self.DOMAIN, id)) assert self.is_on_page(ShopInfoPage) return self.page.get_info() ���������������������������������������������������������������weboob-1.1/modules/prixcarburants/favicon.png�������������������������������������������������������0000664�0000000�0000000�00000002563�12657170273�0021522�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME   k���IDATxoTUwfwswǶZ-#^MkSe.! "‚J0 BXfea1bq"d\5wuaeUwgs 99|Ç>|ÇBp�R}%A8eL. �tZR*F@+[F|CO 8~ 65X\c PLn�;qw遀1݀.] �p8q*)v+p@]{~Z_X"5APs @3pp|_kԶws*_t( $5FmK{Yb!�d+!gܯկC Q?0r-@L>![ܫЌ�V9\|ږt�̐ tL)uxB0Oޟ|PV2j[ecT)v�:3 $Ӆz`x<%r8pL)u~d wK:ྋJ88"B!f)c qNO !|\RSֿ6?l']zYk�~ڳ ƥq.=ڨ `DrpI{8N>t6[W.lk)xJ8ЮJp#` Lce.'3E9#r{fw?=A1:ch,uQz@#S@F<WZT/̰m)X ۖOfNy6rķ<h,dz!|PߟWz\~'ׯt}!dM M,y4l<b[4BU@ZHNk7Z#˳D Y7D 2 hJ!gn��K;}1K'@H<ZO?EcCEimR*gႌ^¬-x2)zhJH=P̐ u%6z�S99In�qJ?f4xSWr]{m0 m*2dfgRka3K\jm[怬~3m\Of=�WY3,-Xi`I{!X*ēͶe&I>@i#ξX� Jm.=�G䂥8x2c[`Q*�`#H㿻 ;h����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/prixcarburants/module.py���������������������������������������������������������0000664�0000000�0000000�00000004522�12657170273�0021223�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value from weboob.capabilities.pricecomparison import CapPriceComparison, Price, Product from .browser import PrixCarburantsBrowser __all__ = ['PrixCarburantsModule'] class PrixCarburantsModule(Module, CapPriceComparison): NAME = 'prixcarburants' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'French governement website to compare fuel prices' LICENSE = 'AGPLv3+' BROWSER = PrixCarburantsBrowser CONFIG = BackendConfig(Value('zipcode', label='Zipcode', regexp='\d+')) def search_products(self, pattern=None): with self.browser: for product in self.browser.iter_products(): if pattern is None or pattern.lower() in product.name.lower(): yield product def iter_prices(self, product): with self.browser: return self.browser.iter_prices(self.config['zipcode'].get(), product) def get_price(self, id): with self.browser: if isinstance(id, Price): price = id else: p_id, s_id = id.split('.', 2) product = Product(p_id) for price in self.iter_prices(product): if price.id == id: break else: return None price.shop.info = self.browser.get_shop_info(price.id.split('.', 2)[-1]) return price def fill_price(self, price, fields): return self.get_price(price) OBJECTS = {Price: fill_price, } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/prixcarburants/pages.py����������������������������������������������������������0000664�0000000�0000000�00000005270�12657170273�0021036�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from decimal import Decimal from weboob.deprecated.browser import Page from weboob.capabilities import NotAvailable from weboob.capabilities.pricecomparison import Product, Shop, Price class IndexPage(Page): def get_token(self): input = self.parser.select(self.document.getroot(), 'div#localisation input#recherche_recherchertype__token', 1) return input.attrib['value'] def iter_products(self): for li in self.parser.select(self.document.getroot(), 'div#choix_carbu ul li'): input = li.find('input') label = li.find('label') product = Product(input.attrib['value']) product.name = unicode(label.text.strip()) if '&' in product.name: # "E10 & SP95" produces a non-supported table. continue yield product class ComparisonResultsPage(Page): def get_product_name(self): th = self.document.getroot().cssselect('table#tab_resultat tr th') if th and len(th) == 9: return u'%s' % th[5].find('a').text def iter_results(self, product=None): price = None product.name = self.get_product_name() for tr in self.document.getroot().cssselect('table#tab_resultat tr'): tds = self.parser.select(tr, 'td') if tds and len(tds) == 9 and product is not None: price = Price('%s.%s' % (product.id, tr.attrib['id'])) price.product = product price.cost = Decimal(tds[5].text.replace(',', '.')) price.currency = u'€' shop = Shop(price.id) shop.name = unicode(tds[3].text.strip()) shop.location = unicode(tds[2].text.strip()) price.shop = shop price.set_empty_fields(NotAvailable) yield price class ShopInfoPage(Page): def get_info(self): return self.parser.tostring(self.parser.select(self.document.getroot(), 'div.infos', 1)) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/prixcarburants/test.py�����������������������������������������������������������0000664�0000000�0000000�00000002077�12657170273�0020720�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class PrixCarburantsTest(BackendTest): MODULE = 'prixcarburants' def test_prixcarburants(self): products = list(self.backend.search_products('gpl')) self.assertTrue(len(products) == 1) prices = list(self.backend.iter_prices(products[0])) self.backend.fillobj(prices[0]) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/quvi/����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015276�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/quvi/__init__.py�����������������������������������������������������������������0000664�0000000�0000000�00000001456�12657170273�0017415�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import QuviModule, QuviVideo __all__ = ['QuviModule', 'QuviVideo'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/quvi/favicon.png�����������������������������������������������������������������0000664�0000000�0000000�00000005547�12657170273�0017444�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@������ pHYs�� �� ����tIME |���tEXtComment�Created with GIMPW��PLTE�%z%z&{'{(|)|*}*}+~ ,~ - . / 001234566789:;<<=>?? @!A"B#B$C%D&E'F)H*H+I,J,K-K.L/M0N1N2O3P4Q5R6S8T9U:V;W<X=Y?Z@[A\B]C^D_E_F`GaHbIcJdKeLeMfNgOhQjRkSkVnWoXpYqZq[r\s]t^u_v`wawcydzd{e{f|g}h}i~jkklmnopqrsuvwxyz{|}~ŒÍÎďĐőŒƓƔǕǖȗȘəɚʛʝ˞̟̠͢͡ΣϤϥЦЧѨѩҪҫӬӭԮԯհձֲֳ״׵ضطٸٹںۻۼܾܽݿ"���bKGDLdW��IDATXÍ{\TUk�<TQ1 fVdd[ZFQn.A$d`x <ag뿽>fa};@4( KHѷ N%-,,*?BfyK�ޱ1P"AJ@N3L~!ðIx;kխꐤ@bS\;+1-%ZRE0{ďS:Xڄ\0 `/(3Q֓�E}h% otR�5+}k${yu�Oٜ(jm<&P*0'�XB13'5{=�Ci,v.-�_;e�ILl`M*6l=ہ ):V6*�FX=�x q]7l/Z^̱lv15ɾ.-߾B&00awq8OC0Bjkv � >AzׂC`%kyE"յR惀Flx@r!CɆ+ I'E8uDz 4{eKO@! aH�u30b~sB0a' gSm9h#�NY:E+"{"WkWjob�Mz:Ǭ{W/H\kaFGf-L,M .HGS?v=Nn(SC}cv->\v.(>/M Cai|kik^~˜;sa'.uV/Fi1`3fa~uw8OeUrwnj0puTfJ|bJ۰&M|Yo{9أCe%7fB!ɵ3J 8[.fy!vwɔȈ w^*; �W_˻aK"B` 멧\Tz@AL ^z]oa2UxYX m|N!U]dͼ3X)JN |l"lA|y. n@WZ~unGq "q'(J^q̧mEͣӎQc,:.F봀 4.Ӕ>! 0Ɍ Em,YRՕ}ں\p{-9@Z P0S{jw#01sK l##oɌQ!H&!z:=*CNю:D$D'aUBaMpITCĻ _g !<&RظL{\-CcR PEhj}0;:4ԥenؿWn6uEeY]D2 $ SxmRBjSyr³-F3ȟv =jŭe{fWt>"D8MWs{D[) C&�qcd_grR!-ky�n~$bl9˃VgS$[đZuf )b)W+ 8`xN&\IԪfXyٮdgv] ;qcl ʽSUe8u4,kO̠8o  ˚݇ \�頩+܍^w˙C3jy�^T%^[#DC3D(npAvSűJOYia$[>7 hNkC#M>ނW/um_ MiΣ|OXH¼"<LX%<0mK nRsrLǠ4á X?#)HGǰe3c&Uj*/+%.zfDDD. t波a'^ޥ9×U`U68o/Q~9 ����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/quvi/module.py�������������������������������������������������������������������0000664�0000000�0000000�00000010053�12657170273�0017134�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. # sample usage: youtube.XXXXXX@quvi # or also: https://www.youtube.com/watch?v=XXXXXX@quvi # shortened URLs are also supported # this backend requires the quvi 0.4 C library to be installed import datetime from weboob.capabilities.base import UserError, StringField from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.image import BaseImage from weboob.tools.backend import Module from weboob.tools.misc import to_unicode from .quvi import LibQuvi, QuviError __all__ = ['QuviModule', 'QuviVideo'] class QuviModule(Module, CapVideo): NAME = 'quvi' DESCRIPTION = u'Multi-website video helper with quvi. Handles Youtube, BBC, and a lot more' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = None def get_video(self, _id): video = QuviVideo(_id) parser = LibQuvi() if not parser.load(): raise UserError('Make sure libquvi 0.4 is installed') try: info = parser.get_info(video.page_url) except QuviError as qerror: raise UserError(qerror.message) video.url = to_unicode(info.get('url')) if not video.url: raise NotImplementedError() video.ext = to_unicode(info.get('suffix')) video.title = to_unicode(info.get('title')) video.page = to_unicode(info.get('page')) duration = int(info.get('duration', 0)) if duration: video.duration = datetime.timedelta(milliseconds=duration) if info.get('thumbnail'): video.thumbnail = BaseImage(info.get('thumbnail')) video.thumbnail.url = video.thumbnail.id return video class QuviVideo(BaseVideo): BACKENDS = { 'youtube': 'https://www.youtube.com/watch?v=%s', 'vimeo': 'http://vimeo.com/%s', 'dailymotion': 'http://www.dailymotion.com/video/%s', 'metacafe': 'http://www.metacafe.com/watch/%s/', 'arte': 'http://videos.arte.tv/fr/videos/plop--%s.html', 'videa': 'http://videa.hu/videok/%s/', 'wimp': 'http://www.wimp.com/%s/', 'funnyordie': 'http://www.funnyordie.com/videos/%s/', 'tapuz': 'http://flix.tapuz.co.il/v/watch-%s-.html', 'liveleak': 'http://www.liveleak.com/view?i=%s', # nsfw 'xhamster': 'https://xhamster.com/movies/%s/plop.html', 'xvideos': 'http://www.xvideos.com/video%s/', 'redtube': 'http://www.redtube.com/%s', 'xnxx': 'http://video.xnxx.com/video%s/', # more websites are supported, but <service>.<id> isn't always enough # however, URLs are supported, like this: # https://www.youtube.com/watch?v=BaW_jenozKc@quvi } page = StringField('Page URL of the video') @classmethod def id2url(cls, _id): if _id.startswith('http'): return _id if '.' not in _id: raise UserError('Please give an ID in form WEBSITE.ID (for example youtube.BaW_jenozKc). Supported websites are: %s' % ', '.join(cls.BACKENDS.keys())) sub_backend, sub_id = _id.split('.', 1) try: return cls.BACKENDS[sub_backend] % sub_id except KeyError: raise NotImplementedError() @property def page_url(self): if self.page: return self.page else: return self.id2url(self.id) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/quvi/quvi.py���������������������������������������������������������������������0000664�0000000�0000000�00000007352�12657170273�0016643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from ctypes import cdll, c_char_p, c_double, c_void_p, byref from ctypes.util import find_library class QuviError(Exception): pass class LibQuvi04(object): QUVI_VERSION = 0 QUVIOPT_FORMAT = 0 QUVIOPT_CATEGORY = 4 QUVI_OK = 0 QUVI_LAST = 5 QUVIPROP_PAGEURL = 0x100002 QUVIPROP_PAGETITLE = 0x100003 QUVIPROP_MEDIAID = 0x100004 QUVIPROP_MEDIAURL = 0x100005 QUVIPROP_FILESUFFIX = 0x100008 #~ QUVIPROP_FORMAT = 0x10000A QUVIPROP_MEDIATHUMBNAILURL = 0x10000C QUVIPROP_MEDIACONTENTLENGTH = 0x300006 QUVIPROP_MEDIADURATION = 0x30000D QUVIPROTO_HTTP = 1 QUVIPROTO_RTMP = 8 def __init__(self, lib=None): self.lib = lib self.qh = c_void_p() self.qmh = c_void_p() def load(self): path = find_library('quvi') if not path: return False self.lib = cdll.LoadLibrary(path) if self.lib is None: return False self.lib.quvi_version.restype = c_char_p version_str = self.lib.quvi_version(self.QUVI_VERSION) if version_str.startswith('v0.4'): return True else: return False def _cleanup(self): if self.qmh: self.lib.quvi_parse_close(byref(self.qmh)) self.qmh = c_void_p() if self.qh: self.lib.quvi_close(byref(self.qh)) self.qh = c_void_p() def get_info(self, url): try: return self._get_info(url) finally: self._cleanup() def _get_info(self, url): status = self.lib.quvi_init(byref(self.qh)) self._assert_ok(status) status = self.lib.quvi_setopt(self.qh, self.QUVIOPT_FORMAT, 'best') self._assert_ok(status) status = self.lib.quvi_parse(self.qh, c_char_p(url), byref(self.qmh)) self._assert_ok(status) info = {} info['url'] = self._get_str(self.QUVIPROP_MEDIAURL) info['title'] = self._get_str(self.QUVIPROP_PAGETITLE) info['suffix'] = self._get_str(self.QUVIPROP_FILESUFFIX) info['page'] = self._get_str(self.QUVIPROP_PAGEURL) # uncut! info['media_id'] = self._get_str(self.QUVIPROP_MEDIAID) info['thumbnail'] = self._get_str(self.QUVIPROP_MEDIATHUMBNAILURL) info['duration'] = self._get_double(self.QUVIPROP_MEDIADURATION) info['size'] = self._get_double(self.QUVIPROP_MEDIACONTENTLENGTH) return info def _assert_ok(self, status): if status != self.QUVI_OK: self.lib.quvi_strerror.restype = c_char_p c_msg = self.lib.quvi_strerror(self.qh, status) raise QuviError(c_msg) def _get_str(self, prop): c_value = c_char_p() status = self.lib.quvi_getprop(self.qmh, prop, byref(c_value)) self._assert_ok(status) return c_value.value def _get_double(self, prop): c_value = c_double() status = self.lib.quvi_getprop(self.qmh, prop, byref(c_value)) self._assert_ok(status) return c_value.value LibQuvi = LibQuvi04 ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/quvi/test.py���������������������������������������������������������������������0000664�0000000�0000000�00000003137�12657170273�0016633�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class QuviTest(BackendTest): MODULE = 'quvi' def test_get_id(self): v = self.backend.get_video('youtube.BaW_jenozKc') assert len(v.url) assert len(v.title) assert (v.page_url == 'https://www.youtube.com/watch?v=BaW_jenozKc') def test_get_url(self): v = self.backend.get_video('https://www.youtube.com/watch?v=BaW_jenozKc') assert len(v.url) assert len(v.title) # did we retrieve more? assert len(v.ext) assert v.duration assert v.thumbnail assert v.page_url == 'https://www.youtube.com/watch?v=BaW_jenozKc' def test_get_shortened(self): v = self.backend.get_video('http://youtu.be/BaW_jenozKc') assert len(v.url) assert len(v.title) assert v.page_url.startswith('http://www.youtube.com/watch?v=BaW_jenozKc') ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/radiofrance/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016567�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/radiofrance/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000001477�12657170273�0020711�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# * -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Johann Broudin, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import RadioFranceModule __all__ = ['RadioFranceModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/radiofrance/browser.py�����������������������������������������������������������0000664�0000000�0000000�00000007313�12657170273�0020630�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# * -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Johann Broudin, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import RadioPage, JsonPage, PodcastPage __all__ = ['RadioFranceBrowser'] class RadioFranceBrowser(PagesBrowser): json_page = URL('sites/default/files/(?P<json_url>.*).json', 'player-json/reecoute/(?P<json_url_fip>.*)', 'station/(?P<fbplayer>.*)', JsonPage) podcast_page = URL('podcast09/rss_(?P<podcast_id>.*)\.xml', PodcastPage) radio_page = URL('(?P<page>.*)', RadioPage) def get_radio_url(self, radio, player): self.BASEURL = 'http://www.%s.fr/' % radio if radio == 'francebleu': return self.json_page.go(fbplayer=player).get_fburl() return self.radio_page.go(page=player).get_url() def get_current(self, radio, url): self.BASEURL = 'http://www.%s.fr/' % radio if radio == 'francebleu': return self.radio_page.go(page=url).get_current() return self.json_page.go(json_url=url).get_current() def get_selection(self, radio_url, json_url, radio_id): self.BASEURL = 'http://www.%s.fr/' % radio_url if radio_id == 'fipradio': return self.json_page.go(json_url_fip=json_url).get_selection(radio_id=radio_id) return self.json_page.go(json_url=json_url).get_selection(radio_id=radio_id) def get_audio(self, _id, radio_url, json_url, radio_id): for item in self.get_selection(radio_url, json_url, radio_id): if item.id == _id: return item return [] def search_audio(self, pattern, radio_url, json_url, radio_id): for item in self.get_selection(radio_url, json_url, radio_id): if pattern.upper() in item.title.upper(): yield item def get_podcast_emissions(self, radio_url, podcast_url, split_path): self.BASEURL = 'http://www.%s.fr/' % radio_url if split_path[0] == 'franceinter': return self.radio_page.go(page=podcast_url).get_france_inter_podcast_emissions(split_path=split_path) elif split_path[0] == 'franceculture': return self.radio_page.go(page=podcast_url).get_france_culture_podcast_emissions(split_path=split_path) elif split_path[0] == 'franceinfo': return self.radio_page.go(page=podcast_url).get_france_info_podcast_emissions(split_path=split_path) elif split_path[0] == 'francemusique': return self.radio_page.go(page=podcast_url).get_france_musique_podcast_emissions(split_path=split_path) elif split_path[0] == 'mouv': return self.radio_page.go(page=podcast_url).get_mouv_podcast_emissions(split_path=split_path) def get_podcasts(self, podcast_id): self.BASEURL = 'http://radiofrance-podcast.net/' return self.podcast_page.go(podcast_id=podcast_id).iter_podcasts() def get_france_culture_podcasts_url(self, url): self.BASEURL = 'http://www.franceculture.fr/podcast/' return self.radio_page.go(page=url).get_france_culture_podcasts_url() ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/radiofrance/favicon.png����������������������������������������������������������0000664�0000000�0000000�00000003657�12657170273�0020735�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���% ���sRGB����bKGD������ pHYs�� �� ����tIMEr ���iTXtComment�����Created with GIMPd.e��IDATh{PSW7$! 0 Ĕ,C"EWS+>ЭeL�LgR]V* 4J!� }R`tw} BQD"7`\�`X�`X�`XGغc&3�<ތ8qg5ﮍ}.Qşs�R7gD$Pn{ۿwmU!%⟚+b˺w4N薙T=Hx@~x3mvڽ%)sac˱L9^)jkʿ5�+$� )}NܸNOT2-2HYl|iv)2 V)z˭}f+NO،!}&rZ�(x6J2Ko.(xCkxB_VȉDUɌU4~w�lOrFDɖx ՟o=�l0;~+� \Dw Wh3[K-w;q$l8R1 Y C}��Y3BZ:V$?SbBVNB<J/hs✎{3v� ь9V[s){sR�PPvIwtvAeQ^/#�0"iy22ЉN�, rl\�ld(fA"rc~Í ;-p.UoI^<�|K}8�8QP�JWV8}SV<XW=&LҘK-wj{(!Txvpf2cGj4|Z{oضs{,6|pvW>f'/lj #Zu]rçM|BN�,Ӯa�xBP((j49BN4A@ HV^*M&S'p@KVjwww� I҅ EQ7%%E vww*$ɢR)ZqݎgϞX h4[Sf!o\*1ԎonbVl\Ԝ0A4N|8isr¢d7O_qyȂ9 !K(qAg쳂E~~6Xk�7.0u<*IUH}�A`iI,ЫҧO k׮-[p8m۶uttz^izB_?ygژuʜ KIV3WuCyrg�`MjXV\oU4\ņGJ?ŕM]]]###f`0LO3+m! ?2hLf'+�Umz 7T�ia�yg˺{6+F4ig�d&8 !%I$I.K'k=HQŏAB+~ (ǿe&g6N7.gJa4d3kC[ȻY3%O7EV5bֲª뚁듛4�P>nӊ?<7nRD+v�䦅<<.ύ{M*]y({&(=۞#Moߔ}Scב\_VO|T(hR}E͗rp`v\]Z9#";yBMuӭcןmٰL7\sCB}Q:q|ttjҭԣNOxK$b&`51  /Ѷ����IENDB`���������������������������������������������������������������������������������weboob-1.1/modules/radiofrance/module.py������������������������������������������������������������0000664�0000000�0000000�00000042437�12657170273�0020440�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# * -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Johann Broudin, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.base import NotLoaded from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.audio import CapAudio, BaseAudio from weboob.capabilities.audiostream import BaseAudioStream from weboob.tools.capabilities.streaminfo import StreamInfo from weboob.capabilities.collection import CapCollection, CollectionNotFound, Collection from weboob.tools.backend import Module from .browser import RadioFranceBrowser import re import time from datetime import datetime __all__ = ['RadioFranceModule'] class RadioFranceModule(Module, CapRadio, CapCollection, CapAudio): NAME = 'radiofrance' MAINTAINER = u'Laurent Bachelier' EMAIL = 'laurent@bachelier.name' VERSION = '1.1' DESCRIPTION = u'Radios of Radio France: Inter, Info, Bleu, Culture, Musique, FIP, Le Mouv\'' LICENSE = 'AGPLv3+' BROWSER = RadioFranceBrowser _RADIOS = { 'franceinter': {u'title': u'France Inter', u'player': u'player', u'live': u'lecteur_commun_json/timeline', u'podcast': u'podcasts', u'selection': u'lecteur_commun_json/reecoute-%s' % int(time.mktime(datetime.now().replace(hour=13, minute=0, second=0).timetuple()))}, 'franceculture': {u'title': u'France Culture', u'player': u'player', u'live': u'lecteur_commun_json/timeline', u'podcast': u'podcasts', u'selection': u'lecteur_commun_json/selection'}, 'franceinfo': {u'title': u'France Info', u'player': u'player', u'live': u'lecteur_commun_json/timeline', u'podcast': u'programmes-chroniques/podcasts', u'selection': u'lecteur_commun_json/reecoute-%s' % int(time.mktime(datetime.now().replace(hour=13, minute=0, second=0).timetuple()))}, 'fbidf': {u'title': u'France Bleu Île-de-France (Paris)', u'player': u'107-1', u'live': u'grid/107-1'}, 'fipradio': {u'title': u'FIP', u'player': u'player', u'live': 'import_si/si_titre_antenne/FIP_player_current', u'selection': u'%s' % int(time.mktime(datetime.now().replace(hour=12, minute=0, second=0).timetuple()))}, 'francemusique': {u'title': u'France Musique', u'player': u'player', u'live': u'lecteur_commun_json/reecoute-%s' % int(time.mktime(datetime.now().replace(hour=13, minute=0, second=0).timetuple())), u'podcast': u'emissions', u'selection': u'lecteur_commun_json/reecoute-%s' % int(time.mktime(datetime.now().replace(hour=13, minute=0, second=0).timetuple()))}, 'mouv': {u'title': u'Le Mouv\'', u'player': u'player', u'live': u'lecteur_commun_json/timeline', u'podcast': u'podcasts', u'selection': u'lecteur_commun_json/reecoute-%s' % int(time.mktime(datetime.now().replace(hour=13, minute=0, second=0).timetuple()))}, 'fbalsace': {u'title': u'France Bleu Alsace (Strasbourg)', u'player': u'alsace', u'live': u'grid/alsace'}, 'fbarmorique': {u'title': u'France Bleu Armorique (Rennes)', u'player': u'armorique', u'live': u'grid/armorique'}, 'fbauxerre': {u'title': u'France Bleu Auxerre', u'player': u'auxerre', u'live': u'grid/auxerre'}, 'fbazur': {u'title': u'France Bleu Azur (Nice)', u'player': u'azur', u'live': u'grid/azur'}, 'fbbassenormandie': {u'title': u'France Bleu Basse Normandie (Caen)', u'player': u'basse-normandie', u'live': u'grid/basse-normandie'}, 'fbbearn': {u'title': u'France Bleu Bearn (Pau)', u'player': u'bearn', u'live': u'grid/bearn'}, 'fbbelfort': {u'title': u'France Bleu Belfort', u'player': u'belfort-montbeliard', u'live': u'grid/belfort-montbeliard'}, 'fbberry': {u'title': u'France Bleu Berry (Châteauroux)', u'player': u'berry', u'live': u'grid/berry'}, 'fbbesancon': {u'title': u'France Bleu Besancon', u'player': u'besancon', u'live': u'grid/besancon'}, 'fbbourgogne': {u'title': u'France Bleu Bourgogne (Dijon)', u'player': u'bourgogne', u'live': u'grid/bourgogne'}, 'fbbreihzizel': {u'title': u'France Bleu Breizh Izel (Quimper)', u'player': u'breizh-izel', u'live': u'grid/breizh-izel'}, 'fbchampagne': {u'title': u'France Bleu Champagne (Reims)', u'player': u'champagne-ardenne', u'live': u'grid/champagne-ardenne'}, 'fbcotentin': {u'title': u'France Bleu Cotentin (Cherbourg)', u'player': u'cotentin', u'live': u'grid/cotentin'}, 'fbcreuse': {u'title': u'France Bleu Creuse (Gueret)', u'player': u'creuse', u'live': u'grid/creuse'}, 'fbdromeardeche': {u'title': u'France Bleu Drome Ardeche (Valence)', u'player': u'drome-ardeche', u'live': u'grid/drome-ardeche'}, 'fbelsass': {u'title': u'France Bleu Elsass', u'player': 'elsass', u'live': u'grid/elsass'}, 'fbgardlozere': {u'title': u'France Bleu Gard Lozère (Nîmes)', u'player': u'gard-lozere', u'live': u'grid/gard-lozere'}, 'fbgascogne': {u'title': u'France Bleu Gascogne (Mont-de-Marsan)', u'player': u'gascogne', u'live': u'grid/gascogne'}, 'fbgironde': {u'title': u'France Bleu Gironde (Bordeaux)', u'player': u'gironde', u'live': u'grid/gironde'}, 'fbhautenormandie': {u'title': u'France Bleu Haute Normandie (Rouen)', u'player': u'haute-normandie', u'live': u'grid/haute-normandie'}, 'fbherault': {u'title': u'France Bleu Hérault (Montpellier)', u'player': u'herault', u'live': u'grid/herault'}, 'fbisere': {u'title': u'France Bleu Isère (Grenoble)', u'player': u'isere', u'live': u'grid/isere'}, 'fblarochelle': {u'title': u'France Bleu La Rochelle', u'player': u'la-rochelle', u'live': u'grid/la-rochelle'}, 'fblimousin': {u'title': u'France Bleu Limousin (Limoges)', u'player': u'limousin', u'live': u'grid/limousin'}, 'fbloireocean': {u'title': u'France Bleu Loire Océan (Nantes)', u'player': u'loire-ocean', u'live': u'grid/loire-ocean'}, 'fblorrainenord': {u'title': u'France Bleu Lorraine Nord (Metz)', u'player': u'lorraine-nord', u'live': u'grid/lorraine-nord'}, 'fbmaine': {u'title': u'France Bleu Maine', u'player': 'maine', u'live': u'grid/maine'}, 'fbmayenne': {u'title': u'France Bleu Mayenne (Laval)', u'player': u'mayenne', u'live': u'grid/mayenne'}, 'fbnord': {u'title': u'France Bleu Nord (Lille)', u'player': u'nord', u'live': u'grid/nord'}, 'fborleans': {u'title': u'France Bleu Orléans', u'player': u'orleans', u'live': u'grid/orleans'}, 'fbpaysbasque': {u'title': u'France Bleu Pays Basque (Bayonne)', u'player': u'pays-basque', u'live': u'grid/pays-basque'}, 'fbpaysdauvergne': {u'title': u'France Bleu Pays d\'Auvergne (Clermont-Ferrand)', u'player': u'pays-d-auvergne', u'live': u'grid/pays-d-auvergne'}, 'fbpaysdesavoie': {u'title': u'France Bleu Pays de Savoie (Chambery)', u'player': u'pays-de-savoie', u'live': u'grid/pays-de-savoie'}, 'fbperigord': {u'title': u'France Bleu Périgord (Périgueux)', u'player': u'perigord', u'live': u'grid/perigord'}, 'fbpicardie': {u'title': u'France Bleu Picardie (Amiens)', u'player': u'picardie', u'live': u'grid/picardie'}, 'fbpoitou': {u'title': u'France Bleu Poitou (Poitiers)', u'player': u'poitou', u'live': u'grid/poitou'}, 'fbprovence': {u'title': u'France Bleu Provence (Aix-en-Provence)', u'player': u'provence', u'live': u'grid/provence'}, 'fbrcfm': {u'title': u'France Bleu RCFM', u'player': u'rcfm', u'live': u'grid/rcfm'}, 'fbsaintetienneloire': {u'title': u'France Bleu Saint-Etienne Loire', u'player': u'saint-etienne-loire', u'live': u'grid/saint-etienne-loire'}, 'fbroussillon': {u'title': u'France Bleu Roussillon', u'player': u'roussillon', u'live': u'grid/roussillon'}, 'fbsudlorraine': {u'title': u'France Bleu Sud Lorraine (Nancy)', u'player': u'sud-lorraine', u'live': u'grid/sud-lorraine'}, 'fbtoulouse': {u'title': u'France Bleu Toulouse', u'player': u'toulouse', u'live': u'grid/toulouse'}, 'fbtouraine': {u'title': u'France Bleu Touraine (Tours)', u'player': u'touraine', u'live': u'grid/touraine'}, 'fbvaucluse': {u'title': u'France Bleu Vaucluse (Avignon)', u'player': u'vaucluse', u'live': u'grid/vaucluse'}, } def iter_resources(self, objs, split_path): if len(split_path) == 0: for _id, item in sorted(self._RADIOS.iteritems()): if not _id.startswith('fb'): yield Collection([_id], item['title']) yield Collection([u'francebleu'], u'France Bleu') elif split_path[0] == u'francebleu': if len(split_path) == 1: for _id, item in sorted(self._RADIOS.iteritems()): if _id.startswith('fb'): yield Collection([_id], item['title']) elif len(split_path) > 1 and split_path[1] in self._RADIOS: if len(split_path) == 2: yield Collection([split_path[0], u'direct'], u'Direct') if 'selection' in self._RADIOS[split_path[1]]: yield Collection([split_path[0], u'selection'], u'Selection') elif len(split_path) == 3 and split_path[2] == 'selection': selection_url = self._RADIOS[split_path[1]]['selection'] for item in self.browser.get_selection('francebleu', selection_url, split_path[1]): yield item elif len(split_path) == 3 and split_path[2] == 'direct': yield self.get_radio(split_path[1]) else: raise CollectionNotFound(split_path) elif len(split_path) == 1: yield Collection([split_path[0], u'direct'], u'Direct') if 'selection' in self._RADIOS[split_path[0]]: yield Collection([split_path[0], u'selection'], u'Selection') if 'podcast' in self._RADIOS[split_path[0]]: yield Collection([split_path[0], u'podcasts'], u'Podcast') elif len(split_path) == 2 and split_path[1] == 'selection': for _id, item in sorted(self._RADIOS.iteritems()): if _id == split_path[0]: if 'selection' in self._RADIOS[_id]: selection_url = self._RADIOS[_id]['selection'] for item in self.browser.get_selection(_id, selection_url, _id): yield item break elif len(split_path) == 2 and split_path[1] == 'podcasts': for item in self.browser.get_podcast_emissions(split_path[0], self._RADIOS[split_path[0]]['podcast'], split_path): yield item elif len(split_path) == 2 and split_path[1] == 'direct': yield self.get_radio(split_path[0]) elif len(split_path) == 3: podcasts_url = split_path[-1] if split_path[0] == 'franceculture': podcasts_url = self.browser.get_france_culture_podcasts_url(split_path[-1]) for item in self.browser.get_podcasts(podcasts_url): yield item else: raise CollectionNotFound(split_path) def get_radio(self, radio): def create_stream(url, hd=True): stream = BaseAudioStream(0) if hd: stream.bitrate = 128 else: stream.bitrate = 32 url = url.replace('midfi128', 'lofi32') stream.format = u'mp3' stream.title = u'%s kbits/s' % (stream.bitrate) stream.url = url return stream if not isinstance(radio, Radio): radio = Radio(radio) if radio.id not in self._RADIOS: return None title = self._RADIOS[radio.id]['title'] player_url = self._RADIOS[radio.id]['player'] radio.title = title radio.description = title radio_name = radio.id if not radio.id.startswith('fb') else 'francebleu' url = self.browser.get_radio_url(radio_name, player_url) self.fillobj(radio, ('current', )) radio.streams = [create_stream(url), create_stream(url, False)] return radio def fill_radio(self, radio, fields): if 'current' in fields: title = self._RADIOS[radio.id]['title'] live_url = self._RADIOS[radio.id]['live'] radio_name = radio.id if not radio.id.startswith('fb') else 'francebleu' artist, title = self.browser.get_current(radio_name, live_url) if not radio.current or radio.current is NotLoaded: radio.current = StreamInfo(0) radio.current.what = title radio.current.who = artist return radio def fill_audio(self, audio, fields): if 'thumbnail' in fields and audio.thumbnail: audio.thumbnail.data = self.browser.open(audio.thumbnail.url) return audio def get_radio_id(self, audio_id): m = re.match('^\w+\.(\w+)\..*', audio_id) if m: return m.group(1) return '' def search_audio(self, pattern, sortby=CapAudio.SEARCH_RELEVANCE): for radio in self._RADIOS: if 'selection' in self._RADIOS[radio]: selection_url = self._RADIOS[radio]['selection'] radio_url = radio if not radio.startswith('fb') else 'francebleu' for item in self.browser.search_audio(pattern, radio_url, selection_url, radio): yield item def get_audio(self, _id): radio = self.get_radio_id(_id) if radio in self._RADIOS: if 'selection' in self._RADIOS[radio]: selection_url = self._RADIOS[radio]['selection'] radio_url = radio if not radio.startswith('fb') else 'francebleu' return self.browser.get_audio(_id, radio_url, selection_url, radio) elif radio == 'podcast': m = re.match('audio\.podcast\.(\d*)-.*', _id) if m: for item in self.browser.get_podcasts(m.group(1)): if _id == item.id: return item def iter_radios_search(self, pattern): for key, radio in self._RADIOS.iteritems(): if pattern.lower() in radio['title'].lower() or pattern.lower() in key.lower(): yield self.get_radio(key) OBJECTS = {Radio: fill_radio, BaseAudio: fill_audio} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/radiofrance/pages.py�������������������������������������������������������������0000664�0000000�0000000�00000026007�12657170273�0020245�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.elements import ItemElement, DictElement, ListElement, method from weboob.browser.pages import HTMLPage, JsonPage, XMLPage from weboob.browser.filters.json import Dict from weboob.browser.filters.standard import Format, CleanText, Join, Env, Regexp, Duration, Time from weboob.capabilities.audio import BaseAudio from weboob.tools.capabilities.audio.audio import BaseAudioIdFilter from weboob.capabilities.image import BaseImage from weboob.capabilities.collection import Collection import time from datetime import timedelta, datetime, date class PodcastPage(XMLPage): @method class iter_podcasts(ListElement): item_xpath = '//item' class item(ItemElement): klass = BaseAudio obj_id = BaseAudioIdFilter(Format('podcast.%s', Regexp(CleanText('./guid'), 'http://media.radiofrance-podcast.net/podcast09/(.*).mp3'))) obj_title = CleanText('title') obj_format = u'mp3' obj_url = CleanText('enclosure/@url') obj_description = CleanText('description') def obj_author(self): author = self.el.xpath('itunes:author', namespaces={'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'}) return CleanText('.')(author[0]) def obj_duration(self): duration = self.el.xpath('itunes:duration', namespaces={'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'}) return Duration(CleanText('.'))(duration[0]) def obj_thumbnail(self): thumbnail = BaseImage(CleanText('//image[1]/url')(self)) thumbnail.url = thumbnail.id return thumbnail class RadioPage(HTMLPage): def get_url(self): url = Regexp(CleanText('//script'), '.*liveUrl: \'(.*)\', timeshiftUrl.*', default=None)(self.doc) if not url: url = CleanText('//a[@id="player"][1]/@href')(self.doc) return url def get_france_culture_podcasts_url(self): return Regexp(CleanText('//a[@class="lien-rss"][1]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml')(self.doc) @method class get_france_culture_podcast_emissions(ListElement): item_xpath = '//li/h3/a' ignore_duplicate = True class item(ItemElement): klass = Collection def condition(self): return u'/podcast/' in CleanText('./@href')(self) def obj_split_path(self): _id = Regexp(CleanText('./@href'), '/podcast/(.*)')(self) self.env['split_path'].append(_id) return self.env['split_path'] obj_id = Regexp(CleanText('./@href'), '/podcast/(.*)') obj_title = CleanText('.') @method class get_france_info_podcast_emissions(ListElement): item_xpath = '//div[@class="emission-gdp"]' ignore_duplicate = True class item(ItemElement): klass = Collection def obj_split_path(self): _id = Regexp(CleanText('./div/div/div/div/ul/li/a[@class="ico-rss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml')(self) self.env['split_path'].append(_id) return self.env['split_path'] obj_id = Regexp(CleanText('./div/div/div/div/ul/li/a[@class="ico-rss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml') obj_title = CleanText('./h2/a') @method class get_mouv_podcast_emissions(ListElement): item_xpath = '//div[@class="view-content"]/div' ignore_duplicate = True class item(ItemElement): klass = Collection def condition(self): return CleanText('./div/a[@class="podcast-rss"]/@href')(self) and \ Regexp(CleanText('./div/a[@class="podcast-rss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml')(self) def obj_split_path(self): _id = Regexp(CleanText('./div/a[@class="podcast-rss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml')(self) self.env['split_path'].append(_id) return self.env['split_path'] obj_id = Regexp(CleanText('./div/a[@class="podcast-rss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml') obj_title = CleanText('./h2') @method class get_france_musique_podcast_emissions(ListElement): item_xpath = '//div[@class="liste-emissions"]/ul/li' ignore_duplicate = True class item(ItemElement): klass = Collection def condition(self): return CleanText('./div/ul/li/a[@class="ico-rss"]/@href')(self) and\ Regexp(CleanText('./div/ul/li/a[@class="ico-rss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml')(self) def obj_split_path(self): _id = Regexp(CleanText('./div/ul/li/a[@class="ico-rss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml')(self) self.env['split_path'].append(_id) return self.env['split_path'] obj_id = Regexp(CleanText('./div/ul/li/a[@class="ico-rss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml') obj_title = CleanText('./div/h3') @method class get_france_inter_podcast_emissions(ListElement): item_xpath = '//div[has-class("item-list")]/ul/li/div/div' ignore_duplicate = True class item(ItemElement): klass = Collection def condition(self): return CleanText('./div/a[@class="podrss"]/@href')(self) and\ Regexp(CleanText('./div/a[@class="podrss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml')(self) def obj_split_path(self): _id = Regexp(CleanText('./div/a[@class="podrss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml')(self) self.env['split_path'].append(_id) return self.env['split_path'] obj_id = Regexp(CleanText('./div/a[@class="podrss"]/@href'), 'http://radiofrance-podcast.net/podcast09/rss_(.*).xml') obj_title = CleanText('./h2/a') def get_current(self): now = datetime.now() today = date.today() emission_title = u'' for el in self.doc.xpath('//li[@class="chronique clear"]'): emission_time = Time(CleanText('./div[@class="quand"]', replace=[(u'à', '')]))(el) emission_datetime = datetime.combine(today, emission_time) if emission_datetime > now: return u'', emission_title emission_title = CleanText('./h3[@class="titre"]')(el) return u'', u'' class JsonPage(JsonPage): @method class get_selection(DictElement): def __init__(self, *args, **kwargs): super(DictElement, self).__init__(*args, **kwargs) if 'json_url' not in self.env or \ self.env['json_url'] != u'lecteur_commun_json/selection': self.item_xpath = 'diffusions' ignore_duplicate = True class item(ItemElement): klass = BaseAudio def condition(self): return Dict('path_mp3')(self) obj_id = BaseAudioIdFilter(Format(u'%s.%s', Env('radio_id'), Dict('nid'))) obj_format = u'mp3' obj_title = Format(u'%s : %s', Dict('title_emission'), Dict('title_diff')) obj_description = Dict('desc_emission', default=u'') obj_author = Join(u', ', Dict('personnes', default=u'')) obj_url = Dict('path_mp3') def obj_thumbnail(self): if 'path_img_emission' in self.el: thumbnail = BaseImage(Dict('path_img_emission')(self)) thumbnail.url = thumbnail.id return thumbnail def obj_duration(self): fin = Dict('fin')(self) debut = Dict('debut')(self) if debut and fin: return timedelta(seconds=int(fin) - int(debut)) def get_current(self): if 'current' in self.doc: emission_title = self.doc['current']['emission']['titre'] song_title = self.doc['current']['song']['titre'] title = u'%s: %s' % (emission_title, song_title) person = self.doc['current']['song']['interpreteMorceau'] return person, title elif 'diffusions' in self.doc: now = int(time.time()) for item in self.doc['diffusions']: if item['debut'] < now and item['fin'] > now: title = u'%s: %s' % (item['title_emission'], item['title_diff'] if 'title_diff' in item else '') person = u'' return person, title return u'', u'' else: now = int(time.time()) for item in self.doc: if int(item['debut']) < now and int(item['fin']) > now: emission = u'' if 'diffusions' in item and item['diffusions'] and 'title' in item['diffusions'][0]: emission = item['diffusions'][0]['title'] title = item['title_emission'] if emission: title = u'%s: %s' % (title, emission) person = u'' if 'personnes' in item and item['personnes'] and item['personnes'][0]: person = u','.join(item['personnes']) return person, title return u'', u'' def get_fburl(self): for el in self.doc['url']: if el['type'] == 'live' and el['bitrate'] == 128: return Dict('url')(el) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/radiofrance/test.py��������������������������������������������������������������0000664�0000000�0000000�00000006625�12657170273�0020131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.audio import BaseAudio from weboob.capabilities.radio import Radio class RadioFranceTest(BackendTest): MODULE = 'radiofrance' def test_ls_radios_and_selections(self): l = list(self.backend.iter_resources(objs=[Radio], split_path=[])) self.assertTrue(0 < len(l) < 30) for radio in l: name = radio.split_path[-1] if name != 'francebleu': streams = self.backend.get_radio(name).streams self.assertTrue(len(streams) > 0) l_sel = list(self.backend.iter_resources(objs=[BaseAudio], split_path=[name, 'selection'])) if len(l_sel) > 0: self.assertTrue(len(l_sel[0].url) > 0) l = list(self.backend.iter_resources(objs=[Radio], split_path=['francebleu'])) self.assertTrue(len(l) > 30) for radio in l: streams = self.backend.get_radio(radio.split_path[-1]).streams self.assertTrue(len(streams) > 0) l_sel1 = list(self.backend.iter_resources(objs=[BaseAudio], split_path=['francebleu', radio.split_path[-1]])) if 'Selection' in [el.title for el in l_sel1]: l_sel = list(self.backend.iter_resources(objs=[BaseAudio], split_path=['francebleu', radio.split_path[-1], 'selection'])) if len(l_sel) > 0: self.assertTrue(len(l_sel[0].url) > 0) def test_podcasts(self): for key, item in self.backend._RADIOS.iteritems(): if 'podcast' in item: emissions = list(self.backend.iter_resources(objs=[BaseAudio], split_path=[key, 'podcasts'])) self.assertTrue(len(emissions) > 0) podcasts = list(self.backend.iter_resources(objs=[BaseAudio], split_path=emissions[0].split_path)) self.assertTrue(len(podcasts) > 0) podcast = self.backend.get_audio(podcasts[0].id) self.assertTrue(podcast.url) def test_search_radio(self): l = list(self.backend.iter_radios_search('bleu')) self.assertTrue(len(l) > 0) self.assertTrue(len(l[0].streams) > 0) def test_search_get_audio(self): l = list(self.backend.search_audio('journal')) self.assertTrue(len(l) > 0) a = self.backend.get_audio(l[0].id) self.assertTrue(a.url) �����������������������������������������������������������������������������������������������������������weboob-1.1/modules/razibus/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015771�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/razibus/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001434�12657170273�0020104�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import RazibusModule __all__ = ['RazibusModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/razibus/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000003370�12657170273�0020031�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import EventListPage, EventPage __all__ = ['RazibusBrowser'] class RazibusBrowser(PagesBrowser): BASEURL = 'http://razibus.net/' TIMEOUT = 20 event_list_page = URL('evenements-a-venir.php\?region=(?P<region>.*)', EventListPage) event_page = URL('(?P<_id>.*).html', EventPage) region = None def __init__(self, region, *args, **kwargs): super(RazibusBrowser, self).__init__(*args, **kwargs) self.region = region def get_event(self, _id, event=None): return self.event_page.go(_id=_id).get_event(obj=event) def list_events(self, date_from, date_to, city=None, categories=None): return self.event_list_page.go(region=self.region).list_events(date_from=date_from, date_to=date_to, city=city, categories=categories) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/razibus/calendar.py��������������������������������������������������������������0000664�0000000�0000000�00000002134�12657170273�0020114�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS, CATEGORIES class RazibusCalendarEvent(BaseCalendarEvent): def __init__(self): BaseCalendarEvent.__init__(self) self.sequence = 1 self.transp = TRANSP.TRANSPARENT self.status = STATUS.CONFIRMED self.category = CATEGORIES.CONCERT self.timezone = 'Europe/Paris' ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/razibus/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000007670�12657170273�0020136�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@��R ���tEXtSoftware�Adobe ImageReadyqe<��ZIDATxb`!|>0×O T _kadׯ 6?XHz~~Qp�H232-J_ "v�.䘙!�S+Pb-t {:/?@Ν'𗁁{1L`;90QhX21- ȏ?u.0t|?|x( gb`eE8 =@;hZ1 ϟg!?$ExooaTdf``/І?{�n7XgJOf/g ` (B/K e UH"ga5We9?& 8fbz;D01a2Z�tTJ1%<QFA�[,Al'Xd7dٌL2kbrsέCWaL+b J~rǹi+E q~owWkaŽᰪ\7 W(ػ6ƣ]O8Yg vر)eaY]>̲׉#?,Dg08Ԃf {JG+°]y r�Ae}x4*(tuEŬzov\M,?,V DSln8ߖ2I)'Ȥ3#J!U(R-(;?[30܏-b9_e#: i;aRӲYi#I2Eb)ܺ vQ*[ܵv}ą|I$3s厣wbf{&99C>4w]h0?;m"o|*u5M+ & H8!eW?:,yB qi0ꟅB]) Nq.9kX4"5$@箋ЊS'yJ g$U[+#^) ,8J&€܅g)E-`UʞR�۱OGmx^*=]JHjld ioZjQ 0 21vG*߆l_DUǡidC @J y۶BLΤ6^'Fzv1xbq9,$x} P#fs7Ž:"%O3�} ùZmٴ_t <<@; Y (4_o= kX2heӶflXd|S nyu,M5/lj}`6^ry{tMOLFv q(1(( wW*hJεAC\AЅJD1kQD\d#NN !8D΅&]tא^Vk~4S {/ S?F/P铇en-WBL8 p FOjAFA4 �wא+݊ҌJ! U ]vB`¶-)EuL< B̔A4cYR \Q 9Vt}!&n7vʲԁ,E49wOT:d[I?[B1. 79N~OTZTVs&D& -W\M0wmy%�*boATNpr<Ĕa z^ )!MmZ99 ēO,)/ѩyqb Y=B'Y7ð$eR>y#%=3fTq+˾e9Yig}A)ImRk4/KV_1AS)oA BwX�T.(U-\ˢRRt(Rr)'7(''W <FǻLQP㏠\6o-1Ax<W i4-G+g<PcWR!P/56 ,)BP?6ݕ.fmi{5㮻cDet28x^g2r'ێ ]YH"DVFcU)|q 75)z&iգ (kYRJwUMLKxܲYz'RyO esB#b~wpB.O BC̶7ȋmyu)hdsQڲ>Z݂EhM͂(ݰ _l۔@@{%L$ U5 :8bF]7Θ !$ov4lAUE0j6(;<? H$bU$(`U TThE*WC- BH �E%B* Q5 ڦ x23v{ [[?6s|9XWD`mVv<5 >#=I<`Op>mR]"$Ѐ?eQ4-1ۆG, d3D %Jrgl[CPwJΥRnVH}ļO&ACB`J'*rNؿA bP"1NkǸQ"n_O$1͕0ݑ؉΋}jwўq!Ȱ^?س7YR$+aX巷>lY8ZץDz~ڧ=J/K (^{ !�k[YIM8eYYQBKn*@ABRn0gvxМ)8D-ܣɓ]UB2 !!3AdwЋ#$p)KmƬ,ԞILְ+R>xcll%zy©prw 6B6+xZ Y_yUDæY$A0 ӵh } X 5q X(,sV/UEy:jhO/ZV|.jӓi 0]Eq0*-}j(tk?VԲ_+] 2蠤mH c@ij�CK}Dx@QX Was _/݀5H>NڃF:W\ |"TX*QoB6gY7u}P m) %<pC*dD 95Jq!%NZֽ9u?..QRrX!_rLZf@GUoTRBiJ84RmryH怞ۄ'_2�.̪Q4z☀yhVLpZgR)}ڂEݡ�3.Cm$6aP <7ѻTR)KkMC0hZ(4 1UD(x:vJS7jSSw9C_H`T{l,iߔJa([)589Z(7(bQ>bz@1>n)PyNGJJ% R Jݾ1 (;iaG8|q ߦSBPs %6o)O _RBt tLb60^PwFo cne oljMS6DՎ> �?{@|!@,M~?&H!Vh (& JU}K|+-S@j7 05vґ�;(tC 8~߅(z X˼>A~UtI!`۞'gCK;h>;D'4F@P77YsmCYn`ዮ{mH xE*nPu Aؼ&;鸓k5~r 4 ,Xx0Da=/xQӼ"s1<\sf:!F ov U����IENDB`������������������������������������������������������������������������weboob-1.1/modules/razibus/module.py����������������������������������������������������������������0000664�0000000�0000000�00000006255�12657170273�0017640�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import Value from .browser import RazibusBrowser from .calendar import RazibusCalendarEvent __all__ = ['RazibusModule'] class RazibusModule(Module, CapCalendarEvent): NAME = 'razibus' DESCRIPTION = u'site annonçant les évènements attendus par les punks a chiens' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' ASSOCIATED_CATEGORIES = [CATEGORIES.CONCERT] BROWSER = RazibusBrowser region_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '': u'-- Indifférent --', 'Alsace': u'Alsace', 'Aquitaine': u'Aquitaine', 'Auvergne': u'Auvergne', 'Basse-Normandie': u'Basse-Normandie', 'Bourgogne': u'Bourgogne', 'Bretagne': u'Bretagne', 'Centre': u'Centre', 'Champagne-Ardenne': u'Champagne-Ardenne', 'Franche-Comte': u'Franche-Comté', 'Haute-Normandie': u'Haute-Normandie', 'Ile-de-France': u'Île-de-France', 'Languedoc-Roussillon': u'Languedoc-Roussillon', 'Limousin': u'Limousin', 'Lorraine': u'Lorraine', 'Midi-Pyrenees': u'Midi-Pyrénées', 'Nord-Pas-de-Calais': u'Nord-Pas-de-Calais', 'Pays-de-la-Loire': u'Pays de la Loire', 'Picardie': u'Picardie', 'Poitou-Charentes': u'Poitou-Charentes', 'PACA': u'PACA', 'Rhone-Alpes': u'Rhône-Alpes', 'Belgique': u'Belgique', 'Suisse': u'Suisse', }.iteritems())]) CONFIG = BackendConfig(Value('region', label=u'Region', choices=region_choices, default='')) def create_default_browser(self): region = self.config['region'].get() return self.create_browser(region) def search_events(self, query): return self.browser.list_events(query.start_date, query.end_date, query.city, query.categories) def get_event(self, _id): return self.browser.get_event(_id) def list_events(self, date_from, date_to=None): return self.browser.list_events(date_from, date_to) def fill_obj(self, event, fields): return self.browser.get_event(event.id, event) OBJECTS = {RazibusCalendarEvent: fill_obj} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/razibus/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000006643�12657170273�0017453�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .calendar import RazibusCalendarEvent from datetime import time from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.html import CleanHTML, Link from weboob.browser.filters.standard import Regexp, CleanText, DateTime, CombineDate, Filter, Env class EndTime(Filter): def filter(self, el): return time.max class EventListPage(HTMLPage): @method class list_events(ListElement): item_xpath = '//div[@class="item"]' class item(ItemElement): klass = RazibusCalendarEvent def validate(self, obj): return (self.is_valid_event(obj, self.env['city'], self.env['categories']) and self.is_event_in_valid_period(obj.start_date, self.env['date_from'], self.env['date_to'])) def is_valid_event(self, event, city, categories): if city and city != '' and city.upper() != event.city.upper(): return False if categories and len(categories) > 0 and event.category not in categories: return False return True def is_event_in_valid_period(self, event_date, date_from, date_to): if event_date >= date_from: if not date_to: return True else: if event_date <= date_to: return True return False obj_id = Regexp(Link('./p/strong/a[@itemprop="url"]'), 'http://razibus.net/(.*).html') obj_summary = CleanText('./p/strong/a[@itemprop="url"]') obj_start_date = DateTime(CleanText('./p/span[@itemprop="startDate"]/@content')) obj_end_date = CombineDate(DateTime(CleanText('./p/span[@itemprop="startDate"]/@content')), EndTime('.')) obj_location = CleanText('./p/span[@itemprop="location"]/@content') obj_city = CleanText('./p/span[@itemprop="location"]') class EventPage(HTMLPage): @method class get_event(ItemElement): klass = RazibusCalendarEvent obj_id = Env('_id') obj_summary = CleanText('//h2[@itemprop="name"]') obj_start_date = DateTime(CleanText('//span[@itemprop="startDate"]/time/@datetime')) obj_end_date = CombineDate(DateTime(CleanText('//span[@itemprop="startDate"]/time/@datetime')), EndTime('.')) obj_location = CleanText('//meta[@property="og:street-address"]/@content') obj_city = CleanText('//meta[@property="og:locality"]/@content') obj_url = CleanText('//meta[@property="og:url"]/@content') obj_description = CleanHTML('//div[@itemprop="description"]') ���������������������������������������������������������������������������������������������weboob-1.1/modules/razibus/test.py������������������������������������������������������������������0000664�0000000�0000000�00000002132�12657170273�0017320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from datetime import datetime class RazibusTest(BackendTest): MODULE = 'razibus' def test_razibus(self): l = list(self.backend.list_events(datetime.now())) assert len(l) event = self.backend.get_event(l[0].id) self.assertTrue(event.url, 'URL for event "%s" not found: %s' % (event.id, event.url)) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015735�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001437�12657170273�0020053�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import RedmineModule __all__ = ['RedmineModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000025656�12657170273�0020010�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from urlparse import urlsplit import urllib import re import lxml.html from weboob.capabilities.bugtracker import IssueError from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from .pages.index import LoginPage, IndexPage, MyPage, ProjectsPage from .pages.wiki import WikiPage, WikiEditPage from .pages.issues import IssuesPage, IssuePage, NewIssuePage, IssueLogTimePage, \ IssueTimeEntriesPage __all__ = ['RedmineBrowser'] # Browser class RedmineBrowser(Browser): ENCODING = 'utf-8' PAGES = { 'https?://[^/]+/': IndexPage, 'https?://[^/]+/login': LoginPage, # compatibility with redmine 0.9 'https?://[^/]+/login\?back_url.*': MyPage, 'https?://[^/]+/my/page': MyPage, 'https?://[^/]+/projects': ProjectsPage, 'https?://[^/]+/projects/([\w-]+)/wiki/([^\/]+)/edit(?:\?version=\d+)?': WikiEditPage, 'https?://[^/]+/projects/[\w-]+/wiki/[^\/]*': WikiPage, 'https?://[^/]+/projects/[\w-]+/issues/new': NewIssuePage, 'https?://[^/]+/projects/[\w-]+/issues': IssuesPage, 'https?://[^/]+/issues(|/?\?.*)': IssuesPage, 'https?://[^/]+/issues/(\d+)': IssuePage, 'https?://[^/]+/issues/(\d+)/time_entries/new': IssueLogTimePage, 'https?://[^/]+/projects/[\w-]+/time_entries': IssueTimeEntriesPage, } def __init__(self, url, *args, **kwargs): self._userid = 0 v = urlsplit(url) self.PROTOCOL = v.scheme self.DOMAIN = v.netloc self.BASEPATH = v.path if self.BASEPATH.endswith('/'): self.BASEPATH = self.BASEPATH[:-1] Browser.__init__(self, *args, **kwargs) self.projects = {} def is_logged(self): return self.is_on_page(LoginPage) or self.page and len(self.page.document.getroot().cssselect('a.my-account')) == 1 def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) if not self.is_on_page(LoginPage): self.location('%s/login' % self.BASEPATH, no_login=True) self.page.login(self.username, self.password) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() divs = self.page.document.getroot().cssselect('div#loggedas') if len(divs) > 0: parts = divs[0].find('a').attrib['href'].split('/') self._userid = int(parts[2]) def get_userid(self): return self._userid def get_wiki_source(self, project, page, version=None): url = '%s/projects/%s/wiki/%s/edit' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8'))) if version: url += '?version=%s' % version self.location(url) return self.page.get_source() def set_wiki_source(self, project, page, data, message): self.location('%s/projects/%s/wiki/%s/edit' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8')))) self.page.set_source(data, message) def get_wiki_preview(self, project, page, data): if (not self.is_on_page(WikiEditPage) or self.page.groups[0] != project or self.page.groups[1] != page): self.location('%s/projects/%s/wiki/%s/edit' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8')))) url = '%s/projects/%s/wiki/%s/preview' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8'))) params = {} params['content[text]'] = data.encode('utf-8') params['authenticity_token'] = "%s" % self.page.get_authenticity_token() preview_html = lxml.html.fragment_fromstring(self.readurl(url, urllib.urlencode(params)), create_parent='div') preview_html.find("fieldset").drop_tag() preview_html.find("legend").drop_tree() return lxml.html.tostring(preview_html) METHODS = {'POST': {'project_id': 'project_id', 'column': 'query[column_names][]', 'value': 'values[%s][]', 'field': 'fields[]', 'operator': 'operators[%s]', }, 'GET': {'project_id': 'project_id', 'column': 'c[]', 'value': 'v[%s][]', 'field': 'f[]', 'operator': 'op[%s]', } } def query_issues(self, project_name, **kwargs): self.location('/projects/%s/issues' % project_name) token = self.page.get_authenticity_token() method = self.page.get_query_method() data = ((self.METHODS[method]['project_id'], project_name), (self.METHODS[method]['column'], 'tracker'), ('authenticity_token', token), (self.METHODS[method]['column'], 'status'), (self.METHODS[method]['column'], 'priority'), (self.METHODS[method]['column'], 'subject'), (self.METHODS[method]['column'], 'assigned_to'), (self.METHODS[method]['column'], 'updated_on'), (self.METHODS[method]['column'], 'category'), (self.METHODS[method]['column'], 'fixed_version'), (self.METHODS[method]['column'], 'done_ratio'), (self.METHODS[method]['column'], 'author'), (self.METHODS[method]['column'], 'start_date'), (self.METHODS[method]['column'], 'due_date'), (self.METHODS[method]['column'], 'estimated_hours'), (self.METHODS[method]['column'], 'created_on'), ) for key, value in kwargs.iteritems(): if value: value = self.page.get_value_from_label(self.METHODS[method]['value'] % key, value) data += ((self.METHODS[method]['value'] % key, value),) data += ((self.METHODS[method]['field'], key),) data += ((self.METHODS[method]['operator'] % key, '~'),) if method == 'POST': self.location('/issues?set_filter=1&per_page=100', urllib.urlencode(data)) else: data += (('set_filter', '1'), ('per_page', '100')) self.location(self.buildurl('/issues', *data)) assert self.is_on_page(IssuesPage) return {'project': self.page.get_project(project_name), 'iter': self.page.iter_issues(), } def get_project(self, project): self.location('/projects/%s/issues/new' % project) assert self.is_on_page(NewIssuePage) return self.page.get_project(project) def get_issue(self, id): self.location('/issues/%s' % id) assert self.is_on_page(IssuePage) return self.page.get_params() def logtime_issue(self, id, hours, message): self.location('/issues/%s/time_entries/new' % id) assert self.is_on_page(IssueLogTimePage) self.page.logtime(hours.seconds/3600, message) def comment_issue(self, id, message): self.location('/issues/%s' % id) assert self.is_on_page(IssuePage) self.page.fill_form(note=message) def get_custom_fields(self, project): self.location('/projects/%s/issues/new' % project) assert self.is_on_page(NewIssuePage) fields = {} for key, div in self.page.iter_custom_fields(): if 'value' in div.attrib: fields[key] = div.attrib['value'] else: olist = div.xpath('.//option[@selected="selected"]') fields[key] = ', '.join([i.attrib['value'] for i in olist]) return fields def create_issue(self, project, **kwargs): self.location('/projects/%s/issues/new' % project) assert self.is_on_page(NewIssuePage) self.page.fill_form(**kwargs) error = self.page.get_errors() if len(error) > 0: raise IssueError(error) assert self.is_on_page(IssuePage) return int(self.page.groups[0]) def edit_issue(self, id, **kwargs): self.location('/issues/%s' % id) assert self.is_on_page(IssuePage) self.page.fill_form(**kwargs) assert self.is_on_page(IssuePage) return int(self.page.groups[0]) def remove_issue(self, id): self.location('/issues/%s' % id) assert self.is_on_page(IssuePage) token = self.page.get_authenticity_token() data = (('authenticity_token', token),) self.openurl('/issues/%s/destroy' % id, urllib.urlencode(data)) def iter_projects(self): self.location('/projects') return self.page.iter_projects() def create_category(self, project, name, token): data = {'issue_category[name]': name.encode('utf-8')} headers = {'X-CSRF-Token': token, 'X-Prototype-Version': '1.7', 'X-Requested-With': 'XMLHttpRequest', 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*', } request = self.request_class(self.absurl(self.buildurl('%s/projects/%s/issue_categories' % (self.BASEPATH, project), **data)), '', headers) r = self.readurl(request) # Element.replace("issue_category_id", "\u003Cselect id=\"issue_category_id\" name=\"issue[category_id]\"\u003E\u003Coption\u003E\u003C/option\u003E\u003Coption value=\"28\"\u003Ebnporc\u003C/option\u003E\n\u003Coption value=\"31\"\u003Ebp\u003C/option\u003E\n\u003Coption value=\"30\"\u003Ecrag2r\u003C/option\u003E\n\u003Coption value=\"29\"\u003Ecragr\u003C/option\u003E\n\u003Coption value=\"27\"\u003Ei\u003C/option\u003E\n\u003Coption value=\"32\"\u003Elol\u003C/option\u003E\n\u003Coption value=\"33\" selected=\"selected\"\u003Elouiel\u003C/option\u003E\u003C/select\u003E"); m = re.search('''value=\\\\"(\d+)\\\\" selected''', r) if m: return m.group(1) ����������������������������������������������������������������������������������weboob-1.1/modules/redmine/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000004062�12657170273�0020072�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ~���tIME 918f=��IDATxZo NqEEY-۰H-;HSiւ-=r)zjhkM&ȑbɕlZ+NhRdT޼Pm,4\d�d�d�d�ZmC?2$9^Os޻ 1 fR<Rb"]IXd_qSZ<6 N[es}�*h*I I!u=a#]l= f2Vx e{s1棧 udpią!qOh'r@XyɹBOGkh\!n&܎2kW+ <$ٕf fVIcό.4M!˕1=�܆qgvV :톳C � ؍,N=zz[q 62dFڴ<N]}HÍADS:u ˬ%,WwI$7Uk=?ZNB劀`M,V_cYo}2?]F8 XfTyZInb11X M!.`YOM01ZǾZb$G wg( uCl2D*_{ЬSLd�Ja Z4Irߩ\ep8<h{w⽛  w8$GPTOW0TMĢW57�v $s%Uu |#X0l:CM=1*n"m��OYܛ̐]4~x'<bMɻ̶ ]H yzĘJFɕm ){��lFFkz,Sk-s4EzAەV8/éd3Ptoj<5cMa2u{wxz^sN"MIH .ZvE e* S"7(Z EcJ2~"B)Ly2+` E0zЂ4hY\!/âa6# 46N{ce- *v Kpe Q-Ud ehߥG<SDXA)bu#nyR4zz[pfȎуV:uYJ⯟ '8Tvm*qfȆcI=N$IV[zZmc[ڸ= Q0}&2nbct&Jp;CN[c "Y|8h'[߅o\d�d�\vn҈ A,3oW+S+KdY,Wƭ``7*] pDŽS~ ,R3KI|2/�GM8f$u;Ig~+lF\$UDo(pߊN=֒q \o~I$Yw( s�](4N�>/s:Җ+hA> e Tm4<6-{kdOAQMAs+iO B`~-MsJ<fŬIn'Vucbv|b7땸<b(Uч:5Ԥ\Πm-nn|ey#SDMg3/ ݲ@~4oJZ39m}þ(rTbګXEҜ7O'�+~KcpD"q-�nkjdŠ"tvmUWI^ݭKjݚm6Lm2TyM8;de*i\<މX{sj<O/.SGvmnONG~{;"%?E ŭɐȬ���������VtyB����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/module.py����������������������������������������������������������������0000664�0000000�0000000�00000027532�12657170273�0017605�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.content import CapContent, Content from weboob.capabilities.bugtracker import CapBugTracker, Issue, Project, User, \ Version, Status, Update, Attachment, \ Query, Change from weboob.capabilities.collection import CapCollection, Collection, CollectionNotFound from weboob.tools.backend import Module, BackendConfig from weboob.exceptions import BrowserHTTPNotFound from weboob.tools.value import ValueBackendPassword, Value from .browser import RedmineBrowser __all__ = ['RedmineModule'] class RedmineModule(Module, CapContent, CapBugTracker, CapCollection): NAME = 'redmine' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'The Redmine project management web application' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('url', label='URL of the Redmine website', regexp=r'https?://.*'), Value('username', label='Login'), ValueBackendPassword('password', label='Password')) BROWSER = RedmineBrowser def create_default_browser(self): return self.create_browser(self.config['url'].get(), self.config['username'].get(), self.config['password'].get()) ############# CapContent ###################################################### def id2path(self, id): return id.split('/', 2) def get_content(self, id, revision=None): if isinstance(id, basestring): content = Content(id) else: content = id id = content.id try: _type, project, page = self.id2path(id) except ValueError: return None version = revision.id if revision else None with self.browser: data = self.browser.get_wiki_source(project, page, version) content.content = data return content def push_content(self, content, message=None, minor=False): try: _type, project, page = self.id2path(content.id) except ValueError: return with self.browser: return self.browser.set_wiki_source(project, page, content.content, message) def get_content_preview(self, content): try: _type, project, page = self.id2path(content.id) except ValueError: return with self.browser: return self.browser.get_wiki_preview(project, page, content.content) ############# CapCollection ################################################### def iter_resources(self, objs, split_path): if Project in objs or Issue in objs: self._restrict_level(split_path, 1) if len(split_path) == 0: return [Collection([project.id], project.name) for project in self.iter_projects()] elif len(split_path) == 1: query = Query() query.project = unicode(split_path[0]) return self.iter_issues(query) def validate_collection(self, objs, collection): if collection.path_level == 0: return if Issue in objs and collection.path_level == 1: for project in self.iter_projects(): if collection.basename == project.id: return Collection([project.id], project.name) # if the project is not found by ID, try again by name for project in self.iter_projects(): if collection.basename == project.name: return Collection([project.id], project.name) raise CollectionNotFound(collection.split_path) ############# CapBugTracker ################################################### @classmethod def _build_project(cls, project_dict): project = Project(project_dict['name'], project_dict['name']) project.members = [User(int(u[0]), u[1]) for u in project_dict['members']] project.versions = [Version(int(v[0]), v[1]) for v in project_dict['versions']] project.categories = [c[1] for c in project_dict['categories']] # TODO set the value of status project.statuses = [Status(int(s[0]), s[1], 0) for s in project_dict['statuses']] return project @staticmethod def _attr_to_id(availables, text): if not text: return None if isinstance(text, basestring) and text.isdigit(): return text for value, key in availables: if key.lower() == text.lower(): return value return text def iter_issues(self, query): """ Iter issues with optionnal patterns. @param query [Query] @return [iter(Issue)] issues """ params = self.browser.get_project(query.project) kwargs = {'subject': query.title, 'author_id': self._attr_to_id(params['members'], query.author), 'assigned_to_id': self._attr_to_id(params['members'], query.assignee), 'fixed_version_id': self._attr_to_id(params['versions'], query.version), 'category_id': self._attr_to_id(params['categories'], query.category), 'status_id': self._attr_to_id(params['statuses'], query.status), } r = self.browser.query_issues(query.project, **kwargs) project = self._build_project(r['project']) for issue in r['iter']: obj = Issue(issue['id']) obj.project = project obj.title = issue['subject'] obj.creation = issue['created_on'] obj.updated = issue['updated_on'] obj.start = issue['start_date'] obj.due = issue['due_date'] if isinstance(issue['author'], tuple): obj.author = project.find_user(*issue['author']) else: obj.author = User(0, issue['author']) if isinstance(issue['assigned_to'], tuple): obj.assignee = project.find_user(*issue['assigned_to']) else: obj.assignee = issue['assigned_to'] obj.tracker = issue['tracker'] obj.category = issue['category'] if issue['fixed_version'] is not None: obj.version = project.find_version(*issue['fixed_version']) else: obj.version = None obj.status = project.find_status(issue['status']) obj.priority = issue['priority'] yield obj def get_issue(self, issue): if isinstance(issue, Issue): id = issue.id else: id = issue issue = Issue(issue) try: with self.browser: params = self.browser.get_issue(id) except BrowserHTTPNotFound: return None issue.project = self._build_project(params['project']) issue.title = params['subject'] issue.body = params['body'] issue.creation = params['created_on'] issue.updated = params['updated_on'] issue.start = params['start_date'] issue.due = params['due_date'] issue.fields = {} for key, value in params['fields'].iteritems(): issue.fields[key] = value issue.attachments = [] for a in params['attachments']: attachment = Attachment(a['id']) attachment.filename = a['filename'] attachment.url = a['url'] issue.attachments.append(attachment) issue.history = [] for u in params['updates']: update = Update(u['id']) update.author = issue.project.find_user(*u['author']) update.date = u['date'] update.message = u['message'] update.changes = [] for i, (field, last, new) in enumerate(u['changes']): change = Change(i) change.field = field change.last = last change.new = new update.changes.append(change) issue.history.append(update) issue.author = issue.project.find_user(*params['author']) issue.assignee = issue.project.find_user(*params['assignee']) issue.tracker = params['tracker'][1] issue.category = params['category'][1] issue.version = issue.project.find_version(*params['version']) issue.status = issue.project.find_status(params['status'][1]) issue.priority = params['priority'][1] return issue def create_issue(self, project): try: with self.browser: r = self.browser.get_project(project) except BrowserHTTPNotFound: return None issue = Issue(0) issue.project = self._build_project(r) with self.browser: issue.fields = self.browser.get_custom_fields(project) return issue def post_issue(self, issue): project = issue.project.id kwargs = {'title': issue.title, 'version': issue.version.id if issue.version else None, 'assignee': issue.assignee.id if issue.assignee else None, 'tracker': issue.tracker if issue.tracker else None, 'category': issue.category, 'status': issue.status.id if issue.status else None, 'priority': issue.priority if issue.priority else None, 'start': issue.start if issue.start else None, 'due': issue.due if issue.due else None, 'body': issue.body, 'fields': issue.fields, } with self.browser: if int(issue.id) < 1: id = self.browser.create_issue(project, **kwargs) else: id = self.browser.edit_issue(issue.id, **kwargs) if id is None: return None issue.id = id return issue def update_issue(self, issue, update): if isinstance(issue, Issue): issue = issue.id with self.browser: if update.hours: return self.browser.logtime_issue(issue, update.hours, update.message) else: return self.browser.comment_issue(issue, update.message) def remove_issue(self, issue): """ Remove an issue. """ if isinstance(issue, Issue): issue = issue.id with self.browser: return self.browser.remove_issue(issue) def iter_projects(self): """ Iter projects. @return [iter(Project)] projects """ with self.browser: for project in self.browser.iter_projects(): yield Project(project['id'], project['name']) def get_project(self, id): try: with self.browser: params = self.browser.get_project(id) except BrowserHTTPNotFound: return None return self._build_project(params) def fill_issue(self, issue, fields): return self.get_issue(issue) OBJECTS = {Issue: fill_issue} ����������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/pages/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017034�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/pages/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021133�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/pages/index.py�����������������������������������������������������������0000664�0000000�0000000�00000003023�12657170273�0020513�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page class LoginPage(Page): def login(self, username, password): self.browser.select_form(predicate=lambda f: f.attrs.get('method', '') == 'post') self.browser['username'] = username.encode(self.browser.ENCODING) self.browser['password'] = password.encode(self.browser.ENCODING) self.browser.submit() class IndexPage(Page): pass class MyPage(Page): pass class ProjectsPage(Page): def iter_projects(self): for ul in self.parser.select(self.document.getroot(), 'ul.projects'): for li in ul.findall('li'): prj = {} link = li.find('div').find('a') prj['id'] = link.attrib['href'].split('/')[-1] prj['name'] = link.text yield prj �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/pages/issues.py����������������������������������������������������������0000664�0000000�0000000�00000051246�12657170273�0020731�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re import datetime from weboob.capabilities.bugtracker import IssueError from weboob.deprecated.browser import Page, BrokenPageError from weboob.tools.date import parse_french_date from weboob.tools.misc import to_unicode from weboob.deprecated.mech import ClientForm from weboob.tools.json import json class BaseIssuePage(Page): def parse_datetime(self, text): m = re.match('(\d+)/(\d+)/(\d+) (\d+):(\d+) (\w+)', text) if m: date = datetime.datetime(int(m.group(3)), int(m.group(1)), int(m.group(2)), int(m.group(4)), int(m.group(5))) if m.group(6) == 'pm': date += datetime.timedelta(0,12*3600) return date m = re.match('(\d+)-(\d+)-(\d+) (\d+):(\d+)', text) if m: return datetime.datetime(int(m.group(1)), int(m.group(2)), int(m.group(3)), int(m.group(4)), int(m.group(5))) m = re.match('(\d+) (\w+) (\d+) (\d+):(\d+)', text) if m: return parse_french_date(text) self.logger.warning('Unable to parse "%s"' % text) return text PROJECT_FIELDS = {'members': 'values_assigned_to_id', 'categories': 'values_category_id', 'versions': 'values_fixed_version_id', 'statuses': 'values_status_id', } def iter_choices(self, name): try: select = self.parser.select(self.document.getroot(), 'select#%s' % name, 1) except BrokenPageError: try: select = self.parser.select(self.document.getroot(), 'select#%s_1' % name, 1) except BrokenPageError: return for option in select.findall('option'): if option.attrib['value'].isdigit(): yield (option.attrib['value'], option.text) def get_project(self, project_name): project = {} project['name'] = project_name for field, elid in self.PROJECT_FIELDS.iteritems(): project[field] = list(self.iter_choices(elid)) return project def get_authenticity_token(self): tokens = self.parser.select(self.document.getroot(), 'input[name=authenticity_token]') if len(tokens) == 0: tokens = self.document.xpath('//meta[@name="csrf-token"]') if len(tokens) == 0: raise IssueError("You don't have rights to remove this issue.") try: token = tokens[0].attrib['value'] except KeyError: token = tokens[0].attrib['content'] return token def get_errors(self): errors = [] for li in self.document.xpath('//div[@id="errorExplanation"]//li'): errors.append(li.text.strip()) return ', '.join(errors) def get_value_from_label(self, name, label): for option in self.document.xpath('//select[@name="%s"]/option' % name): if option.text.strip().lower() == label.lower(): return option.attrib['value'] return label class IssuesPage(BaseIssuePage): PROJECT_FIELDS = {'members': 'values_assigned_to_id', 'categories': 'values_category_id', 'versions': 'values_fixed_version_id', 'statuses': 'values_status_id', } def get_from_js(self, pattern, end, is_list=False): """ find a pattern in any javascript text """ value = None for script in self.document.xpath('//script'): txt = script.text if txt is None: continue start = txt.find(pattern) if start < 0: continue while True: if value is None: value = '' else: value += ',' value += txt[start+len(pattern):start+txt[start+len(pattern):].find(end)+len(pattern)] if not is_list: break txt = txt[start+len(pattern)+txt[start+len(pattern):].find(end):] start = txt.find(pattern) if start < 0: break return value def get_project(self, project_name): project = super(IssuesPage, self).get_project(project_name) if len(project['statuses']) > 0: return project args = self.get_from_js('var availableFilters = ', ';') if args is None: return project args = json.loads(args) def get_values(key): values = [] if key not in args: return values for key, value in args[key]['values']: if value.isdigit(): values.append((value, key)) return values project['members'] = get_values('assigned_to_id') project['categories'] = get_values('category_id') project['versions'] = get_values('fixed_version_id') project['statuses'] = get_values('status_id') return project def get_query_method(self): return self.document.xpath('//form[@id="query_form"]')[0].attrib['method'].upper() def iter_issues(self): try: issues = self.parser.select(self.document.getroot(), 'table.issues', 1) except BrokenPageError: # No results. return for tr in issues.getiterator('tr'): if not tr.attrib.get('id', '').startswith('issue-'): continue issue = {'id': tr.attrib['id'].replace('issue-', '')} for td in tr.getiterator('td'): field = td.attrib.get('class', '') if field in ('checkbox','todo',''): continue a = td.find('a') if a is not None: if a.attrib['href'].startswith('/users/') or \ a.attrib['href'].startswith('/versions/'): text = (int(a.attrib['href'].split('/')[-1]), a.text) else: text = a.text else: text = td.text if field.endswith('_on'): text = self.parse_datetime(text) elif field.endswith('_date') and text is not None: m = re.match('(\d+)-(\d+)-(\d+)', text) if m: text = datetime.datetime(int(m.group(1)), int(m.group(2)), int(m.group(3))) if isinstance(text, str): text = to_unicode(text) issue[field] = text if len(issue) != 0: yield issue class NewIssuePage(BaseIssuePage): PROJECT_FIELDS = {'members': 'issue_assigned_to_id', 'categories': 'issue_category_id', 'versions': 'issue_fixed_version_id', 'statuses': 'issue_status_id', } def get_project_name(self): m = re.search('/projects/([^/]+)/', self.url) return m.group(1) def iter_custom_fields(self): for div in self.document.xpath('//form//input[starts-with(@id, "issue_custom_field")]|//form//select[starts-with(@id, "issue_custom_field")]'): if 'type' in div.attrib and div.attrib['type'] == 'hidden': continue label = self.document.xpath('//label[@for="%s"]' % div.attrib['id'])[0] yield self.parser.tocleanstring(label), div def set_title(self, title): self.browser['issue[subject]'] = title.encode('utf-8') def set_body(self, body): self.browser['issue[description]'] = body.encode('utf-8') def set_assignee(self, member): if member: self.browser['issue[assigned_to_id]'] = [str(member)] else: self.browser['issue[assigned_to_id]'] = [''] def set_version(self, version): try: if version: self.browser['issue[fixed_version_id]'] = [str(version)] else: self.browser['issue[fixed_version_id]'] = [''] except ClientForm.ItemNotFoundError: self.logger.warning('Version not found: %s' % version) def set_tracker(self, tracker): if tracker: select = self.parser.select(self.document.getroot(), 'select#issue_tracker_id', 1) for option in select.findall('option'): if option.text and option.text.strip() == tracker: self.browser['issue[tracker_id]'] = [option.attrib['value']] return # value = None # if len(self.document.xpath('//a[@title="New tracker"]')) > 0: # value = self.browser.create_tracker(self.get_project_name(), tracker, self.get_authenticity_token()) # if value: # control = self.browser.find_control('issue[tracker_id]') # ClientForm.Item(control, {'name': tracker, 'value': value}) # self.browser['issue[tracker_id]'] = [value] # else: # self.logger.warning('Tracker "%s" not found' % tracker) self.logger.warning('Tracker "%s" not found' % tracker) else: try: self.browser['issue[tracker_id]'] = [''] except ClientForm.ControlNotFoundError: self.logger.warning('Tracker item not found') def set_category(self, category): if category: select = self.parser.select(self.document.getroot(), 'select#issue_category_id', 1) for option in select.findall('option'): if option.text and option.text.strip() == category: self.browser['issue[category_id]'] = [option.attrib['value']] return value = None if len(self.document.xpath('//a[@title="New category"]')) > 0: value = self.browser.create_category(self.get_project_name(), category, self.get_authenticity_token()) if value: control = self.browser.find_control('issue[category_id]') ClientForm.Item(control, {'name': category, 'value': value}) self.browser['issue[category_id]'] = [value] else: self.logger.warning('Category "%s" not found' % category) else: try: self.browser['issue[category_id]'] = [''] except ClientForm.ControlNotFoundError: self.logger.warning('Category item not found') def set_status(self, status): assert status is not None self.browser['issue[status_id]'] = [str(status)] def set_priority(self, priority): if priority: select = self.parser.select(self.document.getroot(), 'select#issue_priority_id', 1) for option in select.findall('option'): if option.text and option.text.strip() == priority: self.browser['issue[priority_id]'] = [option.attrib['value']] return # value = None # if len(self.document.xpath('//a[@title="New priority"]')) > 0: # value = self.browser.create_priority(self.get_project_name(), priority, self.get_authenticity_token()) # if value: # control = self.browser.find_control('issue[priority_id]') # ClientForm.Item(control, {'name': priority, 'value': value}) # self.browser['issue[priority_id]'] = [value] # else: # self.logger.warning('Priority "%s" not found' % priority) self.logger.warning('Priority "%s" not found' % priority) else: try: self.browser['issue[priority_id]'] = [''] except ClientForm.ControlNotFoundError: self.logger.warning('Priority item not found') def set_start(self, start): if start is not None: self.browser['issue[start_date]'] = start.strftime("%Y-%m-%d") #XXX: else set to "" ? def set_due(self, due): if due is not None: self.browser['issue[due_date]'] = due.strftime("%Y-%m-%d") #XXX: else set to "" ? def set_note(self, message): try: self.browser['notes'] = message.encode('utf-8') except ClientForm.ControlNotFoundError: self.browser['issue[notes]'] = message.encode('utf-8') def set_fields(self, fields): for key, div in self.iter_custom_fields(): try: control = self.browser.find_control(div.attrib['name'], nr=0) if isinstance(control, ClientForm.TextControl): control.value = fields[key] else: item = control.get(label=fields[key].encode("utf-8"), nr=0) if item and fields[key] != '': item.selected = True except KeyError: continue def fill_form(self, **kwargs): self.browser.select_form(predicate=lambda form: form.attrs.get('id', '') == 'issue-form') for key, value in kwargs.iteritems(): if value is not None: getattr(self, 'set_%s' % key)(value) self.browser.submit() class IssuePage(NewIssuePage): def _parse_selection(self, id): try: select = self.parser.select(self.document.getroot(), 'select#%s' % id, 1) except BrokenPageError: # not available for this project return ('', None) else: options = select.findall('option') for option in options: if 'selected' in option.attrib: return (int(option.attrib['value']), to_unicode(option.text)) return ('', None) def get_params(self): params = {} content = self.parser.select(self.document.getroot(), 'div#content', 1) issue = self.parser.select(content, 'div.issue', 1) params['project'] = self.get_project(to_unicode(self.parser.select(self.document.getroot(), 'h1', 1).text)) params['subject'] = to_unicode(self.parser.select(issue, 'div.subject', 1).find('div').find('h3').text.strip()) params['body'] = to_unicode(self.parser.select(self.document.getroot(), 'textarea#issue_description', 1).text) author = self.parser.select(issue, 'p.author', 1) # check issue 666 on symlink.me i = 0 alist = author.findall('a') if 'title' not in alist[i].attrib: params['author'] = (int(alist[i].attrib['href'].split('/')[-1]), to_unicode(alist[i].text)) i += 1 else: params['author'] = (0, 'Anonymous') params['created_on'] = self.parse_datetime(alist[i].attrib['title']) if len(alist) > i+1: params['updated_on'] = self.parse_datetime(alist[i+1].attrib['title']) else: params['updated_on'] = None params['status'] = self._parse_selection('issue_status_id') params['priority'] = self._parse_selection('issue_priority_id') params['assignee'] = self._parse_selection('issue_assigned_to_id') params['tracker'] = self._parse_selection('issue_tracker_id') params['category'] = self._parse_selection('issue_category_id') params['version'] = self._parse_selection('issue_fixed_version_id') div = self.parser.select(self.document.getroot(), 'input#issue_start_date', 1) if 'value' in div.attrib: params['start_date'] = datetime.datetime.strptime(div.attrib['value'], "%Y-%m-%d") else: params['start_date'] = None div = self.parser.select(self.document.getroot(), 'input#issue_due_date', 1) if 'value' in div.attrib: params['due_date'] = datetime.datetime.strptime(div.attrib['value'], "%Y-%m-%d") else: params['due_date'] = None params['fields'] = {} for key, div in self.iter_custom_fields(): value = '' if 'value' in div.attrib: value = div.attrib['value'] else: # XXX: use _parse_selection()? olist = div.xpath('.//option[@selected="selected"]') value = ', '.join([opt.attrib['value'] for opt in olist]) params['fields'][key] = value params['attachments'] = [] try: for p in self.parser.select(content, 'div.attachments', 1).findall('p'): attachment = {} a = p.find('a') attachment['id'] = int(a.attrib['href'].split('/')[-2]) attachment['filename'] = p.find('a').text attachment['url'] = '%s://%s%s' % (self.browser.PROTOCOL, self.browser.DOMAIN, p.find('a').attrib['href']) params['attachments'].append(attachment) except BrokenPageError: pass params['updates'] = [] for div in self.parser.select(content, 'div.journal'): update = {} update['id'] = div.xpath('.//h4//a')[0].text[1:] user_link = div.xpath('.//h4//a[contains(@href, "/users/")]') if len(user_link) > 0: update['author'] = (int(user_link[0].attrib['href'].split('/')[-1]), to_unicode(user_link[0].text)) else: for txt in div.xpath('.//h4//text()'): m = re.search('Updated by (.*)', txt.strip()) if m: update['author'] = (0, to_unicode(m.group(1))) update['date'] = self.parse_datetime(div.xpath('.//h4//a[last()]')[0].attrib['title']) comments = div.xpath('.//div[starts-with(@id, "journal-")]') if len(comments) > 0: comment = comments[0] subdiv = comment.find('div') if subdiv is not None: # a subdiv which contains changes is found, move the tail text # of this div to comment text, and remove it. comment.text = (comment.text or '') + (subdiv.tail or '') comment.remove(comment.find('div')) update['message'] = self.parser.tostring(comment).strip() else: update['message'] = None changes = [] try: details = self.parser.select(div, 'ul.details', 1) except BrokenPageError: pass else: for li in details.findall('li'): field = li.find('strong').text#.decode('utf-8') i = li.findall('i') new = None last = None if len(i) > 0: if len(i) == 2: last = i[0].text.decode('utf-8') new = i[-1].text#.decode('utf-8') elif li.find('strike') is not None: last = li.find('strike').find('i').text.decode('utf-8') elif li.find('a') is not None: new = li.find('a').text.decode('utf-8') else: self.logger.warning('Unable to handle change for %s' % field) changes.append((field, last, new)) update['changes'] = changes params['updates'].append(update) return params class IssueLogTimePage(Page): def logtime(self, hours, message): self.browser.select_form(predicate=lambda form: form.attrs.get('action', '').endswith('/edit')) self.browser['time_entry[hours]'] = '%.2f' % hours self.browser['time_entry[comments]'] = message.encode('utf-8') self.browser['time_entry[activity_id]'] = ['8'] self.browser.submit() class IssueTimeEntriesPage(Page): pass ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/redmine/pages/wiki.py������������������������������������������������������������0000664�0000000�0000000�00000002576�12657170273�0020363�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page class WikiEditPage(Page): def get_source(self): return self.parser.select(self.document.getroot(), 'textarea#content_text', 1).text def set_source(self, data, message): self.browser.select_form(nr=1) self.browser['content[text]'] = data.encode('utf-8') if message: self.browser['content[comments]'] = message.encode('utf-8') self.browser.submit() def get_authenticity_token(self): wiki_form = self.parser.select(self.document.getroot(), 'form#wiki_form', 1) return wiki_form.xpath('div/input')[0].get('value') class WikiPage(Page): pass ����������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/regionsjob/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016453�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/regionsjob/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000001442�12657170273�0020565�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import RegionsjobModule __all__ = ['RegionsjobModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/regionsjob/browser.py������������������������������������������������������������0000664�0000000�0000000�00000004044�12657170273�0020512�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.browser import PagesBrowser, URL from .pages import SearchPage, AdvertPage __all__ = ['RegionsjobBrowser'] class RegionsjobBrowser(PagesBrowser): search_page = URL('emplois/recherche.html\?.*', SearchPage) advert_page = URL('emplois/(?P<_id>.*)\.html', AdvertPage) def __init__(self, website, *args, **kwargs): self.BASEURL = 'http://%s/' % website PagesBrowser.__init__(self, *args, **kwargs) def search_job(self, pattern='', fonction='', secteur='', contract='', experience='', qualification='', enterprise_type=''): params = {'k': urllib.quote_plus(pattern.encode('utf-8'))} if fonction: params['f'] = fonction if qualification: params['q'] = qualification if contract: params['c'] = contract if experience: params['e'] = experience if secteur: params['s'] = secteur if enterprise_type: params['et'] = enterprise_type return self.search_page.go(params=params).iter_job_adverts(domain=self.BASEURL) def get_job_advert(self, _id, advert): splitted_id = _id.split('#') self.BASEURL = 'http://www.%s.com/' % splitted_id[0] return self.advert_page.go(_id=splitted_id[1]).get_job_advert(obj=advert) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/regionsjob/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000000736�12657170273�0020614�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs����+���tIME/-B��kIDATxڽMA b Qrj )F!9CϷp烙Wog/u]gKl /������������Xh]x,_>^ֻz xjwcK1B 6xDmp/�^23͇粥YmtiGei<!7^`3W_t@SW_t�������u'pLSvASt`<6O A8t8+x*,;03Ý*x5+ӡ4EY3�SěH=�MlJnC DBPN!6Cn�����������������o' l+����IENDB`����������������������������������weboob-1.1/modules/regionsjob/module.py�������������������������������������������������������������0000664�0000000�0000000�00000021542�12657170273�0020316�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.job import CapJob, BaseJobAdvert from .browser import RegionsjobBrowser from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import Value __all__ = ['RegionsjobModule'] class RegionsjobModule(Module, CapJob): NAME = 'regionsjob' DESCRIPTION = u'regionsjob website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = RegionsjobBrowser website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ 'www.centrejob.com': u'CentreJob', 'www.estjob.com': u'EstJob', 'www.nordjob.com': u'NordJob', 'www.ouestjob.com': u'OuestJob', 'www.pacajob.com': u'PacaJob', 'www.parisjob.com': u'ParisJob', 'www.rhonealpesjob.com': u'RhoneAlpesJob', 'www.sudouestjob.com': u'SudOuestJob', 'www.jobtrotter.com': u'JobTrotter', }.iteritems())]) fonction_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '': u'Indifferent', 'Assistanat_admin_accueil': u'Assistanat/Adm.ventes/Accueil', 'BTP_gros_second_oeuvre': u'BTP - Gros Oeuvre/Second Oeuvre', 'Bureau_etude_R_D': u'Bureau d\'Etudes/R & D/BTP archi/conception', 'Commercial_technico_com': u'Commercial - Technico-Commercial', 'Commercial_particulier': u'Commercial auprès des particuliers', 'Commercial_professionnel': u'Commercial auprès des professionnels', 'Commercial_vendeur': u'Commercial-Vendeur en magasin', 'Compta_gestion_finance_audit': u'Compta/Gestion/Finance/Audit', 'Dir_resp_centre_profit': u'Direction/Resp. Co. et Centre de Profit', 'Import_export_inter': u'Import/Export/International', 'Informatique_dev_hard': u'Informatique - Dével. Hardware', 'Informatique_dev': u'Informatique - Développement', 'Informatique_syst_info': u'Informatique - Systèmes d\'Information', 'Informatique_syst_reseaux': u'Informatique - Systèmes/Réseaux', 'Ingenierie_agro_agri': u'Ingénierie - Agro/Agri', 'Ingenierie_chimie_pharma_bio': u'Ingénierie - Chimie/Pharmacie/Bio.', 'Ingenierie_electro_tech': u'Ingénierie - Electro-tech./Automat.', 'Ingenierie_meca_aero': u'Ingénierie - Mécanique/Aéron.', 'Ingenierie_telecom': u'Ingénierie - Telecoms/Electronique', 'Juridique_droit': u'Juridique/Droit', 'Logistique_metiers_transport': u'Logistique/Métiers du Transport', 'Marketing_com_graphisme': u'Marketing/Communication/Graphisme', 'Dir_management_resp': u'Métiers de la distribution - Management/Resp.', 'Metiers_fonction_publique': u'Métiers de la Fonction Publique', 'Negociation_gest_immo': u'Négociation/Gestion immobilière', 'Production_gestion': u'Production - Gestion/Maintenance', 'Production_operateur': u'Production - Opérateur/Manoeuvre', 'Qualite_securite_environnement': u'Qualité/Hygiène/Sécurité/Environnement', 'Restauration_hotellerie_tourisme': u'Restauration/Tourisme/Hôtellerie/Loisirs', 'RH_Personnel_Formation': u'RH/Personnel/Formation', 'Sante_social': u'Santé/Social', 'SAV_Hotline': u'SAV/Hotline/Téléconseiller', 'Services_pers_entreprises': u'Services à la personne/aux entreprises', }.iteritems())]) secteur_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '': u'Indifferent', 'Agri_peche': u'Agriculture/Pêche', 'Banq_assur_finan': u'Banque/Assurance/Finance', 'BTP': u'BTP', 'Distrib_commerce': u'Distribution/Commerce de gros', 'Enseign_forma': u'Enseignement/Formation', 'Immo': u'Immobilier', 'Ind_aero': u'Industrie Aéronautique/Aérospatial', 'Ind_agro': u'Industrie Agro-alimentaire', 'Ind_auto_meca_nav': u'Industrie Auto/Meca/Navale', 'Ind_hightech_telecom': u'Industrie high-tech/Telecom', 'Ind_manufact': u'Industrie Manufacturière', 'Ind_petro': u'Industrie Pétrolière/Pétrochimie', 'Ind_pharma_bio_chim': u'Industrie Pharmaceutique/Biotechn./Chimie', 'Media_internet_com': u'Média/Internet/Communication', 'Resto': u'Restauration', 'Sante_social': u'Santé/Social/Association', 'Energie_envir': u'Secteur Energie/Environnement', 'Inform_SSII': u'Secteur informatique/SSII', 'Serv_public_autre': u'Service public autres', 'Serv_public_collec_terri': u'Service public des collectivités territoriales', 'Serv_public_etat': u'Service public d\'état', 'Serv_public_hosp': u'Service public hospitalier', 'Serv_entreprise': u'Services aux Entreprises', 'Serv_pers_part': u'Services aux Personnes/Particuliers', 'Tourism_hotel_loisir': u'Tourisme/Hôtellerie/Loisirs', 'Transport_logist': u'Transport/Logistique', }.iteritems())]) experience_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ ' ': u'Indifferent', 'Inf_1': u'- 1 an', '1_7': u'1 à 7 ans', 'Sup_7': u'+ 7 ans', }.iteritems())]) contract_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '': u'Tous types de contrat', 'CDD': u'CDD', 'CDI': u'CDI', 'Stage': u'Stage', 'Travail_temp': u'Travail temporaire', 'Alternance': u'Alternance', 'Independant': u'Indépendant', 'Franchise': u'Franchise', }.iteritems())]) qualification_choice = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '': u'Indifferent', 'BEP_CAP': u'BEP/CAP', 'Employe_Operateur': u'Employé/Opérateur/Ouvrier Spe/Bac', 'Technicien_B2': u'Technicien/Employé Bac +2', 'Agent_maitrise_B3': u'Agent de maîtrise/Bac +3/4', 'Ingenieur_B5': u'Ingénieur/Cadre/Bac +5', 'Cadre_dirigeant': u'> Bac + 5 (cadre dirigeant)', }.iteritems())]) enterprise_type_choice = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({ '': u'Tous types d\'entreprises', 'Cabinet_recr': u'Cabinets de recrutement', 'Entreprises': u'Entreprises', 'SSII': u'SSII', 'Travail_temporaire': u'Travail temporaire', }.iteritems())]) CONFIG = BackendConfig(Value('website', label=u'Region', choices=website_choices), Value('metier', label='Job name', masked=False, default=''), Value('fonction', label=u'Fonction', choices=fonction_choices, default=''), Value('secteur', label=u'Secteur', choices=secteur_choices, default=''), Value('contract', label=u'Contract', choices=contract_choices, default=''), Value('experience', label=u'Experience', choices=experience_choices, default=''), Value('qualification', label=u'Qualification', choices=qualification_choice, default=''), Value('enterprise_type', label=u'Enterprise type', choices=enterprise_type_choice, default='')) def create_default_browser(self): return self.create_browser(self.config['website'].get()) def search_job(self, pattern=''): return self.browser.search_job(pattern=pattern) def advanced_search_job(self): return self.browser.search_job(pattern=self.config['metier'].get(), fonction=self.config['fonction'].get(), secteur=self.config['secteur'].get(), contract=self.config['contract'].get(), experience=self.config['experience'].get().strip(), qualification=self.config['qualification'].get(), enterprise_type=self.config['enterprise_type'].get()) def get_job_advert(self, _id, advert=None): return self.browser.get_job_advert(_id, advert) def fill_obj(self, advert, fields): return self.get_job_advert(advert.id, advert) OBJECTS = {BaseJobAdvert: fill_obj} ��������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/regionsjob/pages.py��������������������������������������������������������������0000664�0000000�0000000�00000007212�12657170273�0020126�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import CleanText, Regexp, Format, Env, Date, BrowserURL, Join from weboob.browser.filters.html import CleanHTML, Link from weboob.capabilities.job import BaseJobAdvert from weboob.exceptions import ParseError from datetime import date, timedelta from weboob.capabilities import NotAvailable class SearchPage(HTMLPage): @pagination @method class iter_job_adverts(ListElement): item_xpath = '//section[@class="annonce"]' def next_page(self): return Link('//a[@class="picto picto-nextsmall"]')(self) class item(ItemElement): klass = BaseJobAdvert def condition(self): return Regexp(CleanText('h1/a[@class="lien-annonce"]/@href'), '/emplois/(.*)\.html', default=None)(self) obj_id = Format(u'%s#%s', Regexp(Env('domain'), 'http://www\.(.*)\.com'), Regexp(CleanText('h1/a[@class="lien-annonce"]/@href'), '/emplois/(.*)\.html')) obj_title = CleanText('h1/a[2]') obj_society_name = CleanText('figure/span[@itemprop="name"]') obj_place = CleanText('p[@class="inlineblock max-width-75"]') obj_contract_type = CleanText('p[@class="max-width-75"]') def obj_publication_date(self): _date = CleanText('p[@class="infos"]') try: return Date(_date)(self) except ParseError: str_date = _date(self) if 'hier' in str_date: return date.today() - timedelta(days=1) else: return date.today() class AdvertPage(HTMLPage): @method class get_job_advert(ItemElement): klass = BaseJobAdvert obj_description = Join('\n', '//div[@id="annonce-detail"]/p[@class="text"]', textCleaner=CleanHTML) obj_id = Env('_id') obj_url = BrowserURL('advert_page', _id=Env('_id')) obj_publication_date = Date(Regexp(CleanText('//div[@id="annonce-detail"]/p[@class="infos"]'), '(\d{2}/\d{2}/\d{4})', default=NotAvailable), default=NotAvailable) obj_title = CleanText('//div[@id="annonce"]/div/div/h1') obj_society_name = CleanText('//section[@class="entp-resume"]/h1/a') obj_contract_type = CleanText('//dl[@class="infos-annonce"]/dt[span[@class="picto picto-contrat-grey"]]/following-sibling::dd[1]') obj_place = CleanText('//dl[@class="infos-annonce"]/dt[span[@class="picto picto-geolocalisation-grey"]]/following-sibling::dd[1]') obj_pay = CleanText('//div[@id="annonce-detail"]/p[@class="infos"]/preceding-sibling::p[1]', replace=[('Salaire : ', '')]) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/regionsjob/test.py���������������������������������������������������������������0000664�0000000�0000000�00000002674�12657170273�0020015�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest import itertools class RegionsjobTest(BackendTest): MODULE = 'regionsjob' def test_regionjob_search(self): l = list(itertools.islice(self.backend.search_job(u'informaticien'), 0, 20)) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) def test_regionjob_advanced_search(self): l = list(itertools.islice(self.backend.advanced_search_job(), 0, 20)) assert len(l) advert = self.backend.get_job_advert(l[0].id, None) self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url)) ��������������������������������������������������������������������weboob-1.1/modules/residentadvisor/�����������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017517�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/residentadvisor/__init__.py������������������������������������������������������0000664�0000000�0000000�00000001465�12657170273�0021636�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Alexandre Morignot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import ResidentadvisorModule __all__ = ['ResidentadvisorModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/residentadvisor/browser.py�������������������������������������������������������0000664�0000000�0000000�00000007747�12657170273�0021573�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Alexandre Morignot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from .pages import LoginPage, EventPage, ListPage, SearchPage from datetime import datetime class ResidentadvisorBrowser(LoginBrowser): BASEURL = 'http://www.residentadvisor.net' # this ID is used by Resident Advisor ALBANIA_ID = 223 login = URL('https://www.residentadvisor.net/login', LoginPage) event = URL('/event.aspx\?(?P<id>\d+)', EventPage) list_events = URL('/events.aspx\?ai=(?P<city>\d+)&v=(?P<v>.+)&yr=(?P<year>\d{4})&mn=(?P<month>\d\d?)&dy=(?P<day>\d\d?)', ListPage) search_page = URL('/search.aspx\?searchstr=(?P<query>.+)§ion=events&titles=1', SearchPage) attends = URL('/Output/addhandler.ashx') def do_login(self): self.login.stay_or_go() self.page.login(self.username, self.password) # in case of successful connection, we are redirected to the home page if self.login.is_here(): raise BrowserIncorrectPassword() def get_events(self, city, v = 'week', date = datetime.now()): self.list_events.go(v = v, year = date.year, month = date.month, day = date.day, city = city) assert self.list_events.is_here() for event in self.page.get_events(): yield event def get_event(self, _id): self.event.go(id = _id) if not self.event.is_here(): return None event = self.page.get_event() event.id = _id event.url = self.event.build(id = _id) return event def search_events_by_summary(self, pattern): self.search_page.go(query = pattern) assert self.search_page.is_here() for event in self.page.get_events(): yield event def get_country_city_id(self, country, city): now = datetime.now() self.list_events.go(v = 'day', year = now.year, month = now.month, day = now.day, city = self.ALBANIA_ID) assert self.list_events.is_here() country_id = self.page.get_country_id(country) if country_id is None: return None self.list_events.go(v = 'day', year = now.year, month = now.month, day = now.day, city = country_id) assert self.list_events.is_here() city_id = self.page.get_city_id(city) if city_id is None: return None return city_id def get_city_id(self, city): now = datetime.now() country_id = self.ALBANIA_ID city_id = None while True: self.list_events.go(v = 'day', year = now.year, month = now.month, day = now.day, city = country_id) assert self.list_events.is_here() city_id = self.page.get_city_id(city) country_id = self.page.get_country_id_next_to(country_id) # city_id != None => city found # country_id = None => no more country, city not found if city_id is not None or country_id is None: break return city_id @need_login def attends_event(self, id, is_attending): data = {'type': 'saveFavourite', 'action':'attending', 'id': id} if not is_attending: data['type'] = 'deleteFavourite' self.attends.open(data = data) �������������������������weboob-1.1/modules/residentadvisor/module.py��������������������������������������������������������0000664�0000000�0000000�00000011614�12657170273�0021361�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Alexandre Morignot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.backend import BackendConfig from weboob.capabilities.calendar import CapCalendarEvent, BaseCalendarEvent, CATEGORIES from .browser import ResidentadvisorBrowser from datetime import timedelta __all__ = ['ResidentadvisorModule'] class ResidentadvisorModule(Module, CapCalendarEvent): NAME = 'residentadvisor' DESCRIPTION = u'residentadvisor website' MAINTAINER = u'Alexandre Morignot' EMAIL = 'erdnaxeli@cervoi.se' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = ResidentadvisorBrowser CONFIG = BackendConfig(Value('username', label='Username or email', default=''), ValueBackendPassword('password', label='Password', default=''), Value('country', required=True), Value('city', required=True)) ASSOCIATED_CATEGORIES = [CATEGORIES.CONCERT] _city_id = None @property def city_id(self): if not self._city_id: self._city_id = self.browser.get_country_city_id( country = self.config['country'].get(), city = self.config['city'].get()) return self._city_id def create_default_browser(self): password = None username = self.config['username'].get() if len(username) > 0: password = self.config['password'].get() return self.create_browser(username, password) def attends_event(self, event, is_attending): """ Attends or not to an event :param event : the event :type event : BaseCalendarEvent :param is_attending : is attending to the event or not :type is_attending : bool """ self.browser.attends_event(event.id, is_attending) def get_event(self, _id): """ Get an event from an ID. :param _id: id of the event :type _id: str :rtype: :class:`BaseCalendarEvent` or None is fot found. """ return self.browser.get_event(_id) def list_events(self, date_from, date_to): """ list coming event. :param date_from: date of beguinning of the events list :type date_from: date :param date_to: date of ending of the events list :type date_to: date :rtype: iter[:class:`BaseCalendarEvent`] """ # we check if date_to is defined try: date_to.date() except: # default is week date_to = date_from + timedelta(days = 7) delta = date_to - date_from while delta.days >= 0 : v = 'week' if delta.days > 7: v = 'month' for event in self.browser.get_events(v = v, date = date_from, city = self.city_id): if event.start_date <= date_to: yield event if v == 'week': date_from += timedelta(days = 7) else: date_from += timedelta(days = 30) delta = date_to - date_from def search_events(self, query): """ Search event :param query: search query :type query: :class:`Query` :rtype: iter[:class:`BaseCalendarEvent`] """ if not self.has_matching_categories(query): return events = None if query.city: # FIXME # we need the country to search the city_id in an efficient way city_id = self.browser.get_city_id(query.city) events = self.browser.get_events(city = city_id) elif query.summary: events = self.browser.search_events_by_summary(query.summary) else: events = self.list_events(query.start_date, query.end_date) for event in events: event = self.fillobj(event, ['ticket']) if event.ticket in query.ticket: yield event def fill_event(self, event, fields): if set(fields) & set(('end_date', 'price', 'description', 'ticket')): return self.get_event(event.id) return event OBJECTS = {BaseCalendarEvent: fill_event} ��������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/residentadvisor/pages.py���������������������������������������������������������0000664�0000000�0000000�00000011410�12657170273�0021165�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Alexandre Morignot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.calendar import CATEGORIES, STATUS, TICKET from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.html import Attr, CleanHTML, Link from weboob.browser.filters.standard import CleanDecimal, CleanText, Date, CombineDate, DateTime, Regexp, Time, Type from weboob.browser.pages import HTMLPage from weboob.capabilities.calendar import BaseCalendarEvent from datetime import timedelta class BasePage(HTMLPage): @property def logged(self): return bool(self.doc.xpath('//li[@id="profile"]/span[contains(text(), "Welcome")]')) class LoginPage(BasePage): def login(self, username, password): form = self.get_form() form['UsernameOrEmailAddress'] = username form['Password'] = password form.submit() class ListPage(BasePage): @method class get_events(ListElement): item_xpath = '//ul[@id="items"]/li/article' class item(ItemElement): klass = BaseCalendarEvent obj_url = Link('./div[@class="bbox"]/h1/a') obj_id = Regexp(Link('./div[@class="bbox"]/h1/a'), r'aspx\?(.+)') obj_location = CleanText('./div[@class="bbox"]/span/a') obj_start_date = DateTime(Attr('.//time', 'datetime')) obj_summary = Regexp(Attr('./div[@class="bbox"]/h1/a', 'title'), r'details of (.+)') obj_category = CATEGORIES.CONCERT obj_status = STATUS.CONFIRMED def get_country_id(self, country): return Regexp(Link('//li[@id="liCountry"]/ul/li/a[./text()="%s"]' % country, default=''), r'ai=([^&]+)&?', default=None)(self.doc) def get_city_id(self, city): return Regexp(Link('//li[@id="liArea"]/ul/li/a[./text()="%s"]' % city, default=''), r'ai=([^&]+)&?', default=None)(self.doc) def get_country_id_next_to(self, country_id): return Regexp(Link('//li[@id="liCountry"]/ul/li[./a[contains(@href, "ai=%s&")]]/following-sibling::li/a' % country_id, default=''), r'ai=([^&]+)&?', default=None)(self.doc) class EventPage(BasePage): @method class get_event(ItemElement): klass = BaseCalendarEvent obj_summary = CleanText('//div[@id="sectionHead"]/h1') obj_description = CleanHTML('//div[@id="event-item"]/div[3]/p[2]') obj_price = CleanDecimal(Regexp(CleanText('//aside[@id="detail"]/ul/li[3]'), r'Cost /[^\d]*([\d ,.]+).', default=''), default=None) obj_location = Regexp(CleanText('//aside[@id="detail"]/ul/li[2]'), r'Venue / (.+)') obj_booked_entries = Type(CleanText('//h1[@id="MembersFavouriteCount"]'), type=int) obj_status = STATUS.CONFIRMED obj_category = CATEGORIES.CONCERT _date = Date(CleanText('//aside[@id="detail"]/ul/li[1]/a[1]')) def obj_start_date(self): start_time = Time(Regexp(CleanText('//aside[@id="detail"]/ul/li[1]'), r'(\d{2}:\d{2}) -'))(self) return CombineDate(self._date, start_time)(self) def obj_end_date(self): end_time = Time(Regexp(CleanText('//aside[@id="detail"]/ul/li[1]'), r'- (\d{2}:\d{2})'))(self) end_date = CombineDate(self._date, end_time)(self) if end_date > self.obj_start_date(): end_date += timedelta(days = 1) return end_date def obj_ticket(self): li_class = Attr('//li[@id="tickets"]//li[1]', 'class', default=None)(self) if li_class: if li_class == 'closed': return TICKET.CLOSED else: return TICKET.AVAILABLE return TICKET.NOTAVAILABLE class SearchPage(BasePage): @method class get_events(ListElement): item_xpath = '//main/ul/li/section/div/div/ul/li' class item(ItemElement): klass = BaseCalendarEvent obj_url = Link('./a[1]') obj_id = Regexp(Link('./a[1]'), r'\?(\d+)') obj_summary = CleanText('./a[1]') obj_start_date = Date(CleanText('./span[1]')) obj_category = CATEGORIES.CONCERT obj_status = STATUS.CONFIRMED ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/residentadvisor/test.py����������������������������������������������������������0000664�0000000�0000000�00000003105�12657170273�0021047�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Alexandre Morignot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.calendar import Query from datetime import datetime, timedelta class ResidentadvisorTest(BackendTest): MODULE = 'residentadvisor' def test_searchcity(self): query = Query() query.city = u'Melbourne' self.assertTrue(len(list(self.backend.search_events(query))) > 0) event = self.backend.search_events(query).next() self.assertTrue(self.backend.get_event(event.id)) def test_datefrom(self): query = Query() later = (datetime.now() + timedelta(days=31)) query.start_date = later event = self.backend.search_events(query).next() self.assertTrue(later.date() <= event.start_date.date()) event = self.backend.get_event(event.id) self.assertTrue(later.date() <= event.start_date.date()) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/rmll/����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015260�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/rmll/TODO������������������������������������������������������������������������0000664�0000000�0000000�00000000132�12657170273�0015744�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������Add following pseudo channels: most-viewed most-commented count on latest add API_KEY ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/rmll/__init__.py�����������������������������������������������������������������0000664�0000000�0000000�00000001430�12657170273�0017367�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Guilhem Bonnefille # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import RmllModule __all__ = ['RmllModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/rmll/browser.py������������������������������������������������������������������0000664�0000000�0000000�00000004670�12657170273�0017324�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Guilhem Bonnefille # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from weboob.browser.exceptions import HTTPNotFound from .pages import RmllCollectionPage, RmllVideoPage, RmllChannelsPage, RmllSearchPage, RmllLatestPage __all__ = ['RmllBrowser'] class RmllBrowser(PagesBrowser): BASEURL = 'http://video.rmll.info' index_page = URL(r'channels/content/(?P<id>.+)', RmllCollectionPage) latest_page = URL(r'api/v2/latest/', RmllLatestPage) video_page = URL(r'permalink/(?P<id>.+)/', RmllVideoPage) channels_page = URL(r'api/v2/channels/content/\?parent_oid=(?P<oid>.*)', RmllChannelsPage) search_page = URL(r'api/v2/search/\?search=(?P<pattern>.+)', RmllSearchPage) def __init__(self, *args, **kwargs): self.channels = None PagesBrowser.__init__(self, *args, **kwargs) @video_page.id2url def get_video(self, url, video=None): self.location(url) assert self.video_page.is_here() video = self.page.get_video(obj=video) return video def search_videos(self, pattern): url = self.search_page.build(pattern=pattern) self.location(url) return self.page.iter_resources() def get_latest_videos(self): url = self.latest_page.build() self.location(url) assert self.latest_page.is_here() return self.page.iter_resources() def get_channel_videos(self, split_path): oid = '' if len(split_path) > 0: oid = split_path[-1] try: url = self.channels_page.build(oid=oid) self.location(url) assert self.channels_page.is_here() for video in self.page.iter_resources(split_path): yield video except HTTPNotFound: pass ������������������������������������������������������������������������weboob-1.1/modules/rmll/favicon.png�����������������������������������������������������������������0000664�0000000�0000000�00000011171�12657170273�0017414�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���J���M������sRGB����bKGD������ pHYs��M��Mħ���tIME3GA��IDATx{p]uʒcI<mI40H \bPJ L(BxSBDCZBhH %9N4 F?=孭}-:3gַ ,-j{DF(O 뀊TVG( 1 4#PjnU]'S;׆y2,x@ʀӀ3=l9g�O?5\|�٦;γୈo6�0Ϥ2p ?~q>/DNj1l&v'v< 3~$�5I�[LY`iom�6ڌuOyo&p?�]ZRp@[-v@�x=äS<7b3 |yw�T,& ,1U8y'e X lM>55A&oFS?ya�ߜ9� ]b<2+K;Qs[.^3W n`֏dP#O^t4u`UT&�:Y[X7ع�n�N?6CSzf\b5V!"U/"LjW4#"cEBU+< fUݬ[7D!yRUQՏ 5{Q =L/ B; O qjaNMJ_fR/\`UEdۥEDû]FUIU-?Qէ_ g^Tr7_ӥU[vc1?vlHX+"gIDUUنTTU ȋ&yXzOװ盌Ro zX@2o0i:p""clqj W @H_�DDH#^({´bm:X 2f{*?4O:v7� ל $FUWLŜ4RK�U$I.vDxs&ѱ=jksbw "۟TK{M @<b-^ewj$y'q8u< xȢ~4hX@�_ʑ>ySkUe$ר5!84*@K;~[vE.U~7,4Mȅ u $`4qqmJ(91.Ł *U;I7= "_wZhnk^lj9=is2Lj]MU3z{HvC- <j_ ?|nWhQXybmGw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z5]G5"}U$4l* @VU4M7 uG|.Y]Dֈ5d]WKֵV%ڎ_"դoz@NZk�$U}DU�7sXED:UwI٤_|y]I1]Ow׼E%"g8wn'זJB�' dyOs wTQ+jֳlKL<}^EX{ v;mО "FDp3]P~�@c󼪡sI8u F=rS;,�x'iU9<`Fyɖi49:5zLUUIuUERS[U/}@"wޯnǂɶKzz4Mwx1iUIVq^(2<G>7EX۱2"E}?sk)\OXA<s6?!d%"'w!"3Xq6%"?V#Sm>59e8wm0oR6yQgD�KNBl%+ei.:Orsf!ҿ+-4M%yRKOGjAU%I4MK@)IR4ع "Uj.CmWeRn_ ł�x8O}{3N%)f)JL%s.4_fVd+kx?{5]tL{X <h lc߆*F6E�F;4W +6]c r,1>[aVMpW7 l^ numv686[2B�l dϷbTm%9+nT` mUǤ;?U5 C,6[fm#vTZ|7@-l8ҷm;<q >Iֺ|Y|eIһw5͚gl<N|2,f_&u70p26����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/rmll/module.py�������������������������������������������������������������������0000664�0000000�0000000�00000005565�12657170273�0017132�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Guilhem Bonnefille # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, Collection from weboob.tools.backend import Module from .browser import RmllBrowser from .video import RmllVideo __all__ = ['RmllModule'] class RmllModule(Module, CapVideo, CapCollection): NAME = 'rmll' # The name of module MAINTAINER = u'Guyou' # Name of maintainer of this module EMAIL = 'guilhem.bonnefille@gmail.com' # Email address of the maintainer VERSION = '1.1' # Version of weboob DESCRIPTION = 'Videos from RMLL' # Description of your module LICENSE = 'AGPLv3+' # License of your module BROWSER = RmllBrowser def create_default_browser(self): return self.create_browser() def get_video(self, _id): self.logger.debug("Getting video for %s", _id) return self.browser.get_video(_id) def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): return self.browser.search_videos(pattern) def fill_video(self, video, fields): self.logger.debug("Fill video %s for fields %s", video.id, fields) if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields video = self.browser.get_video(video.id, video) if 'thumbnail' in fields and video and video.thumbnail: video.thumbnail.data = self.browser.open(video.thumbnail.url).content return video def iter_resources(self, objs, split_path): if BaseVideo in objs: if len(split_path) == 0: # Add fake Collection yield Collection(['latest'], u'Latest') if len(split_path) == 1 and split_path[0] == 'latest': for video in self.browser.get_latest_videos(): yield video else: channel_videos = self.browser.get_channel_videos(split_path) if channel_videos: for content in channel_videos: yield content OBJECTS = {RmllVideo: fill_video} �������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/rmll/pages.py��������������������������������������������������������������������0000664�0000000�0000000�00000012775�12657170273�0016745�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Guilhem Bonnefille # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.browser.pages import HTMLPage, JsonPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import Regexp, Format, CleanText, Duration, DateTime, Filter from weboob.browser.filters.html import Link, XPath, CleanHTML from weboob.browser.filters.json import Dict from weboob.capabilities import NotAvailable, NotLoaded from weboob.capabilities.image import BaseImage from weboob.capabilities.collection import Collection from .video import RmllVideo BASE_URL = 'http://video.rmll.info' class NormalizeThumbnail(Filter): def filter(self, thumbnail): if not thumbnail.startswith('http'): thumbnail = BASE_URL + thumbnail if thumbnail == "http://rmll.ubicast.tv/statics/mediaserver/images/video_icon.png": # This is the default: remove it as any frontend default should be better thumbnail = None return thumbnail class RmllDuration(Duration): _regexp = re.compile(r'((?P<hh>\d+) h )?((?P<mm>\d+) m )?(?P<ss>\d+) s') kwargs = {'hours': 'hh', 'minutes': 'mm', 'seconds': 'ss'} def create_video(metadata): video = RmllVideo(metadata['oid']) video.title = unicode(metadata['title']) video.date = DateTime(Dict('creation'), default=NotLoaded)(metadata) video.duration = RmllDuration(Dict('duration', default=''), default=NotLoaded)(metadata) thumbnail = NormalizeThumbnail(Dict('thumb'))(metadata) video.thumbnail = BaseImage(thumbnail) video.thumbnail.url = video.thumbnail.id video.url = NotLoaded return video class RmllVideoPage(HTMLPage): @method class get_video(ItemElement): klass = RmllVideo obj_id = CleanHTML('/html/head/meta[@property="og:url"]/@content') & CleanText() & Regexp(pattern=r'.*/permalink/(.+)/$') obj_title = Format(u'%s', CleanHTML('/html/head/meta[@name="DC.title"]/@content') & CleanText()) obj_description = Format(u'%s', CleanHTML('/html/head/meta[@property="og:description"]/@content') & CleanText()) def obj_thumbnail(self): url = NormalizeThumbnail(CleanText('/html/head/meta[@property="og:image"]/@content'))(self) if url: thumbnail = BaseImage(url) thumbnail.url = thumbnail.id return thumbnail obj_duration = CleanText('/html/head/script[not(@src)]') & Regexp(pattern=r'media_duration: ([^,.]+),?.*,', default='') & Duration(default=NotAvailable) def obj_url(self): links = XPath('//div[@id="tab_sharing_content"]/div/div/div[@class="paragraph"]/div[@class="share"]/a[@target="_blank"]/@href')(self) for link in links: ext = str(link).split('.')[-1] self.logger.debug("Link:%s Ext:%s", link, ext) if ext in ['mp4', 'webm']: return unicode(link) class RmllCollectionPage(HTMLPage): @method class iter_videos(ListElement): item_xpath = '//div[@class="item-entry type-video " or @class="item-entry type-vod "]' class item(ItemElement): klass = RmllVideo obj_id = Link('a') & Regexp(pattern=r'.*/videos/(.+)/$') obj_title = Format(u'%s', CleanHTML('a/span/span/span[@class="item-entry-title"]') & CleanText()) obj_url = NotLoaded #obj_date = XPath('a/span/span/span[@class="item-entry-creation"]') obj_duration = CleanText('a/span/span/span[@class="item-entry-duration"]') & RmllDuration() def obj_thumbnail(self): thumbnail = NormalizeThumbnail(CleanText('a/span[@class="item-entry-preview"]/img/@src'))(self) if thumbnail: thumbnail = BaseImage(thumbnail) thumbnail.url = thumbnail.id return thumbnail class RmllChannelsPage(JsonPage): def iter_resources(self, split_path): if 'channels' in self.doc: for metadata in self.doc['channels']: collection = Collection(split_path+[metadata['oid']], metadata['title']) yield collection if 'videos' in self.doc: for metadata in self.doc['videos']: video = create_video(metadata) yield video class RmllLatestPage(JsonPage): def iter_resources(self): for metadata in self.doc['items']: if metadata['type'] == 'c': collection = Collection([metadata['oid']], metadata['title']) yield collection if metadata['type'] == 'v': video = create_video(metadata) yield video class RmllSearchPage(JsonPage): def iter_resources(self): if 'videos' in self.doc: for metadata in self.doc['videos']: video = create_video(metadata) yield video ���weboob-1.1/modules/rmll/test.py���������������������������������������������������������������������0000664�0000000�0000000�00000005161�12657170273�0016614�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Guilhem Bonnefille # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo class RmllTest(BackendTest): MODULE = 'rmll' def test_video_search(self): videos = self.backend.search_videos('test') self.assertTrue(videos) for video in videos: self.assertTrue(video.id, 'ID for video not found') def test_video_page(self): for slug in ["v124f0bc409e704d92cf", "http://video.rmll.info/permalink/v124f0bc409e704d92cf/"]: video = self.backend.browser.get_video(slug) self.assertTrue(video.id, 'ID for video not found') self.assertTrue(video.url, 'URL for video "%s" not found' % (video.id)) self.assertTrue(video.thumbnail, 'Thumbnail for video "%s" not found' % (video.id)) self.assertTrue(video.title, 'Title for video "%s" not found' % (video.id)) #self.assertTrue(video.description, 'Description for video "%s" not found' % (video.id)) self.assertTrue(video.duration, 'Duration for video "%s" not found' % (video.id)) #help(video) def test_video_fill(self): slug = "v124f0bc409e704d92cf" video = self.backend.browser.get_video(slug) video = self.backend.fill_video(video, ["url"]) self.assertTrue(video) self.assertTrue(video.url, 'URL for video "%s" not found' % (video.id)) def test_browse(self): for path in [[], ['latest']]: videos = self.backend.iter_resources([BaseVideo],path) self.assertTrue(videos) for video in videos: self.assertTrue(video.id, 'ID for video not found') def test_missing_duration(self): videos = self.backend.search_videos('weboob') self.assertTrue(videos) for video in videos: self.assertTrue(video.id, 'ID for video not found') video = self.backend.fill_video(video, ["$full"]) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/rmll/video.py��������������������������������������������������������������������0000664�0000000�0000000�00000001744�12657170273�0016746�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Guilhem Bonnefille # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo class RmllVideo(BaseVideo): @classmethod def id2url(cls, _id): if _id.startswith('http'): return _id else: return 'http://video.rmll.info/permalink/%s/' % (_id) ����������������������������weboob-1.1/modules/s2e/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015003�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/s2e/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000001426�12657170273�0017117�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import S2eModule __all__ = ['S2eModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/s2e/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000013352�12657170273�0017044�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import datetime from decimal import Decimal from dateutil.parser import parse as parse_date from weboob.browser import LoginBrowser, URL, need_login from weboob.browser.profiles import Android from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities.bank import Account, Transaction, Investment from .pages import LoginPage, CalcPage, ProfilPage, AccountsPage, HistoryPage, I18nPage class S2eBrowser(LoginBrowser): PROFILE = Android() CTCC = "" LANG = "FR" sessionId = None loginp = URL('/$', LoginPage) calcp = URL('/s2e_services/restServices/calculetteService/grillemdp\?uuid=(?P<uuid>)', CalcPage) profilp = URL('/s2e_services/restServices/authentification/loginS', ProfilPage) accountsp = URL('/s2e_services/restServices/situationCompte', AccountsPage) historyp = URL('/s2e_services/restServices/listeOperation', HistoryPage) i18np = URL('/(?P<lang1>.*)/LANG/(?P<lang2>.*).json', I18nPage) def __init__(self, url, username, password, *args, **kwargs): super(S2eBrowser, self).__init__(username, password, *args, **kwargs) self.BASEURL = "https://" + url def do_login(self): self.logger.debug('call Browser.do_login') self.loginp.stay_or_go() self.sessionId = self.page.login(self.username, self.password) if self.sessionId is None: raise BrowserIncorrectPassword() self.page.logged = True @need_login def get_accounts_list(self): data = {'clang': self.LANG, 'ctcc': self.CTCC, 'login': self.username, 'session': self.sessionId} for dispositif in self.accountsp.open(data=data).get_list(): if dispositif['montantBrutDispositif'] == 0: continue a = Account() a.id = dispositif['codeDispositif'] a.type = Account.TYPE_MARKET a.balance = Decimal(dispositif["montantBrutDispositif"]).quantize(Decimal('.01')) a.label = dispositif['titreDispositif'] a.currency = u"EUR" # Don't find any possbility to get that from configuration. a._investments = [] for fund in dispositif['listeFonds']: if fund['montantValeurEuro'] == 0: continue i = Investment() i.id = i.code = dispositif['codeEntreprise'] + dispositif["codeDispositif"] + fund["codeSupport"] i.label = fund['libelleSupport'] i.unitvalue = Decimal(fund["montantValeur"]).quantize(Decimal('.01')) i.valuation = Decimal(fund["montantValeurEuro"]).quantize(Decimal('.01')) i.quantity = i.valuation / i.unitvalue i.vdate = parse_date(fund['dateValeur'], dayfirst=True) a._investments.append(i) yield a @need_login def iter_history(self, account): # Load i18n for type translation self.i18np.open(lang1=self.LANG, lang2=self.LANG).load_i18n() # For now detail for each account is not available. History is global for all accounts and very simplist data = {'clang': self.LANG, 'ctcc': self.CTCC, 'login': self.username, 'session': self.sessionId} for trans in self.historyp.open(data=data).get_transactions(): t = Transaction() t.id = trans["referenceOperationIndividuelle"] t.date = datetime.strptime(trans["dateHeureSaisie"], "%d/%m/%Y") t.rdate = datetime.strptime(trans["dateHeureSaisie"], "%d/%m/%Y") t.type = Transaction.TYPE_DEPOSIT if trans["montantNetEuro"] > 0 else Transaction.TYPE_PAYBACK t.raw = trans["typeOperation"] try: t.label = self.i18n["OPERATION_TYPE_" + trans["casDeGestion"]] except KeyError: t.label = self.i18n["OPERATION_TYPE_TOTAL_" + trans["casDeGestion"]] t.amount = Decimal(trans["montantNetEuro"]).quantize(Decimal('.01')) yield t class Esalia(S2eBrowser): CTCC = "SG" loginp = URL('/Esalia/$', LoginPage) i18np = URL('/Esalia/SG/(?P<lang1>.*)/LANG/(?P<lang2>.*).json', I18nPage) class Capeasi(S2eBrowser): CTCC = "AXA" loginp = URL('/AXA/$', LoginPage) i18np = URL('/AXA/(?P<lang1>.*)/LANG/(?P<lang2>.*).json', I18nPage) class EREHSBC(S2eBrowser): CTCC = "HSBC" loginp = URL('/ERE-HSBC/$', LoginPage) i18np = URL('/ERE-HSBC/HSBC/(?P<lang1>.*)/LANG/(?P<lang2>.*).json', I18nPage) class CreditNord(S2eBrowser): CTCC = "" # FIXME : Not Available Yet loginp = URL('//$', LoginPage) # Hack : Lang.json of BNPERE is only available in app. Get it from Esalia i18np = URL('https://m.esalia.com/Esalia/SG/(?P<lang1>.*)/LANG/(?P<lang2>.*).json', I18nPage) class BNPPERE(S2eBrowser): CTCC = "BNP" loginp = URL('/$', LoginPage) # Hack : Lang.json of BNPERE is only available in app. Get it from Esalia i18np = URL('https://m.esalia.com/Esalia/SG/(?P<lang1>.*)/LANG/(?P<lang2>.*).json', I18nPage) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/s2e/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000006147�12657170273�0016652�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Christophe Lampin # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.base import find_object from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.ordereddict import OrderedDict from .browser import Esalia, Capeasi, EREHSBC, BNPPERE __all__ = ['S2eModule'] class S2eModule(Module, CapBank): NAME = 's2e' MAINTAINER = u'Christophe Lampin' EMAIL = 'weboob@lampin.net' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Esalia, Capeasi, BNP PERE, HSBC ERE' website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({ 'm.esalia.com': u'Esalia', # Good Url. Tested 'mobile.capeasi.com': u'Capeasi', # Good Url. Not fully tested 'mobi.ere.hsbc.fr': u'ERE HSBC', # Good Url. Tested 'smartphone.s2e-net.com': u'BNPP ERE', # Good Url. Tested # 'smartphone.s2e-net.com': u'Groupe Crédit du Nord', # Mobile version not available yet. }.iteritems(), key=lambda k_v: (k_v[1], k_v[0]))]) BROWSERS = { 'm.esalia.com': Esalia, 'mobile.capeasi.com': Capeasi, 'mobi.ere.hsbc.fr': EREHSBC, 'smartphone.s2e-net.com': BNPPERE, # 'smartphone.s2e-net.com': CreditNord, # Mobile version not available yet. } CONFIG = BackendConfig(Value('website', label='Banque', choices=website_choices, default='smartphone.s2e-net.com'), ValueBackendPassword('login', label='Identifiant', masked=False), ValueBackendPassword('password', label='Code secret', regexp='^(\d{6}|)$')) def create_default_browser(self): self.BROWSER = self.BROWSERS[self.config['website'].get()] return self.create_browser(self.config['website'].get(), self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.get_accounts_list() def get_account(self, _id): return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound) def iter_investment(self, account): return account._investments def iter_history(self, account): return self.browser.iter_history(account)�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/s2e/pages.py���������������������������������������������������������������������0000664�0000000�0000000�00000005345�12657170273�0016463�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Christophe Lampiné # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import random from weboob.browser.pages import HTMLPage, LoggedPage, JsonPage class LoginPage(HTMLPage): def generate_uuid(self): chars = list('0123456789abcdef') uuid = [None]*36 rnd = random.random for i in (8, 13, 18, 23): uuid[i] = '-' uuid[14] = '4' # version 4 for i in range(36): if uuid[i] is None: r = 0 | int(rnd()*16) idx = (((r & 0x3) | 0x8) if (i == 19) else (r & 0xf)) uuid[i] = chars[idx] i += 1 return ''.join(uuid) def login(self, login, password): uuid = self.generate_uuid() data = self.browser.calcp.open(uuid=uuid).get_data(login, password) return self.browser.profilp.open(data=data).get_session_id() class CalcPage(JsonPage): def get_data(self, login, password): convert_data = {} for num_data in self.doc['grilleMdp']: convert_data[num_data["nom"]] = num_data["valeur"] encrypt_pass = "" for char in password: encrypt_pass += (convert_data[int(char)] + ":") data = {'clang': self.browser.LANG, 'conversationId': self.doc["conversationId"], 'ctcc': self.browser.CTCC, 'login': login, 'password': encrypt_pass} return data class ProfilPage(JsonPage): def get_session_id(self): return self.doc['session'] class AccountsPage(LoggedPage, JsonPage): def get_list(self): for entreprise in self.doc["listeEntreprise"]: for dispositif in entreprise["listeDispositf"]: # Ceci n'est pas une erreur de frappe ;) dispositif['codeEntreprise'] = entreprise['codeEntreprise'] yield dispositif class HistoryPage(LoggedPage, JsonPage): def get_transactions(self): for operation in self.doc["listeOperations"]: yield operation class I18nPage(JsonPage): def load_i18n(self): self.browser.i18n = self.doc["i18n"] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/s2e/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000001736�12657170273�0016343�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class S2eTest(BackendTest): MODULE = 's2e' def test_bank(self): l = list(self.backend.iter_accounts()) if len(l) > 0: a = l[0] list(self.backend.iter_history(a)) ����������������������������������weboob-1.1/modules/sachsen/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015736�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sachsen/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001452�12657170273�0020051�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import SachsenLevelModule __all__ = ['SachsenLevelModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sachsen/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000002542�12657170273�0017776�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import ListPage, HistoryPage __all__ = ['SachsenBrowser'] class SachsenBrowser(PagesBrowser): BASEURL = 'http://www.umwelt.sachsen.de' homepage = URL('/umwelt/infosysteme/hwims/portal/web/wasserstand-uebersicht.*', ListPage) history = URL('/umwelt/infosysteme/hwims/portal/web/wasserstand-pegel-(?P<idgauge>.*)', HistoryPage) def get_rivers_list(self): return self.homepage.stay_or_go().get_rivers_list() def iter_history(self, sensor, **kwargs): self.history.go(idgauge=sensor.gaugeid) return self.page.iter_history(sensor=sensor) ��������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sachsen/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000011740�12657170273�0020074�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� B(x���tIME _P��mIDATx՛wՕB瞞ܓH ,0L0^{c۬vװik.fN,FK0lP@YiY3ӓz:UW?^ Xd9t^[~+ ]Hh$ @Jqա3ml_�n4t7Ґr+rkG8$@X]V 2-c`Ss7 [ æx CSƒ@a�UBǘr!Hd2=?ke|a�$,w /VT'_E9mU !Um}8�> 3 uT)\xK9~夅Q2oYwAc oW=ٖVT*D| 7&0@RowAm>\�zKAyى,:a0T+0m?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$m ����IENDB`��������������������������������weboob-1.1/modules/sachsen/module.py����������������������������������������������������������������0000664�0000000�0000000�00000005246�12657170273�0017604�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .browser import SachsenBrowser from weboob.capabilities.gauge import CapGauge, GaugeSensor, Gauge,\ SensorNotFound from weboob.capabilities.base import find_object from weboob.tools.backend import Module __all__ = ['SachsenLevelModule'] class SachsenLevelModule(Module, CapGauge): NAME = 'sachsen' MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u"Level of Sachsen river" BROWSER = SachsenBrowser def iter_gauges(self, pattern=None): if pattern is None: for gauge in self.browser.get_rivers_list(): yield gauge else: lowpattern = pattern.lower() for gauge in self.browser.get_rivers_list(): if lowpattern in gauge.name.lower()\ or lowpattern in gauge.object.lower(): yield gauge def _get_sensor_by_id(self, id): for gauge in self.browser.get_rivers_list(): for sensor in gauge.sensors: if id == sensor.id: return sensor raise SensorNotFound() def iter_sensors(self, gauge, pattern=None): if not isinstance(gauge, Gauge): gauge = find_object(self.browser.get_rivers_list(), id=gauge, error=SensorNotFound) if pattern is None: for sensor in gauge.sensors: yield sensor else: lowpattern = pattern.lower() for sensor in gauge.sensors: if lowpattern in sensor.name.lower(): yield sensor def iter_gauge_history(self, sensor): if not isinstance(sensor, GaugeSensor): sensor = self._get_sensor_by_id(sensor) return self.browser.iter_history(sensor) def get_last_measure(self, sensor): if not isinstance(sensor, GaugeSensor): sensor = self._get_sensor_by_id(sensor) return sensor.lastvalue ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sachsen/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000013274�12657170273�0017416�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import lxml.html from weboob.browser.pages import HTMLPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import Env, CleanText, Regexp, Field, DateTime, Map from weboob.browser.filters.html import Attr from weboob.capabilities.gauge import Gauge, GaugeMeasure, GaugeSensor from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.exceptions import ParseError import re class ListPage(HTMLPage): @method class get_rivers_list(ListElement): item_xpath = ".//div[@class='msWrapper']/script" class item(ItemElement): klass = Gauge extract = re.compile(".*content:(?P<html>.*),show") forecasts = {'pfeil_gerade.png.jsf': u'stable', 'pfeil_unten.png.jsf': u'Go down', 'pfeil_oben.png.jsf': u'Go up', } alarmlevel = {"as1.gif": u"Alarmstufe 1", "as2.gif": u"Alarmstufe 2", "as3.gif": u"Alarmstufe 3", "as4.gig": u"Alarmstufe 4", "qua_grau.gif": u"No alarm function", "p_gruen.gif": u"", "qua_weiss.gif": u"no data", "as0.gif": u"", "MNW.gif": u""} obj_id = CleanText(Env('id')) obj_name = CleanText(Env('name'), "'") obj_city = Regexp(Field('name'), '^([^\s]+).*') obj_object = Env('object') def parse(self, el): raw = self.extract.match(el.text).group("html") raw = raw.replace('\\"', '"').replace('\\n', '').replace('\\/', '/') parsed = lxml.html.fromstring(raw) self.env['name'] = CleanText('.//span[@class="popUpTitleBold"]')(parsed) self.env['object'] = CleanText('.//span[@class="popUpTitleNormal"]')(parsed).strip(' /') url = Attr('.//div[@class="popUpMsDiagramm"]/img', 'src')(parsed) self.env['id'] = url.split('_')[1] for tr in parsed.xpath('.//tr'): td = tr.xpath('.//td') if len(td) == 1 and "Datum" in td[0].text: l = td[0].text.split()[1:3] self.env['datetime'] = "%s %s" % (l[0], l[1]) elif len(td) == 2: if "Wasserstand" in td[0].text: self.env['levelvalue'] = td[1].text.split()[0] elif "Durchfluss" in td[0].text: self.env['flowvalue'] = td[1].text.split()[0] elif "Tendenz" in td[0].text: try: self.env['forecast'] = Attr('img', 'src')(td[1]).split("/")[-1] except ParseError: self.env['forecast'] = None # TODO self.env['alarm'] = None def add_sensor(self, sensors, name, unit, value, forecast, alarm, date): sensor = GaugeSensor("%s-%s" % (self.obj.id, name.lower())) sensor.name = name sensor.unit = unit sensor.forecast = forecast lastvalue = GaugeMeasure() lastvalue.alarm = alarm try: lastvalue.level = float(value) except ValueError: lastvalue.level = NotAvailable lastvalue.date = date sensor.lastvalue = lastvalue sensor.history = NotLoaded sensor.gaugeid = self.obj.id sensors.append(sensor) def obj_sensors(self): sensors = [] lastdate = DateTime(Regexp(Env('datetime'), r'(\d+)\.(\d+)\.(\d+) (\d+):(\d+)', r'\3-\2-\1 \4:\5', default=NotAvailable), default=NotAvailable)(self) forecast = Map(Env('forecast'), self.forecasts, default=NotAvailable)(self) alarm = Map(Env('alarm'), self.alarmlevel, default=u'')(self) self.add_sensor(sensors, u"Level", u"cm", self.env['levelvalue'], forecast, alarm, lastdate) self.add_sensor(sensors, u"Flow", u"m3/s", self.env['flowvalue'], forecast, alarm, lastdate) return sensors class HistoryPage(HTMLPage): @method class iter_history(ListElement): item_xpath = '//table[@class="quickbarTable"]/tbody/tr' class item(ItemElement): klass = GaugeMeasure verif = re.compile("\d\d.\d\d.\d+ \d\d:\d\d") obj_date = DateTime(Regexp(CleanText('.'), r'(\d+)\.(\d+)\.(\d+) (\d+):(\d+)', r'\3-\2-\1 \4:\5')) sensor_types = [u'Level', u'Flow'] def obj_level(self): index = self.sensor_types.index(self.env['sensor'].name) + 1 try: return float(self.el[index].text_content()) except ValueError: return NotAvailable # TODO: history.alarm ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sachsen/test.py������������������������������������������������������������������0000664�0000000�0000000�00000002640�12657170273�0017271�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.base import find_object class SachsenTest(BackendTest): MODULE = 'sachsen' def test_sachsen(self): l = list(self.backend.iter_gauges()) self.assertTrue(len(l) > 0) gauge = find_object(l, id=u'501060') sensors = list(self.backend.iter_sensors(gauge)) self.assertTrue(len(sensors) > 0) for sensor in sensors: self.assertTrue(sensor.lastvalue.level > 0) sensor = sensors[0] history = list(self.backend.iter_gauge_history(sensor)) self.assertTrue(len(history) > 0) self.assertTrue(self.backend.get_last_measure(sensor) is not None) ������������������������������������������������������������������������������������������������weboob-1.1/modules/seeklyrics/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016467�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seeklyrics/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000001442�12657170273�0020601�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import SeeklyricsModule __all__ = ['SeeklyricsModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seeklyrics/browser.py������������������������������������������������������������0000664�0000000�0000000�00000003712�12657170273�0020527�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import SongResultsPage, SonglyricsPage, ArtistResultsPage, ArtistSongsPage __all__ = ['SeeklyricsBrowser'] class SeeklyricsBrowser(Browser): DOMAIN = 'www.seeklyrics.com' PROTOCOL = 'http' ENCODING = 'iso-8859-1' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.seeklyrics.com/search.php.*t=1': SongResultsPage, 'http://www.seeklyrics.com/search.php.*t=2': ArtistResultsPage, 'http://www.seeklyrics.com/lyrics/.*html': SonglyricsPage, 'http://www.seeklyrics.com/lyrics/.*/': ArtistSongsPage, } def iter_lyrics(self, criteria, pattern): if criteria == 'artist': type = 2 else: type = 1 self.location('http://www.seeklyrics.com/search.php?q=%s&t=%s' % (pattern, type)) assert self.is_on_page(ArtistResultsPage) or self.is_on_page(SongResultsPage) return self.page.iter_lyrics() def get_lyrics(self, id): try: self.location('http://www.seeklyrics.com/lyrics/%s.html' % id) except BrowserHTTPNotFound: return if self.is_on_page(SonglyricsPage): return self.page.get_lyrics(id) ������������������������������������������������������weboob-1.1/modules/seeklyrics/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000003502�12657170273�0020622�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME(߂Q��IDATxiU²*WAI⁀' DLH τ jЀEtV@HPPaó홝f'O&[Qի^H A $CAW tڔK߲Cd#ShW*| p �ˀy Gm%T0ey ^ ])y0(Y |ϔVI,�ŠO?H0=(1'V`0h| <(U#T>=BwZ'c �nT*((x^!'"\Ej=QBj}>!8 q/ zgaL<\(Z 6Y�S@juE-rBs�m!0&Q`h.ɭ1o\/!wv� o T  T|`Ԟb8Jg/f;�% 6ǁJWޮ'ƻ GͿL(I!G`s$r9(avcfUiG(b%0h:ՠ[`9Qj~G0Ѡrn[<@2u `)� (uA(XUZ' ps w /J08q;.ʄH@nnof٭rg#_~sq]j=X <11,G7H\'`>պ]1p 0 xC]n1۷뀫ͨ(]rX 'yg�9Jy99)$H AUWH?0;ۛbfLwlIʲ@g)wl b_R o J,<+Iv~][jlkpbSS}3krJR)ΎLjKOm`[CS X+ @edQA%-_9N�mo5=+%Ve"@!7xG|3ֱņrijn?RֺƘ#%V[sJ:=[ 0~ ڒ~<%D1+F DѤK3}9r2+~>R�x'Y0Zv%p)@\bBvp^n:MB,J*fR0�tXaM]ƾiD 8zu1FL|Ͼ{RIz2-t91l+v1ʔ `eʪ6Č<Cp)2�?sRߺ1j�t3B}"Ѷ*#t!SRZ 1DrV@c2̾ুm}TDmGl lkĈWfR8ˈ52ZW TĖc$Aع 'yB h҅R'͑c3c"ta-G׹>)ϯ~!(1m#A.,_%m\-L`]ug?r,Vp!PK3Ly~6}V '9(6CQbIW}f\Rop/#E)<"g5`)tOW_}!ߊP\Y+```[; (#%<U $H A 9N����IENDB`����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seeklyrics/module.py�������������������������������������������������������������0000664�0000000�0000000�00000003213�12657170273�0020325�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.lyrics import CapLyrics, SongLyrics from weboob.tools.backend import Module from .browser import SeeklyricsBrowser from urllib import quote_plus __all__ = ['SeeklyricsModule'] class SeeklyricsModule(Module, CapLyrics): NAME = 'seeklyrics' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'SeekLyrics lyrics website' LICENSE = 'AGPLv3+' BROWSER = SeeklyricsBrowser def get_lyrics(self, id): return self.browser.get_lyrics(id) def iter_lyrics(self, criteria, pattern): return self.browser.iter_lyrics(criteria, quote_plus(pattern.encode('iso-8859-1'))) def fill_songlyrics(self, songlyrics, fields): if 'content' in fields: sl = self.get_lyrics(songlyrics.id) songlyrics.content = sl.content return songlyrics OBJECTS = { SongLyrics: fill_songlyrics } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seeklyrics/pages.py��������������������������������������������������������������0000664�0000000�0000000�00000006643�12657170273�0020151�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.lyrics import SongLyrics from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page class ArtistResultsPage(Page): def iter_lyrics(self): for link in self.parser.select(self.document.getroot(), 'table[title~=Results] a.tlink'): artist = unicode(link.text_content()) self.browser.location('http://www.seeklyrics.com%s' % link.attrib.get('href', '')) assert self.browser.is_on_page(ArtistSongsPage) for lyr in self.browser.page.iter_lyrics(artist): yield lyr class ArtistSongsPage(Page): def iter_lyrics(self, artist): for th in self.parser.select(self.document.getroot(), 'th.text'): txt = th.text_content() if txt.startswith('Top') and txt.endswith('Lyrics'): for link in self.parser.select(th.getparent().getparent(), 'a.tlink'): title = unicode(link.attrib.get('title', '').replace(' Lyrics', '')) id = link.attrib.get('href', '').replace('/lyrics/', '').replace('.html', '') songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = NotLoaded yield songlyrics class SongResultsPage(Page): def iter_lyrics(self): first = True for tr in self.parser.select(self.document.getroot(), 'table[title~=Results] tr'): if first: first = False continue artist = NotAvailable tds = self.parser.select(tr, 'td') assert len(tds) > 2 title = unicode(tds[1].text_content()) link = self.parser.select(tds[1], 'a', 1) id = link.attrib.get('href', '').replace('/lyrics/', '').replace('.html', '') aartist = self.parser.select(tr, 'a')[-1] artist = unicode(aartist.text) songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = NotLoaded yield songlyrics class SonglyricsPage(Page): def get_lyrics(self, id): artist = NotAvailable title = NotAvailable l_artitle = self.parser.select(self.document.getroot(), 'table.text td > b > h2') if len(l_artitle) > 0: artitle = l_artitle[0].text.split(' Lyrics by ') artist = unicode(artitle[1]) title = unicode(artitle[0]) content = unicode(self.parser.select(self.document.getroot(), 'div#songlyrics', 1).text_content().strip()) songlyrics = SongLyrics(id, title) songlyrics.artist = artist songlyrics.content = content return songlyrics ���������������������������������������������������������������������������������������������weboob-1.1/modules/seeklyrics/test.py���������������������������������������������������������������0000664�0000000�0000000�00000003251�12657170273�0020021�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.base import NotLoaded class SeeklyricsTest(BackendTest): MODULE = 'seeklyrics' def test_search_song_n_get(self): l_lyrics = list(self.backend.iter_lyrics('song', 'Complainte')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded full_lyr = self.backend.get_lyrics(songlyrics.id) assert full_lyr.id assert full_lyr.title assert full_lyr.artist assert full_lyr.content is not NotLoaded def test_search_artist(self): l_lyrics = list(self.backend.iter_lyrics('artist', 'boris vian')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seloger/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015752�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seloger/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000000077�12657170273�0020067�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import SeLogerModule __all__ = ['SeLogerModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seloger/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000005703�12657170273�0020014�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.capabilities.housing import Query, TypeNotSupported from weboob.browser import PagesBrowser, URL from .pages import SearchResultsPage, HousingPage, CitiesPage from weboob.browser.profiles import Android __all__ = ['SeLogerBrowser'] class SeLogerBrowser(PagesBrowser): BASEURL = 'http://www.seloger.com' PROFILE = Android() cities = URL('js,ajax,villequery_v3.htm\?ville=(?P<pattern>.*)', CitiesPage) search = URL('http://ws.seloger.com/search.xml\?(?P<request>.*)', SearchResultsPage) housing = URL('http://ws.seloger.com/annonceDetail.xml\?idAnnonce=(?P<_id>\d+)&noAudiotel=(?P<noAudiotel>\d)', HousingPage) def search_geo(self, pattern): return self.cities.open(pattern=pattern).iter_cities() TYPES = {Query.TYPE_RENT: 1, Query.TYPE_SALE: 2, } RET = {Query.HOUSE_TYPES.HOUSE: '2', Query.HOUSE_TYPES.APART: '1', Query.HOUSE_TYPES.LAND: '4', Query.HOUSE_TYPES.PARKING: '3', Query.HOUSE_TYPES.OTHER: '10'} def search_housings(self, type, cities, nb_rooms, area_min, area_max, cost_min, cost_max, house_types): if type not in self.TYPES: raise TypeNotSupported() data = {'ci': ','.join(cities), 'idtt': self.TYPES.get(type, 1), 'org': 'advanced_search', 'surfacemax': area_max or '', 'surfacemin': area_min or '', 'tri': 'd_dt_crea', } if type == Query.TYPE_SALE: data['pxmax'] = cost_max or '' data['pxmin'] = cost_min or '' else: data['px_loyermax'] = cost_max or '' data['px_loyermin'] = cost_min or '' if nb_rooms: data['nb_pieces'] = nb_rooms ret = [] for house_type in house_types: if house_type in self.RET: ret.append(self.RET.get(house_type)) if ret: data['idtypebien'] = ','.join(ret) return self.search.go(request=urllib.urlencode(data)).iter_housings() def get_housing(self, _id, obj=None): return self.housing.go(_id=_id, noAudiotel=1).get_housing(obj=obj) �������������������������������������������������������������weboob-1.1/modules/seloger/module.py����������������������������������������������������������������0000664�0000000�0000000�00000005143�12657170273�0017614�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.housing import CapHousing, Housing, HousingPhoto from weboob.tools.backend import Module from .browser import SeLogerBrowser __all__ = ['SeLogerModule'] class SeLogerModule(Module, CapHousing): NAME = 'seloger' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'French housing website' LICENSE = 'AGPLv3+' ICON = 'http://static.poliris.com/z/portail/svx/portals/sv6_gen/favicon.png' BROWSER = SeLogerBrowser def search_housings(self, query): cities = [c.id for c in query.cities if c.backend == self.name] if len(cities) == 0: return list([]) return self.browser.search_housings(query.type, cities, query.nb_rooms, query.area_min, query.area_max, query.cost_min, query.cost_max, query.house_types) def get_housing(self, housing): if isinstance(housing, Housing): id = housing.id else: id = housing housing = None return self.browser.get_housing(id, housing) def search_city(self, pattern): return self.browser.search_geo(pattern) def fill_housing(self, housing, fields): if fields != ['photos'] or not housing.photos: housing = self.browser.get_housing(housing.id, housing) if 'photos' in fields: for photo in housing.photos: if not photo.data: photo.data = self.browser.open(photo.url) return housing def fill_photo(self, photo, fields): if 'data' in fields and photo.url and not photo.data: photo.data = self.browser.open(photo.url).content return photo OBJECTS = {Housing: fill_housing, HousingPhoto: fill_photo, } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seloger/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000007132�12657170273�0017426�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import XMLPage, JsonPage, pagination from weboob.browser.elements import ItemElement, ListElement, DictElement, method from weboob.browser.filters.json import Dict from weboob.browser.filters.html import XPath from weboob.browser.filters.standard import CleanText, CleanDecimal, DateTime from weboob.capabilities.base import NotAvailable from weboob.capabilities.housing import Housing, HousingPhoto, City class CitiesPage(JsonPage): @method class iter_cities(DictElement): item_xpath = '0/values' class item(ItemElement): klass = City def condition(self): return Dict('value', default=None)(self) obj_id = Dict('value') obj_name = Dict('label') class SeLogerItem(ItemElement): klass = Housing obj_id = CleanText('idAnnonce') obj_title = CleanText('titre') obj_date = DateTime(CleanText('dtFraicheur')) obj_cost = CleanDecimal('prix') obj_currency = CleanText('prixUnite') obj_area = CleanDecimal('surface') obj_text = CleanText('descriptif') obj_location = CleanText('ville') obj_station = CleanText('proximite', default=NotAvailable) obj_url = CleanText('permaLien') class SearchResultsPage(XMLPage): @pagination @method class iter_housings(ListElement): item_xpath = "//annonce" def next_page(self): page = CleanText('//pageSuivante', default=None)(self) if page: return page class item(SeLogerItem): def obj_photos(self): photos = [] for photo in XPath('./photos/photo/stdurl')(self): photos.append(HousingPhoto(photo)) return photos class HousingPage(XMLPage): @method class get_housing(SeLogerItem): def obj_photos(self): photos = [] for photo in XPath('./photos/photo')(self): url = CleanText('bigUrl', default=None)(photo) if not url: url = CleanText('stdUrl', default=None)(photo) photos.append(HousingPhoto(url)) return photos def obj_location(self): location = CleanText('//detailAnnonce/adresse')(self) quartier = CleanText('//detailAnnonce/quartier', default=None)(self) if not location and quartier is not None: location = quartier ville = CleanText('ville')(self) return u'%s %s' % (location, ville) def obj_details(self): details = {} for detail in XPath('//detailAnnonce/details/detail')(self): details[CleanText('libelle')(detail)] = CleanText('valeur', default='N/A')(detail) details['Reference'] = CleanText('//detailAnnonce/reference')(self) return details obj_phone = CleanText('//contact/telephone') ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/seloger/test.py������������������������������������������������������������������0000664�0000000�0000000�00000002552�12657170273�0017307�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import itertools from weboob.capabilities.housing import Query from weboob.tools.test import BackendTest class SeLogerTest(BackendTest): MODULE = 'seloger' def test_seloger(self): query = Query() query.area_min = 20 query.cost_max = 1000 query.type = Query.TYPE_RENT query.cities = [] for city in self.backend.search_city(u'Ferté'): city.backend = self.backend.name query.cities.append(city) results = list(itertools.islice(self.backend.search_housings(query), 0, 20)) self.assertTrue(len(results) > 0) self.backend.fillobj(results[0], 'phone') ������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/senscritique/��������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017030�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/senscritique/__init__.py���������������������������������������������������������0000664�0000000�0000000�00000001446�12657170273�0021146�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import SenscritiqueModule __all__ = ['SenscritiqueModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/senscritique/browser.py����������������������������������������������������������0000664�0000000�0000000�00000005035�12657170273�0021070�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.base import UserError from weboob.browser import PagesBrowser, URL from .pages import FilmsPage, EventPage, JsonResumePage from weboob.browser.profiles import Firefox __all__ = ['SenscritiqueBrowser'] class SenscritiqueBrowser(PagesBrowser): BASEURL = 'http://www.senscritique.com' films_page = URL('/everymovie/programme-tv/chrono', FilmsPage) event_page = URL('/film/(?P<_id>.*)', EventPage) json_page = URL('/sc/products/storyline/(?P<_id>.*).json', JsonResumePage) def set_json_header(self): self.session.headers.update({"User-Agent": "Mozilla/5.0 (Windows; U; Windows " "NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8" " GTB7.1 (.NET CLR 3.5.30729)", "Accept": "application/json, text/javascript, */*; q=0.01", "X-Requested-With": "XMLHttpRequest", }) def list_events(self, date_from, date_to=None): return self.films_page.go().iter_films(date_from=date_from, date_to=date_to) def get_event(self, _id, event=None): if not event: try: event = self.films_page.go().iter_films(_id=_id).next() except StopIteration: raise UserError('This event (%s) does not exists' % _id) film_id = _id.split('#')[0] event = self.event_page.go(_id=film_id).get_event(obj=event) resume = self.get_resume(film_id) if resume: event.description += resume return event def get_resume(self, film_id): self.set_json_header() _id = film_id.split('/')[-1] resume = self.json_page.go(_id=_id).get_resume() self.set_profile(Firefox()) return resume ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/senscritique/calendar.py���������������������������������������������������������0000664�0000000�0000000�00000002070�12657170273�0021152�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.calendar import BaseCalendarEvent, TRANSP, STATUS, CATEGORIES class SensCritiquenCalendarEvent(BaseCalendarEvent): def __init__(self): BaseCalendarEvent.__init__(self) self.sequence = 1 self.transp = TRANSP.TRANSPARENT self.status = STATUS.CONFIRMED self.category = CATEGORIES.TELE ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/senscritique/favicon.png���������������������������������������������������������0000664�0000000�0000000�00000012210�12657170273�0021157�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����gAMA�� a��� pHYs����+��IDATx^[ Uev~B7 F'4I1JM*L@^!5L&DrL2,iDDF#Uq "h٧̰4{'w=Kwt wH鹦5yooH'锤tKgosq]Rz)qnI >)NI%T9=ҝ�crjK/Y\l}2@J&: -9NyhD.#A^ kE1)@THX)ߎ[Ϧz1v'�D/�N6+`^.S$�"�$ҡ{CAT}wn`$)v<ҥKjurkkk \-o�N\Waq:8�A@Zy`eINM@6wvv::H=ꟾtuAwfCvI[{3땺&lceUr}*@ .GS*,:]DP˕Vim|QCZZu/466,zlDPXQF�8Q5jjj!Z�ӱUb>8'5`c%6̏s04LC Yq3E ȏ$_@'L0Aʔ+**\KKdoKiE?O{*'JyIL/esRZZ*e%㥲b/- +b<BǝPZ!` 2~b$ 1ecq䁌�`…P("`hPp{`H $kh "@BϓDby0LF?p-q9#KH�IB襗^҉J@(r0z? +�HQ$A\#�a_ 0�h , X#_PP>t %92\5UVΛ#_!` 1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RZ4:(s`3RZyޕkH49 yrRV` ޴RV[)O=Xw-|"o�7P;�S�5mgy:)c6=\xB:Z^fƜ{2mQ[ʅdd" &5oW@dȮGjƳRYV,rHn ;?^!,9?} !O`|Vc(P]%?2CI'I�I.�\[AԬoeMonA?<&>gg͒|$X+IOe9Y|YQ!u9%Ҍyx{w݉qj_}vP^߰V‰rRtB?y@W$dK~?N?y |C)Or\ת_jS84+<̰ 05;;$fɐqjoUh> "_iUK�`?"Vx@diDz|\nC|;zVh<%�zAgG\i뒹RU ;(09AP5煅SSn|0rZV&OOUy7c*̉J[opPodWy2 C*4c`qLb|@vew5{F `1/ߘx</ESz9z'HD ,Y݁&l[eWxrK]\]]vכMyB!~5DWҕ+W�Nd l^HoP<7,tҴl#~S <R9w jժd74}v (#�n/O}דMkBb|y-)2dJp#y#[^`~#drD~oBZK&Tf} A Bb\-^ɼBd⁞45{2ǴдI�vݺuLe,e}@c5;7  GQY?W,[L2eUeb hJܫT~vع]qyN웥}T�l0.^A y_k}ll={$?a �B8@e hVve(D{羈y;t1Wj �l2�lss=sr+{-;vl?$H:`ixw hJqh"-l"aĔżirիW'd^7ek}Hx̟<eK 6o,s'6>aҠ#)Nͯ:dlx3Yfh'V1غҕU*srJ(#�Rv[NFf! mq}B^p=sȶ}=zosr<&KĀ9V'�#N̖1?\ޱc>w ieSؼ;83ҿ� XAsCc: ?JOeTR@jر|r"\Z}y<uT3[@o}| :QqKFfo]CG֚%LY^ lIg|Ν~8,[@؇qm@+̊ [Zk;C,Lc Z yGZ?,z& gh& HphGyDj&)Ö$_~$BI1 }$a>?�!'כ$3Fky(ACD?6&ٸqj�0]qz#x7H<[o|ed""v]7y౟7}也%A&y{W(#�t#_zF�APNK\z/ Ybلכ l267\O65ʙ" Kֆ1Rn����IENDB`����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/senscritique/module.py�����������������������������������������������������������0000664�0000000�0000000�00000003623�12657170273�0020673�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.calendar import CapCalendarEvent, CATEGORIES from .browser import SenscritiqueBrowser from .calendar import SensCritiquenCalendarEvent __all__ = ['SenscritiqueModule'] class SenscritiqueModule(Module, CapCalendarEvent): NAME = 'senscritique' DESCRIPTION = u'senscritique website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' ASSOCIATED_CATEGORIES = [CATEGORIES.TELE] BROWSER = SenscritiqueBrowser def search_events(self, query): if self.has_matching_categories(query): return self.list_events(query.start_date, query.end_date) def list_events(self, date_from, date_to=None): items = [] for item in self.browser.list_events(date_from, date_to): items.append(item) items.sort(key=lambda o: o.start_date) return items def get_event(self, _id, event=None): return self.browser.get_event(_id, event) def fill_obj(self, event, fields): return self.get_event(event.id, event) OBJECTS = {SensCritiquenCalendarEvent: fill_obj} �������������������������������������������������������������������������������������������������������������weboob-1.1/modules/senscritique/pages.py������������������������������������������������������������0000664�0000000�0000000�00000011675�12657170273�0020513�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .calendar import SensCritiquenCalendarEvent from datetime import date, datetime, timedelta from weboob.capabilities.base import empty from weboob.browser.pages import HTMLPage, JsonPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.standard import Filter, CleanText, Regexp, Join, Format, BrowserURL, Env from weboob.browser.filters.html import Link class Description(Filter): def filter(self, el): header = "//div[@class='pvi-hero-product']" section = "//section[@class='pvi-productDetails']" return Format(u'%s %s\n\n%s%s\n\n', CleanText("%s/div[@class='d-rubric-inner']/h1" % header), CleanText("%s/div[@class='d-rubric-inner']/small" % header), Join(u'- ', "%s/ul[@class='pvi-product-specs']/li" % header, newline=True), Join(u'- ', "%s/ul/li" % section, newline=True, addBefore='- '))(el[0]) class FormatDate(Filter): def __init__(self, pattern, selector): super(FormatDate, self).__init__(selector) self.pattern = pattern def filter(self, _date): return _date.strftime(self.pattern) class Date(Filter): def filter(self, el): spans_date = el[0].xpath("span[@class='d-date']") _date = date.today() if len(spans_date) == 2: day_number = int(spans_date[1].text) month = _date.month year = _date.year if day_number < _date.day: month = _date.month % 12 + 1 if _date.month == 12: year = _date.year + 1 _date = date(day=day_number, month=month, year=year) elif spans_date[0].attrib['data-sc-day'] == 'Demain': _date += timedelta(days=1) str_time = el[0].xpath("time")[0].attrib['datetime'][:-6] _time = datetime.strptime(str_time, '%H:%M:%S') return datetime.combine(_date, _time.time()) class JsonResumePage(JsonPage): def get_resume(self): if self.doc['json']['success']: return self.doc['json']['data'] class EventPage(HTMLPage): @method class get_event(ItemElement): klass = SensCritiquenCalendarEvent obj_url = BrowserURL('event_page', _id=Env('_id')) obj_description = Description('.') class FilmsPage(HTMLPage): @method class iter_films(ListElement): item_xpath = '//li[@class="elgr-mosaic "]/a' class item(ItemElement): klass = SensCritiquenCalendarEvent def condition(self): if '_id' in self.env and self.env['_id']: return Format(u'%s#%s#%s', Regexp(Link('.'), '/film/(.*)'), FormatDate("%Y%m%d%H%M", Date('div/div[@class="elgr-data-diffusion"]')), CleanText('./div/span[@class="d-offset"]', replace=[(' ', '-')]))(self) == self.env['_id'] return True def validate(self, obj): if 'date_from' in self.env and self.env['date_from'] and obj.start_date > self.env['date_from']: if not self.env['date_to']: return True else: if empty(obj.end_date): if obj.start_date < self.env['date_to']: return True elif obj.end_date <= self.env['date_to']: return True if '_id' in self.env: return True return False obj_id = Format(u'%s#%s#%s', Regexp(Link('.'), '/film/(.*)'), FormatDate("%Y%m%d%H%M", Date('div/div[@class="elgr-data-diffusion"]')), CleanText('./div/span[@class="d-offset"]', replace=[(' ', '-')])) obj_start_date = Date('div/div[@class="elgr-data-diffusion"]') obj_summary = Format('%s - %s', Regexp(CleanText('./div/img/@alt'), '^Affiche(.*)'), CleanText('./div/span[@class="d-offset"]')) �������������������������������������������������������������������weboob-1.1/modules/senscritique/test.py�������������������������������������������������������������0000664�0000000�0000000�00000002151�12657170273�0020360�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from datetime import datetime class SenscritiqueTest(BackendTest): MODULE = 'senscritique' def test_senscritique(self): l = list(self.backend.list_events(datetime.now())) assert len(l) event = self.backend.get_event(l[0].id) self.assertTrue(event.url, 'URL for event "%s" not found: %s' % (event.id, event.url)) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015104�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000000067�12657170273�0017220�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import SfrModule __all__ = ['SfrModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000004576�12657170273�0017155�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from .pages.compose import ClosePage, ComposePage, ConfirmPage, SentPage from .pages.login import LoginPage from weboob.deprecated.browser import Browser, BrowserIncorrectPassword __all__ = ['SfrBrowser'] class SfrBrowser(Browser): DOMAIN = 'www.sfr.fr' PAGES = { 'http://messagerie-.+.sfr.fr/webmail/close_xms_tab.html': ClosePage, 'http://www.sfr.fr/xmscomposer/index.html\?todo=compose': ComposePage, 'http://www.sfr.fr/xmscomposer/mc/envoyer-texto-mms/confirm.html': ConfirmPage, 'https://www.sfr.fr/cas/login\?service=.*': LoginPage, 'http://www.sfr.fr/xmscomposer/mc/envoyer-texto-mms/send.html': SentPage, } def get_nb_remaining_free_sms(self): if not self.is_on_page(ComposePage): self.home() return self.page.get_nb_remaining_free_sms() def home(self): self.location('http://www.sfr.fr/xmscomposer/index.html?todo=compose') def is_logged(self): return 'loginForm' not in [form.name for form in self.forms()] def login(self): service_url = 'http://www.sfr.fr/xmscomposer/j_spring_cas_security_check' self.location('https://www.sfr.fr/cas/login?service=%s' % urllib.quote_plus(service_url), no_login=True) self.page.login(self.username, self.password) if not self.is_logged(): raise BrowserIncorrectPassword() def post_message(self, message): if not self.is_on_page(ComposePage): self.home() self.page.post_message(message) if self.is_on_page(ConfirmPage): self.page.confirm() assert self.is_on_page(ClosePage) or self.is_on_page(SentPage) ����������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/favicon.png������������������������������������������������������������������0000664�0000000�0000000�00000002517�12657170273�0017244�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD���� K��� pHYs�� �� ����tIME  !���tEXtComment�Created with GIMPW��IDATx_h[U?'M[ڎuM 76DTYUt>}PaPdaV'lvXqJ4['Mܟ7mۦiCm;${ d@YT/! Y@|.Y�A�>B`26k#Sn`2;;bo͕-އI`ĺNz[�![K$ѝ%ID5� @�4� @�4� !3}L?\^&=̧g_"ܵ)=>EO5/�U(OLߞl7Cy(e>@/ .8w`* ހZo  ع͙?`7Gvkmӊ*}jX|CDm?r/ 8j~4MҀD7PBX;BcNLk&0FVxAD�ϴZ+O#%kjdS=r{]a+Vz^ڏ߉ g~[$U+)x��.eU;tv tnF:X}Ϟo/D@tUg\=*�J[eUXmK"3Aon1GFc}b޳řake2UJTRӀATA#�=As#ycPp> H @חM"w? zfOCnE{ sgBxuhPS σuk=iǭZK^D0 +Dm1_|%y @?Hq楈I#r4 HLQ.㬖aVͭDD$46.+6H˯#[@>;E  ˽HHmzK~AB!k|0<ϑo?EN xew:}3d9 33X&w#4� @�4� @�4� @�4� ,ɟf1�V�H4؏;QS̯ ,0LٯP�1d&COq@`r5\(rmaAab2QǗ Ѝc}TrQi+x/!1+#3Ptk!p����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000004121�12657170273�0016741�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.messages import CantSendMessage, CapMessages, CapMessagesPost from weboob.capabilities.account import CapAccount, StatusField from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from .browser import SfrBrowser __all__ = ['SfrModule'] class SfrModule(Module, CapAccount, CapMessages, CapMessagesPost): NAME = 'sfr' MAINTAINER = u'Christophe Benz' EMAIL = 'christophe.benz@gmail.com' VERSION = '1.1' DESCRIPTION = 'SFR French mobile phone provider' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('login', label='Login'), ValueBackendPassword('password', label='Password')) BROWSER = SfrBrowser ACCOUNT_REGISTER_PROPERTIES = None def create_default_browser(self): return self.create_browser(self.config['login'].get(), self.config['password'].get()) # CapMessagesPost methods def get_account_status(self): with self.browser: return (StatusField('nb_remaining_free_sms', 'Number of remaining free SMS', self.browser.get_nb_remaining_free_sms()),) def post_message(self, message): if not message.content.strip(): raise CantSendMessage(u'Message content is empty.') with self.browser: self.browser.post_message(message) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/pages/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016203�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/pages/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0020302�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/pages/compose.py�������������������������������������������������������������0000664�0000000�0000000�00000003164�12657170273�0020226�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.messages import CantSendMessage from weboob.deprecated.browser import Page class ClosePage(Page): pass class ComposePage(Page): phone_regex = re.compile('^(\+33|0033|0)(6|7)(\d{8})$') def get_nb_remaining_free_sms(self): nbSms = self.parser.select(self.document.getroot(), '#freeSms',1).text.strip() return nbSms def post_message(self, message): receiver = message.thread.id if self.phone_regex.match(receiver) is None: raise CantSendMessage(u'Invalid receiver: %s' % receiver) self.browser.select_form(nr=0) self.browser['msisdns'] = receiver self.browser['textMessage'] = message.content.encode('utf-8') self.browser.submit() class ConfirmPage(Page): def confirm(self): self.browser.select_form(nr=0) self.browser.submit() class SentPage(Page): pass ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/pages/login.py���������������������������������������������������������������0000664�0000000�0000000�00000002023�12657170273�0017662�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page class LoginPage(Page): def login(self, login, password): self.browser.select_form(nr=0) self.browser['username'] = login self.browser['password'] = password self.browser['remember-me'] = ['on'] self.browser.submit() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sfr/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000002173�12657170273�0016440�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class SFRTest(BackendTest): MODULE = 'sfr' def test_sfr(self): pass def test_create_default_browser(self): connect = self.backend.create_default_browser() assert connect def test_get_account_status(self): nbSms = self.backend.get_account_status() assert nbSms assert isinstance(nbSms[0].value, str) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/simplyreadit/��������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017020�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/simplyreadit/__init__.py���������������������������������������������������������0000664�0000000�0000000�00000001445�12657170273�0021135�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import SimplyreaditModule __all__ = ['SimplyreaditModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/simplyreadit/favicon.png���������������������������������������������������������0000664�0000000�0000000�00000017323�12657170273�0021161�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs����+���tIME 9So���tEXtComment�Created with GIMPW���bKGD������C��.IDATx{i%W}y/ʬ4U۸`C[PAH `-j~�"G4M fM1.גUvUn˗o_bܗe06tK&쨗/{wι>^[}ӿm(DJ.ǓiSU5MEA;enW\3 lD`"dS7(^g컕WFRёC( %JQH(@yv{}~y{z7Hf&'ɪ!)*jFBٶz{,#G2l!놦q!+L1H%3bYJڶ+նⷼW_,H15ȪXPU]p0h0bԍ8h9 OzwҡD1&S8<r г8#&_a+zegCӨ,.|bdH 7iRqU5tUEY"YVt-A{\;zvv'N)oH92z/ O� E 5".\2"/Y|ȃ"ܝJY\Z:uZ5wou?Xt~qR*ξH&IX7ie„t):z"Cl VU]YScuH/[o-$JC~ nX B 6q _dI"^7ⱄ |&ݕ.kPح%Rb>O |IDQDQ oYd1fT<Bl` r<]?x XsqpX|lXX6ffOxByM� <Ah #R"@}""da&<*h5:6lV>B7xuB2etfEQe(̮)>П F<PVgUv1΄/_'bqS@lMi: C@x�8ľQ` "ӌNz] um(X}ߏܢOO҅b!7ƆEM}E4kw&Z,ĝN<p/�/̜xm>~͖,+&$ЂtZF@A2BPNqX| paQW^lqT",Ӄ10p+! UsFQAעpE!3t- x"9/7J�yhᓿHGc,/]zDL>CN,OlB57B~f:>Gr6?FTAu89 D0'<pP)#ON bMV8fH~^sZn2aԬH(V7/3 #s^pg3NN.# rVΞ}<_Y:y#{05!̄Y;ob100QH2ļ !ur1HBJNh4R^3 .l+*4L#ك. BO(4ֶ4u _w*|~H8 CG m~`^rvbD$R #r6၇ܭÔ~${NF€IP  hi(f84yƸ ՛Jjzj;Ѷ 㫥Cek Hn M0e9@ߗDD71o~tC,40!#m(p划҂ `n WڃFrR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ٲmdbT ZnΟu?K#Hfa, ? |U H2./baq D=!m"r0 nUGKv.3tubtv w%+7d_Cdw1/A`/#MQHjn%V~Ym7Xj_?X0tN,Nkh@"q}1 Nݐ$8-$,oírj}bO\:9>y]a;@lB^{wtX,w-ݖUm7W{߿k׷~2bvh#s8QKy`@]U зH8=OA1Ֆl+�_ssJnsr܋E剑c[@lWahp?] ޓ)�E3lL9_'Md0pi[7b(Lt4" V^:h|".S"Ar`HQ Wa^ {s?*_"δ?B?W+V"ج7:SKSe0Wg!#m{+!�2a9EE{٭eT4xڈ2K _E!�i9xqw +)V@ =NND!(ZxzgbE(z HItZΊ22|d ~33 s?of@ {lU=D Y!_֯~ R]oUb@PGߵ·#K^bbIes|�T0Ax~^eM*eT]g@*yi+oWV(ZVpBbg@xJq6_(f#`<_J%oDЯ)ܑ�癠Meppw6WݿW4{W�{r YUmJkHX2a_ 4'\~ h]pyb̯W/_q+YsH@3Lv{z]M#i';kL- :7ߨU3(\(ynPA }VֺHp_eRB] +U|{F{?/7 _x%StL71KXP5?A6mGm/8܎<_+[ht����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/simplyreadit/module.py�����������������������������������������������������������0000664�0000000�0000000�00000002626�12657170273�0020665�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderModule, DisplayPage __all__ = ['SimplyreaditModule'] class SimplyreaditModule(GenericComicReaderModule): NAME = 'simplyreadit' DESCRIPTION = 'SimplyReadIt manga reading website' BROWSER_PARAMS = dict( img_src_xpath="//img[@class='open']/@src", page_list_xpath="(//div[contains(@class,'dropdown_right')]/ul[@class='dropdown'])[1]/li/a/@href") ID_TO_URL = 'http://www.simplyread.it/reader/read/%s' ID_REGEXP = r'[^/]+(?:/[^/]+)*' URL_REGEXP = r'.+simplyread.it/reader/read/(%s)/page/.+' % ID_REGEXP PAGES = {r'http://.+\.simplyread.it/reader/read/.+': DisplayPage} ����������������������������������������������������������������������������������������������������������weboob-1.1/modules/simplyreadit/test.py�������������������������������������������������������������0000664�0000000�0000000�00000001732�12657170273�0020354�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.gallery.genericcomicreadertest import GenericComicReaderTest class SimplyreaditTest(GenericComicReaderTest): MODULE = 'simplyreadit' def test_download(self): return self._test_download('bonnouji/en/1/3') ��������������������������������������weboob-1.1/modules/societegenerale/�����������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017450�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/__init__.py������������������������������������������������������0000664�0000000�0000000�00000001461�12657170273�0021563�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import SocieteGeneraleModule __all__ = ['SocieteGeneraleModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/browser.py�������������������������������������������������������0000664�0000000�0000000�00000015545�12657170273�0021517�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.deprecated.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable from weboob.capabilities.bank import Account from .pages.accounts_list import AccountsList, AccountHistory, CardsList, LifeInsurance, \ LifeInsuranceHistory, LifeInsuranceInvest, Market, ListRibPage from .pages.login import LoginPage, BadLoginPage, ReinitPasswordPage __all__ = ['SocieteGenerale'] class SocieteGenerale(Browser): DOMAIN_LOGIN = 'particuliers.societegenerale.fr' CERTHASH_LOGIN = ['a84fd13e19c80b1dd70498292f983d9d0d19f88c2d35fcd21a5f310072b1d386'] DOMAIN = 'particuliers.secure.societegenerale.fr' CERTHASH = '2275084c61b3d12bfd8886a4c2995fae99ee60f28ef30b11efc414ceb0ee2022' PROTOCOL = 'https' ENCODING = None # refer to the HTML encoding PAGES = { 'https://particuliers.societegenerale.fr/.*': LoginPage, 'https://.*.societegenerale.fr//acces/authlgn.html': BadLoginPage, 'https://.*.societegenerale.fr/error403.html': BadLoginPage, '.*/acces/changecodeobligatoire.html': ReinitPasswordPage, '.*restitution/cns_listeprestation.html': AccountsList, '.*restitution/cns_listeCartes.*.html.*': CardsList, '.*restitution/cns_detail.*\.html.*': AccountHistory, 'https://.*.societegenerale.fr/lgn/url.html.*':AccountHistory, 'https://.*.societegenerale.fr/brs/cct/comti20.html.*': Market, 'https://.*.societegenerale.fr/asv/asvcns10.html.*': LifeInsurance, 'https://.*.societegenerale.fr/asv/AVI/asvcns10a.html': LifeInsurance, 'https://.*.societegenerale.fr/asv/AVI/asvcns20a.html': LifeInsuranceInvest, 'https://.*.societegenerale.fr/asv/AVI/asvcns2[0-9]c.html': LifeInsuranceHistory, 'https://.*.societegenerale.fr/restitution/imp_listeRib.html': ListRibPage, } def home(self): self.lowsslcheck(self.DOMAIN_LOGIN, self.CERTHASH_LOGIN) self.location('https://' + self.DOMAIN_LOGIN + '/index.html') def is_logged(self): if not self.page or self.is_on_page(LoginPage): return False error = self.page.get_error() if error is None: return True if error.startswith('Le service est momentan'): raise BrowserUnavailable(error) return False def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.password.isdigit() if not self.is_on_page(LoginPage): self.location('https://' + self.DOMAIN_LOGIN + '/index.html', no_login=True) self.page.login(self.username, self.password) if self.is_on_page(LoginPage): raise BrowserIncorrectPassword() if self.is_on_page(BadLoginPage): error = self.page.get_error() if error is None: raise BrowserIncorrectPassword() elif error.startswith('Votre session a'): raise BrowserUnavailable('Session has expired') elif error.startswith('Le service est momentan'): raise BrowserUnavailable(error) else: raise BrowserIncorrectPassword(error) def get_accounts_list(self): if not self.is_on_page(AccountsList): self.location('/restitution/cns_listeprestation.html') accounts = [acc for acc in self.page.get_list()] self.location('/restitution/imp_listeRib.html') if self.is_on_page(ListRibPage): # Caching rib url, so we don't have to go back and forth for each account for account in accounts: account._rib_url = self.page.get_rib_url(account) for account in accounts: if account._rib_url: self.location(account._rib_url) account.iban = self.page.get_iban() return accounts def get_account(self, id): assert isinstance(id, basestring) if not self.is_on_page(AccountsList): self.location('/restitution/cns_listeprestation.html') for a in self.page.get_list(): if a.id == id: return a return None def iter_history(self, account): if not account._link_id: return self.location(account._link_id) if self.is_on_page(CardsList): for card_link in self.page.iter_cards(): self.location(card_link) for trans in self.page.iter_transactions(): yield trans elif self.is_on_page(AccountHistory): for trans in self.page.iter_transactions(): yield trans elif self.is_on_page(LifeInsurance): self.location('/asv/AVI/asvcns20c.html') for trans in self.page.iter_transactions(): yield trans # go to next page while self.page.document.xpath('//div[@class="net2g_asv_tableau_pager"]/a[contains(@href, "actionSuivPage")]'): form = self.page.document.xpath('//form[@id="operationForm"]')[0] data = dict((item.name, item.value or '') for item in form.inputs) data['a100_asv_action'] = 'actionSuivPage' self.location('asvcns21c.html', urllib.urlencode(data)) for trans in self.page.iter_transactions(): yield trans else: self.logger.warning('This account is not supported') def key(tr): # Can't compare datetime and date, so cast them. try: return tr.rdate.date() except AttributeError: return tr.rdate def iter_investment(self, account): if account.type == Account.TYPE_MARKET: self.location(account._link_id) elif account.type == Account.TYPE_LIFE_INSURANCE: self.location(account._link_id) self.location('/asv/AVI/asvcns20a.html') else: self.logger.warning('This account is not supported') return for invest in self.page.iter_investment(): yield invest �����������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/captcha.py�������������������������������������������������������0000664�0000000�0000000�00000010440�12657170273�0021424�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import hashlib from PIL import Image from weboob.tools.log import getLogger class TileError(Exception): def __init__(self, msg, tile=None): Exception.__init__(self, msg) self.tile = tile class Captcha(object): def __init__(self, file, infos): self.inim = Image.open(file) self.infos = infos self.nbr = int(infos["nbrows"]) self.nbc = int(infos["nbcols"]) (self.nx, self.ny) = self.inim.size self.inmat = self.inim.load() self.map = {} self.tiles = [[Tile(y * self.nbc + x) for y in xrange(4)] for x in xrange(4)] def __getitem__(self, coords): x, y = coords return self.inmat[x % self.nx, y % self.ny] def all_coords(self): for y in xrange(self.ny): for x in xrange(self.nx): yield x, y def get_codes(self, code): s = '' num = 0 for c in code: index = self.map[int(c)].id keycode = str(self.infos["grid"][num * self.nbr * self.nbc + index]) s += keycode if num < 5: s += ',' num += 1 return s def build_tiles(self): for ty in xrange(0, self.nbc): y = ty * 23 for tx in xrange(0, self.nbr): x = tx * 24 tile = self.tiles[tx][ty] for yy in xrange(y, y + 23): for xx in xrange(x, x + 24): tile.map.append(self[xx, yy]) num = tile.get_num() if num > -1: tile.valid = True self.map[num] = tile class Tile(object): hash = {'ff1441b2c5f90703ef04e688e399aca5': 1, '53d7f3dfd64f54723b231fc398b6be57': 2, '5bcba7fa2107ba9a606e8d0131c162eb': 3, '9db6e7ed063e5f9a69ab831e6cc0d721': 4, '30ebb75bfa5077f41ccfb72e8c9cc15b': 5, '61e27275e494038e524bc9fbbd0be130': 6, '0e0816f1b743f320ca561f090df0fbb1': 7, '11e7d4a6d447e66a5a112c1d9f7fc442': 8, '2ea3c82768030d91571d360acf7a0f75': 9, '28a834ebbf0238b46d3fffae1a0b781b': 0, '04211db029ce488e07010f618a589c71': -1, '9a1bdf493d4067e98d3f364586c81e9d': 1, '932032493860463bb4a3df7c99a900ad': 2, '59cd90f1fa0b416ecdb440bc16d0b8e7': 3, '53fe822c5efebe5f6fdef0f272c29638': 4, '2082a9c830c0c7c9c22e9c809c6cadf7': 5, '7f24aa97f0037bddcf2a4c8c2dbf5948': 6, '725b6f11f44ecc2e9f6e79e86e3a82a5': 7, '61d57da23894b96fab11f7b83c055bba': 8, '18f6290c1cfaecadc5992e7ef6047a49': 9, '1ce77709ec1d7475685d7b50d6f1c89e': 0, '6718858a509fff4b86604f3096cf65e1': -1, } def __init__(self, _id): self.id = _id self.valid = False self.logger = getLogger('societegenerale.captcha') self.map = [] def __repr__(self): return "<Tile(%02d) valid=%s>" % (self.id, self.valid) def checksum(self): s = '' for pxls in self.map: for pxl in pxls: s += '%02d' % pxl return hashlib.md5(s).hexdigest() def get_num(self): sum = self.checksum() try: return self.hash[sum] except KeyError: self.display() raise TileError('Tile not found ' + sum, self) def display(self): self.logger.debug(self.checksum()) #im = Image.new('RGB', (24, 23)) #im.putdata(self.map) #im.save('/tmp/%s.png' % self.checksum()) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/favicon.png������������������������������������������������������0000664�0000000�0000000�00000001672�12657170273�0021611�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ����tIME  2I���tEXtComment�Created with GIMPW��'IDATxKAƿ5[0C-VE*MzQAZHo^_ mⵉYsAzO%ll2DWwCbB޼߾D#@q@7 ���@�� ���@��Pk `#�O5�C�s5č(^&4%v]we�<pG}~ƿanb6|#y5&O\Ee{7wJTR}?kz�`](D鏪�\`o+53}Ʌ?JW'SvKe-r{}f@ sQd@-|'Le>oIo%h- oJ"ꌇ՝:~zu>�U5x*}�iZc@g�m s vuu!ɠT*annCe!";sfYD,slX $q||p89UZU_b4MNLLTb�pll$,Iryyٱ$.gOOOFo܀I, ?0 1 1 14Mvww&�ym΀͊ص5GGGIDʇNSSS3n|cHdTrhjt:bI9D*0 -9Z��mZ夶Ԝ&IW=33:D*A)��@�� ���@�� �@{Z dz#����IENDB`����������������������������������������������������������������������weboob-1.1/modules/societegenerale/module.py��������������������������������������������������������0000664�0000000�0000000�00000005421�12657170273�0021311�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # Copyright(C) 2012-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import CapBank, AccountNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from .browser import SocieteGenerale from .sgpe.browser import SGEnterpriseBrowser, SGProfessionalBrowser __all__ = ['SocieteGeneraleModule'] class SocieteGeneraleModule(Module, CapBank): NAME = 'societegenerale' MAINTAINER = u'Jocelyn Jaubert' EMAIL = 'jocelyn.jaubert@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Société Générale' CONFIG = BackendConfig( ValueBackendPassword('login', label='Code client', masked=False), ValueBackendPassword('password', label='Code secret'), Value('website', label='Type de compte', default='par', choices={'par': 'Particuliers', 'pro': 'Professionnels', 'ent': 'Entreprises'})) def create_default_browser(self): b = {'par': SocieteGenerale, 'pro': SGProfessionalBrowser, 'ent': SGEnterpriseBrowser} self.BROWSER = b[self.config['website'].get()] return self.create_browser(self.config['login'].get(), self.config['password'].get()) def iter_accounts(self): for account in self.browser.get_accounts_list(): yield account def get_account(self, _id): with self.browser: account = self.browser.get_account(_id) if account: return account else: raise AccountNotFound() def iter_history(self, account): with self.browser: for tr in self.browser.iter_history(account): if not tr._coming: yield tr def iter_coming(self, account): with self.browser: for tr in self.browser.iter_history(account): if tr._coming: yield tr def iter_investment(self, account): with self.browser: for inv in self.browser.iter_investment(account): yield inv �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/pages/�����������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020547�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/pages/__init__.py������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0022646�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/pages/accounts_list.py�������������������������������������������0000664�0000000�0000000�00000037426�12657170273�0024007�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib import datetime from urlparse import parse_qs, urlparse from lxml.etree import XML from cStringIO import StringIO from decimal import Decimal, InvalidOperation import re from weboob.capabilities.base import empty, NotAvailable from weboob.capabilities.bank import Account, Investment from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.deprecated.browser import BrokenPageError from weboob.browser.filters.standard import CleanText from .base import BasePage class AccountsList(BasePage): LINKID_REGEXP = re.compile(".*ch4=(\w+).*") def on_loaded(self): pass TYPES = {u'Compte Bancaire': Account.TYPE_CHECKING, u'Compte Epargne': Account.TYPE_SAVINGS, u'Compte Sur Livret': Account.TYPE_SAVINGS, u'Compte Titres': Account.TYPE_MARKET, u'Crédit': Account.TYPE_LOAN, u'Livret': Account.TYPE_SAVINGS, u'PEA': Account.TYPE_SAVINGS, u'Plan Epargne': Account.TYPE_SAVINGS, u'Prêt': Account.TYPE_LOAN, } def get_list(self): def check_valid_url(url): pattern = ['/restitution/cns_detailAVPAT.html', '/restitution/cns_detailPea.html', '/restitution/cns_detailAlterna.html', ] for p in pattern: if url.startswith(p): return False return True for tr in self.document.getiterator('tr'): if 'LGNTableRow' not in tr.attrib.get('class', '').split(): continue account = Account() for td in tr.getiterator('td'): if td.attrib.get('headers', '') == 'TypeCompte': a = td.find('a') if a is None: break account.label = self.parser.tocleanstring(a) account._link_id = a.get('href', '') for pattern, actype in self.TYPES.iteritems(): if account.label.startswith(pattern): account.type = actype break else: if account._link_id.startswith('/asv/asvcns10.html'): account.type = Account.TYPE_LIFE_INSURANCE # Website crashes when going on theses URLs if not check_valid_url(account._link_id): account._link_id = None elif td.attrib.get('headers', '') == 'NumeroCompte': account.id = self.parser.tocleanstring(td).replace(u'\xa0', '') elif td.attrib.get('headers', '') == 'Libelle': text = self.parser.tocleanstring(td) if text != '': account.label = text elif td.attrib.get('headers', '') == 'Solde': div = td.xpath('./div[@class="Solde"]') if len(div) > 0: balance = self.parser.tocleanstring(div[0]) if len(balance) > 0 and balance not in ('ANNULEE', 'OPPOSITION'): try: account.balance = Decimal(FrenchTransaction.clean_amount(balance)) except InvalidOperation: raise BrokenPageError('Unable to parse balance %r' % balance) account.currency = account.get_currency(balance) else: account.balance = NotAvailable if not account.label or empty(account.balance): continue if account._link_id and 'CARTE_' in account._link_id: account.type = account.TYPE_CARD if account.type == Account.TYPE_UNKNOWN: self.logger.debug('Unknown account type: %s', account.label) yield account class CardsList(BasePage): def iter_cards(self): for tr in self.document.getiterator('tr'): tds = tr.findall('td') if len(tds) < 4 or tds[0].attrib.get('class', '') != 'tableauIFrameEcriture1': continue yield tr.xpath('.//a')[0].attrib['href'] class Transaction(FrenchTransaction): PATTERNS = [(re.compile(r'^CARTE \w+ RETRAIT DAB.*? (?P<dd>\d{2})/(?P<mm>\d{2})( (?P<HH>\d+)H(?P<MM>\d+))? (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(r'^CARTE \w+ (?P<dd>\d{2})/(?P<mm>\d{2})( A (?P<HH>\d+)H(?P<MM>\d+))? RETRAIT DAB (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(r'^CARTE \w+ REMBT (?P<dd>\d{2})/(?P<mm>\d{2})( A (?P<HH>\d+)H(?P<MM>\d+))? (?P<text>.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile(r'^(?P<category>CARTE) \w+ (?P<dd>\d{2})/(?P<mm>\d{2}) (?P<text>.*)'), FrenchTransaction.TYPE_CARD), (re.compile(r'^(?P<dd>\d{2})(?P<mm>\d{2})/(?P<text>.*?)/?(-[\d,]+)?$'), FrenchTransaction.TYPE_CARD), (re.compile(r'^(?P<category>(COTISATION|PRELEVEMENT|TELEREGLEMENT|TIP)) (?P<text>.*)'), FrenchTransaction.TYPE_ORDER), (re.compile(r'^(\d+ )?VIR (PERM )?POUR: (.*?) (REF: \d+ )?MOTIF: (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(r'^(?P<category>VIR(EMEN)?T? \w+) (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(r'^(CHEQUE) (?P<text>.*)'), FrenchTransaction.TYPE_CHECK), (re.compile(r'^(FRAIS) (?P<text>.*)'), FrenchTransaction.TYPE_BANK), (re.compile(r'^(?P<category>ECHEANCEPRET)(?P<text>.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile(r'^(?P<category>REMISE CHEQUES)(?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile(r'^CARTE RETRAIT (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL), ] class AccountHistory(BasePage): debit_date = None def get_part_url(self): for script in self.document.getiterator('script'): if script.text is None: continue m = re.search('var listeEcrCavXmlUrl="(.*)";', script.text) if m: return m.group(1) return None def iter_transactions(self): url = self.get_part_url() if url is None: # There are no transactions in this kind of account return while True: d = XML(self.browser.readurl(url)) try: el = self.parser.select(d, '//dataBody', 1, 'xpath') except BrokenPageError: # No transactions. return s = StringIO(unicode(el.text).encode('iso-8859-1')) doc = self.browser.get_document(s) for tr in self._iter_transactions(doc): yield tr el = d.xpath('//dataHeader')[0] if int(el.find('suite').text) != 1: return url = urlparse(url) p = parse_qs(url.query) url = self.browser.buildurl(url.path, n10_nrowcolor=0, operationNumberPG=el.find('operationNumber').text, operationTypePG=el.find('operationType').text, pageNumberPG=el.find('pageNumber').text, idecrit=el.find('idecrit').text or '', sign=p['sign'][0], src=p['src'][0]) def _iter_transactions(self, doc): t = None for i, tr in enumerate(self.parser.select(doc.getroot(), 'tr')): try: raw = tr.attrib['title'].strip() except KeyError: raw = tr.xpath('./td[@headers="Libelle"]//text()')[0].strip() date = tr.xpath('./td[@headers="Date"]')[0].text.strip() if date == '': m = re.search(r'(\d+)/(\d+)', raw) if not m: continue self.debit_date = t.date if t else datetime.date.today() self.debit_date = self.debit_date.replace(day=int(m.group(1)), month=int(m.group(2))) if not t: continue t = Transaction() if 'EnTraitement' in tr.get('class', ''): t._coming = True else: t._coming = False t.set_amount(*reversed([el.text for el in tr.xpath('./td[@class="right"]')])) if date == '': # Credit from main account. t.amount = -t.amount date = self.debit_date t.rdate = t.parse_date(date) t.parse(raw=raw, date=(self.debit_date or date)) yield t def get_iban(self): return CleanText().filter(self.document.xpath("//font[contains(text(),'IBAN')]/b[1]")[0]).replace(' ', '') class Invest(object): def create_investement(self, cells): inv = Investment() inv.quantity = self.parse_decimal(cells[self.COL_QUANTITY]) inv.unitvalue = self.parse_decimal(cells[self.COL_UNITVALUE]) inv.unitprice = NotAvailable inv.valuation = self.parse_decimal(cells[self.COL_VALUATION]) inv.diff = NotAvailable link = cells[self.COL_LABEL].xpath('a[contains(@href, "CDCVAL=")]')[0] m = re.search('CDCVAL=([^&]+)', link.attrib['href']) if m: inv.code = m.group(1) else: inv.code = NotAvailable return inv class Market(BasePage, Invest): COL_LABEL = 0 COL_QUANTITY = 1 COL_UNITVALUE = 2 COL_VALUATION = 3 COL_DIFF = 4 def iter_investment(self): doc = self.browser.get_document(self.browser.openurl('/brs/fisc/fisca10a.html'), encoding='utf-8') num_page = None try: num_page = int(self.parser.tocleanstring(doc.xpath(u'.//tr[contains(td[1], "Relevé des plus ou moins values latentes")]/td[2]')[0]).split('/')[1]) except IndexError: pass docs = [doc] if num_page: for n in range(2, num_page + 1): docs.append(self.browser.get_document(self.browser.openurl('%s%s' % ('/brs/fisc/fisca10a.html?action=12&numPage=', str(n))), encoding='utf-8')) for doc in docs: for tr in doc.xpath('//tr[count(td)=6 and td[1]/strong]'): cells = tr.findall('td') inv = Investment() inv.label = unicode(cells[self.COL_LABEL].xpath('.//span')[0].attrib['title'].split(' - ')[0]) inv.code = unicode(cells[self.COL_LABEL].xpath('.//span')[0].attrib['title'].split(' - ')[1]) inv.quantity = self.parse_decimal(cells[self.COL_QUANTITY]) inv.unitprice = self.parse_decimal(tr.xpath('./following-sibling::tr/td[3]')[0]) inv.unitvalue = self.parse_decimal(cells[self.COL_UNITVALUE]) inv.valuation = self.parse_decimal(cells[self.COL_VALUATION]) inv.diff = self.parse_decimal(cells[self.COL_DIFF]) yield inv class LifeInsurance(BasePage): def get_error(self): try: return self.document.xpath("//div[@class='net2g_asv_error_full_page']")[0].text.strip() except IndexError: return super(LifeInsurance, self).get_error() class LifeInsuranceInvest(LifeInsurance, Invest): COL_LABEL = 0 COL_QUANTITY = 1 COL_UNITVALUE = 2 COL_VALUATION = 3 def iter_investment(self): for tr in self.document.xpath("//table/tbody/tr[starts-with(@class, 'net2g_asv_tableau_ligne_')]"): cells = tr.findall('td') inv = self.create_investement(cells) inv.label = cells[self.COL_LABEL].xpath('a/span')[0].text.strip() inv.description = cells[self.COL_LABEL].xpath('a//div/b[last()]')[0].tail yield inv class LifeInsuranceHistory(LifeInsurance): COL_DATE = 0 COL_LABEL = 1 COL_AMOUNT = 2 COL_STATUS = 3 def iter_transactions(self): for tr in self.document.xpath("//table/tbody/tr[starts-with(@class, 'net2g_asv_tableau_ligne_')]"): cells = tr.findall('td') link = cells[self.COL_LABEL].xpath('a')[0] # javascript:detailOperation('operationForm', '2'); m = re.search(", '([0-9]+)'", link.attrib['href']) if m: id_trans = m.group(1) else: id_trans = '' trans = Transaction() trans._temp_id = id_trans trans.parse(raw=link.attrib['title'], date=cells[self.COL_DATE].text) trans.set_amount(cells[self.COL_AMOUNT].text) # search for 'Réalisé' trans._coming = 'alis' not in cells[self.COL_STATUS].text.strip() self.set_date(trans) yield trans def set_date(self, trans): """fetch date and vdate from another page""" form = self.document.xpath('//form[@id="operationForm"]')[0] # go to the page containing the dates data = dict((item.name, item.value or '') for item in form.inputs) data['a100_asv_action'] = 'detail' data['a100_asv_indexOp'] = trans._temp_id doc = self.browser.get_document(self.browser.openurl('/asv/AVI/asvcns21c.html', urllib.urlencode(data)), encoding='utf-8') # process the data date_xpath = '//td[@class="net2g_asv_suiviOperation_element1"]/following-sibling::td' vdate_xpath = '//td[@class="net2g_asv_tableau_cell_date"]' trans.date = self.parse_date(doc, trans, date_xpath, 1) trans.vdate = self.parse_date(doc, trans, vdate_xpath, 0) @staticmethod def parse_date(doc, trans, xpath, index): elem = doc.xpath(xpath)[index] if elem.text: return trans.parse_date(elem.text.strip()) else: return NotAvailable class ListRibPage(BasePage): def get_rib_url(self, account): for div in self.document.xpath('//table//td[@class="fond_cellule"]//div[@class="tableauBodyEcriture1"]//table//tr'): if account.id == CleanText().filter(div.xpath('./td[2]//div/div')).replace(' ', ''): href = CleanText().filter(div.xpath('./td[4]//a/@href')) m = re.search("javascript:windowOpenerRib\('(.*?)'(.*)\)", href) if m: return m.group(1) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/pages/base.py����������������������������������������������������0000664�0000000�0000000�00000002520�12657170273�0022032�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from decimal import Decimal from weboob.capabilities.base import NotAvailable from weboob.deprecated.browser import Page as _BasePage from weboob.tools.capabilities.bank.transactions import FrenchTransaction class BasePage(_BasePage): def get_error(self): try: return self.document.xpath('//span[@class="error_msg"]')[0].text.strip() except IndexError: return None def parse_decimal(self, td): value = self.parser.tocleanstring(td) if value: return Decimal(FrenchTransaction.clean_amount(value)) else: return NotAvailable ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/pages/login.py���������������������������������������������������0000664�0000000�0000000�00000011361�12657170273�0022233�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from base64 import b64decode from logging import error import re from weboob.tools.json import json from weboob.deprecated.browser import BrowserUnavailable from weboob.deprecated.mech import ClientForm from weboob.exceptions import BrowserPasswordExpired from .base import BasePage from ..captcha import Captcha, TileError class LoginPage(BasePage): STRANGE_KEY = ["180","149","244","125","115","058","017","071","075","119","167","040","066","083","254","151","212","245","193","224","006","068","139","054","089","083","111","208","105","235","109","030","130","226","155","245","157","044","061","233","036","101","145","103","185","017","126","142","007","192","239","140","133","250","194","222","079","178","048","184","158","158","086","160","001","114","022","158","030","210","008","067","056","026","042","113","043","169","128","051","107","112","063","240","108","003","079","059","053","127","116","084","157","203","244","031","062","012","062","093"] strange_map = None def on_loaded(self): for td in self.document.getroot().cssselect('td.LibelleErreur'): if td.text is None: continue msg = td.text.strip() if 'indisponible' in msg: raise BrowserUnavailable(msg) def decode_grid(self, infos): grid = b64decode(infos['grid']) grid = map(int, re.findall('[0-9]{3}', grid)) n = int(infos['nbrows']) * int(infos['nbcols']) self.strange_map = list(grid[:n]) grid = list(grid[n:]) new_grid = list(grid) s = n u = list(infos['crypto']) for j in xrange(s): u[j] = '%02d' % ord(u[j]) for i in xrange(5, 0, -1): for j in xrange(s): new_grid[i*s+j] = '%03d' % (new_grid[i*s+j]^new_grid[(i-1)*s+j]) for j in xrange(s): new_grid[j] = '%03d' % (new_grid[j]^int(self.STRANGE_KEY[j])^self.strange_map[j]) for j in xrange(s): self.strange_map[j] = int(u[j])^self.strange_map[j] return new_grid def login(self, login, password): DOMAIN_LOGIN = self.browser.DOMAIN_LOGIN DOMAIN = self.browser.DOMAIN url_login = 'https://' + DOMAIN_LOGIN + '/index.html' base_url = 'https://' + DOMAIN url = base_url + '//sec/vkm/gen_crypto?estSession=0' headers = { 'Referer': url_login } request = self.browser.request_class(url, None, headers) infos_data = self.browser.readurl(request) infos_data = re.match('^_vkCallback\((.*)\);$', infos_data).group(1) infos = json.loads(infos_data.replace("'", '"')) infos['grid'] = self.decode_grid(infos) url = base_url + '//sec/vkm/gen_ui?modeClavier=0&cryptogramme=' + infos["crypto"] img = Captcha(self.browser.openurl(url), infos) try: img.build_tiles() except TileError as err: error("Error: %s" % err) if err.tile: err.tile.display() self.browser.select_form('n2g_authentification') self.browser.controls.append(ClientForm.TextControl('text', 'codsec', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', 'cryptocvcs', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', 'vkm_op', {'value': 'auth'})) self.browser.set_all_readonly(False) pwd = img.get_codes(password[:6]) t = pwd.split(',') newpwd = ','.join([t[self.strange_map[j]] for j in xrange(6)]) self.browser['codcli'] = login.encode('iso-8859-1') self.browser['user_id'] = login.encode('iso-8859-1') self.browser['codsec'] = newpwd self.browser['cryptocvcs'] = infos["crypto"].encode('iso-8859-1') self.browser.form.action = 'https://particuliers.secure.societegenerale.fr//acces/authlgn.html' self.browser.submit(nologin=True) class BadLoginPage(BasePage): pass class ReinitPasswordPage(BasePage): def on_loaded(self): raise BrowserPasswordExpired() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/sgpe/������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020406�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/sgpe/__init__.py�������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0022505�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/sgpe/browser.py��������������������������������������������������0000664�0000000�0000000�00000014021�12657170273�0022441�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserIncorrectPassword from weboob.deprecated.browser.parsers.jsonparser import JsonParser from weboob.tools.ordereddict import OrderedDict from .pages import LoginPage, ErrorPage, AccountsPage, CardsPage, HistoryPage, CardHistoryPage, OrderPage __all__ = ['SGProfessionalBrowser', 'SGEnterpriseBrowser'] class SGPEBrowser(Browser): PROTOCOL = 'https' ENCODING = 'ISO-8859-1' def __init__(self, *args, **kwargs): self.PAGES = OrderedDict(( ('%s://%s/Pgn/.+PageID=SoldeV3&.+' % (self.PROTOCOL, self.DOMAIN), AccountsPage), ('%s://%s/Pgn/.+PageID=Cartes&.+' % (self.PROTOCOL, self.DOMAIN), CardsPage), ('%s://%s/Pgn/.+PageID=ReleveCompteV3&.+' % (self.PROTOCOL, self.DOMAIN), HistoryPage), ('%s://%s/Pgn/.+PageID=ReleveCarte&.+' % (self.PROTOCOL, self.DOMAIN), CardHistoryPage), ('%s://%s/ord-web/ord//ord-liste-compte-emetteur.json' % (self.PROTOCOL, self.DOMAIN), (OrderPage, JsonParser())), ('%s://%s/authent\.html' % (self.PROTOCOL, self.DOMAIN), ErrorPage), ('%s://%s/' % (self.PROTOCOL, self.DOMAIN), LoginPage), )) Browser.__init__(self, *args, **kwargs) def is_logged(self): if not self.page or self.is_on_page(LoginPage): return False error = self.page.get_error() if error is None: return True return False def login(self): assert isinstance(self.username, basestring) assert isinstance(self.password, basestring) assert self.password.isdigit() if not self.is_on_page(LoginPage): self.location('https://' + self.DOMAIN + '/', no_login=True) self.page.login(self.username, self.password) # force page change if not self.is_on_page(AccountsPage): self.accounts(no_login=True) if not self.is_logged(): raise BrowserIncorrectPassword() def accounts(self, no_login=False): self.location('/Pgn/NavigationServlet?PageID=SoldeV3&MenuID=%sCPT&Classeur=1&NumeroPage=1' % self.MENUID, no_login=no_login) def cards(self): doc = self.get_document(self.openurl('/Pgn/NavigationServlet?PageID=CartesFutures&MenuID=%sOPF&Classeur=1&NumeroPage=1&PageDetail=1' % self.MENUID)) try: url = doc.xpath('//iframe[@name="cartes"]')[0].attrib['src'] except IndexError: return False else: self.location(url) return True def history(self, _id, page=1): if page > 1: pgadd = '&page_numero_page_courante=%s' % page else: pgadd = '' self.location('/Pgn/NavigationServlet?PageID=ReleveCompteV3&MenuID=%sCPT&Classeur=1&Rib=%s&NumeroPage=1%s' % (self.MENUID, _id, pgadd)) def card_history(self, rib, _id, date, currency, page=1): self.location('/Pgn/NavigationServlet?PageID=ReleveCarte&MenuID=%sOPF&Classeur=1&Rib=%s&Carte=%s&Date=%s&PageDetail=%s&Devise=%s' % (self.MENUID, rib, _id, date, page, currency)) def get_accounts_list(self): if not self.is_on_page(AccountsPage): self.accounts() assert self.is_on_page(AccountsPage) accounts = [] for acc in self.page.get_list(): accounts.append(acc) if self.cards(): assert self.is_on_page(CardsPage) for acc in self.page.get_list(): accounts.append(acc) self.location('/ord-web/ord//ord-liste-compte-emetteur.json') for acc in accounts: acc.iban = self.page.get_iban(acc.id) yield acc def get_account(self, _id): for a in self.get_accounts_list(): if a.id == _id: yield a def iter_history(self, account): if account._is_card: for history_link in [account.id, account._link]: page = 1 while page: self.card_history(account._link_rib, history_link, account._link_date, account._link_currency, page) assert self.is_on_page(CardHistoryPage) for tr in self.page.iter_transactions(): yield tr if self.page.has_next(): page += 1 else: page = False else: page = 1 basecount = 0 while page: self.history(account.id, page) assert self.is_on_page(HistoryPage) for transaction in self.page.iter_transactions(account, basecount): basecount = int(transaction._index) + 1 yield transaction if self.page.has_next(): page += 1 else: page = False def iter_investment(self, account): raise NotImplementedError() class SGProfessionalBrowser(SGPEBrowser): DOMAIN = 'professionnels.secure.societegenerale.fr' LOGIN_FORM = 'auth_reco' MENUID = 'SBOREL' CERTHASH = '9f5232c9b2283814976608bfd5bba9d8030247f44c8493d8d205e574ea75148e' class SGEnterpriseBrowser(SGPEBrowser): DOMAIN = 'entreprises.secure.societegenerale.fr' LOGIN_FORM = 'auth' MENUID = 'BANREL' CERTHASH = '2231d5ddb97d2950d5e6fc4d986c23be4cd231c31ad530942343a8fdcc44bb99' ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/sgpe/pages.py����������������������������������������������������0000664�0000000�0000000�00000027131�12657170273�0022063�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from logging import error import re from decimal import Decimal from datetime import datetime from weboob.deprecated.browser import Page from weboob.tools.json import json from weboob.deprecated.mech import ClientForm from weboob.tools.misc import to_unicode from weboob.capabilities.bank import Account from weboob.capabilities.base import NotAvailable from weboob.tools.capabilities.bank.transactions import FrenchTransaction from ..captcha import Captcha, TileError class Transaction(FrenchTransaction): PATTERNS = [(re.compile(r'^CARTE \w+ RETRAIT DAB.* (?P<dd>\d{2})/(?P<mm>\d{2})( (?P<HH>\d+)H(?P<MM>\d+))? (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(r'^CARTE \w+ (?P<dd>\d{2})/(?P<mm>\d{2})( A (?P<HH>\d+)H(?P<MM>\d+))? RETRAIT DAB (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL), (re.compile(r'^CARTE \w+ REMBT (?P<dd>\d{2})/(?P<mm>\d{2})( A (?P<HH>\d+)H(?P<MM>\d+))? (?P<text>.*)'), FrenchTransaction.TYPE_PAYBACK), (re.compile(r'^(?P<category>CARTE) \w+ (?P<dd>\d{2})/(?P<mm>\d{2}) (?P<text>.*)'), FrenchTransaction.TYPE_CARD), (re.compile(r'^(?P<dd>\d{2})(?P<mm>\d{2})/(?P<text>.*?)/?(-[\d,]+)?$'), FrenchTransaction.TYPE_CARD), (re.compile(r'^(?P<category>(COTISATION|PRELEVEMENT|TELEREGLEMENT|TIP)) (?P<text>.*)'), FrenchTransaction.TYPE_ORDER), (re.compile(r'^(\d+ )?VIR (PERM )?POUR: (.*?) (REF: \d+ )?MOTIF: (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(r'^(?P<category>VIR(EMEN)?T? \w+) (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(r'^(CHEQUE) (?P<text>.*)'), FrenchTransaction.TYPE_CHECK), (re.compile(r'^(FRAIS) (?P<text>.*)'), FrenchTransaction.TYPE_BANK), (re.compile(r'^(?P<category>ECHEANCEPRET)(?P<text>.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), (re.compile(r'^(?P<category>REMISE CHEQUES)(?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile(r'^CARTE RETRAIT (?P<text>.*)'), FrenchTransaction.TYPE_WITHDRAWAL), ] _coming = False class SGPEPage(Page): def get_error(self): err = self.document.getroot().cssselect('div.ngo_mire_reco_message') \ or self.document.getroot().cssselect('#nge_zone_centre .nge_cadre_message_utilisateur') if err: return err[0].text.strip() class ErrorPage(SGPEPage): def get_error(self): return SGPEPage.get_error(self) or 'Unknown error' class LoginPage(SGPEPage): def login(self, login, password): DOMAIN = self.browser.DOMAIN url_login = 'https://' + DOMAIN + '/' base_url = 'https://' + DOMAIN url = base_url + '//sec/vk/gen_crypto?estSession=0' headers = {'Referer': url_login} request = self.browser.request_class(url, None, headers) infos_data = self.browser.readurl(request) infos_data = re.match('^_vkCallback\((.*)\);$', infos_data).group(1) infos = json.loads(infos_data.replace("'", '"')) url = base_url + '//sec/vk/gen_ui?modeClavier=0&cryptogramme=' + infos["crypto"] self.browser.readurl(url) img = Captcha(self.browser.openurl(url), infos) try: img.build_tiles() except TileError as err: error("Error: %s" % err) if err.tile: err.tile.display() self.browser.select_form(self.browser.LOGIN_FORM) self.browser.controls.append(ClientForm.TextControl('text', 'codsec', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', 'cryptocvcs', {'value': ''})) self.browser.controls.append(ClientForm.TextControl('text', 'vk_op', {'value': 'auth'})) self.browser.set_all_readonly(False) self.browser['user_id'] = login.encode(self.browser.ENCODING) self.browser['codsec'] = img.get_codes(password[:6]) self.browser['cryptocvcs'] = infos["crypto"] self.browser.form.action = base_url + '/authent.html' self.browser.submit(nologin=True) class AccountsPage(SGPEPage): TYPES = {u'COMPTE COURANT': Account.TYPE_CHECKING, u'COMPTE PERSONNEL': Account.TYPE_CHECKING, } def get_list(self): table = self.parser.select(self.document.getroot(), '#tab-corps', 1) for tr in self.parser.select(table, 'tr', 'many'): tdname, tdid, tdagency, tdbalance = [td.text_content().strip() for td in self.parser.select(tr, 'td', 4)] # it has empty rows - ignore those without the necessary info if all((tdname, tdid, tdbalance)): account = Account() account.label = to_unicode(tdname) account.type = self.TYPES.get(account.label, Account.TYPE_UNKNOWN) account.id = to_unicode(tdid.replace(u'\xa0', '').replace(' ', '')) account._agency = to_unicode(tdagency) account._is_card = False account.balance = Decimal(Transaction.clean_amount(tdbalance)) account.currency = account.get_currency(tdbalance) yield account class CardsPage(SGPEPage): COL_ID = 0 COL_LABEL = 1 COL_BALANCE = 2 def get_list(self): rib = None currency = None for script in self.document.xpath('//script'): if script.text is None: continue m = re.search('var rib = "(\d+)"', script.text) if m: rib = m.group(1) m = re.search("var devise='(\w+)'", script.text) if m: currency = m.group(1) if all((rib, currency)): break if not all((rib, currency)): self.logger.error('Unable to find rib or currency') for tr in self.document.xpath('//table[@id="tab-corps"]//tr'): tds = tr.findall('td') if len(tds) != 3: continue account = Account() account.type = Account.TYPE_CARD account.label = self.parser.tocleanstring(tds[self.COL_LABEL]) if len(account.label) == 0: continue link = tds[self.COL_ID].xpath('.//a')[0] m = re.match(r"changeCarte\('(\d+)','(\d+)','([^']+)'\);.*", link.attrib['onclick']) if not m: self.logger.error('Unable to parse link %r' % link.attrib['onclick']) continue account._link_num = m.group(1) #useless account._link = m.group(2) account.id = m.group(2) + account._link_num account._link_date = urllib.quote(m.group(3)) account._link_rib = rib account._link_currency = currency account._is_card = True tdbalance = self.parser.tocleanstring(tds[self.COL_BALANCE]) account.balance = - Decimal(Transaction.clean_amount(tdbalance)) account.currency = account.get_currency(tdbalance) yield account class HistoryPage(SGPEPage): def iter_transactions(self, account, basecount): table = self.parser.select(self.document.getroot(), '#tab-corps', 1) for i, tr in enumerate(self.parser.select(table, 'tr', 'many'), basecount): # td colspan=5 if len(self.parser.select(tr, 'td')) == 1: continue tddate, tdlabel, tddebit, tdcredit, tdval, tdbal = [td.text_content().strip() for td in self.parser.select(tr, 'td', 6)] tdamount = tddebit or tdcredit # not sure it has empty rows like AccountsPage, but check anyway if all((tddate, tdlabel, tdamount)): t = Transaction() t._index = i t.set_amount(tdamount) date = datetime.strptime(tddate, '%d/%m/%Y') val = datetime.strptime(tdval, '%d/%m/%Y') # so that first line is separated by parse() # also clean up tabs, spaces, etc. l1, _, l2 = tdlabel.partition('\n') l1 = ' '.join(l1.split()) l2 = ' '.join(l2.split()) t.parse(date, l1 + ' ' + l2) t.vdate = val yield t def has_next(self): for n in self.parser.select(self.document.getroot(), '#numPageBloc'): cur = int(self.parser.select(n, '#numPage', 1).value) for end in self.parser.select(n, '.contenu3-lien'): return end.text != '/' and int(end.text.replace('/', '')) > cur return False class CardHistoryPage(SGPEPage): COL_DATE = 0 COL_LABEL = 1 COL_AMOUNT = -1 def iter_transactions(self): table = self.parser.select(self.document.getroot(), '#tab-corps', 1) for i, tr in enumerate(self.parser.select(table, 'tr', 'many')): tds = tr.findall('td') date = self.parser.tocleanstring(tds[self.COL_DATE]) raw = self.parser.tocleanstring(tds[self.COL_LABEL]) amount = self.parser.tocleanstring(tds[self.COL_AMOUNT]) if len(date) == 0: continue t = Transaction() t._index = i t.parse(date, raw) t.set_amount(amount) yield t def has_next(self): current = None total = None for script in self.document.xpath('//script'): if script.text is None: continue m = re.search('var pageActive\s+= (\d+)', script.text) if m: current = int(m.group(1)) m = re.search("var nombrePage\s+= (\d+)", script.text) if m: total = int(m.group(1)) if all((current, total)) and current < total: return True return False class OrderPage(Page): def get_iban(self, acc_id): for acc in self.document['donnees']: if acc_id in acc['ibanCompte']: return unicode(acc['ibanCompte']) return NotAvailable def get_error(self): # Maybe later we need to implement this return None ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/societegenerale/test.py����������������������������������������������������������0000664�0000000�0000000�00000002063�12657170273�0021002�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jocelyn Jaubert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class SocieteGeneraleTest(BackendTest): MODULE = 'societegenerale' def test_societegenerale(self): l = list(self.backend.iter_accounts()) self.assertTrue(len(l) > 0) a = l[0] list(self.backend.iter_coming(a)) list(self.backend.iter_history(a)) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/somafm/��������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015574�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/somafm/__init__.py���������������������������������������������������������������0000664�0000000�0000000�00000001433�12657170273�0017706�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import SomaFMModule __all__ = ['SomaFMModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/somafm/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000007170�12657170273�0017734�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME3 A����tEXtComment�Created with GIMPW�� IDATx{\u?Νξ۳f񲀱Ā5DQDIFBE"Ap%R(R(Qj+uUE4$ۀ^ޗw;?ιeX$f>~wXcy,<l�9{ԆUi48?{y5h<Ϋ5ߗw4/&|� `pGIo >8NS+OYQhik}s8:; yWG` L0BɇjBڄ 5Ț<gF�$wn 9{v[@vVos%l>^'6LQ%[qпyKkq}U@Ԩ,8é*);z`2K-qȤ9_M"!C;Er8 3jB!'0=vCCxi�@D[$g]]ew n. 0<#2<_U$F1[[\?&�V(w_|ܴ-NOx(xR=ӂe;ugJ{aZS="_eY^tG#')ؙ֐l_�0 jXW}(Pt lO@[.I.x�||XgOáb<@47}ɦASFN/#o]L<W 㐝?{ TAX}8b /7�豠߀Q Q' h2cDT|<Go}I�M`~uF-g}_sA2)N=0p�nkiF`,N$slǧ9ͬ3ʫF]l=`M0ׇEa#0IGٓ[a�x ƶNز Kλ  n_ /ēf=ܶ( � dظQf= X !-`ƅ_;.ke(z%qH:}xEmalp0y yxm<k{zJ1{uleJC11^P6% M8ps N8pԮDgf< WKܻ's1�%9O"* }7Z >!#oH+9Z-XմIÚkaC(`K|Q VCl-YE[R#`8"}cΥ*kj8Aޓ�Ͽ+X2AK`8USi,I.ׅRA V`I2%u<[)]a._< @WMq$KCɇ| /m@+~Dcnw.+^gp lBqკ)|% \VjܡwxTDIW�q޳9.cՀT.+|z8M?tusPiXՆdHS�|H$b,`:3$\D.#[ syR!*2BHČk I .<QG|ʕVDي$a�v?'ᅉ|mS,ɣp-qו*C 7AnV Tbx1/;U9n~H4SJV%V[pJýEkz_k|XkXzL R+^`xe/v%zni:,n s+*,l9)05&jq7a \V*,]yZLX[RoBj~T H@Ҁ[** OHK3 rt`mbrB.+ NQ2&HkdTlnNKoMn`<DԐdƒk&B-{%MM1)R?{~& ܫx;ߟx;9wA`✤S"w-ml:{> -)"F7{8~[Z{|@pXQw`g"#LwtEF%n0BLtfxןVE`x 3?yjކ|Kly%w42Goxg~0!kh\+ O�VH0F^�0!|Qoix@^զ㱾a*f�E|vP>߁\v^CN }X0qOFA>gERKkܤFzCC~z7ڤQӼH?)Q/07B}_H+ �8Qs@KR^/Z2p8 u?X^6MՊ60�[:wRu7WR\)XX�k5]J0;i` �>}U!`?p۠h,�z }W�K=_S{Y5 f5 .z$pS,�dt5:.*�D(0^^pox[ c)58!<Ʒ@躚4luBzWjd4C SZ�m#^b:N�<9iiܥym0D_j!)7TYj@ߢ 484a)Z6X#+X:%橫%)Wg.]YLI�^)d|*zjP_P$ 9b\@<@^2&^"*E[݆zo9T('T247(Q Uy%yֺWN* 4_VڂcPN-~A JTxgÚj eZDt|1Y:�r 7`MEn�C@7#Xk,':�PnW ZU"urj�`ͳ2p x8ﳉ CnܕPn "JK=AZ~tOѾaF؁jT8jt$`m4lM@}{up*7@�Jnz7aN nuO)Rh�Աr�Ly ]`i)N'}Ṗ0W%U)<vxbfP]C`�Q]*9cP)(u|*tE�*POw鹣b0Ϧ^ROy5n{!ꔊV/3kNh-qn16/t1tkUnP۵ZidL g5F=\vAhI̅52~`�Bñ +iEiG(ֹ.ʀ~_$Kr/<(7Dt7����IENDB`��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/somafm/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000010113�12657170273�0017427�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import lxml.etree from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.audiostream import BaseAudioStream from weboob.tools.capabilities.streaminfo import StreamInfo from weboob.capabilities.collection import CapCollection from weboob.tools.backend import Module from weboob.deprecated.browser import StandardBrowser from weboob.deprecated.browser.parsers.iparser import IParser __all__ = ['SomaFMModule'] class LxmlParser(IParser): def parse(self, data, encoding=None): return lxml.etree.fromstring(data.read()) class SomaFMModule(Module, CapRadio, CapCollection): NAME = 'somafm' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' VERSION = '1.1' DESCRIPTION = u'SomaFM web radio' LICENSE = 'AGPLv3+' BROWSER = StandardBrowser QUALITIES = ['fast', 'slow', 'highest'] ALLINFO = 'http://api.somafm.com/channels.xml' def create_default_browser(self): return self.create_browser(parser=LxmlParser()) def _parse_current(self, data): current = data.split(' - ') if len(current) == 2: return current else: return ('Unknown', 'Unknown') def _fetch_radio_list(self): radios = [] document = self.browser.location(self.ALLINFO) for channel in document.iter('channel'): id=channel.get('id') radio = Radio(id) radio.title = channel.findtext('title') radio.description = channel.findtext('description') current_data = channel.findtext('lastPlaying') current = StreamInfo(0) current.what, current.who = self._parse_current(current_data) radio.current = current radio.streams = [] stream_id = 0 for subtag in channel: if subtag.tag.endswith('pls'): stream = BaseAudioStream(stream_id) bitrate=subtag.text.replace('http://somafm.com/'+id,'').replace('.pls','') if(bitrate != ''): stream.bitrate=int(bitrate) bitrate+='Kbps' else: stream.bitrate=0 bitrate=subtag.tag.replace('pls','') stream.format=subtag.get('format') stream.title = '%s/%s' % (bitrate, stream.format) stream.url = subtag.text radio.streams.append(stream) stream_id += 1 radios.append(radio) return radios def iter_radios_search(self, pattern): radios = self._fetch_radio_list() pattern = pattern.lower() for radio in radios: if pattern in radio.title.lower() or pattern in radio.description.lower(): yield radio def iter_resources(self, objs, split_path): radios = self._fetch_radio_list() if Radio in objs: self._restrict_level(split_path) for radio in radios: yield radio def get_radio(self, radio_id): radios = self._fetch_radio_list() for radio in radios: if radio_id == radio.id: return radio def fill_radio(self, radio, fields): if 'current' in fields: return self.get_radio(radio.id) return radio OBJECTS = {Radio: fill_radio} �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/somafm/test.py�������������������������������������������������������������������0000664�0000000�0000000�00000002666�12657170273�0017137�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.radio import Radio class SomaFMTest(BackendTest): MODULE = 'somafm' def test_difm(self): ls = list(self.backend.iter_resources((Radio, ), [])) self.assertTrue(len(ls) > 0) search = list(self.backend.iter_radios_search('doom')) self.assertTrue(len(search) > 0) self.assertTrue(len(search) < len(ls)) radio = self.backend.get_radio('doomed') self.assertTrue(radio.title) self.assertTrue(radio.description) self.assertTrue(radio.current.who) self.assertTrue(radio.current.what) self.assertTrue(radio.streams[0].url) self.assertTrue(radio.streams[0].title) ��������������������������������������������������������������������������weboob-1.1/modules/sueurdemetal/��������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017011�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sueurdemetal/__init__.py���������������������������������������������������������0000664�0000000�0000000�00000001446�12657170273�0021127�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import SueurDeMetalModule __all__ = ['SueurDeMetalModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sueurdemetal/browser.py����������������������������������������������������������0000664�0000000�0000000�00000004620�12657170273�0021050�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser from .pages import PageCity, PageConcert, PageCityList, PageDate, PageDates __all__ = ['SueurDeMetalBrowser'] class SueurDeMetalBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'www.sueurdemetal.com' ENCODING = 'iso-8859-15' PAGES = { '%s://%s/ville-metal-.+.htm' % (PROTOCOL, DOMAIN): PageCity, r'%s://%s/detail-concert-metal.php\?c=.+' % (PROTOCOL, DOMAIN): PageConcert, '%s://%s/recherchemulti.php' % (PROTOCOL, DOMAIN): PageCityList, '%s://%s/liste-dates-concerts.php' % (PROTOCOL, DOMAIN): PageDates, r'%s://%s/date-metal-.+.htm' % (PROTOCOL, DOMAIN): PageDate, } def get_concerts_city(self, city): self.location('%s://%s/ville-metal-%s.htm' % (self.PROTOCOL, self.DOMAIN, city)) assert self.is_on_page(PageCity) return self.page.get_concerts() def get_concerts_date(self, date_from, date_end=None): self.location('%s://%s/liste-dates-concerts.php' % (self.PROTOCOL, self.DOMAIN)) assert self.is_on_page(PageDates) for day in self.page.get_dates_filtered(date_from, date_end): self.location(day['url']) assert self.is_on_page(PageDate) for data in self.page.get_concerts(): yield data def get_concert(self, _id): self.location('%s://%s/detail-concert-metal.php?c=%s' % (self.PROTOCOL, self.DOMAIN, _id)) assert self.is_on_page(PageConcert) return self.page.get_concert() def get_cities(self): self.location('%s://%s/recherchemulti.php' % (self.PROTOCOL, self.DOMAIN)) assert self.is_on_page(PageCityList) return self.page.get_cities() ����������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sueurdemetal/favicon.png���������������������������������������������������������0000664�0000000�0000000�00000001575�12657170273�0021154�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME ,y"���tEXtComment�Created with GIMPW��IDATxZAr0 )>g){rS<<dˀbnu%3LX1΃�7@�<uݝ&bhrOPgXO<@To.99�E%%TDude0TH}+w �סp-n[>ߧwK+[܇<wc?e;4R�*-_]EkxP0kM/ݖ7LG~竁߲go+o@F7OۥY@c>>�Z~HM.�%?#Zݞe@Py\1�9\=u:R�ݍa@v Zm ꠒ^/XBL�Y1gs4acr=]aF=fHC"==&hS9Ӯ'yh;[8JoA04{@1\U쟾9; _ae6 -)ÇǶSӪ"ǥABUʲװi_{ P͑dAP@ܮ5a_ٕF[e&ʠ<Q_: >01o9j+ }M*̽Cϓ/nPa}u- BDLO40d#<�O-]`=mqJE  S ;ү auǦ']/+cX[6����IENDB`�����������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sueurdemetal/module.py�����������������������������������������������������������0000664�0000000�0000000�00000007762�12657170273�0020664�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.calendar import CapCalendarEvent, BaseCalendarEvent, CATEGORIES, TRANSP, STATUS import datetime from .browser import SueurDeMetalBrowser __all__ = ['SueurDeMetalModule'] class Concert(BaseCalendarEvent): @classmethod def id2url(cls, _id): return 'http://www.sueurdemetal.com/detail-concert-metal.php?c=%s' % _id class SueurDeMetalModule(Module, CapCalendarEvent): NAME = 'sueurdemetal' DESCRIPTION = u'SueurDeMetal French concerts list website' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = SueurDeMetalBrowser ASSOCIATED_CATEGORIES = [CATEGORIES.CONCERT] def __init__(self, *a, **kw): super(SueurDeMetalModule, self).__init__(*a, **kw) self.cities = {} def list_events(self, from_date, to_date=None): for d in self.browser.get_concerts_date(from_date, date_end=to_date): yield self._make_event(d) def search_events(self, query): if not self.has_matching_categories(query): return if query.city: city_id = self.find_city_id(query.city) for d in self.browser.get_concerts_city(city_id): if self._date_matches(d['date'], query): yield self._make_event(d) else: for e in self.list_events(query.start_date, query.end_date): yield e def get_event(self, _id): d = self.browser.get_concert(_id) return self._make_event(d) def _make_event(self, d): event = Concert(d['id']) event.category = CATEGORIES.CONCERT event.start_date = d['date'] event.end_date = datetime.datetime.combine(event.start_date.date(), datetime.time.max) event.summary = d['summary'] event.url = d['url'] if 'price' in d: event.price = d['price'] if d['active']: event.status = STATUS.CONFIRMED else: event.status = STATUS.CANCELLED if 'city' in d: event.city = d['city'] else: event.city = self.find_city_name(d['city_id']) event.transp = TRANSP.OPAQUE # "room, address" or "room" or "address" or "" location = ', '.join(filter(None, (d.get('room', ''), d.get('address', '')))) if location: event.location = location return event def _fetch_cities(self): if self.cities: return self.cities = self.browser.get_cities() def find_city_id(self, name): self._fetch_cities() name = name.lower() for c in self.cities: if c.lower() == name: return self.cities[c]['id'] def find_city_name(self, _id): self._fetch_cities() for c in self.cities.values(): if c['id'] == _id: return c['name'] def _date_matches(self, date, query): return ((not query.start_date or query.start_date <= date) and (not query.end_date or date <= query.end_date)) def fill_concert(self, obj, fields): if set(fields) & set(('price', 'location', 'description')): return self.get_event(obj.id) return obj OBJECTS = {Concert: fill_concert} ��������������weboob-1.1/modules/sueurdemetal/pages.py������������������������������������������������������������0000664�0000000�0000000�00000013221�12657170273�0020461�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page from weboob.tools.date import parse_french_date import re from urlparse import urljoin class PageWithConcerts(Page): def extract_concert(self, concert_table): d = {} date_h3 = concert_table.iter('h3').next() d['date'] = parse_french_date(date_h3.text) cancel_h2 = next(date_h3.itersiblings('h2'), None) if cancel_h2 is not None and cancel_h2.text.startswith('ANNUL'): d['active'] = False else: d['active'] = True performers_table = concert_table.iterdescendants('table').next() d['performers'] = list(self.extract_performers(performers_table)) d['summary'] = ' + '.join(p['name'] for p in d['performers']) d['description'] = d['summary'] return d def extract_performers(self, performers_table): for performer_tr in performers_table.findall('tr'): performer_td = performer_tr.find('td') d = {'name': performer_td.find('strong').text.strip(' \t\r\n+')} # handle '+ GUESTS' rest = performer_td.tail if rest: d['genre'] = rest yield d def extract_id_from_url(self, url): return re.search(r'c=(\d+)', url).group(1) def extract_city_from_url(self, url): return re.search('metal-(.+).htm$', url).group(1) def extract_concert_link(self, concert_table, d): infos_a = concert_table.xpath('.//a[starts-with(@href, "detail-concert-metal.php")]')[0] infos_a = concert_table.xpath('.//a[starts-with(@href, "detail-concert-metal.php")]')[0] d['id'] = self.extract_id_from_url(infos_a.get('href')) d['url'] = 'http://www.sueurdemetal.com/detail-concert-metal.php?c=%s' % d['id'] class PageCity(PageWithConcerts): def get_concerts(self): for concert_table in self.document.xpath('//div[@id="centre-page"]//div/table'): yield self.extract_concert(concert_table) def extract_concert(self, concert_table): d = PageWithConcerts.extract_concert(self, concert_table) self.extract_concert_link(concert_table, d) d['city_id'] = self.extract_city_from_url(self.url) return d class PageDate(PageWithConcerts): def get_concerts(self): for concert_table in self.document.xpath('//div[@id="centre-page"]//div/table'): yield self.extract_concert(concert_table) def extract_concert(self, concert_table): d = PageWithConcerts.extract_concert(self, concert_table) self.extract_concert_link(concert_table, d) city_a = concert_table.xpath('.//a[starts-with(@href, "ville-metal-")]')[0] d['city_id'] = self.extract_city_from_url(city_a.get('href')) return d class PageConcert(PageWithConcerts): def get_concert(self): concert_table = self.document.xpath('//div[@id="centre-page"]//div/table')[0] d = self.extract_concert(concert_table) d['id'] = self.extract_id_from_url(self.url) d['url'] = self.url it = concert_table.iterdescendants('table') it.next() # ignore performers table infos_table = it.next() self.infos_table = infos_table info_trs = infos_table.findall('tr') d['room'] = (info_trs[3].findall('td')[1].text or '').strip() d['address'] = (info_trs[4].findall('td')[1].text or '').strip() price = self.parse_price(info_trs[5].findall('td')[1].text) if price is not None: # "None" is different from "0€" d['price'] = price city_a = self.document.xpath('//a[starts-with(@href, "ville-metal-")]')[0] d['city_id'] = self.extract_city_from_url(city_a.get('href')) d['city'] = city_a.text return d def parse_price(self, s): if not s: return parts = filter(None, re.split(r'[^\d.]+', s.strip())) if not parts: return return float(parts[-1]) class PageCityList(Page): def get_cities(self): cities = {} for option in self.document.xpath('//select[@name="ville"]/option'): v = option.get('value') if not v: continue d = {} d['code'], d['dept'] = re.search(r'ville-metal-(.*)-([0-9AB]+).htm$', v).groups() # french dept d['id'] = '%s-%s' % (d['code'], d['dept']) d['name'] = option.text.split('(')[0].strip() cities[d['name']] = d return cities class PageDates(Page): def get_dates(self): for a in self.document.xpath('//div[@id="dateconcerts"]//a'): d = {} d['date'] = parse_french_date(a.text.strip()) d['url'] = urljoin(self.url, a.get('href')) yield d def get_dates_filtered(self, date_from=None, date_end=None): for d in self.get_dates(): date = d['date'] if (not date_from or date_from <= date) and \ (not date_end or date <= date_end): yield d �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/sueurdemetal/test.py�������������������������������������������������������������0000664�0000000�0000000�00000003154�12657170273�0020345�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.calendar import Query, CATEGORIES from datetime import datetime, timedelta class SueurDeMetalTest(BackendTest): MODULE = 'sueurdemetal' def test_sueurdemetal_searchcity(self): q = Query() q.city = u'paris' self.assertTrue(len(list(self.backend.search_events(q))) > 0) ev = self.backend.search_events(q).next() self.assertTrue(self.backend.get_event(ev.id)) def test_sueurdemetal_datefrom(self): q = Query() later = (datetime.now() + timedelta(days=31)) q.start_date = later ev = self.backend.search_events(q).next() self.assertTrue(later.date() <= ev.start_date.date()) def test_sueurdemetal_nocategory(self): q = Query() q.categories = [CATEGORIES.CINE] self.assertTrue(len(list(self.backend.search_events(q))) == 0) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/supertoinette/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017224�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/supertoinette/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000001447�12657170273�0021343�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import SupertoinetteModule __all__ = ['SupertoinetteModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/supertoinette/browser.py���������������������������������������������������������0000664�0000000�0000000�00000003223�12657170273�0021261�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import RecipePage, ResultsPage __all__ = ['SupertoinetteBrowser'] class SupertoinetteBrowser(Browser): DOMAIN = 'www.supertoinette.com' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['desktop_firefox'] PAGES = { 'http://www.supertoinette.com/liste-recettes/.*': ResultsPage, 'http://www.supertoinette.com/recette/[0-9]*.*': RecipePage, } def iter_recipes(self, pattern): self.location('http://www.supertoinette.com/liste-recettes/%s/' % (pattern)) assert self.is_on_page(ResultsPage) return self.page.iter_recipes() def get_recipe(self, id): try: self.location('http://www.supertoinette.com/recette/%s/' % id) except BrowserHTTPNotFound: return if self.is_on_page(RecipePage): return self.page.get_recipe(id) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/supertoinette/favicon.png��������������������������������������������������������0000664�0000000�0000000�00000012003�12657170273�0021353�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME g ���tEXtComment�Created with GIMPW��^IDATx[ixUչ~װs2Y@@EW "VrCkUʃWz:PSm R[#"EP @3ى/zY}a�dpn�?S,�VfgguݑﻕKbDľW[[�*%{~|ɧ=xO\'X׮]SXX8ZJ=۱cdž? 뮻8sL$ `IҰQҥK8SO=n+V%K/o$[IEJJg̝;� Hӈ}^|fĉܰa[3iҤ)L2 7jk-ZID3g/eI ,PM!`SO=o0˖-c,;Xyyy9y8y衇_N" e˖Ʊ � &L�u"rrry;ebY xkd�wtnJJ!7HBJyVG!Xku 9jԨh˱~D/A|p$:d;:DB$}#h42L6DV @ap}XS�<`t'iսwC\^>VVV[[l5kW`bۼ56ӂmVP0@H3~6o̶C,㣏>#FΙ3qƭ 8G68>8֋ ODiӦ98{=wG#w8^"}� Ҟlzv &w8ZcȐ!�PG}G�:_pjb"HGMœ2�Iot&i@'J(@ fn )�Hk;:ܫX,iixվ]m �9&hs|`hRv.*BtGnE߼A΃w֔5+^<:ۇ%ָ7Sݴ̬6| "i7E@Qɒm5k>\{//}yԢ5JFa4X-5[:x/ V~`�x6D³�ۚ s�TW^/d)f'og`o% @uz NẫGoٌ!} ̖?MW`{[j*KQR D(lxd(Dz!^ c^q7DP"=hǘX' 1 pcRpLǕcn$Um}{;b[т[+~xj(rmseq!ЊKW͘LI ؚJ]߄P5)%cR0ZsV\eR3}ƅ`nzʽ6UIX# !-+̞=�pW?4kۦ:lf6T.К^ڜP<O*njû侩,gB 4j'b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7=H۪<y0Ha�8cҤKGH2eoZ14� I :;?et|ʬ|&>b<q%Ix٧WWݰU=M `G$O?" i;nڢ/4e$(WW:.$g(ȶ96 )6q\nS!F`L+57ͽ'�ߋ$H$U={@CGZq/!bD]rOs#`THFb\ +pθXdʋ4]<PSSNuLĖL�JͨL1`\4OZ1. e{!g͎OvJ2׶ O:~Ԛ_ymo> qQ%)cav(gBSRxѲ-!-ǶW'buƜ>gHUvi4GҞdX)R[Dz(mKs^]2{EpܣF^^�g1h`w*/L"v'��{S1q)i컨{2a7!Y77Kjm\ G{Lګl|L5RJӗ@;Wf,|j`*{8(ԒmC?�wޯҍiI}J{&\gU}˭fdVlS)[Bi3uJ:b. O<Y,l[ {W\x'5dw[ /,}�;Gٌ[iЊz}vc4mRr怒kvftS>34[#Gd(x#R3P[5|ж+s'dZ7ϻc2�<hi઎.Ǐ$:tY~f{4B10UPh7N0| C[ѝG#SΝ| 2 2u`^qCԻGܜb#_~^hcJ[.RjrⰔptԩ�@E<ڙͮFL7(O%eFzo|WgO|`Ɨ<|@�TUWTf۷W٨tΜ5$Cws/NX69+�?ö݊7lbomÿY]޼_Ih?/`����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/supertoinette/module.py����������������������������������������������������������0000664�0000000�0000000�00000003725�12657170273�0021072�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.recipe import CapRecipe, Recipe from weboob.tools.backend import Module from .browser import SupertoinetteBrowser __all__ = ['SupertoinetteModule'] class SupertoinetteModule(Module, CapRecipe): NAME = 'supertoinette' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = u'Super Toinette, la cuisine familiale French recipe website' LICENSE = 'AGPLv3+' BROWSER = SupertoinetteBrowser def get_recipe(self, id): return self.browser.get_recipe(id) def iter_recipes(self, pattern): return self.browser.iter_recipes(pattern.encode('utf-8')) def fill_recipe(self, recipe, fields): if 'nb_person' in fields or 'instructions' in fields: rec = self.get_recipe(recipe.id) recipe.picture_url = rec.picture_url recipe.instructions = rec.instructions recipe.ingredients = rec.ingredients recipe.comments = rec.comments recipe.author = rec.author recipe.nb_person = rec.nb_person recipe.cooking_time = rec.cooking_time recipe.preparation_time = rec.preparation_time return recipe OBJECTS = { Recipe: fill_recipe, } �������������������������������������������weboob-1.1/modules/supertoinette/pages.py�����������������������������������������������������������0000664�0000000�0000000�00000012157�12657170273�0020703�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.recipe import Recipe from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.deprecated.browser import Page import string class ResultsPage(Page): """ Page which contains results as a list of recipies """ def iter_recipes(self): for div in self.parser.select(self.document.getroot(), 'div.result-recipe'): thumbnail_url = NotAvailable short_description = NotAvailable imgs = self.parser.select(div, 'a.pull-image-left img') if len(imgs) > 0: url = unicode(imgs[0].attrib.get('src', '')) if url.startswith('http://'): thumbnail_url = url link = self.parser.select(div, 'div.result-text a', 1) title = unicode(link.text) id = unicode(link.attrib.get('href', '').split('/')[2]) txt = self.parser.select(div, 'div.result-text p', 1) short_description = unicode(txt.text_content()) recipe = Recipe(id, title) recipe.thumbnail_url = thumbnail_url recipe.short_description = short_description recipe.instructions = NotLoaded recipe.ingredients = NotLoaded recipe.nb_person = NotLoaded recipe.cooking_time = NotLoaded recipe.preparation_time = NotLoaded recipe.author = NotLoaded yield recipe class RecipePage(Page): """ Page which contains a recipe """ def get_recipe(self, id): title = NotAvailable preparation_time = NotAvailable cooking_time = NotAvailable author = NotAvailable nb_person = NotAvailable ingredients = NotAvailable picture_url = NotAvailable instructions = NotAvailable comments = NotAvailable title = unicode(self.parser.select(self.document.getroot(), 'h1 span[property$=name]', 1).text) main = self.parser.select(self.document.getroot(), 'div[typeof$=Recipe]', 1) imgillu = self.parser.select(main, 'div.image-with-credit img') if len(imgillu) > 0: picture_url = unicode(imgillu[0].attrib.get('src', '')) l_spanprep = self.parser.select(self.document.getroot(), 'span.preptime[property$=prepTime]') if len(l_spanprep) > 0: preparation_time = 0 prep = l_spanprep[0].attrib.get('content','') if 'H' in prep: preparation_time += 60 * (int(prep.split('PT')[-1].split('H')[0])) if 'M' in prep: preparation_time += int(prep.split('PT')[-1].split('H')[-1].split('M')[0]) l_cooktime = self.parser.select(main, 'span.cooktime[property$=cookTime]') if len(l_cooktime) > 0: cooking_time = 0 cook = l_cooktime[0].attrib.get('content','') if 'H' in cook: cooking_time += 60 * (int(cook.split('PT')[-1].split('H')[0])) if 'M' in cook: cooking_time += int(cook.split('PT')[-1].split('H')[-1].split('M')[0]) l_nbpers = self.parser.select(main, 'div.ingredients p.servings') if len(l_nbpers) > 0: rawnb = l_nbpers[0].text.strip(string.letters+' ') if '/' in rawnb: nbs = rawnb.split('/') nb_person = [int(nbs[0]), int(nbs[1])] else: nb_person = [int(rawnb)] ingredients = [] l_ing = self.parser.select(main, 'div.ingredients ul.dotlist') for ing in l_ing: sublists = self.parser.select(ing, 'li') for i in sublists: ingtxt = unicode(i.text_content().strip()) if ingtxt != '': ingredients.append(' '.join(ingtxt.split())) instructions = u'' num_inst = 1 l_divinst = self.parser.select(self.document.getroot(), 'div#recipe-steps-list p.step-details') for inst in l_divinst: instructions += '%s: %s\n' % (num_inst, inst.text_content()) num_inst += 1 recipe = Recipe(id, title) recipe.preparation_time = preparation_time recipe.cooking_time = cooking_time recipe.nb_person = nb_person recipe.ingredients = ingredients recipe.instructions = instructions recipe.picture_url = picture_url recipe.comments = comments recipe.author = author recipe.thumbnail_url = NotLoaded return recipe �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/supertoinette/test.py������������������������������������������������������������0000664�0000000�0000000�00000002165�12657170273�0020561�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class SupertoinetteTest(BackendTest): MODULE = 'supertoinette' def test_recipe(self): recipes = self.backend.iter_recipes('fondue') for recipe in recipes: full_recipe = self.backend.get_recipe(recipe.id) assert full_recipe.instructions assert full_recipe.ingredients assert full_recipe.title �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015003�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/__init__.py�����������������������������������������������������������������0000664�0000000�0000000�00000000071�12657170273�0017112�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import T411Module __all__ = ['T411Module'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/browser.py������������������������������������������������������������������0000664�0000000�0000000�00000004144�12657170273�0017043�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015-2016 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.exceptions import BrowserHTTPNotFound from weboob.browser import LoginBrowser, need_login from weboob.browser.url import URL from weboob.browser.profiles import Wget from weboob.exceptions import BrowserIncorrectPassword from .pages.index import HomePage from .pages.torrents import TorrentPage, SearchPage __all__ = ['T411Browser'] class T411Browser(LoginBrowser): PROFILE = Wget() TIMEOUT = 30 BASEURL = 'https://www.t411.in/' home = URL('$', HomePage) search = URL('torrents/search/\?search=(?P<pattern>.*)&order=seeders&type=desc', SearchPage) torrent = URL('/torrents/details/\?id=(?P<id>.*)&r=1', 'torrents/[^&]*', TorrentPage) #def __init__(self, *args, **kwargs): # Browser.__init__(self, *args, **kwargs) def do_login(self): self.home.go() if not self.page.logged: self.page.login(self.username, self.password) if not self.page.logged: raise BrowserIncorrectPassword() @need_login def iter_torrents(self, pattern): return self.search.go(pattern=pattern).iter_torrents() @need_login def get_torrent(self, fullid, torrent=None): try: self.torrent.go(id=fullid) torrent = self.page.get_torrent() return torrent except BrowserHTTPNotFound: return ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/favicon.png�����������������������������������������������������������������0000664�0000000�0000000�00000001245�12657170273�0017140�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME  �5v>��2IDATx[;0XA!pG)bAOUVl7?*2۱MTT5Sju[^|,J "DG(A.k~s*�VHA+BJXD*v䓔� M.Ԋm<`/ iD^P�A^|{kctjZ }| zl?p"|M|q>$r;QpĀplA |`S FdCM1L۩D!YɠW"ڨ :>I,vUJi*;.LͼCȿADJI*@Nk)ustәo;S}WۚDuneh_SFc-tXO1YP,=9C9(8`q>㍒n 6DƓsn U{ӳ<(�%#tbŔ5z8a.r!R�ʀr:"0;b^g[2o Ui&@l+#hׁ0dD_N]@cOS."p'<�_|W"0k����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/module.py�������������������������������������������������������������������0000664�0000000�0000000�00000004232�12657170273�0016643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015-2016 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from urllib import quote_plus from weboob.capabilities.torrent import CapTorrent, Torrent from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword, Value from .browser import T411Browser __all__ = ['T411Module'] class T411Module(Module, CapTorrent): NAME = 't411' MAINTAINER = u'Julien Veyssier' EMAIL = 'eneiluj@gmx.fr' VERSION = '1.1' DESCRIPTION = 'T411 BitTorrent tracker' LICENSE = 'AGPLv3+' CONFIG = BackendConfig(Value('username', label='Username'), ValueBackendPassword('password', label='Password')) BROWSER = T411Browser def create_default_browser(self): return self.create_browser(self.config['username'].get(), self.config['password'].get()) def get_torrent(self, id): return self.browser.get_torrent(id) def get_torrent_file(self, id): torrent = self.browser.get_torrent(id) if not torrent: return None resp = self.browser.open(torrent.url) return resp.content def iter_torrents(self, pattern): return self.browser.iter_torrents(quote_plus(pattern.encode('utf-8'))) def fill_torrent(self, torrent, fields): if 'description' in fields or 'files' in fields: torrent = self.browser.get_torrent(torrent.id, torrent) return torrent OBJECTS = { Torrent: fill_torrent } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/pages/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016102�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/pages/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0020201�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/pages/index.py��������������������������������������������������������������0000664�0000000�0000000�00000002147�12657170273�0017567�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015-2016 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. #from .base import BasePage from weboob.browser.pages import HTMLPage class HomePage(HTMLPage): def login(self, login, password): form = self.get_form(xpath='//form[contains(@id, "loginform")]') form['login'] = login form['password'] = password form.submit() @property def logged(self): return self.doc.xpath('//a[@class="logout"]') �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/t411/pages/torrents.py�����������������������������������������������������������0000664�0000000�0000000�00000007713�12657170273�0020344�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015-2016 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.tools.misc import get_bytes_size from weboob.capabilities.torrent import Torrent from weboob.capabilities.base import NotLoaded, NotAvailable from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.pages import HTMLPage, LoggedPage from weboob.browser.filters.standard import Regexp, CleanText, Type, Format from weboob.browser.filters.html import CleanHTML class SearchPage(LoggedPage, HTMLPage): @method class iter_torrents(ListElement): item_xpath = '//table[@class="results"]/tbody/tr' class item(ItemElement): klass = Torrent obj_id = Regexp(CleanText('./td[3]/a/@href'), '/torrents/nfo/\?id=(.*)') obj_name = CleanText('./td[2]/a/@title') obj_seeders = CleanText('./td[8]') & Type(type=int) obj_leechers = CleanText('./td[9]') & Type(type=int) obj_description = NotLoaded obj_files = NotLoaded obj_filename = Format('%s.torrent',CleanText('./td[2]/a/@title')) obj_magnet = NotAvailable def obj_url(self): fullid = Regexp(CleanText('./td[3]/a/@href'),'/torrents/nfo/\?id=(.*)')(self) downurl = 'https://www.t411.in/torrents/download/?id=%s'%fullid return downurl def obj_size(self): rawsize = CleanText('./td[6]')(self) nsize = float(rawsize.split()[0]) usize = rawsize.split()[-1].upper() size = get_bytes_size(nsize,usize) return size class TorrentPage(LoggedPage, HTMLPage): @method class get_torrent(ItemElement): klass = Torrent def obj_description(self): desctxt = CleanHTML('//div[has-class("description")]/article')(self) strippedlines = '\n'.join([s.strip() for s in desctxt.split('\n') if re.search(r'\[[0-9]+\]', s) is None]) description = re.sub(r'\s\s+', '\n\n', strippedlines) return description obj_name = CleanText('//div[has-class("torrentDetails")]/h2/span/text()') obj_id = CleanText('//input[@id="torrent-id"][1]/@value') def obj_url(self): fullid = CleanText('//input[@id="torrent-id"][1]/@value')(self) downurl = 'https://www.t411.in/torrents/download/?id=%s'%fullid return downurl obj_filename = CleanText('//div[@class="accordion"]//tr[th="Torrent"]/td') def obj_size(self): rawsize = CleanText('//div[@class="accordion"]//tr[th="Taille totale"]/td')(self) nsize = float(rawsize.split()[0]) usize = rawsize.split()[-1].upper() size = get_bytes_size(nsize,usize) return size def obj_files(self): res = [] for f in Type('//div[@class="accordion"]/h3[text()="Liste des Fichiers"]\ /following-sibling::div[1]//tr', type=list)(self)[1:]: res.append(CleanText(f)(self)) return res obj_seeders = CleanText('//div[@class="details"]//td[@class="up"]') & Type(type=int) obj_leechers = CleanText('//div[@class="details"]//td[@class="down"]') & Type(type=int) obj_magnet = NotAvailable �����������������������������������������������������weboob-1.1/modules/t411/test.py���������������������������������������������������������������������0000664�0000000�0000000�00000001727�12657170273�0016343�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class T411Test(BackendTest): MODULE = 't411' def test_torrent(self): l = list(self.backend.iter_torrents('spider')) if len(l) > 0: self.backend.get_torrent_file(l[0].id) �����������������������������������������weboob-1.1/modules/taz/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015110�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/taz/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000001501�12657170273�0017216�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"NewspaperTazModule init" # -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import NewspaperTazModule __all__ = ['NewspaperTazModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/taz/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000002357�12657170273�0017154�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"browser for taz website" # -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .pages.article import ArticlePage from weboob.deprecated.browser import Browser class NewspaperTazBrowser(Browser): "NewspaperTazBrowser class" PAGES = { "http://www.taz.de/.*": ArticlePage, } def is_logged(self): return False def login(self): pass def fillobj(self, obj, fields): pass def get_content(self, _id): "return page article content" self.location(_id) return self.page.get_article(_id) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/taz/favicon.png������������������������������������������������������������������0000664�0000000�0000000�00000000725�12657170273�0017247�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���% ���sRGB���� pHYs�� �� ����tIME3酧a��gIDATh 0 E5`�`2`#G{gL<_]5]G%kWV+&�U�zBQ(QL q:HL8R_+BQ8Rz{K�շd~[� C:КДQ WaXOV佮)t3Gan�(^ԩ e xF*d b̻jpT�>A lۮC),Z==vE�qs�ƨUZ:Tbn, އ z*@7it~!�$xg� V�> IȄtf OXhϬK 7$n% � �'k����IENDB`�������������������������������������������weboob-1.1/modules/taz/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000002577�12657170273�0016762�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. "backend for http://www.taz.de" from weboob.capabilities.messages import CapMessages from weboob.tools.capabilities.messages.GenericModule import GenericNewspaperModule from .browser import NewspaperTazBrowser from .tools import rssid, url2id class NewspaperTazModule(GenericNewspaperModule, CapMessages): MAINTAINER = u'Florent Fourcot' EMAIL = 'weboob@flo.fourcot.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' STORAGE = {'seen': {}} NAME = 'taz' DESCRIPTION = u'Taz newspaper website' BROWSER = NewspaperTazBrowser RSSID = staticmethod(rssid) URL2ID = staticmethod(url2id) RSSSIZE = 30 RSS_FEED = "http://www.taz.de/!p3270;rss/" ���������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/taz/pages/�����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016207�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/taz/pages/__init__.py������������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0020306�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/taz/pages/article.py�������������������������������������������������������������0000664�0000000�0000000�00000003166�12657170273�0020212�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"ArticlePage object for Taz newspaper" # -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.messages.genericArticle import GenericNewsPage,\ try_drop_tree, clean_relativ_urls class ArticlePage(GenericNewsPage): "ArticlePage object for taz" def on_loaded(self): self.main_div = self.document.getroot() self.element_title_selector = "title" self.element_author_selector = ".content-author>a" def get_body(self): div = self.document.getroot().find('.//div[@class="sectbody"]') try_drop_tree(self.parser, div, "div.anchor") clean_relativ_urls(div, "http://taz.de") return self.parser.tostring(div) def get_title(self): title = GenericNewsPage.get_title(self) return title def get_author(self): author = self.document.getroot().xpath('//span[@class="author"]') if author: return author[0].text.replace('von ', '') ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/taz/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000001647�12657170273�0016451�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class TazTest(BackendTest): MODULE = 'taz' def test_new_messages(self): for message in self.backend.iter_unread_messages(): pass �����������������������������������������������������������������������������������������weboob-1.1/modules/taz/tools.py���������������������������������������������������������������������0000664�0000000�0000000�00000001674�12657170273�0016632�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"tools for taz module" # -*- coding: utf-8 -*- # Copyright(C) 2012 Florent Fourcot # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re def url2id(url): "return an id from an url" regexp = re.compile(".*/!([0-9]+)/") id = regexp.match(url).group(1) return id def rssid(entry): return url2id(entry.link) ��������������������������������������������������������������������weboob-1.1/modules/tinder/��������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015577�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tinder/__init__.py���������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0017707�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import TinderModule __all__ = ['TinderModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tinder/browser.py����������������������������������������������������������������0000664�0000000�0000000�00000010412�12657170273�0017632�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.browser.browsers import DomainBrowser, APIBrowser from weboob.browser.pages import HTMLPage from weboob.browser.profiles import IPhone from weboob.exceptions import BrowserIncorrectPassword from weboob.tools.json import json __all__ = ['TinderBrowser', 'FacebookBrowser'] class FacebookBrowser(DomainBrowser): BASEURL = 'https://graph.facebook.com' CLIENT_ID = "464891386855067" access_token = None info = None def login(self, username, password): self.location('https://www.facebook.com/dialog/oauth?client_id=%s&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=basic_info,email,public_profile,user_about_me,user_activities,user_birthday,user_education_history,user_friends,user_interests,user_likes,user_location,user_photos,user_relationship_details&response_type=token' % self.CLIENT_ID) page = HTMLPage(self, self.response) form = page.get_form('//form[@id="login_form"]') form['email'] = username form['pass'] = password form['persistent'] = 1 for script in page.doc.xpath('//script'): m = re.search('"_js_datr","([^"]+)"', script.text or '') if m: self.session.cookies.set('_js_datr', m.group(1)) form.submit(allow_redirects=False) if 'Location' not in self.response.headers: raise BrowserIncorrectPassword() self.location(self.response.headers['Location']) m = re.search('access_token=([^&]+)&', self.url) if m: self.access_token = m.group(1) self.info = self.request('/me') def request(self, url, *args, **kwargs): url += '?access_token=' + self.access_token self.location(self.absurl(url, base=True), *args, **kwargs) return json.loads(self.response.content) class TinderBrowser(APIBrowser): BASEURL = 'https://api.gotinder.com/' PROFILE = IPhone('Tinder/3.0.2') recs = [] def __init__(self, facebook, *args, **kwargs): super(TinderBrowser, self).__init__(*args, **kwargs) self.facebook = facebook me = self.request('/auth', data={'facebook_id': facebook.info['id'], 'facebook_token': facebook.access_token}) self.session.headers['Authorization'] = 'Token token="%s"' % me['token'] self.session.headers['X-Auth-Token'] = me['token'] self.my_id = me['user']['_id'] self.my_name = me['user']['name'] def get_threads(self): resp = self.request('/updates', data={'last_activity_date': '2014-05-01T06:13:16.971Z'}) return sorted(resp['matches'], key=lambda m: m['last_activity_date'], reverse=True) def post_message(self, match_id, content): self.request('/user/matches/%s' % match_id, data={'message': content}) def update_recs(self): resp = self.request('/user/recs') try: self.recs = resp['results'] except KeyError: self.recs = [] def like_profile(self): if len(self.recs) == 0: self.update_recs() if len(self.recs) == 0: return 60 profile = self.recs.pop() if 'tinder_rate_limited' in profile['_id']: self.logger.info(profile['bio']) return 600 resp = self.request('/like/%s' % profile['_id']) if resp['match']: self.logger.error('Match with %s!' % profile['name']) else: self.logger.info('Liked %s (%r)' % (profile['name'], profile['common_likes'])) if len(self.recs) > 0: return 1 else: return 60 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tinder/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000002230�12657170273�0017727�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������C��� pHYs��.#��.#x?v���tIME 974���tEXtComment�Created with GIMPW���IDATxOhW?Qj`zlEhIm$[מA*cK) YbBzKT6Г4hZHj}=/tnvwvޛy6}3߼%yq6^*==$�V'~GJ0\O�Vy`,wՐUK\7P0� �:`�_x�x&[zyEj_,w�/I/W3G}:6ˣ �4WgV(}Wwߴ:B mZ{c|FPcN+5p+]�r'о:\^fK!.wPmg�Hv_SRڊU`ħ>'�۟sOqxKoվڜ(�@CƷ�Fϵjp\HCQsF$%DWR5'q,30 ^2q@Rx�ێg xЬ$ 2% pK3q@_x-.)oqyMnE*; 1uMLĴJ.@bɡ Q7l*9�l ` Ԗ�Xjӑ ]*/Qp_YҶ�<^†r�pF�4/�6�>O&bnȴ'p&)(�.9wo]<�/p<U;G@5�x0pw�)@\�x~?_Һ �grAS}I~u�b)rYصNMۀIƇ"$Fpڤe^*=|_ߛ4>tC٥r0 G& %>0|)}Ȝi#@8 li)r^ok(�dD<Og28-NCME_^/Sdch� �"]f=]#W/OƦUUUUU l Ңd����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tinder/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000014636�12657170273�0017450�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import datetime from dateutil.parser import parse as parse_date from weboob.capabilities.messages import CapMessages, CapMessagesPost, Thread, Message from weboob.capabilities.dating import CapDating, Optimization from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.log import getLogger from .browser import TinderBrowser, FacebookBrowser __all__ = ['TinderModule'] class ProfilesWalker(Optimization): def __init__(self, sched, storage, browser): self._sched = sched self._storage = storage self._browser = browser self._logger = getLogger('walker', browser.logger) self._view_cron = None def start(self): self._view_cron = self._sched.schedule(1, self.view_profile) return True def stop(self): self._sched.cancel(self._view_cron) self._view_cron = None return True def set_config(self, params): pass def is_running(self): return self._view_cron is not None def view_profile(self): next_try = 1 try: next_try = self._browser.like_profile() finally: if self._view_cron is not None: self._view_cron = self._sched.schedule(next_try, self.view_profile) class TinderModule(Module, CapMessages, CapMessagesPost, CapDating): NAME = 'tinder' DESCRIPTION = u'Tinder dating mobile application' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(Value('username', label='Facebook email'), ValueBackendPassword('password', label='Facebook password')) BROWSER = TinderBrowser STORAGE = {'contacts': {}, } def create_default_browser(self): facebook = FacebookBrowser() facebook.login(self.config['username'].get(), self.config['password'].get()) return self.create_browser(facebook) # ---- CapDating methods ----------------------- def init_optimizations(self): self.add_optimization('PROFILE_WALKER', ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)) # ---- CapMessages methods --------------------- def fill_thread(self, thread, fields): return self.get_thread(thread) def iter_threads(self): for thread in self.browser.get_threads(): if 'person' not in thread: # The account has been removed, probably because it was a # spammer. continue t = Thread(thread['_id']) t.flags = Thread.IS_DISCUSSION t.title = u'Discussion with %s' % thread['person']['name'] contact = self.storage.get('contacts', t.id, default={'lastmsg': 0}) birthday = parse_date(thread['person']['birth_date']).date() signature = u'Age: %d (%s)' % ((datetime.date.today() - birthday).days / 365.25, birthday) signature += u'\nLast ping: %s' % parse_date(thread['person']['ping_time']).strftime('%Y-%m-%d %H:%M:%S') signature += u'\nPhotos:\n\t%s' % '\n\t'.join([photo['url'] for photo in thread['person']['photos']]) signature += u'\n\n%s' % thread['person']['bio'] t.root = Message(thread=t, id=1, title=t.title, sender=unicode(thread['person']['name']), receivers=[self.browser.my_name], date=parse_date(thread['created_date']), content=u'Match!', children=[], signature=signature, flags=Message.IS_UNREAD if int(contact['lastmsg']) < 1 else 0) parent = t.root for msg in thread['messages']: flags = 0 if int(contact['lastmsg']) < msg['timestamp']: flags = Message.IS_UNREAD msg = Message(thread=t, id=msg['timestamp'], title=t.title, sender=unicode(self.browser.my_name if msg['from'] == self.browser.my_id else thread['person']['name']), receivers=[unicode(self.browser.my_name if msg['to'] == self.browser.my_id else thread['person']['name'])], date=parse_date(msg['sent_date']), content=unicode(msg['message']), children=[], parent=parent, signature=signature if msg['to'] == self.browser.my_id else u'', flags=flags) parent.children.append(msg) parent = msg yield t def get_thread(self, _id): for t in self.iter_threads(): if t.id == _id: return t def iter_unread_messages(self): for thread in self.iter_threads(): for message in thread.iter_all_messages(): if message.flags & message.IS_UNREAD: yield message def set_message_read(self, message): contact = self.storage.get('contacts', message.thread.id, default={'lastmsg': 0}) if int(contact['lastmsg']) < int(message.id): contact['lastmsg'] = int(message.id) self.storage.set('contacts', message.thread.id, contact) self.storage.save() # ---- CapMessagesPost methods --------------------- def post_message(self, message): self.browser.post_message(message.thread.id, message.content) OBJECTS = {Thread: fill_thread, } ��������������������������������������������������������������������������������������������������weboob-1.1/modules/tinder/test.py�������������������������������������������������������������������0000664�0000000�0000000�00000001613�12657170273�0017131�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class TinderTest(BackendTest): MODULE = 'tinder' def test_tinder(self): self.backend.browser.like_profile() ���������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/transilien/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016462�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/transilien/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000001465�12657170273�0020601�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Hébert, Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import TransilienModule __all__ = ['TransilienModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/transilien/browser.py������������������������������������������������������������0000664�0000000�0000000�00000006137�12657170273�0020526�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Hébert, Romain Bignon # Copyright(C) 2014 Benjamin Carton # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import datetime from weboob.browser import PagesBrowser, URL from .pages import StationsPage, DeparturesPage, DeparturesPage2, HorairesPage, RoadMapPage class Transilien(PagesBrowser): BASEURL = 'http://www.transilien.com' stations_page = URL('aidesaisie/autocompletion\?saisie=(?P<pattern>.*)', StationsPage) departures_page = URL('gare/pagegare/chargerGare\?nomGare=(?P<station>.*)', 'gare/.*', DeparturesPage) departures_page2 = URL('fichehoraire/fichehoraire/(?P<url>.*)', 'fichehoraire/fichehoraire/.*', DeparturesPage2) horaires_page = URL('fiche-horaire/(?P<station>.*)--(?P<arrival>.*)-(?P<station2>.*)-(?P<arrival2>)-(?P<date>)', 'fiche-horaire/.*', HorairesPage) roadmap_page = URL('itineraire/rechercheitineraire/(?P<url>.*)', 'itineraire/rechercheitineraire/.*', RoadMapPage) def get_roadmap(self, departure, arrival, filters): dep = self.get_stations(departure, False).next().name arr = self.get_stations(arrival, False).next().name self.roadmap_page.go(url='init').request_roadmap(dep, arr, filters.arrival_time) if self.page.is_ambiguous(): self.page.fix_ambiguity() return self.page.get_roadmap() def get_stations(self, pattern, only_station=True): return self.stations_page.go(pattern=pattern).get_stations(only_station=only_station) def get_station_departues(self, station, arrival_id, date): if arrival_id is not None: arrival_name = arrival_id.replace('-', ' ') self.departures_page2.go(url='init').init_departure(station) arrival = self.page.get_potential_arrivals().get(arrival_name) if arrival: station_id = self.page.get_station_id() if date is None: date = datetime.now() _date = datetime.strftime(date, "%d/%m/%Y-%H:%M") self.horaires_page.go(station=station.replace(' ', '-'), arrival=arrival_id, station2=station_id, arrival2=arrival, date=_date) return self.page.get_departures(station, arrival_name, date) return [] else: return self.departures_page.go(station=station).get_departures(station=station) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/transilien/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000002721�12657170273�0020617�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ����tIME#_0��cIDATx_h[U?7MMG\D1pn3PPE18&T}ȋ: ({_3Y>8ahjmkCmiܤM89ɽs;{~^"X oTvGzɬE{hWqh�X0MB>h"�Oeas-K@29Odp0 8$ +6MUP%+Ev(`S2e6�&qh_{'n �Ο4+/uo74�8 zbxdCLf*󓾠w.'j4~AA<f-.�% ?U+V}Ao/%�e-WR/>Y(S@Go=C²c)> :ڨ#.I0̝/�� z'IΟURVi]Yu6Pks03?MRK i%  ׿ɜN�FdyvxG,顖yvls;5߿^G2P'X+N`@6ٚG%nm&O Jv.�&I,&ֵll(XWэu<a=ip7"I"Uu/$\b4>—W>[`f~,O oқF0rge/r#G ]ηRiOL[7qv cf.6_gOʩ$% _zwZxZ=m{Hʲe&QT�<z^.O@�!?lɰQޖkUڴײ`^�,ͱF1,�t#JRDr @W]㡺f*J/Wĺg=oKG,=o� [b-�q$R^ <LR!2)<Bq Wa"K/]U/ҧ4�}P&�dyQ^e.#RbZCG5?,.5lRFޱ[}�Dzg8vi~v~Fܓʈp.xX`,,-V+աRb1$ JOQy[% GD'͖&R4� He Bfc@^#u"TH8�2!3[T2j]Eu2-C=*[I=} ܣ|BzA�Xc< <O꽀y6p7 0A`њy0pg|ep]7C kM%bfpI(*G�v r (�ц�r@T_#�j"omٖmYVf񺫶'����IENDB`�����������������������������������������������weboob-1.1/modules/transilien/module.py�������������������������������������������������������������0000664�0000000�0000000�00000003042�12657170273�0020320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Hébert, Romain Bignon # Copyright(C) 2014 Benjamin Carton # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.travel import CapTravel from weboob.tools.backend import Module from .browser import Transilien class TransilienModule(Module, CapTravel): NAME = 'transilien' MAINTAINER = u'Julien Hébert' EMAIL = 'juke@free.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u"Public transportation in the Paris area" BROWSER = Transilien def iter_station_search(self, pattern): return self.browser.get_stations(pattern) def iter_station_departures(self, station_id, arrival_id=None, date=None): return self.browser.get_station_departues(station_id.replace('-', ' '), arrival_id, date) def iter_roadmap(self, departure, arrival, filters): return self.browser.get_roadmap(departure, arrival, filters) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/transilien/pages.py��������������������������������������������������������������0000664�0000000�0000000�00000016172�12657170273�0020142�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Hébert, Romain Bignon # Copyright(C) 2014 Benjamin Carton # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.browser.pages import JsonPage, HTMLPage from weboob.browser.elements import TableElement, ItemElement, DictElement, method from weboob.capabilities.travel import Station, Departure, RoadStep from weboob.capabilities import NotAvailable from weboob.browser.filters.standard import CleanText, TableCell, Filter, DateTime, Env, Regexp, Duration from weboob.browser.filters.json import Dict from weboob.browser.filters.html import Link from weboob.tools.date import LinearDateGuesser class RoadMapDuration(Duration): _regexp = re.compile(r'(?P<mn>\d+)') kwargs = {'minutes': 'mn'} class DepartureTypeFilter(Filter): def filter(self, el): result = [] for img in el[0].getiterator(tag='img'): result.append(img.attrib['alt']) return u' '.join(result) class Child(Filter): def filter(self, el): return list(el[0].iterchildren()) class RoadMapPage(HTMLPage): def request_roadmap(self, station, arrival, arrival_date): form = self.get_form('//form[@id="cRechercheItineraire"]') form['depart'] = '%s' % station form['arrivee'] = '%s' % arrival form.submit() def is_ambiguous(self): return self.doc.xpath('//select[@id="gare_arrivee_ambigu"] | //select[@id="gare_depart_ambigu"]') def fix_ambiguity(self): form = self.get_form('//form[@id="cRechercheItineraire"]') if self.doc.xpath('//select[@id="gare_arrivee_ambigu"]'): form['coordArrivee'] = self.doc.xpath('//select[@id="gare_arrivee_ambigu"]/option[@cat="STOP_AREA"]/@value')[0] if self.doc.xpath('//select[@id="gare_depart_ambigu"]'): form['coordDepart'] = self.doc.xpath('//select[@id="gare_depart_ambigu"]/option[@cat="STOP_AREA"]/@value')[0] form.submit() def get_roadmap(self): for step in self.doc.xpath('//table[@class="trajet_etapes"]/tr[@class="etape"]'): roadstep = RoadStep() roadstep.line = '%s %s' % (DepartureTypeFilter(step.xpath('./td[@class="moyen"]'))(self), CleanText('./td[@class="moyen"]')(step)) roadstep.start_time = DateTime(CleanText('./th/span[@class="depart"]'), LinearDateGuesser())(step) roadstep.end_time = DateTime(CleanText('./th/span[@class="depart"]/following-sibling::span'), LinearDateGuesser())(step) roadstep.departure = CleanText('./td[@class="arret"]/p/strong')(step) roadstep.arrival = CleanText('./td[@class="arret"]/p/following-sibling::p/strong')(step) roadstep.duration = RoadMapDuration(CleanText('./td[@class="time"]'))(step) yield roadstep class HorairesPage(HTMLPage): def get_departures(self, station, arrival, date): for table in self.doc.xpath('//table[@class="trajet_horaires trajet_etapes"]'): lignes = table.xpath('./tr[@class="ligne"]/th') arrives = table.xpath('./tr[@class="arrivee"]/td') departs = table.xpath('./tr[@class="depart"]/td') items = zip(lignes, arrives, departs) for item in items: departure = Departure() departure.id = Regexp(Link('./div/a'), '.*?vehicleJourneyExternalCode=(.*?)&.*?')(item[1]) departure.departure_station = station departure.arrival_station = arrival hour, minute = CleanText('./div/a')(item[1]).split('h') departure.time = date.replace(hour=int(hour), minute=int(minute)) hour, minute = CleanText('./div/a')(item[2]).split('h') departure.arrival_time = date.replace(hour=int(hour), minute=int(minute)) departure.information = CleanText('.')(item[0]) departure.type = DepartureTypeFilter(item)(self) yield departure class StationsPage(JsonPage): @method class get_stations(DictElement): item_xpath = 'gares' class item(ItemElement): klass = Station def condition(self): if self.env['only_station']: return Dict('entryPointType')(self.el) == 'StopArea' and Dict('reseau')(self.el)[0] return True obj_name = CleanText(Dict('gare')) obj_id = CleanText(Dict('gare'), replace=[(' ', '-')]) class DeparturesPage2(HTMLPage): def get_potential_arrivals(self): arrivals = {} for el in self.doc.xpath('//select[@id="gare_arrive_ambigu"]/option'): arrivals[el.text] = el.attrib['value'] return arrivals def get_station_id(self): form = self.get_form('//form[@id="cfichehoraire"]') return form['departExternalCode'] def init_departure(self, station): form = self.get_form('//form[@id="cfichehoraire"]') form['depart'] = station form.submit() def get_departures(self, arrival, date): form = self.get_form('//form[@id="cfichehoraire"]') form['arrive'] = arrival if date: form['jourHoraire'] = date.day form['moiHoraire'] = '%s|%s' % (date.month, date.year) form['heureHoraire'] = date.hour form['minuteHoraire'] = date.minute self.logger.debug(form) form.submit() class DeparturesPage(HTMLPage): @method class get_departures(TableElement): head_xpath = u'//table[@class="etat_trafic"][1]/thead/tr/th[@scope="col"]/text()' item_xpath = u'//table[@class="etat_trafic"]/tr' col_type = u'Ligne' col_info = u'Nom du train' col_time = u'Heure de départ' col_arrival = u'Destination' col_plateform = u'Voie/quai' col_id = u'Gares desservies' class item(ItemElement): klass = Departure def condition(self): return len(self.el.xpath('./td')) >= 6 obj_time = TableCell('time') & CleanText & DateTime | NotAvailable obj_type = DepartureTypeFilter(TableCell('type')) obj_departure_station = CleanText(Env('station')) obj_arrival_station = CleanText(TableCell('arrival')) obj_information = TableCell('time') & CleanText & Regexp(pattern='([^\d:]+)') | u'' obj_plateform = CleanText(TableCell('plateform')) obj_id = Regexp(Link(Child(TableCell('id'))), '.*?numeroTrain=(.*?)&.*?') ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/transilien/test.py���������������������������������������������������������������0000664�0000000�0000000�00000003147�12657170273�0020020�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import datetime from weboob.capabilities.travel import RoadmapFilters from weboob.tools.test import BackendTest class TransilienTest(BackendTest): MODULE = 'transilien' def test_stations(self): stations = list(self.backend.iter_station_search('aul')) self.assertTrue(len(stations) > 0) def test_departures(self): stations = list(self.backend.iter_station_search('paris')) self.assertTrue(len(stations) > 0) list(self.backend.iter_station_departures(stations[0].id)) def test_roadmap(self): filters = RoadmapFilters() roadmap = list(self.backend.iter_roadmap('aul', u'aub', filters)) self.assertTrue(len(roadmap) > 0) filters.arrival_time = datetime.datetime.now() + datetime.timedelta(days=1) roadmap = list(self.backend.iter_roadmap('aul', u'bag', filters)) self.assertTrue(len(roadmap) > 0) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/trictractv/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016477�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/trictractv/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000000105�12657170273�0020604�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import TricTracTVModule __all__ = ['TricTracTVModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/trictractv/browser.py������������������������������������������������������������0000664�0000000�0000000�00000005011�12657170273�0020531�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Romain Bignon, Laurent Bachelier, Benjamin Drieu # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.deprecated.browser import Browser from weboob.deprecated.browser.decorators import id2url from .pages import IndexPage, VideoPage from .video import TricTracTVVideo __all__ = ['TricTracTVBrowser'] class TricTracTVBrowser(Browser): DOMAIN = 'trictrac.tv' ENCODING = 'ISO-8859-1' PAGES = {r'http://[w\.]*trictrac.tv/': IndexPage, r'http://[w\.]*trictrac.tv/home/listing.php.*': IndexPage, r'http://[w\.]*trictrac.tv/video-(.+)': VideoPage, } @id2url(TricTracTVVideo.id2url) def get_video(self, url, video=None): self.location(url) assert self.is_on_page(VideoPage) _id = self.page.get_id() if video is None: video = TricTracTVVideo(_id) infourl = self.page.get_info_url() if infourl is not None: self.parse_info(self.openurl(infourl).read(), video) return video def home(self): self.location(self.buildurl('http://www.trictrac.tv/home/listing.php', mot='%')) def search_videos(self, pattern): if not pattern: self.home() else: self.location(self.buildurl('http://www.trictrac.tv/home/listing.php', mot=pattern.encode('utf-8'))) assert self.is_on_page(IndexPage) return self.page.iter_videos() def parse_info(self, data, video): m = re.match ( '.*fichier=(.*?)&', data ) video.url = unicode ( r'http://src.povcon.net/videos/%s' % m.group ( 1 ) ) video.description = self.page.get_descriptif() video.duration = self.page.get_duration() video.title = self.page.get_title() video.date = self.page.get_date() video.rating = self.page.get_rating() video.rating_max = 5 return video �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/trictractv/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000002345�12657170273�0020636�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME6 m��rIDATx]h[e[XIgKq!(J;pH wcÉ)BBgވPqJ^42DR#ùycUiM]ؓt!'<y?F;3/W uW k ZugFB6p H8퀆*jh LQ9" *JˬFgv3/;Fae ro/(WXhQRZTGL&C@@8`H.H/@8Ldp8}9@ߨ|}Er0SL�ۋʪDUV/ߩ7 ͔>IM&#NOxZ6v;IU3'b\LU_VBnc5ŋB! = `&xwMcCSO-3Bn3`lqi~Ɨ4Rq7s@fj,Rn7C" ;s(4Rۭ3glR3iCdr#ƭ64[RE13^a$Fc\6SzH!cˮ ΜK%/[ؔ$ĄS!n",͒c9`PU3'$fJ6E֞kWS{kW$Ƙv* ~ɞ>eMӚkdE&J[sCe'd*S^W84.~fw=}?4i�,--oZDž7>řK/浌@=V�.~fK^O?��2>@/W^}~M4S`bvxp?'zynlcu "|,s;B�}[80޽<g봺̔-(Ymzrb;N>=NúoWh,k_#w4,8'/8tӇ,kr^Pr8LH.Prh&́q)fc!m{4S+a>kiZ!n4 r%v ȓ@g[yca_eg%8`gjD5�l?B cU…2[ZiVwB����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/trictractv/module.py�������������������������������������������������������������0000664�0000000�0000000�00000003751�12657170273�0020344�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # Copyright(C) 2012 Benjamin Drieu # # This file is *not yet* part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import CapVideo from weboob.tools.backend import Module from .browser import TricTracTVBrowser from .video import TricTracTVVideo __all__ = ['TricTracTVModule'] class TricTracTVModule(Module, CapVideo): NAME = 'trictractv' MAINTAINER = u'Benjamin Drieu' EMAIL = 'benjamin@drieu.org' VERSION = '1.1' DESCRIPTION = u'TricTrac.tv video website' LICENSE = 'AGPLv3+' BROWSER = TricTracTVBrowser def get_video(self, _id): with self.browser: return self.browser.get_video(_id) def search_videos(self, pattern=None, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): with self.browser: return self.browser.search_videos(pattern) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields with self.browser: video = self.browser.get_video(TricTracTVVideo.id2url(video.id), video) if 'thumbnail' in fields and video.thumbnail: with self.browser: video.thumbnail.data = self.browser.readurl(video.thumbnail.url) return video OBJECTS = {TricTracTVVideo: fill_video} �����������������������weboob-1.1/modules/trictractv/pages.py��������������������������������������������������������������0000664�0000000�0000000�00000011042�12657170273�0020146�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import datetime import re from weboob.capabilities.image import BaseImage from weboob.deprecated.browser import Page, BrokenPageError from .video import TricTracTVVideo class IndexPage(Page): def iter_videos(self): for div in self.parser.select(self.document.getroot(), 'li#contentsearch'): title = self.parser.select(div, '#titlesearch span', 1) a = self.parser.select(div, 'a', 1) url = a.attrib['href'] m = re.match('/video-(.*)', url) if not m: self.logger.debug('url %s does not match' % url) continue _id = m.group(1) video = TricTracTVVideo(_id) video.title = unicode(title.text) url = self.parser.select(div, 'img', 1).attrib['src'] stars = self.parser.select(div, '.etoile_on') video.rating = len(stars) video.rating_max = 5 video.thumbnail = BaseImage('http://www.trictrac.tv/%s' % url) video.thumbnail.url = video.thumbnail.id yield video class VideoPage(Page): def on_loaded(self): p = self.parser.select(self.document.getroot(), 'p.alert') if len(p) > 0: raise Exception(p[0].text) def get_info_url(self): try: div = self.parser.select(self.document.getroot(), '#Content_Video object', 1) except BrokenPageError: return None else: for param in self.parser.select(div, 'param', None): if param.get('name') == 'flashvars': m = re.match('varplaymedia=([0-9]*)', param.attrib['value']) if m: return r'http://www.trictrac.tv/swf/listelement.php?idfile=%s' % m.group(1) def get_title(self): try: title = self.parser.select(self.document.getroot(), 'title', 1) except BrokenPageError: return None else: return title.text def get_descriptif(self): try: descriptif = self.parser.select(self.document.getroot(), '.video_descriptif p', 1) except BrokenPageError: return None else: return descriptif.text def get_duration(self): try: details = self.parser.select(self.document.getroot(), 'div#video_detail div') except BrokenPageError: return None else: duration = details[2] duration_string = duration.text [ duration.text.rfind ( ' ' ) + 1 : ] tokens = duration_string.split(':') if len(tokens) > 2: return datetime.timedelta(hours=int(tokens[0]), minutes=int(tokens[1]), seconds=int(tokens[2])) else: return datetime.timedelta(minutes=int(tokens[0]), seconds=int(tokens[1])) def get_date(self): try: date = self.parser.select(self.document.getroot(), 'div#video_detail div.date', 1) except BrokenPageError: return None else: string = date.text string = string [ string.rfind('le ') + 3 : ] months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] words = string.split ( ' ' ) month_no = months.index ( words [ 1 ] ) + 1 return datetime.datetime.strptime ( ( '%s %s %s %s' % ( words [ 0 ], month_no, words [ 2 ], words [ 3 ] ) ), '%d %m %Y, %H:%M:%S') def get_rating(self): try: stars = self.parser.select(self.document.getroot(), '#video_info .etoile_on') except BrokenPageError: return None else: return len(stars) def get_id(self): return self.groups[0] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/trictractv/test.py���������������������������������������������������������������0000664�0000000�0000000�00000002210�12657170273�0020023�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011-2012 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class TricTracTVTest(BackendTest): MODULE = 'trictractv' def test_trictractv(self): l = list(self.backend.search_videos('TricTrac')) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/trictractv/video.py��������������������������������������������������������������0000664�0000000�0000000�00000002010�12657170273�0020150�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo class TricTracTVVideo(BaseVideo): def __init__(self, *args, **kwargs): BaseVideo.__init__(self, *args, **kwargs) self.ext = u'flv' @classmethod def id2url(cls, _id): return 'http://www.trictrac.tv/video-%s' % _id ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tvsubtitles/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016702�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tvsubtitles/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000001443�12657170273�0021015�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import TvsubtitlesModule __all__ = ['TvsubtitlesModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tvsubtitles/browser.py�����������������������������������������������������������0000664�0000000�0000000�00000003713�12657170273�0020743�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser, BrowserHTTPNotFound from .pages import SeriePage, SearchPage, SeasonPage, HomePage __all__ = ['TvsubtitlesBrowser'] LANGUAGE_LIST = ['en', 'es', 'fr', 'de', 'br', 'ru', 'ua', 'it', 'gr', 'ar', 'hu', 'pl', 'tr', 'nl', 'pt', 'sv', 'da', 'fi', 'ko', 'cn', 'jp', 'bg', 'cz', 'ro'] class TvsubtitlesBrowser(Browser): DOMAIN = 'www.tvsubtitles.net' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = Browser.USER_AGENTS['wget'] PAGES = { 'http://www.tvsubtitles.net': HomePage, 'http://www.tvsubtitles.net/search.php': SearchPage, 'http://www.tvsubtitles.net/tvshow-.*.html': SeriePage, 'http://www.tvsubtitles.net/subtitle-[0-9]*-[0-9]*-.*.html': SeasonPage } def iter_subtitles(self, language, pattern): self.location('http://www.tvsubtitles.net') assert self.is_on_page(HomePage) return self.page.iter_subtitles(language, pattern) def get_subtitle(self, id): try: self.location('http://www.tvsubtitles.net/subtitle-%s.html' % id) except BrowserHTTPNotFound: return if self.is_on_page(SeasonPage): return self.page.get_subtitle() �����������������������������������������������������weboob-1.1/modules/tvsubtitles/favicon.png����������������������������������������������������������0000664�0000000�0000000�00000002512�12657170273�0021035�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� ����tIME 6��IDATx_U?G:dl%$e ,ycZV(A>ԃHT[,-d$ee&Z=YY*6JZڸN<ͽ3wg\w~=wΜYE ^5~{49r*3�l Iy�eS-� .g�UƸoueQ~�PugSP9ske)Tg ;P܂LEcU'8`٤ŵ$C`ͬ/[eh:o+�P-�HS/}Ƞ:c< z?})ݖ}@ v_NZw-P]@ưS S�hK!!^S|[NeJ-kia ЦĪ \e@ @@C/bX6K3zC[tSuE] FNJjIir 7Qb҇@V'-MQ;䀘6?Df;�E*JO*-})k7.qǀyn|k5}hʍ_ < ,.�>m"[;dT |6. xX,�F׀F8X=;8.6ʟ9Wg bC+Vzpl mmVԺڸѶG=f[}}h{B= zߛUbgNWߕ @F #[�y_]).d{(; 1Q�x;'yuߕ`FA!sDQЕ�eEC޹;P;//(Pa, R.}<y1=fBpmF7�<#�|^ ,UKφQSF� a @= :vp )Bc� Ȋ%sEƟ0 2n�umO�Ox%sG(B xΞU }~lO�y9 zV\D;~6 M y@/7k_mnu#"A > |<~; �'\V@�&0d[£@`T k7h+QuO8ׁ[FۑSQEIXڐ$F����IENDB`��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tvsubtitles/module.py������������������������������������������������������������0000664�0000000�0000000�00000003327�12657170273�0020546�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.subtitle import CapSubtitle, LanguageNotSupported from weboob.tools.backend import Module from .browser import TvsubtitlesBrowser, LANGUAGE_LIST from urllib import quote_plus __all__ = ['TvsubtitlesModule'] class TvsubtitlesModule(Module, CapSubtitle): NAME = 'tvsubtitles' MAINTAINER = u'Julien Veyssier' EMAIL = 'julien.veyssier@aiur.fr' VERSION = '1.1' DESCRIPTION = 'Tvsubtitles subtitle website' LICENSE = 'AGPLv3+' BROWSER = TvsubtitlesBrowser def get_subtitle(self, id): return self.browser.get_subtitle(id) def get_subtitle_file(self, id): subtitle = self.browser.get_subtitle(id) if not subtitle: return None return self.browser.openurl(subtitle.url.encode('utf-8')).read() def iter_subtitles(self, language, pattern): if language not in LANGUAGE_LIST: raise LanguageNotSupported() return self.browser.iter_subtitles(language, quote_plus(pattern.encode('utf-8'))) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tvsubtitles/pages.py�������������������������������������������������������������0000664�0000000�0000000�00000011224�12657170273�0020353�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.capabilities.subtitle import Subtitle from weboob.deprecated.browser import Page class HomePage(Page): def iter_subtitles(self, language, pattern): self.browser.select_form(nr=0) self.browser['q'] = pattern.encode('utf-8') self.browser.submit() assert self.browser.is_on_page(SearchPage) for subtitle in self.browser.page.iter_subtitles(language): yield subtitle class SearchPage(Page): """ Page which contains results as a list of series """ def iter_subtitles(self, language): list_result = self.parser.select(self.document.getroot(), 'div.left_articles ul') if len(list_result) > 0: li_result = self.parser.select(list_result[0], 'li') for line in li_result: if len(self.parser.select(line, 'img[alt=%s]' % language)) > 0: link = self.parser.select(line, 'a', 1) href = link.attrib.get('href', '') self.browser.location("http://%s%s" % (self.browser.DOMAIN, href)) assert self.browser.is_on_page(SeriePage) for subtitle in self.browser.page.iter_subtitles(language): yield subtitle class SeriePage(Page): """ Page of all seasons """ def iter_subtitles(self, language, only_one_season=False): # handle the current season last_table_line = self.parser.select(self.document.getroot(), 'table#table5 tr')[-1] amount = int(self.parser.select(last_table_line, 'td')[2].text_content()) if amount > 0: my_lang_img = self.parser.select(last_table_line, 'img[alt=%s]' % language) if len(my_lang_img) > 0: url_current_season = self.browser.geturl().split('/')[-1].replace( 'tvshow', 'subtitle').replace('.html', '-%s.html' % language) self.browser.location(url_current_season) assert self.browser.is_on_page(SeasonPage) yield self.browser.page.iter_subtitles() if not only_one_season: # handle the other seasons by following top links other_seasons_links = self.parser.select(self.document.getroot(), 'p.description a') for link in other_seasons_links: href = link.attrib.get('href', '') self.browser.location("http://%s/%s" % (self.browser.DOMAIN, href)) assert self.browser.is_on_page(SeriePage) for subtitle in self.browser.page.iter_subtitles(language, True): yield subtitle class SeasonPage(Page): """ Page of a season with the right language """ def get_subtitle(self): filename_line = self.parser.select(self.document.getroot(), 'img[alt=filename]', 1).getparent().getparent() name = unicode(self.parser.select(filename_line, 'td')[2].text) id = self.browser.geturl().split('/')[-1].replace('.html', '').replace('subtitle-', '') url = unicode('http://%s/download-%s.html' % (self.browser.DOMAIN, id)) amount_line = self.parser.select(self.document.getroot(), 'tr[title~=amount]', 1) nb_cd = int(self.parser.select(amount_line, 'td')[2].text) lang = unicode(url.split('-')[-1].split('.html')[0]) filenames_line = self.parser.select(self.document.getroot(), 'tr[title~=list]', 1) file_names = self.parser.select(filenames_line, 'td')[2].text_content().strip().replace('.srt', '.srt\n') desc = u"files :\n" desc += file_names m = re.match('(.*?)\.(\w+)$', name) if m: name = m.group(1) ext = m.group(2) else: ext = 'zip' subtitle = Subtitle(id, name) subtitle.url = url subtitle.ext = ext subtitle.language = lang subtitle.nb_cd = nb_cd subtitle.description = desc return subtitle def iter_subtitles(self): return self.get_subtitle() ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/tvsubtitles/test.py��������������������������������������������������������������0000664�0000000�0000000�00000002717�12657170273�0020242�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from random import choice class TvsubtitlesTest(BackendTest): MODULE = 'tvsubtitles' def test_subtitle(self): subtitles = list(self.backend.iter_subtitles('fr', 'sopranos')) assert (len(subtitles) > 0) for subtitle in subtitles: assert subtitle.url.startswith('http') # get the file of a random sub if len(subtitles): subtitle = choice(subtitles) self.backend.get_subtitle_file(subtitle.id) def test_get_subtitle(self): subtitles = list(self.backend.iter_subtitles('fr', 'sopranos')) assert (len(subtitles) > 0) subtitle = choice(subtitles) assert self.backend.get_subtitle(subtitle.id) �������������������������������������������������weboob-1.1/modules/twitter/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016014�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/twitter/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001434�12657170273�0020127�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import TwitterModule __all__ = ['TwitterModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/twitter/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000011534�12657170273�0020055�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword from weboob.capabilities.messages import Message from .pages import LoginPage, LoginErrorPage, ThreadPage, Tweet, TrendsPage,\ TimelinePage, HomeTimelinePage, SearchTimelinePage, SearchPage __all__ = ['TwitterBrowser'] class TwitterBrowser(LoginBrowser): BASEURL = 'https://twitter.com/' authenticity_token = None thread_page = URL(u'(?P<user>.+)/status/(?P<_id>.+)', ThreadPage) login_error = URL(u'login/error.+', LoginErrorPage) tweet = URL(u'i/tweet/create', Tweet) trends = URL(u'i/trends\?pc=true&show_context=false&src=search-home&k=(?P<token>.*)', TrendsPage) search = URL(u'i/search/timeline', SearchTimelinePage) search_page = URL(u'search\?q=(?P<pattern>.+)&src=sprv', u'search-home', SearchPage) profil = URL(u'i/profiles/show/(?P<path>.+)/timeline/with_replies', HomeTimelinePage) timeline = URL(u'i/timeline', TimelinePage) login = URL(u'', LoginPage) def do_login(self): self.login.stay_or_go() if not self.authenticity_token: self.authenticity_token = self.page.login(self.username, self.password) if not self.page.logged or self.login_error.is_here(): raise BrowserIncorrectPassword() @need_login def get_me(self): return self.login.stay_or_go().get_me() @need_login def iter_threads(self): return self.timeline.go().iter_threads() def get_trendy_subjects(self): if self.username: return self.get_logged_trendy_subject() else: return self.trends.open(token="").get_trendy_subjects() def get_logged_trendy_subject(self): if not self.authenticity_token: self.do_login() trends_token = self.search_page.open().get_trends_token() return self.trends.open(token=trends_token).get_trendy_subjects() @need_login def post(self, thread, message): datas = {'place_id': '', 'tagged_users': ''} datas['authenticity_token'] = self.authenticity_token datas['status'] = message if thread: datas['in_reply_to_status_id'] = thread.id.split('#')[-1] self.tweet.open(data=datas) def get_thread(self, _id, thread=None, seen=None): splitted_id = _id.split('#') if not thread: thread = self.thread_page.go(_id=splitted_id[1].split('.')[-1], user=splitted_id[0]).get_thread(obj=thread) title_content = thread.title.split('\n\t')[-1] thread.root = Message(thread=thread, id=splitted_id[1].split('.')[-1], title=title_content[:50] if len(title_content) > 50 else title_content, sender=splitted_id[0], receivers=None, date=thread.date, parent=thread.root, content=title_content, signature=u'', children=[] ) if seen and (_id not in seen): thread.root.flags = Message.IS_UNREAD comments = self.thread_page.stay_or_go(_id=splitted_id[1].split('.')[-1], user=splitted_id[0]).iter_comments() for comment in comments: comment.thread = thread comment.parent = thread.root if seen and comment.id not in seen.keys(): comment.flags = Message.IS_UNREAD thread.root.children.append(comment) return thread def get_tweets_from_profil(self, path): return self.profil.go(path=path).iter_threads() def get_tweets_from_hashtag(self, path): return self.get_tweets_from_search(u'#%s' % path if not path.startswith('#') else path) def get_tweets_from_search(self, path): min_position = self.search_page.go(pattern=path).get_min_position() params = {'q': "%s" % path, 'src': 'sprv'} return self.search.go(params=params).iter_threads(params=params, min_position=min_position) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/twitter/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000015457�12657170273�0020163�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sBIT|d��� pHYs����+��IDATxy]UgX!UJBB(b Ԁ(' ؾ'`-(( abHU$dPsy89y/ *xqϾwZ{<E�| |?�>nzVއ[;٧ĎXW�ia;ͲQ0z}_dժUfT]"DUa+V048¦7ߤSO=Gwb bw۾mZ93*[aww7</| i:;;ykغu+VxW|Yfa5\&;7o[(2*&xG|�Ew_:BѪ8n47tx衇HVu׌j)]bB1#fE/"7p/ϯʽK&aӖ<S,\ JY6Hq([oŖ͛ho_fddիWsĮ]Xf wy'Lq"5-I)UtZZ߹lULE!x?_dOmvDA  p-uG L&b̝; /DUD",˘ל xqvɌ'vRK_bɒ%c1L4 t]'RTH&tuK%:t.dYfq%PPOJQ<? �GeŊ}=5 e_r7K#?8N(~0Mx2d;G]B2Esֆ88C8�G ~WWk�bY_Ï︓TLh&UCGk+aPUfΜSQ>!KSS[OoUϿB{M3zۼK\uU_K L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E4FQ5c.|p8H*&"LA`ekW\Y^|UnV~ς3`^;TWn(8D+,Y-SL&J10MH(W,jjH &Oi!_KAAp5"(8].R"&,JFxsmt]R) sBf͚E˄ LAs*FE+s9 \Y}"[o  hllih4Sr!$i,K}RD&3J!T*Q*(mضM<GeGaGdla[kYpƧ8oхȊ_0@>Ǵ-C ࣬k}a Z06#"Dueyl׸Ra1i$g]'acㆆuuu 4a,RL&o'x"g-@4r �4}%,4 ʺ$Il߹rH8%RSS8_1a<~G6%˰`f3(Jiعs'he˖a܌iAl0 \EE$I"^~.X~BL$Cį&ikk#_*cv iooCp%\ץtCgU7֭Ư],Ice.Ǥn6ar7qL2\&KG/eUW#8& <95_JY#(覃 XE8C,E\.S|x `[H@MmT"Ah<$>1(zUF1)Gb be O vlD,~r‡gcDY;KD#rZ[[`cㅫ|HH0dP{p8aHʻoub̛7R6;>OH)r"eӳvuɿ; k% zNɇ7`mc{.4^K> p==*}  3jAV}Hoxsq#H(edFߣvWWMg8}iWPͮ8p�A&Me„q#`T Nvp6۶l"1q"ZZ4MBgŬXO?.B; fedئc{Ȳ*8K$KԌ /":{%K:oLcS=H"bX ;DG*Bꠊ4MlA@D(:(I3gY/_ߏ(puh�.c$EA?�'a``ry99N>qfChÏv ouv˹>.P(D>ŶM0@�P;U"y�OESz=����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/twitter/module.py����������������������������������������������������������������0000664�0000000�0000000�00000017526�12657170273�0017666�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import datetime, timedelta from weboob.tools.value import Value, ValueBackendPassword from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.messages import CapMessages, Thread, CapMessagesPost from weboob.capabilities.collection import CapCollection, CollectionNotFound, Collection from weboob.capabilities.base import find_object from weboob.exceptions import BrowserForbidden from .browser import TwitterBrowser import itertools __all__ = ['TwitterModule'] class TwitterModule(Module, CapMessages, CapMessagesPost, CapCollection): NAME = 'twitter' DESCRIPTION = u'twitter website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = TwitterBrowser STORAGE = {'seen': {}} CONFIG = BackendConfig(Value('username', label='Username', default=''), ValueBackendPassword('password', label='Password', default=''), Value('hashtags_subscribe', label='Hashtags subscribe', default=''), Value('search_subscribe', label='Search subscribe', default=''), Value('profils_subscribe', label='Profils subscribe', default='')) def create_default_browser(self): username = self.config['username'].get() if username: password = self.config['password'].get() else: password = None return self.create_browser(username, password) def iter_threads(self): if self.config['username'].get(): return self.browser.iter_threads() else: profils = self.config['profils_subscribe'].get() hashtags = self.config['hashtags_subscribe'].get() searchs = self.config['search_subscribe'].get() tweets = [] if profils: for profil in profils.split(','): for tweet in itertools.islice(self.browser.get_tweets_from_profil(profil), 0, 20): tweets.append(tweet) if hashtags: for hashtag in hashtags.split(','): for tweet in itertools.islice(self.browser.get_tweets_from_hashtag(hashtag), 0, 20): tweets.append(tweet) if searchs: for search in searchs.split(','): for tweet in itertools.islice(self.browser.get_tweets_from_search(search), 0, 20): tweets.append(tweet) tweets.sort(key=lambda o: o.date, reverse=True) return tweets def get_thread(self, _id, thread=None, getseen=True): seen = None if getseen: seen = self.storage.get('seen', default={}) return self.browser.get_thread(_id, thread, seen) def fill_thread(self, thread, fields, getseen=True): return self.get_thread(thread.id, thread, getseen) def set_message_read(self, message): self.storage.set('seen', message.thread.id, message.thread.date) self.storage.save() self._purge_message_read() def _purge_message_read(self): lastpurge = self.storage.get('lastpurge', default=datetime.now() - timedelta(days=60)) if datetime.now() - lastpurge > timedelta(days=60): self.storage.set('lastpurge', datetime.now() - timedelta(days=60)) self.storage.save() # we can't directly delete without a "RuntimeError: dictionary changed size during iteration" todelete = [] for id, date in self.storage.get('seen', default={}).iteritems(): # if no date available, create a new one (compatibility with "old" storage) if not date: self.storage.set('seen', id, datetime.now()) elif lastpurge > date: todelete.append(id) for id in todelete: self.storage.delete('seen', id) self.storage.save() def post_message(self, message): if not self.config['username'].get(): raise BrowserForbidden() self.browser.post(find_object(self.iter_threads(), id=message.full_id.split('.')[0]), message.content) def iter_resources(self, objs, split_path): collection = self.get_collection(objs, split_path) if collection.path_level == 0: if self.config['username'].get(): yield Collection([u'me'], u'me') yield Collection([u'profils'], u'profils') yield Collection([u'trendy'], u'trendy') yield Collection([u'hashtags'], u'hashtags') yield Collection([u'search'], u'search') if collection.path_level == 1: if collection.split_path[0] == u'me': for el in self.browser.get_tweets_from_profil(self.browser.get_me()): yield el if collection.split_path[0] == u'profils': profils = self.config['profils_subscribe'].get() if profils: for profil in profils.split(','): yield Collection([profil], profil) if collection.split_path[0] == u'hashtags': hashtags = self.config['hashtags_subscribe'].get() if hashtags: for hashtag in hashtags.split(','): yield Collection([hashtag], hashtag) if collection.split_path[0] == u'search': searchs = self.config['search_subscribe'].get() if searchs: for search in searchs.split(','): yield Collection([search], search) if collection.split_path[0] == u'trendy': for obj in self.browser.get_trendy_subjects(): yield Collection([obj.id], obj.id) if collection.path_level == 2: if collection.split_path[0] == u'profils': for el in self.browser.get_tweets_from_profil(collection.split_path[1]): yield el if collection.split_path[0] == u'trendy': if collection.split_path[1].startswith('#'): for el in self.browser.get_tweets_from_hashtag(collection.split_path[1]): yield el else: for el in self.browser.get_tweets_from_search(collection.split_path[1]): yield el if collection.split_path[0] == u'hashtags': for el in self.browser.get_tweets_from_hashtag(collection.split_path[1]): yield el if collection.split_path[0] == u'search': for el in self.browser.get_tweets_from_search(collection.split_path[1]): yield el def validate_collection(self, objs, collection): if collection.path_level == 0: return if collection.path_level == 1 and collection.split_path[0] in [u'profils', u'trendy', u'me', u'hashtags', u'search']: return if collection.path_level == 2: return raise CollectionNotFound(collection.split_path) OBJECTS = {Thread: fill_thread} ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/twitter/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000017153�12657170273�0017474�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from datetime import datetime from weboob.tools.date import DATE_TRANSLATE_FR from io import StringIO import lxml.html as html import urllib from weboob.tools.json import json from weboob.browser.pages import HTMLPage, JsonPage, FormNotFound, pagination, LoggedPage from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, Format, Regexp, Env, DateTime, Filter from weboob.browser.filters.html import Link, Attr from weboob.capabilities.messages import Thread, Message from weboob.capabilities.base import BaseObject class DatetimeFromTimestamp(Filter): def filter(self, el): return datetime.fromtimestamp(float(el)) class TwitterJsonHTMLPage(JsonPage): ENCODING = None has_next = None scroll_cursor = None def __init__(self, browser, response, *args, **kwargs): super(TwitterJsonHTMLPage, self).__init__(browser, response, *args, **kwargs) self.encoding = self.ENCODING or response.encoding parser = html.HTMLParser(encoding=self.encoding) if 'module_html' in self.doc: self.doc = html.parse(StringIO(self.doc['module_html']), parser) else: self.has_next = self.doc['has_more_items'] self.min_position = None if 'min_position' in self.doc: self.min_position = self.doc['min_position'] if self.doc['items_html']: el = html.parse(StringIO(self.doc['items_html']), parser) self.doc = el if el.getroot() is not None else html.Element('brinbrin') else: self.doc = html.Element('brinbrin') class LoginPage(HTMLPage): def login(self, login, passwd): try: form = self.get_form(xpath='//form[@action="https://twitter.com/sessions"]') form['session[username_or_email]'] = login form['session[password]'] = passwd form.submit() return form['authenticity_token'] except FormNotFound: return CleanText('(//input[@id="authenticity_token"])[1]/@value')(self.doc) @property def logged(self): try: self.get_form(xpath='//form[@action="https://twitter.com/sessions"]') return False except FormNotFound: return True def get_me(self): return Regexp(Link('//a[@data-nav="view_profile"]'), '/(.+)')(self.doc) class ThreadPage(HTMLPage): @method class get_thread(ItemElement): klass = Thread obj_id = Format('%s#%s', Env('user'), Env('_id')) obj_title = Format('%s \n\t %s', CleanText('//div[@class="permalink-inner permalink-tweet-container"]/div/div/div/a', replace=[('@ ', '@'), ('# ', '#'), ('http:// ', 'http://')]), CleanText('//div[@class="permalink-inner permalink-tweet-container"]/div/p', replace=[('@ ', '@'), ('# ', '#'), ('http:// ', 'http://')])) obj_date = DateTime(Regexp(CleanText('//div[@class="permalink-inner permalink-tweet-container"]/div/div/div[@class="client-and-actions"]/span/span'), '(\d+:\d+).+- (.+\d{4})', '\\2 \\1'), translations=DATE_TRANSLATE_FR) @method class iter_comments(ListElement): item_xpath = '//ol[@id="stream-items-id"]/li/ol/div/li/div' class item(ItemElement): klass = Message obj_id = Regexp(Link('./div/div/small/a', default=''), '/.+/status/(.+)', default=None) obj_title = Regexp(CleanText('./div/p', replace=[('@ ', '@'), ('# ', '#'), ('http:// ', 'http://')]), '(.{50}|.+).+') obj_content = CleanText('./div/p', replace=[('@ ', '@'), ('# ', '#'), ('http:// ', 'http://')]) obj_sender = Regexp(Link('./div/div/small/a', default=''), '/(.+)/status/.+', default=None) obj_date = DatetimeFromTimestamp(Attr('./div/div[@class="stream-item-header"]/small/a/span | ./div/div[@class="ProfileTweet-authorDetails"]/span/a/span', 'data-time')) def validate(self, obj): return obj.id is not None class SearchPage(HTMLPage): def get_trends_token(self): json_data = CleanText('//input[@id="init-data"]/@value')(self.doc) return json.loads(json_data)['trendsCacheKey'] def get_min_position(self): return CleanText('//div[@class="stream-container "]/@data-min-position')(self.doc) class TrendsPage(TwitterJsonHTMLPage): @method class get_trendy_subjects(ListElement): item_xpath = '//li[@class="trend-item js-trend-item "]' class item(ItemElement): klass = BaseObject obj_id = Attr('.', 'data-trend-name') class TimelineListElement(ListElement): item_xpath = '//*[@data-item-type="tweet"]/div[@data-tweet-id]' ignore_duplicate = True def get_last_id(self): _el = self.page.doc.xpath('//*[@data-item-type="tweet"]/div')[-1] return CleanText('./@data-tweet-id')(_el) class item(ItemElement): klass = Thread obj_id = Format('%s#%s', CleanText('./@data-screen-name'), CleanText('./@data-tweet-id')) obj_title = Format('%s \n\t %s', CleanText('./div/div[@class="stream-item-header"]/a|./div/div[@class="ProfileTweet-authorDetails"]/a', replace=[('@ ', '@'), ('# ', '#'), ('http:// ', 'http://')]), CleanText('./div/p', replace=[('@ ', '@'), ('# ', '#'), ('http:// ', 'http://')])) obj_date = DatetimeFromTimestamp(Attr('./div/div[@class="stream-item-header"]/small/a/span | ./div/div[@class="ProfileTweet-authorDetails"]/span/a/span', 'data-time')) class TimelinePage(TwitterJsonHTMLPage): @pagination @method class iter_threads(TimelineListElement): def next_page(self): if self.page.has_next: return u'%s?max_position=%s' % (self.page.url.split('?')[0], self.get_last_id()) class HomeTimelinePage(TwitterJsonHTMLPage, LoggedPage): @pagination @method class iter_threads(TimelineListElement): def next_page(self): if self.page.has_next: return u'%s?max_id=%s' % (self.page.url.split('?')[0], self.get_last_id()) class SearchTimelinePage(TwitterJsonHTMLPage): @pagination @method class iter_threads(TimelineListElement): def next_page(self): params = self.env['params'] params['max_position'] = self.page.min_position if 'min_position' in self.env and not params['max_position']: params['max_position'] = self.env['min_position'] if self.page.has_next: return u'%s?%s' % (self.page.url.split('?')[0], urllib.urlencode(params)) class LoginErrorPage(HTMLPage): pass class Tweet(JsonPage): pass ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/twitter/test.py������������������������������������������������������������������0000664�0000000�0000000�00000005572�12657170273�0017356�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import itertools from weboob.capabilities.base import BaseObject from weboob.tools.test import BackendTest, SkipTest class TwitterTest(BackendTest): MODULE = 'twitter' def test_twitter_logged(self): if self.backend.browser.username: assert(self.backend.browser.get_me()) else: raise SkipTest("User credentials not defined") def test_twitter_list(self): if self.backend.browser.username: l = list(itertools.islice(self.backend.iter_threads(), 0, 20)) assert len(l) thread = self.backend.get_thread(l[0].id) assert len(thread.root.content) else: raise SkipTest("User credentials not defined") def test_ls_me(self): if self.backend.browser.username: l = list(itertools.islice(self.backend.iter_resources([BaseObject], ['me']), 0, 20)) assert len(l) thread = self.backend.get_thread(l[0].id) assert len(thread.root.content) else: raise SkipTest("User credentials not defined") def test_ls_search(self): l = list(itertools.islice(self.backend.iter_resources([BaseObject], ['search', 'weboob']), 0, 20)) assert len(l) thread = self.backend.get_thread(l[0].id) assert len(thread.root.content) def test_ls_hashtag(self): l = list(itertools.islice(self.backend.iter_resources([BaseObject], ['hashtags', 'weboob']), 0, 20)) assert len(l) thread = self.backend.get_thread(l[0].id) assert len(thread.root.content) def test_ls_profils(self): l = list(itertools.islice(self.backend.iter_resources([BaseObject], ['profils', 'jf_cope']), 0, 20)) assert len(l) thread = self.backend.get_thread(l[0].id) assert len(thread.root.content) def test_ls_trend(self): l = list(self.backend.iter_resources([BaseObject], ['trendy'])) assert len(l) l1 = list(itertools.islice(self.backend.iter_resources([BaseObject], ['trendy', u'%s' % l[0].split_path[0]]), 0, 20)) assert len(l1) thread = self.backend.get_thread(l1[0].id) assert len(thread.root.content) ��������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/unsee/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015431�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/unsee/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000001430�12657170273�0017540�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import UnseeModule __all__ = ['UnseeModule'] ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/unsee/browser.py�����������������������������������������������������������������0000664�0000000�0000000�00000006141�12657170273�0017470�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser import os from uuid import uuid4 from urllib2 import Request from urlparse import urljoin from weboob.tools.json import json from weboob.deprecated.browser.parsers.lxmlparser import LxmlHtmlParser __all__ = ['UnseeBrowser'] def to_bytes(s): if isinstance(s, unicode): return s.encode('utf-8') else: return s class FileField(object): def __init__(self, filename, contents=None, headers=None): self.filename = to_bytes(os.path.basename(filename)) self.headers = headers or {} if contents is not None: self.contents = contents else: self.contents = open(filename).read() class UnseeBrowser(Browser): PROTOCOL = 'https' DOMAIN = 'unsee.cc' ENCODING = 'utf-8' def _make_boundary(self): return '==%s==' % uuid4() def _make_multipart(self, pairs, boundary): s = [] for k, v in pairs: s.append('--%s' % boundary) if isinstance(v, FileField): s.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (k, v.filename)) for hk, hv in v.headers.items(): s.append('%s: %s' % (hk, hv)) v = v.contents else: s.append('Content-Disposition: form-data; name="%s"' % k) s.append('') s.append(to_bytes(v)) s.append('--%s--' % boundary) s.append('') return '\r\n'.join(s) def _multipart(self, url, fields): b = self._make_boundary() data = self._make_multipart(fields, b) headers = {'Content-type': 'multipart/form-data; boundary=%s' % b, 'Content-length': len(data)} return Request(url, data=self._make_multipart(fields, b), headers=headers) def post_image(self, name, contents, time): # time='first' for one-shot view params = [('time', time), ('image[]', FileField(name or '-', contents))] request = self._multipart('https://unsee.cc/upload/', params) d = json.loads(self.readurl(request)) return {'id': d['hash']} def get_image(self, id): doc = self.get_document(self.openurl('https://unsee.cc/%s/' % id)) images = LxmlHtmlParser.select(doc, '//img/@src[starts-with(., "/image/")]', method='xpath') url = urljoin('https://unsee.cc', images[0]) return self.readurl(url) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/unsee/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000000743�12657170273�0017570�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME�I���tEXtComment�Created with GIMPW��KIDATxK C'&C-;2'%!B!~SE5_av< p"+�x E!F`z='NL( * BKX;|F^PڮỦyàR"l44nDȓ[TP怴9}*}tsnIQNxDjUk-@X""RxeɍU;=G鋴y5EwM11$d@<u eFTg!財(pk5A8�[c|Addd I!B!B|ǀ&_8����IENDB`�����������������������������weboob-1.1/modules/unsee/module.py������������������������������������������������������������������0000664�0000000�0000000�00000004636�12657170273�0017301�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.paste import BasePaste from weboob.tools.capabilities.paste import BasePasteModule from weboob.tools.capabilities.paste import image_mime from weboob.deprecated.browser.decorators import check_url import re from .browser import UnseeBrowser __all__ = ['UnseeModule'] class UnPaste(BasePaste): @classmethod def id2url(cls, id): return 'https://unsee.cc/%s' % id class UnseeModule(Module, BasePasteModule): NAME = 'unsee' DESCRIPTION = u'unsee.cc expiring image hosting' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = UnseeBrowser EXPIRATIONS = {3600: 'hour', 86400: 'day', 86400 * 7: 'week'} def can_post(self, contents, title=None, public=None, max_age=None): if re.search(r'[^a-zA-Z0-9=+/\s]', contents): return 0 elif max_age is not None and not self.get_closest_expiration(max_age): return 0 else: mime = image_mime(contents, ('gif', 'jpeg', 'png')) return 20 * int(mime is not None) @check_url('https?://unsee.cc/.+') def get_paste(self, id): paste = UnPaste(id) paste.contents = self.browser.get_image(id).encode('base64') return paste def new_paste(self, *a, **kw): return UnPaste(*a, **kw) def post_paste(self, paste, max_age=None): if max_age is None: max_code = 'week' else: max_code = self.EXPIRATIONS[self.get_closest_expiration(max_age)] d = self.browser.post_image(paste.title, paste.contents.decode('base64'), max_code) paste.id = d['id'] return paste ��������������������������������������������������������������������������������������������������weboob-1.1/modules/unsee/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000002544�12657170273�0016767�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Vincent A # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class UnseeTest(BackendTest): MODULE = 'unsee' # small gif file DATA = 'R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==\n' def test_unsee(self): assert self.backend.can_post(self.DATA, max_age=3600) post = self.backend.new_paste(None) post.contents = self.DATA post = self.backend.post_paste(post, max_age=3600) assert post.id got = self.backend.get_paste(post.id) assert got assert got.contents.decode('base64').startswith('GIF89a') # we can't check the exact data, unsee.cc modifies the images... ������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ups/�����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015121�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ups/__init__.py������������������������������������������������������������������0000664�0000000�0000000�00000001424�12657170273�0017233�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import UpsModule __all__ = ['UpsModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ups/browser.py�������������������������������������������������������������������0000664�0000000�0000000�00000002756�12657170273�0017170�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.deprecated.browser import Browser from .pages import TrackPage __all__ = ['UpsBrowser'] class UpsBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'wwwapps.ups.com' ENCODING = None PAGES = { 'http://wwwapps.ups.com/WebTracking/track': TrackPage, } def get_tracking_info(self, _id): data = {'HTMLVersion': '5.0', 'USER_HISTORY_LIST': '', 'loc': 'en_US', 'track.x': 'Track', 'trackNums': _id.encode('utf-8'), } self.location('http://wwwapps.ups.com/WebTracking/track', urllib.urlencode(data)) assert self.is_on_page(TrackPage) return self.page.get_info(_id) ������������������weboob-1.1/modules/ups/favicon.png������������������������������������������������������������������0000664�0000000�0000000�00000012444�12657170273�0017261�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq��IDATx՛y]W}?s[zoւeY-kbYm�6! bLJ0IH2Ibec8LX,’ZjR{?}{- U3W=w�,>/}� 1Q1V5b,*c#XcFA4Q #!x4{T=Z~v�>'!KCB <w >-誷>管ߧ'".Han!ւ:{Xc-bUlN R�$@5 -&/�!EԻpXWua`�Wb"^1EE$kXLtPc1ƀ2�j @e%�J�<A=Z 'NڮC KA )C/O}0�m#J]Q_JݣJUOo%MeE[/5Www-�*+%k2D"z'Aڄ YQ%bڼ-]$UH�o?T`!0(H~"%VPDjtڄAT E%bT5(+bEmm=olNU6N%&iݮ-A .8P%J+m#ZV%HIPo,ӕ4\\kJ:EC2w*Ky!jT_~IDH,@d >03=gG8wvR, !EΟenn=>(k:0K̟'!y=bԂǎ+<8HA/o̭{הe(c\,ع)NO099ωr(B<p!9gDMLLJ`=wx} ڸRxp'v> �<�S30=QmBGDGdRRB2 Q&&zJk \4b₯#c&& XLrHo ڀUA) B0`"FR- ҙȚjE`r?:x(sEO(^obT|=[5Y J5ZbD͌p4_!FF1`ڈ(2DIFhii|즔4Z65-�HV7tV,Oz~QMv-ۑ|.Hs.}9h#4CR[�@hLdYXt;y~p?{l6C&cwҪvZeb&JܺP2|CϜSB.ELժe b[м6H{k&.%/F>ЩI2/3e3OK@5V j\֔@jظzBc˸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kc֮;=.?瀱4oFoOGrZCWKc6 *Pj?:)%n*VwO �&Ə?,gٽk΅'Wn<ݥQZZX}6Vcm)G�#r/_ '$ ܳkLӼ,PohRdٷ{5%Oﻒ"{ ^nܷcLUġœѼ#M|1xI{ְqm!$ST{AZ³Rw`Dkٲ!e>Vr9Y/]b|L ?u> 5;[R'0T vljR ѕsrPaGVش=zq.G s㟻fi��?>p\RO}\w*dI'}˲*,ki8޴9I&.]})�d_Af+rovkovFUQ[ts-@R+m}/!vAVѥx%@0A/ĀMk^wUR+rv/}M|Wc)?:~��?A;njO{*{.پ;6]`^kENu;b6"Z:7��$v} ! ӹ|^qVWqa|nsK3MBPeS;wy'o>[G&'?rV  swd6Lfӯ}~@4 ѻ, åu<#M2W\ǞѤ,(?pr%ЛD&(GKvUWTWIvFc>>z/zԢu^�e-;rv㻧{8*dzM\u*,ѮL g#nOq< }g^07.poA8T?cmE2I=ȡ|9NpBVHN$7z/jO{Gw񪽛(h.=W^Cmiʟp3e##bEѠdnbOq<$FSb\^@�uc_!6mtwXw sW|gğ"f[7jeH6kCe9|:5(wKs@r E:2-lKGβ'C.^Q/=疯NL}Vzn�07&7mB/-NwgBbD(K9WfC;w`Ej /̾bx}W~Рf@n.* 1QCChpZrvdoIf-IuvK{[lZK%VWUһ_Tt~^� L~J߽҅GѠjz*\L9&=+WU&1U_<̷ϿL�go?rZUjkV�|֗oIz^z}zモ_܋^_pȆ4nJ&?ވBթ?wS¢3@N81w7Q tZ.��6+y?Ɍjؤ:%xI/U5 K @b :Q�gگ=_ sݒ'����IENDB`����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ups/module.py��������������������������������������������������������������������0000664�0000000�0000000�00000002265�12657170273�0016765�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.parcel import CapParcel from weboob.tools.backend import Module from .browser import UpsBrowser __all__ = ['UpsModule'] class UpsModule(Module, CapParcel): NAME = 'ups' DESCRIPTION = u'UPS website' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' BROWSER = UpsBrowser def get_parcel_tracking(self, id): with self.browser: return self.browser.get_tracking_info(id) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ups/pages.py���������������������������������������������������������������������0000664�0000000�0000000�00000004241�12657170273�0016573�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from dateutil.parser import parse as parse_date from weboob.capabilities.parcel import Parcel, Event from weboob.deprecated.browser import Page class TrackPage(Page): def get_info(self, id): if len(self.parser.tocleanstring(self.document.xpath('//p[@class="error"]')[0])) > 0: return None p = Parcel(id) for dl in self.document.xpath('//dl'): dt = dl.find('dt') dd = dl.find('dd') if dt is None or dd is None: continue label = self.parser.tocleanstring(dt) if label == 'Scheduled Delivery:': p.status = p.STATUS_IN_TRANSIT elif label == u'Delivered On:': p.status = p.STATUS_ARRIVED else: continue m = re.search('(\d+/\d+/\d+)', dd.text) if m: p.arrival = parse_date(m.group(1)) p.history = [] for i, tr in enumerate(self.document.xpath('//table[@class="dataTable"]//tr')): tds = tr.findall('td') if len(tds) < 4: continue ev = Event(i) ev.location = self.parser.tocleanstring(tds[0]) ev.activity = self.parser.tocleanstring(tds[-1]) ev.date = parse_date('%s %s' % (tds[1].text, tds[2].text)) p.history.append(ev) p.info = self.document.xpath('//a[@id="tt_spStatus"]')[0].text.strip() return p ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/ups/test.py����������������������������������������������������������������������0000664�0000000�0000000�00000001570�12657170273�0016455�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class UpsTest(BackendTest): MODULE = 'ups' def test_ups(self): raise NotImplementedError() ����������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicsec/��������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015566�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicsec/__init__.py���������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0017676�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import VicSecModule __all__ = ['VicSecModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicsec/browser.py����������������������������������������������������������������0000664�0000000�0000000�00000016015�12657170273�0017626�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.browser import LoginBrowser, URL, need_login from weboob.browser.pages import HTMLPage from weboob.capabilities.base import Currency from weboob.capabilities.shop import OrderNotFound, Order, Item, Payment from weboob.exceptions import BrowserIncorrectPassword from datetime import datetime from decimal import Decimal from itertools import chain import re __all__ = ['VicSec'] class VicSecPage(HTMLPage): @property def logged(self): return bool(self.doc.xpath( '//a[@href="https://www.victoriassecret.com/account/profile"]')) class LoginPage(VicSecPage): def login(self, email, password): form = self.get_form(name='accountLogonForm') form['j_username'] = email form['j_password'] = password form.submit() class HistoryPage(VicSecPage): def iter_orders(self): return [onum for date, onum in sorted( chain(self.orders(), self.returns()), reverse=True)] def orders(self): for tr in self.doc.xpath('//table[@class="order-status"]/tbody[1]/tr'): date = datetime.strptime(tr.xpath('td[1]/text()')[0], '%m/%d/%Y') num = tr.xpath('td[2]/a/text()')[0] status = tr.xpath('td[4]/span/text()')[0] if status == u'Delivered': yield date, num def returns(self): for tr in self.doc.xpath('//table[@class="order-status"]/tbody[3]/tr'): num = tr.xpath('td[1]/a/text()')[0] date = datetime.strptime(tr.xpath('td[2]/text()')[0], '%m/%d/%Y') status = tr.xpath('td[4]/span/text()')[0] if status == u'Complete': yield date, num class OrderPage(VicSecPage): def order(self): order = Order(id=self.order_number()) order.date = self.order_date() order.tax = self.tax() order.discount = self.discount() order.shipping = self.shipping() return order def payments(self): for tr in self.doc.xpath('//tbody[@class="payment-summary"]' '//th[text()="Payment Summary"]/../../../tbody/tr'): method = tr.xpath('td[1]/text()')[0] amnode = tr.xpath('td[2]')[0] amsign = -1 if amnode.xpath('em') else 1 amount = amnode.text_content().strip() pmt = Payment() pmt.date = self.order_date() pmt.method = unicode(method) pmt.amount = amsign * AmTr.decimal_amount(amount) yield pmt def items(self): for tr in self.doc.xpath('//tbody[@class="order-items"]/tr'): label = tr.xpath('*//h1')[0].text_content() price = AmTr.decimal_amount(re.match(r'^\s*([^\s]+)(\s+.*)?', tr.xpath('*//div[@class="price"]')[0].text_content(), re.DOTALL).group(1)) url = 'http:' + tr.xpath('*//img/@src')[0] item = Item() item.label = unicode(label) item.url = unicode(url) item.price = price yield item def is_void(self): return not self.doc.xpath('//tbody[@class="order-items"]/tr') def order_number(self): return self.order_info(u'Order Number') def order_date(self): return datetime.strptime(self.order_info(u'Order Date'), '%m/%d/%Y') def tax(self): return self.payment_part(u'Sales Tax') def shipping(self): return self.payment_part(u'Shipping & Handling') def order_info(self, which): info = self.doc.xpath('//p[@class="orderinfo details"]' )[0].text_content() return re.match(u'.*%s:\\s+([^\\s]+)\\s'%which,info,re.DOTALL).group(1) def discount(self): # Sometimes subtotal doesn't add up with items. # I saw that "Special Offer" was actually added to the item's price, # instead of being subtracted. Looks like a bug on VS' side. # To compensate for it I'm correcting discount value. dcnt = self.payment_part(u'Special Offer') subt = self.payment_part(u'Merchandise Subtotal') rett = self.payment_part(u'Return Merchandise Total') items = sum(i.price for i in self.items()) return dcnt + subt + rett - items def payment_part(self, which): # The numbers notation on VS is super wierd. # Sometimes negative amounts are represented by <em> element. for node in self.doc.xpath('//tbody[@class="payment-summary"]' '//td[contains(text(),"%s")]/../td[2]' % which): strv = node.text_content().strip() v = Decimal(0) if strv == u'FREE' else AmTr.decimal_amount(strv) return -v if node.xpath('em') and v > 0 else v return Decimal(0) class VicSec(LoginBrowser): BASEURL = 'https://www.victoriassecret.com' login = URL(r'/account/signin/overlay$', LoginPage) history = URL(r'/account/orderhistory$', HistoryPage) order = URL(r'/account/orderdetails\?orderNumber=(?P<order_num>\d+)$', r'/account/orderdetails.*$', OrderPage) unknown = URL(r'/.*$', VicSecPage) def get_currency(self): # Victoria's Secret uses only U.S. dollars. return Currency.get_currency(u'$') def get_order(self, id_): return self.to_order(id_).order() def iter_orders(self): for order in self.to_history().iter_orders(): yield self.to_order(order).order() def iter_payments(self, order): return self.to_order(order.id).payments() def iter_items(self, order): return self.to_order(order.id).items() @need_login def to_history(self): self.history.stay_or_go() assert self.history.is_here() return self.page @need_login def to_order(self, order_num): self.order.stay_or_go(order_num=order_num) assert self.order.is_here(order_num=order_num) if self.page.is_void(): raise OrderNotFound() return self.page def do_login(self): self.session.cookies.clear() # Need to go there two times. Perhaps because of cookies... self.login.go() self.login.go().login(self.username, self.password) self.history.go() if not self.history.is_here(): raise BrowserIncorrectPassword() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicsec/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000003752�12657170273�0017730�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@����.���gAMA�� a��� cHRM��z&���������u0��`��:��pQ<���bKGD�̿���tIME7��IDATXW{PU[1MҦX3ԭf3MrMJM9FQ{IYM\ P): 05 +pIdT8<Γ^kF0SP4sל>k[!F�J!oPXJ*oK��tnRa�Z]xX0eH�-1̿{ Cw27B[`ٿ$djDQ\Nn%`i7~<K>:!JkatBu±+i(l>C`_�G?u.z<98D=L>-PPhn u^@@vD,rr IvDw�4U]cNP,PjN?&4(Gd@=i#�E&6Ս+SA7͗L&PJEĴ)tx~sTPiƒ=#(̠ѵ,OxŢT)q�f־M> r�t�e^̒O}hA;@2e'S돳ߥ a@ ,9('�(xhK{5&`"FClvF�8-'t$!C .y$ &xڈ5L ʄ^`AQ\٤yJ  قVOLŻOGe { *�#ڝBwHvm'*SW7 BǁAwmoWmŵ{9.7,>4Զxrk}l?kyvGNY.<V<WX5^TW#ݍ;Wo'}(aaڀ#rZUzL]#w RwU0G(sϸ ;#4J[^&n4.xy,Y =;{÷'G@Q�ywq GH/;zfא0,8c̦0'rD#XyFw[f"Ŵ8 F:9/_ؔq=wt2o/KJSpF+/i fJ+?oQ; ^*Jo? - sx_9pF!F〺EM*Oz&ҽ5Y#N'49y&s9@󄵞M y-8`ʽZpka p`9ou|RGɤv:[;R/x:wV>L!UkbO`ʴJIV(z57$/LҘVf:ض3) ֲRg) ϔNRb6.Ժ$ϯ�i-"aW3X5/!' ;P,ǜ 7<.'iMçc8 Xz{bڦ,t5DR(ex PtcA]xqh%{Ȝ439+Y 0Cr E҇bZ-bˆ�ËN_HE4-�򤄣ѭ()ȒƏcpp�J(Yk^wFgG6&Bf0 u0�w/3fE)HU*p]lt5̸>-uegnd_ �KuwT �o<E Q?D7���%tEXtdate:create�2015-02-22T22:25:33-06:00e���%tEXtdate:modify�2015-02-22T22:25:33-06:00:����IENDB`����������������������weboob-1.1/modules/vicsec/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000003543�12657170273�0017432�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.shop import CapShop from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import VicSec __all__ = ['VicSecModule'] class VicSecModule(Module, CapShop): NAME = 'vicsec' MAINTAINER = u'Oleg Plakhotniuk' EMAIL = 'olegus8@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Victoria\'s Secret' CONFIG = BackendConfig( ValueBackendPassword('email', label='Username', masked=False), ValueBackendPassword('password', label='Password')) BROWSER = VicSec def create_default_browser(self): return self.create_browser(self.config['email'].get(), self.config['password'].get()) def get_currency(self): return self.browser.get_currency() def get_order(self, id_): return self.browser.get_order(id_) def iter_orders(self): return self.browser.iter_orders() def iter_payments(self, order): return self.browser.iter_payments(order) def iter_items(self, order): return self.browser.iter_items(order) �������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicsec/test.py�������������������������������������������������������������������0000664�0000000�0000000�00000002146�12657170273�0017122�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class VicSecTest(BackendTest): MODULE = 'vicsec' def test_history(self): """ Test that at least one item was ordered in the whole history. """ b = self.backend items = (i for o in b.iter_orders() for i in b.iter_items(o)) item = next(items, None) self.assertNotEqual(item, None) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicseccard/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016420�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicseccard/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000001447�12657170273�0020537�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import VicSecCardModule __all__ = ['VicSecCardModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicseccard/browser.py������������������������������������������������������������0000664�0000000�0000000�00000011211�12657170273�0020451�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from requests.exceptions import Timeout, ConnectionError from weboob.capabilities.bank import AccountNotFound, Account, Transaction from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.browser import LoginBrowser, URL, need_login from weboob.browser.exceptions import ServerError from weboob.browser.pages import HTMLPage from weboob.exceptions import BrowserIncorrectPassword from datetime import datetime __all__ = ['VicSecCard'] class SomePage(HTMLPage): @property def logged(self): return bool(self.doc.xpath(u'//span[text()="Sign Out"]')) class LoginPage(SomePage): def login(self, username, password): form = self.get_form(name='frmLogin') form['username_input'] = username form['userName'] = username form['password_input'] = password form['hiddenPassword'] = password form['btnLogin'] = 'btnLogin' form.submit() class HomePage(SomePage): def account(self): id_ = self.doc.xpath(u'//strong[contains(text(),' '"credit card account ending in")]/text()')[0].strip()[-4:] balance = self.doc.xpath(u'//section[@id=" account_summary"]' '//span[text()="Current Balance"]/../span[2]/text()')[0].strip() cardlimit = self.doc.xpath(u'//span[contains(text(),"Credit limit")]' '/text()')[0].split()[-1] paymin = self.doc.xpath(u'//section[@id=" account_summary"]' '//strong[text()="Minimum Payment Due"]/../../span[2]/text()' )[0].strip() a = Account() a.id = id_ a.label = u'ACCOUNT ENDING IN %s' % id_ a.currency = Account.get_currency(balance) a.balance = -AmTr.decimal_amount(balance) a.type = Account.TYPE_CARD a.cardlimit = AmTr.decimal_amount(cardlimit) a.paymin = AmTr.decimal_amount(paymin) #TODO: Add paydate. #Oleg: I don't have an account with scheduled payment. # Need to wait for a while... return a class RecentPage(SomePage): def iter_transactions(self): for li in self.doc.xpath('//section[@class="transactions"]//div/li'): date = li.xpath('p[@data-type="date"]//text()')[0].strip() label = li.xpath('p[@data-type="description"]//text()')[0].strip() amount = li.xpath('p[@data-type="amount"]//text()')[0].strip() t = Transaction() t.date = datetime.strptime(date, '%m/%d/%Y') t.rdate = datetime.strptime(date, '%m/%d/%Y') t.type = Transaction.TYPE_UNKNOWN t.raw = unicode(label) t.label = unicode(label) t.amount = -AmTr.decimal_amount(amount) yield t class VicSecCard(LoginBrowser): BASEURL = 'https://c.comenity.net' MAX_RETRIES = 10 TIMEOUT = 30.0 login = URL(r'/victoriassecret/$', LoginPage) home = URL(r'/victoriassecret/secure/SecureHome.xhtml', HomePage) recent = URL(r'/victoriassecret/secure/accountactivity/Transactions.xhtml', RecentPage) unknown = URL('.*', SomePage) def get_account(self, id_): a = next(self.iter_accounts()) if (a.id != id_): raise AccountNotFound() return a @need_login def iter_accounts(self): yield self.home.stay_or_go().account() @need_login def iter_history(self, account): for trans in self.recent.stay_or_go().iter_transactions(): yield trans def do_login(self): self.session.cookies.clear() self.login.go().login(self.username, self.password) if not self.page.logged: raise BrowserIncorrectPassword() def location(self, *args, **kwargs): for i in xrange(self.MAX_RETRIES): try: return super(VicSecCard, self).location(*args, **kwargs) except (ServerError, Timeout, ConnectionError) as e: pass raise e ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicseccard/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000036461�12657170273�0020565�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@������gAMA�� a��� cHRM��z&���������u0��`��:��pQ<���bKGD X���tIME,/��<5IDATxգUgιQP)QPP $-@IT)A HIK#)% 'k9{ ܎q\!Z/%/////9<53vozc<u+ȕy]V3etp¯V2 :6\)C_%Fz MXM, ӑ& zYdk aX jcy+;-vPl`glyK&dqFچxf:fO!C rMn ]⺸ʧ*`X@o<d~u.rm-I9) fWYg'Kz*T O@MAju>�1O)OB\lQ>|mzQHTS5'oz=DD?ߓ iw7Gg7\9w-!k.;|C= 9grq'@m7;ޜ qӮ3pj eYj U;SU7z~Z : g # 62"�3K0H7/M~t,gzNioM!wEN~('ɷ?vgK8`qM0!jA2l^0Am0{"#pv#ZM)(+@ Sd ܆E7!9 r>U_~9mL/ :`Fj<a"Ne`& BܠCwӖksP8L[B_4 r[9*%z''L#|k(d佼+xKCl.sÖഉfDA|cva;2xN,Ps <dĮM'#zj?:AL4A1{m H,Z"X+CjVxEe<vA4 Kc`s]c>E t0DR )*iYx(i[XqF, ӱ[j] ;2r=vXdz(vq٧;{# z8ݺ8%'9#`GtB7rd�xMnesSWCtH}1Jp6َ:0$Xs<b[NtiT9ﮇ yԧA4$Tp׃|;ȧu5\kZAڍS҆9 "vDFʼG=+Z9 .@ɂjgN3uuK ދy`ʞ:= I&_^ZWc3 NKJN=gj>@|+= S43Y-Bp5@lo/9@ogME8Kh0 D#,"aU+&֫@5Q^PCM)նAU �^|): 3ρ1V)@SQMֈ7(\| %Pm%X=,a xY[Oۀvvk${; )x [3"H*̎HQ:@#P֮6?- aʂӍb dSL)9RG Jk?ˊ+u{/!H= b HH5!<O B" t_HU0u*lXR02{yt%P;\yDGN)0{ X_>扅 ʅ>vnSNC(' u? ^H�w8ū!) ?h .nR BPfyB@I!m"΋YB,θ4-6;ԁ}6{,8U8Y TeZU&LqQP8ցWCw KL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RDI0ljee5o֞�yw;oB؛xAWm@ CsįfR%$;7@.xg#u~ښ JV^LRvO0#XWA|@֗9m!Xw/ (ag|pgU>\g@Ɲg2l}_Al^q D[*;g8IQC5y֥]w;Ӑ60G|ݝI"Άt~0ueN+g{ 7D[6ߛ.UlzYVj֫9Y* bpğv;;x&*ژ@pfx BRȶAp֚`Prr;Yq˃ʹ1[ȱ)<LE7ulSeOr w;L} 9c@ԏ�kl哏< ;E=]0Ns"pS{sfՏ<VwxbY$GΎh_ du j*C|  ,`+\;[o^�5k/Խ22ƝvEpSʞ bkwZr%~-Ȯx|˅<~Z:}!<$1"}D7?YdH{f3#Ph|ᤀ2x АR@]mYy gUxL歡`եw{z} P@S  |DpMIt1 dʉ%`Ϋb+1䗙,p�bq /'!)Gy_ F0+<HvJ+8 /NG5;C @?JAt5̒Hs7 5'Eb%@}nQ DEHlN�^ vDE֝XLH^hmfKrJf8$?;:v(V܍8qENjt!hYQ-{{Tv!?rK+&@u�g>g-L>)! oHWՁZ^R/_O7B,m LQYw } )^!A<5sP>i/'ol�zw&S*'o [JCng!o/rW@LԻ`."Ò>}PP;{2M u*) ߥ/////G%Q!E���%tEXtdate:create�2015-02-23T12:44:47-06:00N���%tEXtdate:modify�2015-02-23T12:44:47-06:00?S9����IENDB`���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicseccard/module.py�������������������������������������������������������������0000664�0000000�0000000�00000003372�12657170273�0020264�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import CapBank from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import VicSecCard __all__ = ['VicSecCardModule'] class VicSecCardModule(Module, CapBank): NAME = 'vicseccard' MAINTAINER = u'Oleg Plakhotniuk' EMAIL = 'olegus8@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Victoria\'s Secret Angel Card' CONFIG = BackendConfig( ValueBackendPassword('username', label='User name', masked=False), ValueBackendPassword('password', label='Password')) BROWSER = VicSecCard def create_default_browser(self): return self.create_browser(self.config['username'].get(), self.config['password'].get()) def iter_accounts(self): return self.browser.iter_accounts() def get_account(self, id_): return self.browser.get_account(id_) def iter_history(self, account): return self.browser.iter_history(account) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vicseccard/test.py���������������������������������������������������������������0000664�0000000�0000000�00000002202�12657170273�0017745�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from itertools import chain class VicSecCardTest(BackendTest): MODULE = 'vicseccard' def test_history(self): """ Test that there's at least one transaction in the whole history. """ b = self.backend ts = chain(*[b.iter_history(a) for a in b.iter_accounts()]) t = next(ts, None) self.assertNotEqual(t, None) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vimeo/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015431�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vimeo/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000000073�12657170273�0017542�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import VimeoModule __all__ = ['VimeoModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vimeo/browser.py�����������������������������������������������������������������0000664�0000000�0000000�00000004674�12657170273�0017501�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from weboob.browser.exceptions import HTTPNotFound from .pages import SearchPage, VideoPage, VideoJsonPage, CategoriesPage, ChannelsPage import urllib __all__ = ['VimeoBrowser'] class VimeoBrowser(PagesBrowser): BASEURL = 'https://vimeo.com' search_page = URL(r'search/page:(?P<page>.*)/sort:(?P<sortby>.*)/format:thumbnail\?type=videos&q=(?P<pattern>.*)', r'channels/(?P<channel>.*)/videos/.*?', r'categories/(?P<category>.*)/videos/.*?', SearchPage) categories_page = URL('categories', CategoriesPage) channels_page = URL('channels', ChannelsPage) video_url = URL(r'https://player.vimeo.com/video/(?P<_id>.*)/config', VideoJsonPage) video_page = URL('https://vimeo.com/(?P<_id>.*)', VideoPage) def get_video(self, _id, video=None): try: video = self.video_page.go(_id=_id).get_video(video) return self.video_url.open(_id=_id).fill_url(obj=video) except HTTPNotFound: return None def search_videos(self, pattern, sortby): return self.search_page.go(pattern=urllib.quote_plus(pattern.encode('utf-8')), sortby=sortby, page=1).iter_videos() def get_categories(self): return self.categories_page.go().iter_categories() def get_channels(self): return self.channels_page.go().iter_channels() def get_channel_videos(self, channel): return self.search_page.go(channel=channel).iter_videos() def get_category_videos(self, category): return self.search_page.go(category=category).iter_videos() ��������������������������������������������������������������������weboob-1.1/modules/vimeo/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000003571�12657170273�0017572�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD�Q��X��� pHYs�� �� ����tIME ֺ���tEXtComment�Created with GIMPW��IDATxklSeގ:v7.:Ec $/~ ނ#~`DLD"KbBH0e!b(Q.[i{zzZҝntOɻ9<  ok!rd \@nLH1 ) b3~* EH1t/Xb}V0xh2Y}Ot껹Bj˧]Ƶ1�TaczY}׺}<QYxa &zN0h2^p_Hz 7.'tK4`ct}@{}*hnҐza.Yg2a��+Rqx|hԫPUIN: �z;jR` UwDj`kU/sw%Hf*R/+bxy{a,t ]a -�{аu-dhPUy^)�W8 `@Z0b)DK{A¨b]Pm$+y 'tc~}!ݘ6G�āԛ6Xx8R|Q-[�mH =e_OmeШW�'}nЫՌ4#0N x߇1龑[T/uG77K8Ⱥ5ixjN\'Y#hay��tɞ|g0vJJH q ]tysLV_."CBq0ܕ1J& mh Cppϱ0#R]@"9֋q..[SPRp @waD޵> r/�\89X^5-i57טv'qx%�K� _o]CI]o5c094z#A{A?o�F 6dph}e\^cq<^p9 .ņr=\!rޓx u:(x7M884"gm8ߟZDhh7buE {q$'-ANwL<eZW ZNܙ¢WźTQs^#DW;J4h񈚝ĩ^)YҴ IxS6Up Pb!UVN�iγQĚ}0㗁UY A~ ILFRP"Vs }FLYڬF'1�B0I˷Kke8EȻñxTkb ֈ׆R-ĵ; U�w&cGͥZ,;=Ò I#hMmZ#'DbYMF20v+J;MQ[D`D|IZ"R'R.m-d)H7v#\/yt:tX"_kҫ€b ih'b|bym4Ey&~6'Gk{LZhq'=,^,)�7\5R`VWLŎ+IpD\ł\)MMdke ScQaI=` �q?67U�bL/U¤Qb$Ň7pp]=>߲ Epg=Zl]:4SQ[r:8 <�bև*\7TT ����IENDB`���������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vimeo/favicon.xcf����������������������������������������������������������������0000664�0000000�0000000�00000014124�12657170273�0017562�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������gimp xcf file����@���@����������������BB�����������������������m��� gimp-comment�������Created with GIMP����gimp-image-grid�������(style solid) (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000)) (bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000)) (xspacing 10.000000) (yspacing 10.000000) (spacing-unit inches) (xoffset 0.000000) (yoffset 0.000000) (offset-unit inches) ����gamma�������0.45454999804496765������������� �������������6��� ������i ...���������������������� �������������������� ���������� ���������� ���������� �������������������������������������������P���gimp-text-layer������4(text "i \nménon") (font "Serif Bold Italic") (font-size 14.000000) (font-size-unit pixels) (antialias yes) (language "fr-fr") (base-direction ltr) (color (color-rgb 1.000000 1.000000 1.000000)) (justify right) (box-mode fixed) (box-width 54.000000) (box-height 32.000000) (box-unit pixels) (hinting yes) ������������������6��� ������������6��� ���������1��1��/��0��0��1��1��0��0��0�����/��0��U�������������������������������������������������������������������������������������������������������1��1��/��0��0��1��1��0��0��0�����/��0��U�������������������������������������������������������������������������������������������������������1��1��/��0��0��1��1��0��0��0�����/��0��U������������������������������������������������������������������������������������������������������go�1��1�"�/�-5�0�_�0��1��1��0�[�0�@.�0�m��� �/� �0� �U�K/��2R��q��*�q���~l���84&�c�2({�c��C0����<<�C6�h ���C6�h ��p����@a�p��@b���p���̜���^�xʨ^�����x4�������� e�C1�y��7S�����q�N:�����u�39�o�4I�;�u�_�#2�u�_��"I�^���^Ű:��"I�>-�EY��"I�>-������7���@������v���������������������� �������������������� ���������� ���������� ���������� ����������������������������������������E���gimp-text-layer������)(text "v") (font "Serif Bold Italic") (font-size 50.000000) (font-size-unit pixels) (antialias yes) (language "fr-fr") (base-direction ltr) (color (color-rgb 1.000000 1.000000 1.000000)) (justify left) (box-mode fixed) (box-width 55.000000) (box-height 64.000000) (box-unit pixels) (hinting yes) ������������������7���@������������7���@�������������������� ���� ���� ������������������������������!����!����"����"����#���%��%��&� �'� �'��)��*��+����������������� ���� ���� ������������������������������!����!����"����"����#���%��%��&� �'� �'��)��*��+����������������� ���� ���� ������������������������������!����!����"����"����#���%��%��&� �'� �'��)��*��+����W1��RL��q��^����D��� �?��� ���E� ���`z��5V��+�� ��������)��N����X��0��$��1�!����!�#��|�"�X��I�"�Q��"7�#�� �%�  �%�0�&�~ p�'�I �'� �)��*�'�+�v)�����@���@������ favicon.png����������������������������� �������������������� ���������� ���������� ���������� ���������������������������������������������������������@���@������������@���@������ A)QA-QA1Q A3Q A5QA7QA9QA;QA;QA=QA=QAQ QAQ<QA=QA;QA;QA9QA7QA5Q A3Q A1QA-QA)Q A )-1 3 579;;== <=;;975 3 1-) )-1 3 579;;== <=;;975 3 1-) �)�-�1 �3 �5�7�9�;�;�=�=� �<�=�;�;�9�7�5 �3 �1�-�) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vimeo/module.py������������������������������������������������������������������0000664�0000000�0000000�00000007122�12657170273�0017272�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import CapVideo, BaseVideo from weboob.tools.backend import Module from weboob.capabilities.collection import CapCollection, CollectionNotFound, Collection from .browser import VimeoBrowser import re __all__ = ['VimeoModule'] class VimeoModule(Module, CapVideo, CapCollection): NAME = 'vimeo' MAINTAINER = u'François Revol' EMAIL = 'revol@free.fr' VERSION = '1.1' DESCRIPTION = 'Vimeo video streaming website' LICENSE = 'AGPLv3+' BROWSER = VimeoBrowser SORTBY = ['relevance', 'rating', 'views', 'time'] def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): return self.browser.search_videos(pattern, self.SORTBY[sortby]) def get_video(self, _id): return self.browser.get_video(self.parse_id(_id)) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields video = self.browser.get_video(video.id, video) if 'thumbnail' in fields and video.thumbnail: video.thumbnail.data = self.browser.open(video.thumbnail.url).content return video def parse_id(self, _id): m = re.match('https?://vimeo.com/(.*)', _id) if m: return m.group(1) return _id def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield Collection([u'vimeo-categories'], u'Vimeo categories') yield Collection([u'vimeo-channels'], u'Vimeo channels') if collection.path_level == 1: if collection.split_path == [u'vimeo-categories']: for category in self.browser.get_categories(): yield category if collection.split_path == [u'vimeo-channels']: for channel in self.browser.get_channels(): yield channel if collection.path_level == 2: if collection.split_path[0] == u'vimeo-channels': for video in self.browser.get_channel_videos(collection.split_path[1]): yield video if collection.split_path[0] == u'vimeo-categories': for video in self.browser.get_category_videos(collection.split_path[1]): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and (collection.split_path[0] == u'vimeo-categories' or collection.split_path[0] == u'vimeo-channels'): return raise CollectionNotFound(collection.split_path) OBJECTS = {BaseVideo: fill_video} ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vimeo/pages.py�������������������������������������������������������������������0000664�0000000�0000000�00000011502�12657170273�0017101�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo from weboob.capabilities.image import BaseImage from weboob.capabilities.collection import Collection from weboob.exceptions import ParseError from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.pages import HTMLPage, pagination, JsonPage from weboob.browser.filters.standard import Regexp, Env, CleanText, DateTime, Duration, Field from weboob.browser.filters.html import Attr, Link, CleanHTML, XPath from weboob.browser.filters.json import Dict import re class VimeoDuration(Duration): _regexp = re.compile(r'PT(?P<hh>\d+)H(?P<mm>\d+)M(?P<ss>\d+)S') class SearchPage(HTMLPage): @pagination @method class iter_videos(ListElement): item_xpath = '//div[@id="browse_content"]/ol/li' next_page = Link(u'//a[text()="Next"]') class item(ItemElement): klass = BaseVideo obj_id = Regexp(Attr('.', 'id'), 'clip_(.*)') obj_title = Attr('./a', 'title') def obj_thumbnail(self): thumbnail = BaseImage(self.xpath('./a/img')[0].attrib['src']) thumbnail.url = thumbnail.id return thumbnail class VideoPage(HTMLPage): def __init__(self, *args, **kwargs): super(VideoPage, self).__init__(*args, **kwargs) from weboob.tools.json import json jsoncontent = XPath('//script[@type="application/ld+json"]/text()')(self.doc)[0] self.doc = json.loads(jsoncontent)[0] @method class get_video(ItemElement): klass = BaseVideo obj_id = Env('_id') obj_title = CleanText(Dict('name')) obj_description = CleanHTML(Dict('description')) obj_date = DateTime(Dict('datePublished')) obj_duration = VimeoDuration(Dict('duration')) obj_author = CleanText(Dict('author/name')) def obj_nsfw(self): _sfw = Dict('isFamilyFriendly', default="True")(self) return _sfw != "True" def obj_thumbnail(self): thumbnail = BaseImage(Dict('thumbnailUrl')(self.el)) thumbnail.url = thumbnail.id return thumbnail class VideoJsonPage(JsonPage): @method class fill_url(ItemElement): klass = BaseVideo def obj_url(self): quality = 'sd' codec = None data = self.el if 'vp6' in data['request']['files']: codec = 'vp6' if 'vp8' in data['request']['files']: codec = 'vp8' if 'h264' in data['request']['files']: codec = 'h264' if not codec: raise ParseError('Unable to detect available codec for id: %r' % int(Field('id')(self))) if 'hd' in data['request']['files'][codec]: quality = 'hd' return data['request']['files'][codec][quality]['url'] obj_ext = Regexp(Field('url'), '.*\.(.*?)\?.*') class CategoriesPage(HTMLPage): @method class iter_categories(ListElement): item_xpath = '//div[@class="category_grid"]/div/a' class item(ItemElement): klass = Collection obj_id = CleanText('./@href') obj_title = CleanText('./div/div/p') def obj_split_path(self): split_path = ['vimeo-categories'] category = CleanText('./@href', replace=[('/categories/', '')])(self) split_path.append(category) return split_path class ChannelsPage(HTMLPage): @pagination @method class iter_channels(ListElement): item_xpath = '//div[@id="browse_content"]/ol/li' next_page = Link('//li[@class="pagination_next"]/a') class item(ItemElement): klass = Collection obj_title = CleanText('div/a/div/p[@class="title"]') obj_id = CleanText('./@id') def obj_split_path(self): split_path = ['vimeo-channels'] channel = CleanText('div/a/@href', replace=[('/channels/', '')])(self) split_path.append(channel) return split_path ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vimeo/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000004261�12657170273�0016765�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2012 François Revol # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo from weboob.tools.test import BackendTest import itertools class VimeoTest(BackendTest): MODULE = 'vimeo' def test_search(self): l = list(itertools.islice(self.backend.search_videos('boobs'), 0, 20)) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('https://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) def test_channels(self): l = list(itertools.islice(self.backend.iter_resources([BaseVideo], [u'vimeo-channels']), 0, 20)) self.assertTrue(len(l) > 0) l1 = list(itertools.islice(self.backend.iter_resources([BaseVideo], l[0].split_path), 0, 20)) self.assertTrue(len(l1) > 0) v = l1[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('https://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) def test_categories(self): l = list(itertools.islice(self.backend.iter_resources([BaseVideo], [u'vimeo-categories']), 0, 20)) self.assertTrue(len(l) > 0) l1 = list(itertools.islice(self.backend.iter_resources([BaseVideo], l[0].split_path), 0, 20)) self.assertTrue(len(l1) > 0) v = l1[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('https://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vine/����������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015253�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vine/__init__.py�����������������������������������������������������������������0000664�0000000�0000000�00000001424�12657170273�0017365�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 P4ncake # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import VineModule __all__ = ['VineModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vine/browser.py������������������������������������������������������������������0000664�0000000�0000000�00000002357�12657170273�0017317�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 P4ncake # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import SearchPage, PostPage import urllib class VineBrowser(PagesBrowser): BASEURL = 'https://vine.co' search_page = URL(r'/api/posts/search/(?P<pattern>.*)',SearchPage) post_page = URL('r/api/timelines/posts/s/(?P<_id>.*)', PostPage) def search_videos(self, pattern): return self.search_page.go(pattern=urllib.quote_plus(pattern.encode('utf-8'))).iter_videos() def get_video(self, _id): return self.post_page.go(_id=_id).get_video() ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vine/favicon.png�����������������������������������������������������������������0000664�0000000�0000000�00000006650�12657170273�0017415�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���tEXtSoftware�Adobe ImageReadyqe<��"iTXtXML:com.adobe.xmp�����<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmp:CreatorTool="Adobe Photoshop CS6 (Windows)" xmpMM:InstanceID="xmp.iid:3628AE485B6A11E3878FFC9BDA611944" xmpMM:DocumentID="xmp.did:3628AE495B6A11E3878FFC9BDA611944"> <xmpMM:DerivedFrom stRef:instanceID="xmp.iid:3628AE465B6A11E3878FFC9BDA611944" stRef:documentID="xmp.did:3628AE475B6A11E3878FFC9BDA611944"/> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="r"?>*��� IDATx[{TW;wvfw]! Pti  hR5mDV(K&Dkbh+Z yF..]sfuw9w>f6'9ǽs=va[ؑ�8)D:EIVr!#Ȧ%xR%3 x -]M~L3'f֘E3m,8  FC4g+1`fp@8M!ff8Ālfdwqm{WB0�wZu0`!Ck-`1nj@.Zm-XC1s/^:k2$; !Gr2 A U҆_|aPA2eYXhDO/@eRx[ 0r8-@KQ\y] yt2/-w*٢IMjh;I4;jQeճT Vlۗ( tZs ǥ'�mrf?]37_g`*\rTt>fKHjM{u5T|~Z#ͭot0}{v[ucZfKh4�Jg�ie47CZxKyZC/} IEx`{:DoF'Π( afm@Z Ƭ ٮ^ 7l&6r"/5 _gpb dpƂw,f0 =n;?\,M*hr>>J311�Ty->.Ф@"婹.r�Wk׍յ> 9I9ǹ>g(P.\@<YW?Pr?]D pKI7c!CV_Gr9A%s}>?w�yw)f_y8͎y=>D9"8H-#8 y}>@+Y+nޛ΍KMITT~f|sqf/;w16}%1H2$MjيILH8% 0ن#pO�p*r4}1Q<׾֥zk}vmx?:!9y5='^,E|7̤sa:Y:|oi<x kAxZvglb %uJz#KW^=0'_H!#?O`NJ}~] e`42rα5 dwV\}Cw_ {L$P-6mbL?>�+( 8r zC=: `'ƴ&N a[x0R>3'?g LUgH:N@<tf͖ -Ruo}|k.+C1 P`NC96\";�R P0)d9) [֗p 7Q`MZgas9FG̀R9t||Ծz]\ڥʐUX9g= :!RaPuD�W;`  ]qc$o0jP5Ūƅe$ᱭ\9% $Hlgϖ"(z +흇|~뿏U52^SV݀k#gy8~}-1hS!JlȳB>@)c4eK\f`M\}.X0oAkmzmV4 }ĥ�3pM}Q6o~@k7FRrx~\=] j걇PS[OEj>tdc(h=wHm nrdBpGQ 7$#/7m=]xCٱ^?H(HUlDݳ1ǮG"SgH16 8VKPf(#mGF-43 Ky|ST(x+Bp<-1QV(|BRE.YM(_EwEu׶]Ӱ".mr^Lgfᙏ3ޔ!{ ʁ)t#r>{=x(.LBb;<b9wS\C!E*D}"(rwN dB\>sX>ۓ Q<`,�fFe!<OQa#U{k󅚢(E.د[Ye[iKgXV#/-($��9 eXL_5x! zmGs&޴1|)di?NLI{JˇV͑mJ-.,cݝ&dq2ìƙ7YHYvqp[BuXCu/WhDe?Hi)QK @kSkMYI_�}o1����IENDB`����������������������������������������������������������������������������������������weboob-1.1/modules/vine/module.py�������������������������������������������������������������������0000664�0000000�0000000�00000003044�12657170273�0017113�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 P4ncake # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module from weboob.capabilities.video import CapVideo from .browser import VineBrowser __all__ = ['VineModule'] class VineModule(Module, CapVideo): NAME = 'vine' DESCRIPTION = u'vine website' MAINTAINER = u'P4ncake' EMAIL = 'me@p4ncake.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = VineBrowser def search_videos(self, pattern, nsfw=False): return self.browser.search_videos(pattern) def get_video(self, _id): return self.browser.get_video(_id=_id) def fill_video(self, video, fields): if fields != ['thumbnail']: video = self.browser.get_video(video.id, video) if 'thumbnail' in fields and video.thumbnail: video.thumbnail.data = self.browser.open(video.thumbnail.url).content return video ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vine/pages.py��������������������������������������������������������������������0000664�0000000�0000000�00000003061�12657170273�0016724�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 P4ncake # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo from weboob.browser.elements import ItemElement, DictElement, method from weboob.browser.pages import JsonPage from weboob.browser.filters.standard import Regexp from weboob.browser.filters.json import Dict class SearchPage(JsonPage): @method class iter_videos(DictElement): item_xpath ='data/records' class item(ItemElement): klass = BaseVideo obj_id = Regexp(Dict('shareUrl'), '/([a-zA-Z0-9]*)$') obj_title = Dict('description') obj_url = Dict('videoUrl') obj_ext = Regexp(Dict('videoUrl'), r'.*\.(.*?)\?.*') obj_author = Dict('username') class PostPage(JsonPage): @method class get_video(ItemElement): klass = BaseVideo obj_id = Dict('postId') obj_url = Dict('videoUrl') �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vine/test.py���������������������������������������������������������������������0000664�0000000�0000000�00000002206�12657170273�0016604�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2015 P4ncake # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest import itertools class VineTest(BackendTest): MODULE = 'vine' def test_search(self): l = list(itertools.islice(self.backend.search_videos('coucou'), 0, 20)) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/virginradio/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016627�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/virginradio/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000001442�12657170273�0020741�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Johann Broudin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import VirginRadioModule __all__ = ['VirginRadioModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/virginradio/favicon.licence������������������������������������������������������0000664�0000000�0000000�00000002006�12657170273�0021576�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������favicon.png is licenced under the Créative Commons Attribution-Share Alike 4.0 International licence Original picture attribution: © Hans Hillewaert You are free to: Share — copy and redistribute the material in any medium or format Adapt — remix, transform, and build upon the material for any purpose, even commercially. The licensor cannot revoke these freedoms as long as you follow the license terms. Under the following terms: Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/virginradio/favicon.png����������������������������������������������������������0000664�0000000�0000000�00000011625�12657170273�0020767�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������C��� pHYs�� �� ����tIME ��IDATx[y|T޷̾f2IBX" QDۂOkتRZZ7jբUk?b*u-Y  !$d&ٗ7f{IX$w߽|Ϲg{3hdcw<q3q#~v%;es�oeuw0U/Z%,:;0 Z{_"@:`pB0߼hԯ �}3o�H~p-`DN 5�9 M@:_�0I$, lsE�%f)�(t\;`F%�>F'�`+= ":*Fݼ^vY}LD24g暪DBDZƙGn] -;Fr-ԩ8KD AlK \I]O~3 qj&"R{!Y`�:}'Ui-WKr+?�9q4z�%\CPxԽ0O,ܢc�錱йI֕e.RO�$2#~�g􍕞vHoZC Pwl19svdɌ#|ӽϘ:`~@��MQn%|H@i\4@oL[L�&Jc1Ҵ-F@:@AZY@ソ@߽buc'/U,&%x\"F|l�e�~ `gO<> r@zs�n�//cl�K2ơ ̄0lp&Au"."zQ;�g{J<`e* h+h{Xg] `deI-emPly =4=ןg"d7IF<h˨zO\yhu0ȖT:x+anX}uc8�CnGiI7 mW!xo&M;q\,( 5 JApYn?άqYc1"&XNDc/ +�_1x0֝fvA!B*. 0߭< c`G& f0A�m-{p빽u]`� 9O"-W{ti^I�.GNOȇ.'Z81E�5fEˏyKѧ}� k+٠p#ԎC M7z}�P6c|UwWɱU/vJR8c|zP2 ^sC0;uNσde^!(Ml3\tLim#I802(&"{ۯ햽�e(J>`vU%س-YrɂRx�X2O1bܹb(#܌ K?q1 @U�DlzfHiԆ#R hQ?4v4`=:o}cAo 2�Xy͡rB[L7 NW2#}y.EU[={Plzssz*]/sYׁ/(j]}䔊,Y:dx3G>|6 hppoߑdu �n��ʌCFTB\_8o1AܹӝWzdPU!r ]uiI-|kj瞵Mu1s3�A'dBUr8 i!qx/8G. f7Ɲ4 tK�<�^`+�?�XwEEDcy+ 0qOZ'?<Giɩ9*G,)iELuW6 rN?JDiG:g d<:a{&((L)q�ͼ_%lás~ZX _Ҧ-+`rU�LuCzQaq0) x>/ t @ t& sP}B!a*?E(c?D>X9m>kފS._"tW܁Цa5Jx `Іbk��;|=^d#Ěas w9%ڑ-׬<Qi9qx+?3~[j:59q:oHǔ#h&@ aWm:j, d?79(7vA`( CEY߄Zyw9Ls`e#u'e'RїE]>PF޿ 5;1(;mCo L'G?P ުGD#)!\4?0{|ľ х� e5rO]Muo0úbpQCjA@"2�Ɣ.nD `+.gq )֕)A.�sO^ˎq`t &7谱D,1J@Uieڹ*j1b1v0� AڄTS%YF��' J'\H �b,)R  PvVKR fJz=Z:e#FîHB0Q8o&X scP+0L=|$թHSbTCZ L򂒻ݼ1/CN>']}=,e @*H�׿A`˲�4 A[AG]dˁ�0$ C<Q˧[f.Qc=[8AɩDŽV9BӻFZZ!2㋳"(JKJT~�A_}ܩ{J h0?;Ť?mOSq_y95%ƃ0IJ*TDRIC"rQК$eS ӄgv3s{>a👫7L-/޸Ӿ6xִz^IaQsw冞a]Ru5)Ʀmu+4l>sJ{ `mXwi:Y'Z6>pME  gI�,Ǵڮ((f`JJ1ztp;wℊ438j"-c]yz / xw=Ctjm*G2~6D " /z1[IHq!)0*w#wdܶ&0=ňב;ҽe#@S��C�^E!ykXIB$ I 'vg|kϛ{X~(QDO0Dhnm1RItc`/3N`CK+eko~co#;qPl5AHIH+IvҞල vƵ% i)B.Nqx2x&<QVjC:懎7rh b+|W# 7}Y$!X@0e8r:J! .۷߯~XqN`rZx[a60LT -]͙Ez8/rF %O J'vE"DR<�A=yf>�lgl=25ufb ֖6x<ȱl1o_zg#�=>�9V%%$hYF= d- S1rmw) hl: hE';I�h v=p5#�m(i9g"al&~ hz> s_JRqM85?BKc+XT$@kSѫ'<k-q$c}k޸脇ݼ|}$`njn"`>Ek&'0/YJE&O(rS`E 3̬KA鵏=3@f1N͗4dx&kDP;^+\?._鍳栌B�AFQX]?r �N�{ cܱPX0d: B,FP߼v]ю5;SW!N0ÿ�L3SN5s6׮s �cǴmvγ,x4iwfcng>ls % .މZO2pO+GMqs挳R"R&AdO='2sc JM>"w>l�O P"&?Qn$~;_ȷ0yOď�sKrU<+ϖ 0xp' ː Cup?*͢ (HB��skM(Qur3A)"R^?C[-\ۛ-rrKJ 0 (o6dϬ:j#>*{cXs)6uè��<wDMлlЕ/�~hZ?sw/iGW{OX-ʩr$@B*`Ae&k\qo=coʎ81k)@CSd;&/<M6ɒQZ4q(MbKNZ@ݲWk,B4(,f*&wS*#gku>×^3@0%8q;'K@G8hב-M\n-CCD8B����IENDB`�����������������������������������������������������������������������������������������������������������weboob-1.1/modules/virginradio/module.py������������������������������������������������������������0000664�0000000�0000000�00000010525�12657170273�0020471�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Johann Broudin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.audiostream import BaseAudioStream from weboob.tools.capabilities.streaminfo import StreamInfo from weboob.capabilities.collection import CapCollection from weboob.tools.backend import Module from weboob.browser import Browser from weboob.tools.misc import to_unicode __all__ = ['VirginRadioModule'] class VirginRadioModule(Module, CapRadio, CapCollection): NAME = 'virginradio' MAINTAINER = u'Johann Broudin' EMAIL = 'Johann.Broudin@6-8.fr' VERSION = '1.1' DESCRIPTION = u'VirginRadio french radio' LICENSE = 'AGPLv3+' BROWSER = Browser _RADIOS = { 'officiel': ( u'Virgin Radio', u'Virgin Radio', u'http://mp3lg3.scdn.arkena.com/10490/virginradio.mp3', 64), 'new': ( u'Virgin Radio New', u'Virgin Radio New', u'http://mp3lg3.tdf-cdn.com/9145/lag_103228.mp3', 64), 'classics': ( u'Virgin Radio Classics', u'Virgin Radio Classics', u'http://mp3lg3.tdf-cdn.com/9146/lag_103325.mp3', 64), 'electroshock': ( u'Virgin Radio Electroshock', u'Virgin Radio Electroshock', u'http://mp3lg3.tdf-cdn.com/9148/lag_103401.mp3', 64), 'hits': ( u'Virgin Radio Hits', u'Virgin Radio Hits', u'http://mp3lg3.tdf-cdn.com/9150/lag_103440.mp3', 64), 'rock': ( u'Virgin Radio Rock', u'Virgin Radio Rock', u'http://mp3lg3.scdn.arkena.com/9151/lag_103523.mp3', 64) } def get_stream_info(self, radio, url): stream = BaseAudioStream(0) current = StreamInfo(0) r = self.browser.open(url, stream=True, headers={'Icy-Metadata':1}) stream.bitrate = int(r.headers['icy-br'].split(',')[0]) r.raw.read(int(r.headers['icy-metaint'])) size = ord(r.raw.read(1)) content = r.raw.read(size*16) r.close() for s in content.split("\x00")[0].split(";"): a = s.split("=") if a[0] == "StreamTitle": stream.title = to_unicode(a[1].split("'")[1]) res = a[1].split("'")[1].split(" - ") current.who = to_unicode(res[0]) current.what = to_unicode(res[1]) stream.format=u'mp3' stream.url = url return [stream], current def get_radio(self, radio): if not isinstance(radio, Radio): radio = Radio(radio) if radio.id not in self._RADIOS: return None title, description, url, bitrate = self._RADIOS[radio.id] radio.title = title radio.description = description radio.streams, radio.current = self.get_stream_info(radio.id, url) return radio def iter_resources(self, objs, split_path): if Radio in objs: self._restrict_level(split_path) for id in self._RADIOS.iterkeys(): yield self.get_radio(id) def iter_radios_search(self, pattern): for radio in self.iter_resources((Radio, ), []): if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower(): yield radio def fill_radio(self, radio, fields): if 'current' in fields: if not radio.current: radio = self.get_radio(radio.id) return radio OBJECTS = {Radio: fill_radio} ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/virginradio/test.py��������������������������������������������������������������0000664�0000000�0000000�00000001765�12657170273�0020171�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Johann Broudin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.radio import Radio class VirginRadioTest(BackendTest): MODULE = 'virginradio' def test_virginradio(self): l = list(self.backend.iter_resources((Radio, ), [])) self.assertTrue(len(l) > 0) �����������weboob-1.1/modules/vlille/��������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015601�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vlille/__init__.py���������������������������������������������������������������0000664�0000000�0000000�00000001432�12657170273�0017712�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import VlilleModule __all__ = ['VlilleModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vlille/browser.py����������������������������������������������������������������0000664�0000000�0000000�00000002436�12657170273�0017643�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import ListStationsPage, InfoStationPage __all__ = ['VlilleBrowser'] class VlilleBrowser(PagesBrowser): BASEURL = 'http://www.vlille.fr' list_page = URL('/stations/les-stations-vlille.aspx', ListStationsPage) info_page = URL('/stations/xml-station.aspx\?borne=(?P<idgauge>.*)', InfoStationPage) def get_station_list(self): return self.list_page.go().get_station_list() def get_station_infos(self, gauge): return self.info_page.go(idgauge=gauge.id).get_station_infos(obj=gauge) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vlille/favicon.png���������������������������������������������������������������0000664�0000000�0000000�00000001031�12657170273�0017727�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME#��IDATxZ }bY \AJ !9v|l>�WDGf1WYZ�@ @R~7 ^RyL^RylLi@MiKDu #|R3߿)޺ @yx>@^t,cJAg_!4{}KpE:G pj1rJDgAcbBn9=k{8Ke.uJcCFw[!lYC1�Kl6\|Rԩd7j8Od�L~@X'� @�l;~R喷%֍ƀ O*Z}!K<W+$l͐AQ ZuOsh6L5C(rںJ��0~$Jgb����IENDB`�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vlille/module.py�����������������������������������������������������������������0000664�0000000�0000000�00000005601�12657170273�0017442�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.tools.backend import Module from weboob.capabilities.base import find_object from weboob.capabilities.gauge import CapGauge, GaugeSensor, Gauge, SensorNotFound from .browser import VlilleBrowser __all__ = ['VlilleModule'] class VlilleModule(Module, CapGauge): NAME = 'vlille' DESCRIPTION = u'Lille bike renting availability information' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' VERSION = '1.1' BROWSER = VlilleBrowser def iter_gauges(self, pattern=None): if pattern is None: for gauge in self.browser.get_station_list(): yield gauge else: lowpattern = pattern.lower() for gauge in self.browser.get_station_list(): if lowpattern in gauge.name.lower(): yield gauge def iter_sensors(self, gauge, pattern=None): if not isinstance(gauge, Gauge): gauge = find_object(self.iter_gauges(), id=gauge, error=SensorNotFound) gauge = self.browser.get_station_infos(gauge).next() if pattern is None: for sensor in gauge.sensors: yield sensor else: lowpattern = pattern.lower() for sensor in gauge.sensors: if lowpattern in sensor.name.lower(): yield sensor def get_last_measure(self, sensor): if not isinstance(sensor, GaugeSensor): sensor = self._get_sensor_by_id(sensor) if sensor is None: raise SensorNotFound() return sensor.lastvalue """ def _get_gauge_by_id(self, id): for gauge in self.browser.get_station_list(): if id == gauge.id: return gauge return None """ def _get_sensor_by_id(self, id): reSensorId = re.search('(\d+)-((bikes|attach|status))', id, re.IGNORECASE) if reSensorId: gauge = reSensorId.group(1) pattern = reSensorId.group(2) sensor_generator = self.iter_sensors(gauge, pattern) if sensor_generator: return next(sensor_generator) else: return None return None �������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vlille/pages.py������������������������������������������������������������������0000664�0000000�0000000�00000012602�12657170273�0017253�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage, XMLPage from weboob.browser.elements import ListElement, ItemElement, TableElement, method from weboob.browser.filters.standard import CleanText, TableCell, Filter from weboob.capabilities.gauge import Gauge, GaugeMeasure, GaugeSensor from weboob.capabilities.base import NotLoaded import datetime import re class LastDateFilter(Filter): def filter(self, last_update): return datetime.datetime.now() - datetime.timedelta(seconds=int(re.match(r'\d+', last_update).group(0))) class InfoStationPage(XMLPage): ENCODING = 'utf-8' @method class get_station_infos(ListElement): item_xpath = "." class item(ItemElement): klass = Gauge def _create_bikes_sensor(self, value, gauge_id, last_update, adresse): levelbikes = GaugeSensor(gauge_id + '-bikes') levelbikes.name = u'Bikes' levelbikes.address = u'%s' % adresse lastvalue = GaugeMeasure() lastvalue.level = float(value) lastvalue.date = last_update if lastvalue.level < 1: lastvalue.alarm = u'Empty station' levelbikes.lastvalue = lastvalue levelbikes.history = NotLoaded levelbikes.gaugeid = gauge_id return levelbikes def _create_attach_sensor(self, value, gauge_id, last_update, adresse): levelattach = GaugeSensor(gauge_id + '-attach') levelattach.name = u'Attach' levelattach.address = u'%s' % adresse lastvalue = GaugeMeasure() if lastvalue.level < 1: lastvalue.alarm = u'Full station' lastvalue.level = float(value) lastvalue.date = last_update levelattach.lastvalue = lastvalue levelattach.history = NotLoaded levelattach.gaugeid = gauge_id return levelattach def _create_status_sensor(self, value, gauge_id, last_update, adresse): levelstatus = GaugeSensor(gauge_id + '-status') levelstatus.name = u'Status' levelstatus.address = u'%s' % adresse lastvalue = GaugeMeasure() status = float(value) if status == 0: status = 1 else: status = -1 if lastvalue.level < 1: lastvalue.alarm = u'Not available station' lastvalue.level = float(status) lastvalue.date = last_update levelstatus.lastvalue = lastvalue levelstatus.history = NotLoaded levelstatus.gaugeid = gauge_id return levelstatus def parse(self, el): self.obj = self.env['obj'] def obj_sensors(self): sensors = [] last_update = LastDateFilter(CleanText('lastupd'))(self) adresse = CleanText('adress')(self) sensors.append(self._create_bikes_sensor(CleanText('bikes')(self), self.env['idgauge'], last_update, adresse)) sensors.append(self._create_attach_sensor(CleanText('attachs')(self), self.env['idgauge'], last_update, adresse)) sensors.append(self._create_status_sensor(CleanText('status')(self), self.env['idgauge'], last_update, adresse)) return sensors class ListStationsPage(HTMLPage): @method class get_station_list(TableElement): item_xpath = "//table[@id='ctl00_Contenu_ListeStations1_ListViewStations_itemPlaceholderContainer']/tr" head_xpath = "//table[@id='ctl00_Contenu_ListeStations1_ListViewStations_itemPlaceholderContainer']/tr/th/@id" col_id = 'ctl00_Contenu_ListeStations1_ListViewStations_Th1' col_name = 'ctl00_Contenu_ListeStations1_ListViewStations_Th2' col_city = 'ctl00_Contenu_ListeStations1_ListViewStations_Th9' class item(ItemElement): klass = Gauge condition = lambda self: (len(self.el.xpath('td/span')) > 4 and not ('id' in self.el.attrib)) obj_id = CleanText(TableCell('id')) obj_name = CleanText(TableCell('name')) obj_city = CleanText(TableCell('city')) obj_object = u'vLille' ������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/vlille/test.py�������������������������������������������������������������������0000664�0000000�0000000�00000002173�12657170273�0017135�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class VlilleTest(BackendTest): MODULE = 'vlille' def test_vlille(self): l = list(self.backend.iter_gauges()) self.assertTrue(len(l) > 0) gauge = l[0] s = list(self.backend.iter_sensors(gauge)) self.assertTrue(len(s) > 0) sensor = s[0] self.assertTrue(self.backend.get_last_measure(sensor.id) is not None) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/voyagessncf/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016641�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/voyagessncf/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000001450�12657170273�0020752�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import VoyagesSNCFModule __all__ = ['VoyagesSNCFModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/voyagessncf/browser.py�����������������������������������������������������������0000664�0000000�0000000�00000004242�12657170273�0020700�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from random import randint from weboob.deprecated.browser import Browser from .pages import CitiesPage, SearchPage, SearchErrorPage, \ SearchInProgressPage, ResultsPage, ForeignPage __all__ = ['VoyagesSNCFBrowser'] class VoyagesSNCFBrowser(Browser): PROTOCOL = 'http' DOMAIN = 'www.voyages-sncf.com' ENCODING = 'utf-8' PAGES = { 'http://www.voyages-sncf.com/completion/VSC/FR/fr/cityList.js': (CitiesPage, 'raw'), 'http://www.voyages-sncf.com/billet-train': SearchPage, 'http://www.voyages-sncf.com/billet-train\?.+': SearchErrorPage, 'http://www.voyages-sncf.com/billet-train/recherche-en-cours.*': SearchInProgressPage, 'http://www.voyages-sncf.com/billet-train/resultat.*': ResultsPage, 'http://(?P<country>\w{2})\.voyages-sncf.com/\w{2}/.*': ForeignPage, } def __init__(self, *args, **kwargs): Browser.__init__(self, *args, **kwargs) self.addheaders += (('X-Forwarded-For', '82.228.147.%s' % randint(1,254)),) def get_stations(self): self.location('/completion/VSC/FR/fr/cityList.js') return self.page.get_stations() def iter_departures(self, departure, arrival, date, age, card, comfort_class): self.location('/billet-train') self.page.search(departure, arrival, date, age, card, comfort_class) return self.page.iter_results() ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/voyagessncf/favicon.png����������������������������������������������������������0000664�0000000�0000000�00000012346�12657170273�0021002�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���bKGD������ pHYs�� �� ����tIME ,M���tEXtComment�Created with GIMPW��NIDATx{eu׿k9{yy?j'ı؉ *MP(⡀DQQ@ DA!"PZZDEUQ$hIΌ]>oĐĉ=Lɒ>wcc,t+Cg.ߧ�Џ>|Tx3 (�x�n�Ľk~#t+omk�ĺFT8D&* ` |q(LGTE"(4szd>#\p @:Tt1KpD{ B$RP` �A1 4W^8](LޏDeȴB&JP�IUtm-s=~/6\�18Pz�I)Hdl ]F+ec#ʃ~"w$ɣIxs O kbR=VUC$dF"IEI�q/T/{s1OB^Y3CJ BD䡘W�se/G�c."[e\'݇~=YeW],@(AXHhm\Wk~?iG5{^%aeM 7vˀTnm?+q]�_&o ~rSP�+ w!)rH" URQ,i[6ыey<{2Ni9Z%% F tXVmR9IKVZC VRYLKpABU{ VwXff + @6e(tP6%nKሺ<@ΔDUg,+,)eH4d31gYcgl&oɹyͽbiX?ݬCX[JӀ Ka@5`2$mKk6I=tp\Ǘ1ixaXYFf:)h @A+PK �@I.x. h@ Zlk@G*Q>8.#<@$q!F (  pD>tпZfZ=׽&�G#!, c:&LRBחv, n'I>hvzk@�?#)gX,p7dyY\T΢*#-i`/D ql U(S:ճ<RM{\x-oһtp֡p*v'K7-[-P�b )!4a" +"et("1p 00A-iO.ш׷<bN'ozS+;,<?4p2uCt/T c <+anfAv5! :r7Hl4k$ϗg(?5+U0:HUBe5+AfG{jf?~>Y廛 du =�G#)) Bdu59TK0.UtMK,"y[jş-a�q, O診0WWU㠚 :Ӑ7YefßLO@kqz¼#CL5 BY[z̖bA./`Ijy ^_] ss|+|XƠ sй=Tn~-9-,(b/)ntwԕWBw| oH^avAp"#SSAf` �2,*iiNJ̏~um7c�ۏ<'ޡsG YG4(ծh*+ >� � OhmSC.۟T:sO.J 2*4 r *X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> /Z,HtЧȹ� fs3cM: a@=GzϹL�٨׿k ��|7~Ecݒb% F&C]n254R�ȀD|2Hv)LLʱayj~d�wo~qÔ9, &F1J) )@l Xa@$6Is]駗tM�cŵ'o D5/ݵ t .$ $͐k^Ӯ\[/j6O}9ik:(SM�j+�I5j0w,[kulz5swt;a*߉}|$S}WxL+ʡ5{  NAa\@5b` ͸/øt-m9(v%^}FSwJUf>U9 `Y#4H f4CSu6y*v&UИrͻeĮ)0}6Vqp< Z I8`K(c Ia5(u\=њq Kw@6�ٗkN`fQL`Bd`e̅' (Eg[ul*J`6+�ǿ?񇛁_O2 hps<)-g-.e̘uhJ*\<0Mx]�C~n5q1P1%YzK `J2By6\wk�vWR2F@@e!6 b [1BOͼgz`oؙ=k[i�;Czz5w㸮>C3ϸ?ֳ {  B"B/uۏ/]:2gI -#KwN<1t"jwgIVˌп8OV[09CU{kLy0@K3ޚD:"U%IKl)ut;Upz_ 7 v!OtN]NG����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/voyagessncf/module.py������������������������������������������������������������0000664�0000000�0000000�00000014122�12657170273�0020500�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.tools.ordereddict import OrderedDict from weboob.tools.value import Value from weboob.capabilities.travel import CapTravel, Station, Departure from weboob.capabilities import UserError from .browser import VoyagesSNCFBrowser __all__ = ['VoyagesSNCFModule'] class VoyagesSNCFModule(Module, CapTravel): NAME = 'voyagessncf' DESCRIPTION = u'Voyages SNCF' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' LICENSE = 'AGPLv3+' VERSION = '1.1' CONFIG = BackendConfig(Value('age', label='Passenger age', default='ADULT', choices=OrderedDict((('ADULT', '26-59 ans'), ('SENIOR', '60 et +'), ('YOUNG', '12-25 ans'), ('CHILD_UNDER_FOUR', '0-3 ans'), ('CHILDREN', '4-11 ans')))), Value('card', label='Passenger card', default='default', choices=OrderedDict((('default', u'Pas de carte'), ('YOUNGS', u'Carte Jeune'), ('ESCA', u'Carte Escapades'), ('WEEKE', u'Carte Week-end'), ('FQ2ND', u'Abo Fréquence 2e'), ('FQ1ST', u'Abo Fréquence 1e'), ('FF2ND', u'Abo Forfait 2e'), ('FF1ST', u'Abo Forfait 1e'), ('ACCWE', u'Accompagnant Carte Week-end'), ('ACCCHD', u'Accompagnant Carte Enfant+'), ('ENFAM', u'Carte Enfant Famille'), ('FAM30', u'Carte Familles Nombreuses 30%'), ('FAM40', u'Carte Familles Nombreuses 40%'), ('FAM50', u'Carte Familles Nombreuses 50%'), ('FAM75', u'Carte Familles Nombreuses 75%'), ('MI2ND', u'Carte Militaire 2e'), ('MI1ST', u'Carte Militaire 1e'), ('MIFAM', u'Carte Famille Militaire'), ('THBIZ', u'Thalys ThePass Business'), ('THPREM', u'Thalys ThePass Premium'), ('THWE', u'Thalys ThePass Weekend')))), Value('class', label='Comfort class', default='2', choices=OrderedDict((('1', u'1e classe'), ('2', u'2e classe'))))) BROWSER = VoyagesSNCFBrowser STATIONS = [] def _populate_stations(self): if len(self.STATIONS) == 0: with self.browser: self.STATIONS = self.browser.get_stations() def iter_station_search(self, pattern): self._populate_stations() pattern = pattern.lower() already = set() # First stations whose name starts with pattern... for _id, name in enumerate(self.STATIONS): if name.lower().startswith(pattern): already.add(_id) yield Station(_id, unicode(name)) # ...then ones whose name contains pattern. for _id, name in enumerate(self.STATIONS): if pattern in name.lower() and _id not in already: yield Station(_id, unicode(name)) def iter_station_departures(self, station_id, arrival_id=None, date=None): self._populate_stations() if arrival_id is None: raise UserError('The arrival station is required') try: station = self.STATIONS[int(station_id)] arrival = self.STATIONS[int(arrival_id)] except (IndexError, ValueError): try: station = list(self.iter_station_search(station_id))[0].name arrival = list(self.iter_station_search(arrival_id))[0].name except IndexError: raise UserError('Unknown station') with self.browser: for i, d in enumerate(self.browser.iter_departures(station, arrival, date, self.config['age'].get(), self.config['card'].get(), self.config['class'].get())): departure = Departure(i, d['type'], d['time']) departure.departure_station = d['departure'] departure.arrival_station = d['arrival'] departure.arrival_time = d['arrival_time'] departure.price = d['price'] departure.currency = d['currency'] departure.information = d['price_info'] yield departure ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/voyagessncf/pages.py�������������������������������������������������������������0000664�0000000�0000000�00000010547�12657170273�0020321�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from decimal import Decimal from datetime import time, datetime, timedelta from weboob.deprecated.browser import Page from weboob.tools.json import json from weboob.deprecated.mech import ClientForm from weboob.capabilities.base import UserError, Currency class ForeignPage(Page): def on_loaded(self): raise UserError('Your IP address is localized in a country not supported by this module (%s). Currently only the French website is supported.' % self.group_dict['country']) class CitiesPage(Page): def get_stations(self): result = json.loads(self.document[self.document.find('{'):-2]) return result['CITIES'] class SearchPage(Page): def search(self, departure, arrival, date, age, card, comfort_class): self.browser.select_form(name='saisie') self.browser['ORIGIN_CITY'] = departure.encode(self.browser.ENCODING) self.browser['DESTINATION_CITY'] = arrival.encode(self.browser.ENCODING) if date is None: date = datetime.now() + timedelta(hours=1) elif date < datetime.now(): raise UserError("You cannot look for older departures") self.browser['OUTWARD_DATE'] = date.strftime('%d/%m/%y') self.browser['OUTWARD_TIME'] = [str(date.hour)] self.browser['PASSENGER_1'] = [age] self.browser['PASSENGER_1_CARD'] = [card] self.browser['COMFORT_CLASS'] = [str(comfort_class)] self.browser.controls.append(ClientForm.TextControl('text', 'nbAnimalsForTravel', {'value': ''})) self.browser['nbAnimalsForTravel'] = '0' self.browser.submit() class SearchErrorPage(Page): def on_loaded(self): p = self.document.getroot().cssselect('div.messagesError p') if len(p) > 0: message = p[0].text.strip() raise UserError(message) class SearchInProgressPage(Page): def on_loaded(self): link = self.document.xpath('//a[@id="url_redirect_proposals"]')[0] self.browser.location(link.attrib['href']) class ResultsPage(Page): def get_value(self, div, name, last=False): i = -1 if last else 0 p = div.cssselect(name)[i] sub = p.find('p') if sub is not None: txt = sub.tail.strip() if txt == '': p.remove(sub) else: return unicode(txt) return unicode(self.parser.tocleanstring(p)) def parse_hour(self, div, name, last=False): txt = self.get_value(div, name, last) hour, minute = map(int, txt.split('h')) return time(hour, minute) def iter_results(self): for div in self.document.getroot().cssselect('div.train_info'): info = None price = None currency = None for td in div.cssselect('td.price'): txt = self.parser.tocleanstring(td) p = Decimal(re.sub('([^\d\.]+)', '', txt)) if price is None or p < price: info = list(div.cssselect('strong.price_label')[0].itertext())[-1].strip().strip(':') price = p currency = Currency.get_currency(txt) yield {'type': self.get_value(div, 'div.transporteur-txt'), 'time': self.parse_hour(div, 'div.departure div.hour'), 'departure': self.get_value(div, 'div.departure div.station'), 'arrival': self.get_value(div, 'div.arrival div.station', last=True), 'arrival_time': self.parse_hour(div, 'div.arrival div.hour', last=True), 'price': price, 'currency': currency, 'price_info': info, } ���������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/voyagessncf/test.py��������������������������������������������������������������0000664�0000000�0000000�00000002476�12657170273�0020203�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class VoyagesSNCFTest(BackendTest): MODULE = 'voyagessncf' def test_stations(self): stations = list(self.backend.iter_station_search('paris')) self.assertTrue(len(stations) > 0) self.assertTrue('Paris Massy' in stations[-1].name) def test_departures(self): departure = list(self.backend.iter_station_search('paris'))[0] arrival = list(self.backend.iter_station_search('lyon'))[0] prices = list(self.backend.iter_station_departures(departure.id, arrival.id)) self.assertTrue(len(prices) > 0) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/weather/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015751�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/weather/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001432�12657170273�0020062�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Arno Renevier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import WeatherModule __all__ = ['WeatherModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/weather/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000004455�12657170273�0020016�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Arno Renevier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib from weboob.deprecated.browser import Browser from .pages import ForecastPage, WeatherPage, CityPage __all__ = ['WeatherBrowser'] class WeatherBrowser(Browser): DOMAIN = 'www.weather.com' PROTOCOL = 'http' ENCODING = 'utf-8' PAGES = {} SEARCH_URL = 'http://www.weather.com/search/enhancedlocalsearch?where=%s' WEATHER_URL = 'http://www.weather.com/weather/today/%s' FORECAST_URL = 'http://www.weather.com/weather/tenday/%s' RIGHTNOW_URL = 'http://www.weather.com/weather/right-now/%s' USER_AGENT = Browser.USER_AGENTS['desktop_firefox'] PAGES = { (SEARCH_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): CityPage, (WEATHER_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): WeatherPage, (FORECAST_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): ForecastPage, (RIGHTNOW_URL.replace('.', '\\.').replace('?', '\\?') % '.*'): WeatherPage, } def iter_city_search(self, pattern): self.location(self.SEARCH_URL % urllib.quote_plus(pattern.encode('utf-8'))) if self.is_on_page(CityPage): return self.page.iter_city_search() elif self.is_on_page(WeatherPage): return [self.page.get_city()] def get_current(self, city_id): self.location(self.WEATHER_URL % urllib.quote_plus(city_id.encode('utf-8'))) return self.page.get_current() def iter_forecast(self, city_id): self.location(self.FORECAST_URL % urllib.quote_plus(city_id.encode('utf-8'))) assert self.is_on_page(ForecastPage) return self.page.iter_forecast() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/weather/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000002743�12657170273�0020112�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@�����@PLTE��  !!##$$%%&&(())**,,..//001122445566778899::;;<<??AABBDDIIJJKKMMNNQQRRWWXXYYZZ[[]]^^``aabbccddeeffiijjllmmnnppqqrruuwwyyzz{{~~ĀŁłƄDždžLJȈȋʌʎ˔ΗϘЙКћќҞҠӡԢԤե֦֧רשتثج٭ٮگڰ۱۲ܴܳݵݶ޷޻༼྾῿Vn��^IDATXoUǿyq'JLI*QITRN*'$\�BQ "4 I4?&l`rC]!sڧ}ٙ7y;0&ABNΞK~<}rt\Xq1$LLDbY.U8%PItEs��PaIUH~~@ermP];[�쭻:STn:~w?:!Z`}=[HY7o~31sDlwNz!~-= 3N"H]~뎏Rsljk*�j>sG!#ޡD��|KtQg^\h{O 5@fZyTJ!̕@Wlj>_^&L&i\>L}ξ Ra*V(P:9XiRl`f/tۺ}Y@lmجВ� y_Up%./JC*oִLa FFmO4ZiI:h>5\�ャP` W(*&F@na; \#$@7BC(@UD~Bk ?$p{)G~yV9:�fL_Vd–+ @.7{{wn6>8,@jt8|v\GӇ,[j׍4o:{ APŢFT NvUE}&TP*`js Z/}?lw*����IENDB`�����������������������������weboob-1.1/modules/weather/module.py����������������������������������������������������������������0000664�0000000�0000000�00000002606�12657170273�0017614�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Arno Renevier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.weather import CapWeather from weboob.tools.backend import Module from .browser import WeatherBrowser __all__ = ['WeatherModule'] class WeatherModule(Module, CapWeather): NAME = 'weather' MAINTAINER = u'Arno Renevier' EMAIL = 'arno@renevier.net' VERSION = '1.1' DESCRIPTION = 'Get forecasts from weather.com' LICENSE = 'AGPLv3+' BROWSER = WeatherBrowser def iter_city_search(self, pattern): return self.browser.iter_city_search(pattern) def get_current(self, city_id): return self.browser.get_current(city_id) def iter_forecast(self, city_id): return self.browser.iter_forecast(city_id) ��������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/weather/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000005260�12657170273�0017425�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Arno Renevier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Page from weboob.capabilities.weather import Forecast, Current, City import datetime class CityPage(Page): def iter_city_search(self): for item in self.document.findall('//div[@class="searchResultsList"]/ul/li'): if item.attrib.get('class', '') == 'searchResultsMoreLink': continue city_name = unicode(item.text_content().strip()) city_id = item.find('a').attrib.get("href", "").split("+")[-1] yield City(city_id, city_name) class WeatherPage(Page): def get_city(self): parts = self.url.split('/')[-1].split('+') return City(parts[-1], u', '.join(parts[:-1])) def get_current(self): date = datetime.datetime.now() text = unicode(self.document.findall('//p[@class="wx-narrative"]')[0].text_content().strip()) temp = float(self.document.find('//p[@class="wx-temp"]').text_content().strip().split(u'°')[0]) return Current(date, temp, text, u'F') class ForecastPage(Page): def iter_forecast(self): divs = self.document.findall('//div[@class="wx-daypart"]') for day in range (0, len(divs)): div = divs[day].find('div[@class="wx-conditions"]') text = unicode(div.find('p[@class="wx-phrase"]').text_content().strip()) try: thigh = float(div.find('p[@class="wx-temp"]').text_content().strip().split(u'°')[0]) except: thigh = None try: tlow = float(div.find('p[@class="wx-temp-alt"]').text_content().strip().split(u'°')[0]) except: tlow = None date = divs[day].find('h3/span').text_content().strip() #date = self.document.findall('//table[@class="twc-forecast-table twc-first"]//th')[day].text #if len (date.split(' ')) > 3: # date = " ".join(date.split(' ', 3)[:3]) yield Forecast(date, tlow, thigh, text, u'F') ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/weather/test.py������������������������������������������������������������������0000664�0000000�0000000�00000002643�12657170273�0017307�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Arno Renevier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class WeatherTest(BackendTest): MODULE = 'weather' def test_cities(self): paris = self.backend.iter_city_search('crappything¶m=;drop database') self.assertTrue(len(list(paris)) == 0) paris = self.backend.iter_city_search('paris') self.assertTrue(len(list(paris)) >= 1) paris = self.backend.iter_city_search('paris france') self.assertTrue(len(list(paris)) == 1) current = self.backend.get_current(paris[0].id) self.assertTrue(current.temp.value is float(current.temp.value)) forecasts = list(self.backend.iter_forecast(paris[0].id)) self.assertTrue(len(forecasts) == 10) ���������������������������������������������������������������������������������������������weboob-1.1/modules/wellsfargo/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016457�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wellsfargo/__init__.py�����������������������������������������������������������0000664�0000000�0000000�00000001450�12657170273�0020570�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import WellsFargoModule __all__ = ['WellsFargoModule'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wellsfargo/browser.py������������������������������������������������������������0000664�0000000�0000000�00000022303�12657170273�0020514�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import AccountNotFound from weboob.browser import LoginBrowser, URL, need_login from weboob.exceptions import BrowserIncorrectPassword import ssl import json import os from tempfile import mkstemp from subprocess import STDOUT from weboob.tools.compat import check_output from urllib import unquote from .pages import LoginProceedPage, LoginRedirectPage, \ SummaryPage, ActivityCashPage, ActivityCardPage, \ StatementsPage, StatementPage, LoggedInPage __all__ = ['WellsFargo'] class WellsFargo(LoginBrowser): BASEURL = 'https://online.wellsfargo.com' TIMEOUT = 30 MAX_RETRIES = 10 login_proceed = URL('/das/cgi-bin/session.cgi\?screenid=SIGNON.*$', '/login\?ERROR_CODE=.*LOB=CONS&$', LoginProceedPage) login_redirect = URL('/das/cgi-bin/session.cgi\?screenid=SIGNON.*$', '/login\?ERROR_CODE=.*LOB=CONS&$', LoginRedirectPage) summary = URL('/das/channel/accountSummary$', SummaryPage) activity_cash = URL('/das/cgi-bin/session.cgi\?sessargs=.+$', ActivityCashPage) activity_card = URL('/das/cgi-bin/session.cgi\?sessargs=.+$', ActivityCardPage) statements = URL( '/das/cgi-bin/session.cgi\?sessargs=.+$', '/das/channel/accountActivityDDA\?action=doSetPage&page=.*$', StatementsPage) statement = URL('/das/cgi-bin/session.cgi\?sessargs=.+$', StatementPage) unknown = URL('/.*$', LoggedInPage) # E.g. random advertisement pages. def __init__(self, question1, answer1, question2, answer2, question3, answer3, *args, **kwargs): super(WellsFargo, self).__init__(*args, **kwargs) self.question1 = question1 self.answer1 = answer1 self.question2 = question2 self.answer2 = answer2 self.question3 = question3 self.answer3 = answer3 def do_login(self): ''' There's a bunch of dynamically generated obfuscated JavaScript, which uses DOM. For now the easiest option seems to be to run it in PhantomJs. ''' for i in xrange(self.MAX_RETRIES): scrf, scrn = mkstemp('.js') cookf, cookn = mkstemp('.json') os.write(scrf, LOGIN_JS % { 'timeout': self.TIMEOUT, 'username': self.username, 'password': self.password, 'output': cookn, 'question1': self.question1, 'answer1': self.answer1, 'question2': self.question2, 'answer2': self.answer2, 'question3': self.question3, 'answer3': self.answer3}) os.close(scrf) os.close(cookf) check_output(["phantomjs", scrn], stderr=STDOUT) with open(cookn) as cookf: cookies = json.loads(cookf.read()) os.remove(scrn) os.remove(cookn) self.session.cookies.clear() for c in cookies: for k in ['expiry', 'expires', 'httponly']: c.pop(k, None) c['value'] = unquote(c['value']) self.session.cookies.set(**c) self.summary.go() if self.page.logged: break else: raise BrowserIncorrectPassword def location(self, *args, **kwargs): """ Wells Fargo inserts redirecting pages from time to time, so we should follow them whenever we see them. """ r = super(WellsFargo, self).location(*args, **kwargs) if self.login_proceed.is_here(): return self.page.proceed() elif self.login_redirect.is_here(): return self.page.redirect() else: return r def prepare_request(self, req): """ Wells Fargo uses TLS v1.0. See issue #1647 for details. """ preq = super(WellsFargo, self).prepare_request(req) conn = self.session.adapters['https://'].get_connection(preq.url) conn.ssl_version = ssl.PROTOCOL_TLSv1 return preq def get_account(self, id_): self.to_activity() if id_ not in self.page.accounts_ids(): raise AccountNotFound() else: self.to_activity(id_) return self.page.get_account() def iter_accounts(self): self.to_activity() for id_ in self.page.accounts_ids(): self.to_activity(id_) yield self.page.get_account() @need_login def to_summary(self): self.summary.stay_or_go() assert self.summary.is_here() def is_activity(self): return self.activity_cash.is_here() or self.activity_card.is_here() @need_login def to_activity(self, id_=None): if not self.is_activity(): self.to_summary() self.page.to_activity() assert self.is_activity() if id_ and self.page.account_id() != id_: self.page.to_account(id_) assert self.is_activity() assert self.page.account_id() == id_ @need_login def to_statements(self, id_=None, year=None): if not self.statements.is_here(): self.to_summary() self.page.to_statements() assert self.statements.is_here() if id_ and self.page.account_id() != id_: self.page.to_account(id_) assert self.statements.is_here() assert self.page.account_id() == id_ if year and self.page.year() != year: self.page.to_year(year) assert self.statements.is_here() assert self.page.year() == year @need_login def to_statement(self, uri): self.location(uri) assert self.statement.is_here() def iter_history(self, account): self.to_activity(account.id) # Skip transactions on web page if we cannot apply # "since last statement" filter. # This might be the case, for example, if Wells Fargo # is processing the current statement: # "Since your credit card account statement is being processed, # transactions grouped by statement period will not be available # for up to seven days." # (www.wellsfargo.com, 2014-07-20) if self.page.since_last_statement(): assert self.page.account_id() == account.id while True: for trans in self.page.iter_transactions(): yield trans if not self.page.next_(): break self.to_statements(account.id) for year in self.page.years(): self.to_statements(account.id, year) for stmt in self.page.statements(): self.to_statement(stmt) for trans in self.page.iter_transactions(): yield trans LOGIN_JS = u'''\ var TIMEOUT = %(timeout)s*1000; // milliseconds var page = require('webpage').create(); page.open('https://online.wellsfargo.com/'); var waitForForm = function() { var hasForm = page.evaluate(function(){ return !!document.getElementById('Signon') }); if (hasForm) { page.evaluate(function(){ document.getElementById('username').value = '%(username)s'; document.getElementById('password').value = '%(password)s'; document.getElementById('Signon').submit(); }); } else { setTimeout(waitForForm, 1000); } } var waitForQuestions = function() { var isQuestion = page.content.indexOf('Confirm Your Identity') != -1; if (isQuestion) { var questions = { "%(question1)s": "%(answer1)s", "%(question2)s": "%(answer2)s", "%(question3)s": "%(answer3)s" }; for (var question in questions) { if (page.content.indexOf(question)) { page.evaluate(function(answer){ document.getElementById('answer').value = answer; document.getElementById('command').submit.click(); }, questions[question]); } } } setTimeout(waitForQuestions, 2000); } var waitForLogin = function() { var isSplash = page.content.indexOf('Splash Page') != -1; var hasSignOff = page.content.indexOf('Sign Off') != -1; if (isSplash || hasSignOff) { var cookies = JSON.stringify(phantom.cookies); require('fs').write('%(output)s', cookies, 'w'); phantom.exit(); } else { setTimeout(waitForLogin, 2000); } } waitForForm(); waitForQuestions(); waitForLogin(); setTimeout(function(){phantom.exit(-1);}, TIMEOUT); ''' �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wellsfargo/favicon.png�����������������������������������������������������������0000664�0000000�0000000�00000000435�12657170273�0020614�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@������PLTE�KXP���IDAT(c`#`o�30f~e C[Y l ';E00\> T�d|<p a@Fbl=>a q<<G Dxj v99dϟ? ,!0`}axg1L<P]Ll`{;4�T*G!,T����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wellsfargo/module.py�������������������������������������������������������������0000664�0000000�0000000�00000005007�12657170273�0020320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import CapBank from weboob.tools.backend import Module, BackendConfig from weboob.tools.value import ValueBackendPassword from .browser import WellsFargo __all__ = ['WellsFargoModule'] class WellsFargoModule(Module, CapBank): NAME = 'wellsfargo' MAINTAINER = u'Oleg Plakhotniuk' EMAIL = 'olegus8@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' DESCRIPTION = u'Wells Fargo' CONFIG = BackendConfig( ValueBackendPassword('login', label='Username', masked=False), ValueBackendPassword('password', label='Password'), ValueBackendPassword('question1', label='Question 1', masked=False), ValueBackendPassword('answer1', label='Answer 1', masked=False), ValueBackendPassword('question2', label='Question 2', masked=False), ValueBackendPassword('answer2', label='Answer 2', masked=False), ValueBackendPassword('question3', label='Question 3', masked=False), ValueBackendPassword('answer3', label='Answer 3', masked=False)) BROWSER = WellsFargo def create_default_browser(self): return self.create_browser( username = self.config['login'].get(), password = self.config['password'].get(), question1 = self.config['question1'].get(), answer1 = self.config['answer1'].get(), question2 = self.config['question2'].get(), answer2 = self.config['answer2'].get(), question3 = self.config['question3'].get(), answer3 = self.config['answer3'].get()) def iter_accounts(self): return self.browser.iter_accounts() def get_account(self, id_): return self.browser.get_account(id_) def iter_history(self, account): return self.browser.iter_history(account) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wellsfargo/pages.py��������������������������������������������������������������0000664�0000000�0000000�00000032364�12657170273�0020140�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import Account, Transaction from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.browser.pages import HTMLPage, LoggedPage, RawPage from urllib import unquote from decimal import Decimal from requests.cookies import morsel_to_cookie from .parsers import StatementParser, clean_label import itertools import re import datetime import Cookie class LoginProceedPage(LoggedPage, HTMLPage): is_here = '//script[contains(text(),"setAndCheckCookie")]' def proceed(self): script = self.doc.xpath('//script/text()')[0] cookieStr = re.match('.*document\.cookie = "([^"]+)".*', script, re.DOTALL).group(1) morsel = Cookie.Cookie(cookieStr).values()[0] self.browser.session.cookies.set_cookie(morsel_to_cookie(morsel)) form = self.get_form() return form.submit() class LoginRedirectPage(LoggedPage, HTMLPage): is_here = 'contains(//meta[@http-equiv="Refresh"]/@content,' \ '"SIGNON_PORTAL_PAUSE")' def redirect(self): refresh = self.doc.xpath( '//meta[@http-equiv="Refresh"]/@content')[0] url = re.match(r'^.*URL=(.*)$', refresh).group(1) return self.browser.location(url) class LoggedInPage(HTMLPage): @property def logged(self): return bool(self.doc.xpath(u'//a[text()="Sign Off"]')) \ or bool(self.doc.xpath(u'//title[text()="Splash Page"]')) class SummaryPage(LoggedInPage): is_here = u'//title[contains(text(),"Account Summary")]' def to_activity(self): href = self.doc.xpath(u'//a[text()="Account Activity"]/@href')[0] self.browser.location(href) def to_statements(self): href = self.doc.xpath('//a[text()="Statements & Documents"]' '/@href')[0] self.browser.location(href) class AccountPage(LoggedInPage): def account_id(self, name=None): if name: return name[-4:] # Last 4 digits of "BLAH XXXXXXX1234" else: return self.account_id(self.account_name()) class ActivityPage(AccountPage): def is_here(self): return bool(self.doc.xpath( u'contains(//title/text(),"Account Activity")')) def accounts_names(self): return self.doc.xpath( u'//select[@name="selectedAccountUID"]/option/text()') def accounts_ids(self): return [self.account_id(name) for name in self.accounts_names()] def account_uid(self, id_=None): if id_: return self.doc.xpath( u'//select[@name="selectedAccountUID"]' u'/option[contains(text(),"%s")]/@value' % id_)[0] else: return self.doc.xpath( u'//select[@name="selectedAccountUID"]' u'/option[@selected="selected"]/@value')[0] def account_name(self): for name in self.doc.xpath(u'//select[@name="selectedAccountUID"]' u'/option[@selected="selected"]/text()'): return name return u'' def account_type(self, name=None): raise NotImplementedError() def account_balance(self): raise NotImplementedError() def account_paydatemin(self): return None, None def account_cardlimit(self): return None def to_account(self, id_): form = self.get_form(xpath='//form[@name="AccountActivityForm"]') form['selectedAccountUID'] = [self.account_uid(id_)] form.submit() def get_account(self): name = self.account_name() balance = self.account_balance() currency = Account.get_currency(balance) id_ = self.account_id() type_ = self.account_type() paydate, paymin = self.account_paydatemin() cardlimit = self.account_cardlimit() account = Account() account.id = id_ account.label = name account.currency = currency account.balance = AmTr.decimal_amount(balance) account.type = type_ if paydate is not None: account.paydate = paydate if paymin is not None: account.paymin = paymin if cardlimit is not None: account.cardlimit = AmTr.decimal_amount(cardlimit) return account def since_last_statement(self): raise NotImplementedError() def iter_transactions(self): raise NotImplementedError() def next_(self): raise NotImplementedError() class ActivityCashPage(ActivityPage): def is_here(self): return super(ActivityCashPage, self).is_here() and \ (u'CHECKING' in self.account_name() or u'SAVINGS' in self.account_name()) def account_type(self, name=None): name = name or self.account_name() if u'CHECKING' in name: return Account.TYPE_CHECKING elif u'SAVINGS' in name: return Account.TYPE_SAVINGS else: return Account.TYPE_UNKNOWN def account_balance(self): return self.doc.xpath( u'//td[@headers="currentPostedBalance"]/span/text()')[0] def since_last_statement(self): form = self.get_form(xpath='//form[@id="ddaShowForm"]') form['showTabDDACommand.transactionTypeFilterValue'] = [ u'All Transactions'] form['showTabDDACommand.timeFilterValue'] = ['8'] form.submit() return True def iter_transactions(self): for row in self.doc.xpath('//tr/th[@headers=' '"postedHeader dateHeader"]/..'): date = row.xpath('th[@headers="postedHeader ' 'dateHeader"]/text()')[0] desc = row.xpath('td[@headers="postedHeader ' 'descriptionHeader"]/span/text()')[0] deposit = row.xpath('td[@headers="postedHeader ' 'depositsConsumerHeader"]/span/text()')[0] withdraw = row.xpath('td[@headers="postedHeader ' 'withdrawalsConsumerHeader"]/span/text()')[0] date = datetime.datetime.strptime(date, '%m/%d/%y') desc = clean_label(desc) deposit = deposit.strip() deposit = AmTr.decimal_amount(deposit or '0') withdraw = withdraw.strip() withdraw = AmTr.decimal_amount(withdraw or '0') amount = deposit - withdraw trans = Transaction(u'') trans.date = date trans.rdate = date trans.type = Transaction.TYPE_UNKNOWN trans.raw = desc trans.label = desc trans.amount = amount yield trans def next_(self): links = self.doc.xpath('//a[@title="Go To Next Page"]/@href') if links: self.browser.location(links[0]) return True else: return False class ActivityCardPage(ActivityPage): def is_here(self): return super(ActivityCardPage, self).is_here() and \ u'CARD' in self.account_name() def account_type(self, name=None): return Account.TYPE_CARD def account_balance(self): return self.doc.xpath( u'//td[@headers="outstandingBalance"]/text()')[0] def account_cardlimit(self): return self.doc.xpath( u'//td[@headers="totalCreditLimit"]/text()')[0] def account_paydatemin(self): if self.doc.xpath(u'//p[contains(text(),' '"payment due date is not yet scheduled")]'): # If payment date is not scheduled yet, set it somewhere in a # distant future, so that we always have a valid date. return datetime.datetime.now() + datetime.timedelta(days=999), \ Decimal(0) else: date = self.doc.xpath(u'//span[contains(text(),"Minimum Payment")]' '/span/text()')[0] date = re.match(u'.*(../../..).*', date).group(1) date = datetime.datetime.strptime(date, '%m/%d/%y') amount = self.doc.xpath(u'//td[@headers="minimumPaymentDue"]' '//text()')[0].strip() return date, AmTr.decimal_amount(amount) def get_account(self): account = ActivityPage.get_account(self) # Credit card is essentially a liability. # Negative amount means there's a payment due. account.balance = -account.balance return account def since_last_statement(self): if self.doc.xpath('//select[@name="showTabCommand.' 'transactionTypeFilterValue"]' '/option[@value="sincelastStmt"]'): form = self.get_form(xpath='//form[@id="creditCardShowForm"]') form['showTabCommand.transactionTypeFilterValue'] = [ 'sincelastStmt'] form.submit() return True def iter_transactions(self): for row in self.doc.xpath('//tr/th[@headers=' '"postedHeader transactionDateHeader"]/..'): tdate = row.xpath('th[@headers="postedHeader ' 'transactionDateHeader"]/text()')[0] pdate = row.xpath('td[@headers="postedHeader ' 'postingDateHeader"]/text()')[0] desc = row.xpath('td[@headers="postedHeader ' 'descriptionHeader"]/span/text()')[0] ref = row.xpath('td[@headers="postedHeader ' 'descriptionHeader"]/text()')[0] amount = row.xpath('td[@headers="postedHeader ' 'amountHeader"]/text()')[0] tdate = datetime.datetime.strptime(tdate, '%m/%d/%y') pdate = datetime.datetime.strptime(pdate, '%m/%d/%y') desc = clean_label(desc) ref = re.match('.*<REFERENCE ([^>]+)>.*', ref).group(1) if amount.startswith('+'): amount = AmTr.decimal_amount(amount[1:]) else: amount = -AmTr.decimal_amount(amount) trans = Transaction(ref) trans.date = tdate trans.rdate = pdate trans.type = Transaction.TYPE_UNKNOWN trans.raw = desc trans.label = desc trans.amount = amount yield trans def next_(self): # As of 2014-07-05, there's only one page for cards history. return False class StatementsPage(AccountPage): is_here = u'contains(//title/text(),"Statements")' def account_name(self): return self.doc.xpath( u'//select[@name="selectedAccountKey"]' u'/option[@selected="selected"]/text()')[0] def account_uid(self, id_): return self.doc.xpath( u'//select[@name="selectedAccountKey"]' u'/option[contains(text(),"%s")]/@value' % id_)[0] def to_account(self, id_): form = self.get_form(xpath='//form[@id="statementsAndDocumentsModel"]') form['selectedAccountKey'] = [self.account_uid(id_)] form.submit() def year(self): for text in self.doc.xpath('//h2/strong/text()'): try: return int(text) except ValueError: pass def years(self): for text in self.doc.xpath('//h2//strong/text()'): try: yield int(text) except ValueError: pass def to_year(self, year): href = self.doc.xpath('//h2/a/strong[text()="%s"]/../@href' % year)[0] self.browser.location(href) def statements(self): for outer_uri in self.doc.xpath( '//table[@id="listOfStatements"]' '//a[contains(text(), "Statement")]/@href'): inner_uri = re.match('.*destinationClickUrl=([^&]+)&.*', outer_uri).group(1) yield unquote(inner_uri) class StatementPage(LoggedPage, RawPage): def __init__(self, *args, **kwArgs): RawPage.__init__(self, *args, **kwArgs) self._parser = StatementParser(self.doc) def is_here(self): return self.doc[:4] == '%PDF' def iter_transactions(self): # Maintain a nice consistent newer-to-older order of transactions. return sorted( itertools.chain( self._parser.read_cash_transactions(), self._parser.read_card_transactions()), cmp=lambda t1, t2: cmp(t2.date, t1.date) or cmp(t1.label, t2.label) or cmp(t1.amount, t2.amount)) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wellsfargo/parsers.py������������������������������������������������������������0000664�0000000�0000000�00000024575�12657170273�0020525�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.bank import Transaction from weboob.tools.capabilities.bank.transactions import \ AmericanTransaction as AmTr from weboob.tools.date import closest_date from weboob.tools.pdf import decompress_pdf from weboob.tools.tokenizer import ReTokenizer import re import datetime def clean_label(text): """ Web view and statements use different label formatting. User shouldn't be able to see the difference, so we need to make labels from both sources look the same. """ return re.sub(u' +', u' ', text.strip().upper(), re.UNICODE) class StatementParser(object): """ Each "read_*" method takes position as its argument, and returns next token position if read was successful, or the same position if it was not. """ LEX = [ ('amount', r'^\[\(([0-9,]+\.\d+)\)\] TJ$'), ('date', r'^\[\((\d+/\d+)\)\] TJ$'), ('date_range_1', r'^\[\(([A-z]+ \d+, \d{4})' r' - ([A-z]+ \d+, \d{4})\)\] TJ$'), ('date_range_2', r'^\[\((\d{2}/\d{2}/\d{4})' r' to (\d{2}/\d{2}/\d{4})\)\] TJ$'), ('layout_tz', r'^(\d+\.\d{2}) Tz$'), ('layout_tc', r'^(\d+\.\d{2}) Tc$'), ('layout_tw', r'^(\d+\.\d{2}) Tw$'), ('layout_tf', r'^/F(\d) (\d+\.\d{2}) Tf$'), ('layout_tm', r'^' + (r'(\d+\.\d+ )'*6) + r'Tm$'), ('ref', r'^\[\(([0-9A-Z]{17})\)\] TJ$'), ('text', r'^\[\(([^\)]+)\)\] TJ$') ] def __init__(self, pdf): self._pdf = decompress_pdf(pdf) self._tok = ReTokenizer(self._pdf, '\n', self.LEX) def read_card_transactions(self): # Early check if this is a card account statement at all. if '[(Transactions)] TJ' not in self._pdf: return # Read statement dates range. date_from, date_to = self.read_first_date_range() # Read transactions. pos = 0 while not self._tok.tok(pos).is_eof(): pos, trans = self.read_card_transaction(pos, date_from, date_to) if trans: yield trans else: pos += 1 def read_cash_transactions(self): # Early check if this is a cash account statement at all. if '[(Transaction history)] TJ' not in self._pdf: return # Read statement dates range. date_from, date_to = self.read_first_date_range() # Read transactions. pos = 0 while not self._tok.tok(pos).is_eof(): pos, trans = self.read_cash_transaction(pos, date_from, date_to) if trans: yield trans else: pos += 1 def read_first_date_range(self): pos = 0 while not self._tok.tok(pos).is_eof(): pos, date_range = self.read_date_range(pos) if date_range is not None: return date_range else: pos += 1 def read_card_transaction(self, pos, date_from, date_to): INDENT_CHARGES = 520 startPos = pos pos, tdate = self.read_date(pos) pos, pdate_layout = self.read_layout_tm(pos) pos, pdate = self.read_date(pos) pos, ref_layout = self.read_layout_tm(pos) pos, ref = self.read_ref(pos) pos, desc = self.read_multiline_desc(pos) pos, amount = self.read_indent_amount( pos, range_minus = (INDENT_CHARGES, 9999), range_plus = (0, INDENT_CHARGES)) if tdate is None or pdate_layout is None or pdate is None \ or ref_layout is None or ref is None or desc is None or amount is None: return startPos, None else: tdate = closest_date(tdate, date_from, date_to) pdate = closest_date(pdate, date_from, date_to) trans = Transaction(ref) trans.date = tdate trans.rdate = pdate trans.type = Transaction.TYPE_UNKNOWN trans.raw = desc trans.label = desc trans.amount = amount return pos, trans def read_cash_transaction(self, pos, date_from, date_to): INDENT_BALANCE = 520 INDENT_WITHDRAWAL = 470 startPos = pos pos, date = self.read_date(pos) pos, _ = self.read_star(pos) pos, desc = self.read_multiline_desc(pos) pos, amount = self.read_indent_amount( pos, range_plus = (0, INDENT_WITHDRAWAL), range_minus = (INDENT_WITHDRAWAL, INDENT_BALANCE), range_skip = (INDENT_BALANCE, 9999)) if desc is None or date is None or amount is None: return startPos, None else: date = closest_date(date, date_from, date_to) trans = Transaction(u'') trans.date = date trans.rdate = date trans.type = Transaction.TYPE_UNKNOWN trans.raw = desc trans.label = desc trans.amount = amount return pos, trans def read_multiline_desc(self, pos): startPos = pos descs = [] while True: prevPos = pos pos, layout = self.read_layout_tm(pos) pos, desc = self.read_text(pos) if layout is None or desc is None: pos = prevPos break else: descs.append(desc) if descs: return pos, clean_label(' '.join(descs)) else: return startPos, None def read_indent_amount(self, pos, range_skip=(0,0), range_plus=(0,0), range_minus=(0,0)): startPos = pos # Read layout-amount pairs. amounts = [] while True: prevPos = pos pos, layout = self.read_layout_tm(pos) pos, amount = self.read_amount(pos) if layout is None or amount is None: pos = prevPos break else: amounts.append((layout, amount)) if not amounts: return startPos, None else: # Infer amount type by its indentation in the layout. amount_total = AmTr.decimal_amount('0') for (_, _, _, _, indent, _), amount in amounts: within = lambda xmin_xmax: xmin_xmax[0] <= indent <= xmin_xmax[1] if within(range_skip): continue elif within(range_plus): amount_total += amount elif within(range_minus): amount_total -= amount return pos, amount_total def read_star(self, pos): pos1, star1 = self.read_star_1(pos) pos2, star2 = self.read_star_2(pos) if star1 is not None: return pos1, star1 else: return pos2, star2 def read_star_1(self, pos): startPos = pos vals = list() pos, v = self.read_layout_tz(pos); vals.append(v) pos, v = self.read_layout_tc(pos); vals.append(v) pos, v = self.read_layout_tw(pos); vals.append(v) pos, v = self.read_layout_tf(pos); vals.append(v) pos, v = self.read_layout_tm(pos); vals.append(v) pos, star = self.read_text(pos) pos, v = self.read_layout_tz(pos); vals.append(v) pos, v = self.read_layout_tc(pos); vals.append(v) pos, v = self.read_layout_tw(pos); vals.append(v) pos, v = self.read_layout_tf(pos); vals.append(v) if star == 'S' and None not in vals: return pos, star else: return startPos, None def read_star_2(self, pos): startPos = pos vals = list() pos, v = self.read_layout_tf(pos); vals.append(v) pos, v = self.read_layout_tm(pos); vals.append(v) pos, star = self.read_text(pos) pos, v = self.read_layout_tf(pos); vals.append(v) if star == 'S' and None not in vals: return pos, star else: return startPos, None def read_date(self, pos): t = self._tok.tok(pos) return (pos+1, datetime.datetime.strptime(t.value(), '%m/%d')) \ if t.is_date() else (pos, None) def read_text(self, pos): t = self._tok.tok(pos) #TODO: handle PDF encodings properly. return (pos+1, unicode(t.value(), errors='ignore')) \ if t.is_text() else (pos, None) def read_amount(self, pos): t = self._tok.tok(pos) return (pos+1, AmTr.decimal_amount(t.value())) \ if t.is_amount() else (pos, None) def read_date_range(self, pos): t = self._tok.tok(pos) if t.is_date_range_1(): return (pos+1, [datetime.datetime.strptime(v, '%B %d, %Y') for v in t.value()]) elif t.is_date_range_2(): return (pos+1, [datetime.datetime.strptime(v, '%m/%d/%Y') for v in t.value()]) else: return (pos, None) def read_ref(self, pos): t = self._tok.tok(pos) return (pos+1, t.value()) if t.is_ref() else (pos, None) def read_layout_tz(self, pos): t = self._tok.tok(pos) return (pos+1, t.value()) if t.is_layout_tz() else (pos, None) def read_layout_tc(self, pos): t = self._tok.tok(pos) return (pos+1, t.value()) if t.is_layout_tc() else (pos, None) def read_layout_tw(self, pos): t = self._tok.tok(pos) return (pos+1, t.value()) if t.is_layout_tw() else (pos, None) def read_layout_tf(self, pos): t = self._tok.tok(pos) return (pos+1, t.value()) if t.is_layout_tf() else (pos, None) def read_layout_tm(self, pos): t = self._tok.tok(pos) return (pos+1, [float(v) for v in t.value()]) \ if t.is_layout_tm() else (pos, None) �����������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wellsfargo/test.py���������������������������������������������������������������0000664�0000000�0000000�00000002202�12657170273�0020004�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from itertools import chain class WellsFargoTest(BackendTest): MODULE = 'wellsfargo' def test_history(self): """ Test that there's at least one transaction in the whole history. """ b = self.backend ts = chain(*[b.iter_history(a) for a in b.iter_accounts()]) t = next(ts, None) self.assertNotEqual(t, None) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wordreference/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017144�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wordreference/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000001503�12657170273�0021254�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������"WordReferenceModule init" # -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import WordReferenceModule __all__ = ['WordReferenceModule'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wordreference/browser.py���������������������������������������������������������0000664�0000000�0000000�00000002546�12657170273�0021210�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from .pages import TranslatePage __all__ = ['WordReferenceBrowser'] class WordReferenceBrowser(PagesBrowser): BASEURL = 'http://www.wordreference.com' translation_page = URL('(?P<sl>[a-z]{2})(?P<tl>[a-z]{2})/(?P<pattern>.*)', TranslatePage) def translate(self, source, to, text): """ translate 'text' from 'source' language to 'to' language """ return self.translation_page.go(sl=source.encode('utf-8'), tl=to.encode('utf-8'), pattern=text.encode('utf-8')).get_translation() ����������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wordreference/favicon.png��������������������������������������������������������0000664�0000000�0000000�00000004110�12657170273�0021273�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB����bKGD������ pHYs�� �� B(x���tIME  sC2���iTXtComment�����Created with GIMPd.e��IDATx}e?Wr'H̕@m(-&-`btmD !cTL'PC`k(PǦԥml I]yIx rEԡwr=gannyk$_y>gC:)s_( [r�?fwO�Q~&�p8& ܝ'7�K,.񣁏 �U;˯^r,r,+͂ѸfZl3�6 h~~4wA<b./D;0 �!{ }jΡVMrE]a7� K) + irEgl ��LN;wkDl�X~7 X׎c?HKϯsy�T<AGͭk@t�i^�TShFF?�%F<bt �*F{)|w?gUѭ]l' S\g/$?e5NepS.F! �״scp�OG] -hDŎTsO*fe5FE(rwbR]�إ_2 O\O'{T4j_<SnIJ e(,k"؅� �U\ (7֘)b5,;58>_q ˉ4fJ '#)cmNx>n�}7cA>M`%QV�d1܉E:3X<H1*ZUO+ $*d_(n�," pQ?+jMIbys 6)âF6-Bn)<59/֭6aP׊[uWHFqv]ڪiM0Y)o厫<Wu{Y0T %@֙Ib({ ԕƪ#$M20Ը/o� h3rhmfZ g7nJjMUz{։d2L`"@xۺn;4߰X Xf:�U{P| 򽩻;3;v'D۩[҉dRKOOӾCjc/M<{swh4eefX[[ʌ'̯-55YDh7kEh޹5-뀷M6>@U SٿLFɺ_EQnIWE_yrL.*'#$%/ʺ: `{\ӿ6ԗ(+�&;~(pw�2xn'4%}A$ {`u K/ 퉱KMPe/OѷCO7+*ہnAt?\jAeWh <Q[ZJEjʭ@`J zj�Gpo)pD&l۫?0;nˁm'66@lh/?4lP.$NlFz/S�@)p?S !gU,^i|GԾ4-/A&JZ&FTWET9;~Tqk 2�dmǁK1[7IG8ӄ [nXv;~t^JהffCE,wwQ1&}8Oz`In>n/S© li38,׉!& }ل~#QeYTCxS:w(o &U$-sZD$bscR 6 enl?^(\}vS良�+%M L>z <] =+loCP:ԡuCg(TB����IENDB`��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wordreference/module.py����������������������������������������������������������0000664�0000000�0000000�00000004061�12657170273�0021004�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. "backend for http://www.wordreference.com" from weboob.capabilities.translate import CapTranslate, TranslationFail, LanguageNotSupported from weboob.tools.backend import Module from .browser import WordReferenceBrowser __all__ = ['WordReferenceModule'] class WordReferenceModule(Module, CapTranslate): MAINTAINER = u'Lucien Loiseau' EMAIL = 'loiseau.lucien@gmail.com' VERSION = '1.1' LICENSE = 'AGPLv3+' NAME = 'wordreference' DESCRIPTION = u'Free online translator' BROWSER = WordReferenceBrowser WRLANGUAGE = { 'Arabic': 'ar', 'Chinese': 'zh', 'Czech': 'cz', 'English': 'en', 'French': 'fr', 'Greek': 'gr', 'Italian': 'it', 'Japanese': 'ja', 'Korean': 'ko', 'Polish': 'pl', 'Portuguese': 'pt', 'Romanian': 'ro', 'Spanish': 'es', 'Turkish': 'tr', } def translate(self, lan_from, lan_to, text): if lan_from not in self.WRLANGUAGE.keys(): raise LanguageNotSupported() if lan_to not in self.WRLANGUAGE.keys(): raise LanguageNotSupported() translations = self.browser.translate(self.WRLANGUAGE[lan_from], self.WRLANGUAGE[lan_to], text) has_translation = False for translation in translations: has_translation = True yield translation if not has_translation: raise TranslationFail() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wordreference/pages.py�����������������������������������������������������������0000664�0000000�0000000�00000002615�12657170273�0020621�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.capabilities.translate import Translation from weboob.browser.filters.standard import CleanText, Regexp, Env from weboob.browser.filters.html import CleanHTML class TranslatePage(HTMLPage): @method class get_translation(ListElement): item_xpath = '//table[@class="WRD" and not(@id)]/tr[@id]' class item(ItemElement): klass = Translation obj_id = Regexp(CleanText('./@id'), '.*:(.*)') obj_lang_src = Env('sl') obj_lang_dst = Env('tl') obj_text = CleanHTML('./td[@class="ToWrd"]') �������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/wordreference/test.py������������������������������������������������������������0000664�0000000�0000000�00000001726�12657170273�0020503�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- CODing: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class WordReferenceTest(BackendTest): MODULE = 'wordreference' def test_translate(self): tr = self.backend.translate('French', 'English', 'chat') self.assertTrue(tr.text == u'cat') ������������������������������������������weboob-1.1/modules/yahoo/���������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0015431�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/yahoo/__init__.py����������������������������������������������������������������0000664�0000000�0000000�00000001433�12657170273�0017543�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import YahooModule __all__ = ['YahooModule'] �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/yahoo/favicon.png����������������������������������������������������������������0000664�0000000�0000000�00000000562�12657170273�0017567�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ����tIME(Ԯ\���tEXtComment�Created with GIMPW���IDATx 07y@)e2R{7ɧɬ#B<q.טqzȥr.[` {P0��T�0��@0��T�0��c�1Ʊ%poŀ[�5�(+#H�`� T P xUҩ)�1|Sl:d P |q֊_nw�����������!e<c,!yF����IENDB`����������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/yahoo/module.py������������������������������������������������������������������0000664�0000000�0000000�00000006460�12657170273�0017276�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import urllib2 from xml.dom import minidom from dateutil.parser import parse as parse_dt from weboob.capabilities.weather import CapWeather, CityNotFound, Current, Forecast, City from weboob.tools.backend import Module from weboob.deprecated.browser import StandardBrowser __all__ = ['YahooModule'] class YahooModule(Module, CapWeather): NAME = 'yahoo' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'Yahoo!' LICENSE = 'AGPLv3+' BROWSER = StandardBrowser WEATHER_URL = 'http://weather.yahooapis.com/forecastrss?w=%s&u=%s' def create_default_browser(self): return self.create_browser(parser='json') def iter_city_search(self, pattern): args = {'q': 'select line1, line2, line3, line4, city, uzip, statecode, countrycode, latitude, longitude, ' 'country, woeid, quality, house, street, state from locdrop.placefinder ' 'where text="%s" and locale="fr-FR" and gflags="f"' % pattern.encode('utf-8'), 'format': 'json', } doc = self.browser.location(self.browser.buildurl('http://locdrop.query.yahoo.com/v1/public/yql', **args)) cities = doc['query']['results']['Result'] if not isinstance(cities, (tuple, list)): cities = [cities] for result in cities: c = City(result['woeid'], u'%s, %s, %s' % (result['city'], result['state'], result['country'])) yield c def _get_weather_dom(self, city_id): handler = urllib2.urlopen(self.WEATHER_URL % (city_id, 'c')) dom = minidom.parse(handler) handler.close() if not dom.getElementsByTagName('yweather:condition'): raise CityNotFound('City not found: %s' % city_id) return dom def get_current(self, city_id): dom = self._get_weather_dom(city_id) current = dom.getElementsByTagName('yweather:condition')[0] return Current(parse_dt(current.getAttribute('date')).date(), float(current.getAttribute('temp')), unicode(current.getAttribute('text')), u'C') def iter_forecast(self, city_id): dom = self._get_weather_dom(city_id) for forecast in dom.getElementsByTagName('yweather:forecast'): yield Forecast(parse_dt(forecast.getAttribute('date')).date(), float(forecast.getAttribute('low')), float(forecast.getAttribute('high')), unicode(forecast.getAttribute('text')), u'C', ) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/yahoo/test.py��������������������������������������������������������������������0000664�0000000�0000000�00000002265�12657170273�0016767�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest class YahooTest(BackendTest): MODULE = 'yahoo' def test_meteo(self): l = list(self.backend.iter_city_search('paris')) self.assertTrue(len(l) > 0) city = l[0] current = self.backend.get_current(city.id) self.assertTrue(current.temp.value > -20 and current.temp.value < 50) forecasts = list(self.backend.iter_forecast(city.id)) self.assertTrue(len(forecasts) > 0) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016035�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0020145�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import YoujizzModule __all__ = ['YoujizzModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000003455�12657170273�0020101�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from weboob.capabilities.base import UserError from .pages.index import IndexPage from .pages.video import VideoPage __all__ = ['YoujizzBrowser'] class YoujizzBrowser(PagesBrowser): BASEURL = 'http://www.youjizz.com' index = URL(r'/?(index.php)?$', r'/page/\d+.html', IndexPage) search = URL(r'/search/(?P<pattern>.+)-(?P<pagenum>\d+).html', IndexPage) video = URL(r'/videos/(?P<id>.*).html', VideoPage) @video.id2url def get_video(self, url, video=None): self.location(url) assert self.video.is_here() return self.page.get_video(video) def search_videos(self, pattern): if len(pattern) < 3: raise UserError('Pattern to short (min length : 3 characters)') self.search.go(pattern=pattern, pagenum=1) assert self.search.is_here(pattern=pattern, pagenum=1) return self.page.iter_videos() def latest_videos(self): self.index.go() assert self.index.is_here() return self.page.iter_videos() �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000006164�12657170273�0020177�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ����tIME -i�� IDATx]l[>c'M|M(!!ka#㣄 $h (EBH `Lf傋EUҤ!MH6X+R2Z6)K&M{' ;'c;Yd|}yW]g~]]j@ [;K2s!s?}83S- �fC-h"@5fmy X,ex ~E`tum~+/;`bTUqTQ<&0jKdR( XUU4ݮ醑JR] dҧ뺠=sIS �I֬lZO߿o!� d>yrp|Ju0 �!I2YDѭz\8@Jݪʂ(ɤ[uO}.c713$Β�08phTD߯z;7m] un3�H1(+0�%)0E�ɹ&u &t'`rǎY_E0is`YNǁ @Za9MR\j-Mx@vknmHO1MץQEm��DqIE+zWZ3l965屼b d2ùܮW0f4TV^47!^p$R)`y3= Zv[fW]zok1�~cJ%p `[V(u@,%aN}Ʋ‚/Ȫ_ }L  :) ϳOyϹKjI}g'eB'^׉֙KhMw#p&jMl'a?nU(re%89hŋWlp N\O0t%?0:<JV[l| 0?顡,--\kjz=F>[n茶H#~dfj�8Ȳ ̹{ٰc$qb~ݛ&XJJ٧XjOp|T|lڽ-'/]w _1-$dx*9G]Eadd$}#<5:ʶ>bKSUEöm ʨHQ0TMK/ӧN͞=<&! "--yYдep ϲH<.qܵ\ +߼*~Z dC\6�a]fNJ($k9 ko#?N2N?P8Ctb U*?TZ�9 -#G=wođ#~ܵ }h9dK/w @(| @k)Ce/)ooC8ݍ G2;56>$wڻG9CjfzlDlSɛjV_ӃtSZ@577طT0,�r4 oHA?gfhh6lڽ{YYF+,􄣿?` FM$LcPIRY<Ζ ɋe r ߽ ^/ 뛗! T7-$LË^MO=20KsϱqNR0_JH)Nfb1bbh3,C\};Ux˸jj�[\`JJcRcC9ATUĶO>㲔VUف) bR ~m$P([qMÖ-K jjl cyt[ !t]'O3nu]�,Q"gļ>_\Ϣ9,'p{Șa?+ݱH{@NL4wzI']haX1�NYfY.1ݮ^bz@/]],E¸jjhlᬨYQAbz'<~ hmSWL bt) 1/\^f7ș 쒤2wQ;:套Fl=R\s |c:a%J'qj<Y^Npp0 8*f`tJIc1@0H$嚛VWW#�b $H\Vţ3ח/�3K2�=j:t.{׭㮷ʫ&S>E;J6U"R::pϩ Ұ-$Ifʶ6ΦcH eS N@�h[_[`as}}}u݆(f/l ޹ZV^(r,CUA0?e<8'Z �'2YVc)J}}oƝ;iݾ|7p8dxՉĜa TKU<Lrǘ ;$3&.7aժX0dX8:wov:,CL]wߍw:OVɲիv,#SȔ;"hmmIK?^B箮0q𚋉[]>[{ %8+*cAUU͆iahj"A"޽{|555gnom [? ~J*�-e ? #hr//]-r;o |x~Skkrxj/.0#禧 1 n3Q_Y9۵aEY0)ec?9\ Y%%%%vǓII7 &(H)/4l*lUH ȑx\:39 b(ꪦ a 6Ql6avIҜ&TՖL$fӽ.W]8hVaQ3\I*Ҋa kSED歕-cnf? �53yw`�aSU:J|4M uw][����IENDB`������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/module.py����������������������������������������������������������������0000664�0000000�0000000�00000005210�12657170273�0017672�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound from weboob.tools.backend import Module from .browser import YoujizzBrowser __all__ = ['YoujizzModule'] class YoujizzModule(Module, CapVideo, CapCollection): NAME = 'youjizz' MAINTAINER = u'Roger Philibert' EMAIL = 'roger.philibert@gmail.com' VERSION = '1.1' DESCRIPTION = 'YouJizz pornographic video streaming website' LICENSE = 'AGPLv3+' BROWSER = YoujizzBrowser def get_video(self, _id): video = self.browser.get_video(_id) return video def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): if not nsfw: return set() return self.browser.search_videos(pattern) def fill_video(self, video, fields): if fields != ['thumbnail']: # if we don't want only the thumbnail, we probably want also every fields video = self.browser.get_video(video.id, video) if 'thumbnail' in fields and video.thumbnail: video.thumbnail.data = self.browser.open(video.thumbnail.url).content return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest_nsfw']) if collection.split_path == [u'latest_nsfw']: for video in self.browser.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest_nsfw']: collection.title = u'Latest Youjizz videos (NSFW)' return raise CollectionNotFound(collection.split_path) OBJECTS = {BaseVideo: fill_video} ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/pages/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017134�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/pages/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021233�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/pages/index.py�����������������������������������������������������������0000664�0000000�0000000�00000003461�12657170273�0020621�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage, pagination from weboob.browser.elements import ListElement, ItemElement, method from weboob.browser.filters.standard import CleanText, Duration, Regexp from weboob.browser.filters.html import Link, CSS from weboob.capabilities.base import NotAvailable from weboob.capabilities.image import BaseImage from weboob.capabilities.video import BaseVideo class IndexPage(HTMLPage): @pagination @method class iter_videos(ListElement): item_xpath = '//span[@id="miniatura"]' next_page = Link(u'//a[text()="Next »"]') class item(ItemElement): klass = BaseVideo obj_id = CSS('a') & Link & Regexp(pattern=r'/videos/(.+)\.html') obj_title = CSS('span#title1') & CleanText obj_duration = CSS('span.thumbtime span') & CleanText & Duration | NotAvailable obj_nsfw = True def obj_thumbnail(self): thumbnail = BaseImage(self.xpath('.//img')[0].attrib['data-original']) thumbnail.url = thumbnail.id return thumbnail ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/pages/video.py�����������������������������������������������������������0000664�0000000�0000000�00000003556�12657170273�0020625�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, method from weboob.browser.filters.standard import CleanText, Env, Duration from weboob.capabilities.video import BaseVideo from weboob.tools.misc import to_unicode class VideoPage(HTMLPage): @method class get_video(ItemElement): klass = BaseVideo obj_id = Env('id') obj_title = CleanText('//title') obj_nsfw = True obj_ext = u'flv' obj_duration = CleanText('//div[@id="video_text"]') & Duration def obj_url(self): real_id = int(self.env['id'].split('-')[-1]) response = self.page.browser.open('http://www.youjizz.com/videos/embed/%s' % real_id) data = response.text video_file_urls = re.findall(r'"(http://[^",]+\.yjcontentdelivery.com[^",]+\.flv(?:\?[^"]*)?)"', data) if len(video_file_urls) == 0: raise ValueError('Video URL not found') elif len(video_file_urls) > 1: raise ValueError('Many video file URL found') else: return to_unicode(video_file_urls[0]) ��������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youjizz/test.py������������������������������������������������������������������0000664�0000000�0000000�00000003323�12657170273�0017367�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.misc import limit from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo class YoujizzTest(BackendTest): MODULE = 'youjizz' def test_search(self): self.assertTrue(len(self.backend.search_videos('anus', nsfw=False)) == 0) l = list(limit(self.backend.search_videos('anus', nsfw=True), 100)) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) r = self.backend.browser.open(v.url, stream=True) self.assertTrue(r.status_code == 200) def test_latest(self): l = list(limit(self.backend.iter_resources([BaseVideo], [u'latest_nsfw']), 100)) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016025�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000000077�12657170273�0020142�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������from .module import YoupornModule __all__ = ['YoupornModule'] �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000003226�12657170273�0020065�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser import PagesBrowser, URL from weboob.capabilities.base import UserError from .pages.index import IndexPage from .pages.video import VideoPage __all__ = ['YoupornBrowser'] class YoupornBrowser(PagesBrowser): BASEURL = 'http://www.youporn.com' home = URL('/$', IndexPage) search = URL('/search/\?query=(?P<query>.*)', IndexPage) video = URL('/watch/(?P<id>[0-9]+)/.*', VideoPage) def get_video(self, _id): self.video.go(id=_id) assert self.video.is_here() return self.page.get_video() def search_videos(self, pattern, sortby): if pattern == 'a' or pattern == 'i': raise UserError('this pattern is not supported'); self.search.go(query=pattern) assert self.search.is_here() return self.page.iter_videos() def latest_videos(self): self.home.go() assert self.home.is_here() return self.page.iter_videos() ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000002176�12657170273�0020166�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ����tIME5 ���tEXtComment�Created with GIMPW��IDATxOHQ?VDY)CObCFPiPIXuH nCA%I <NB%#2-u- q/,}H AEa0m@?`�c@rP p@+RO@0õU.`zh:{҆t?{:Upo,�qTCSs$Bӡ8S vԄ] Ɓ�{WJ?㤀>~S'PN,X#9!4 p>ZJW@gP $ӡ9Hx.*6YH �GnP#.Ue>1T<1S4,�4m/e6ߟ|ڽzMCǽ&!`&*TL8DZmU,\g_MR>]UB|TR6pe3%�=Z!Q x\p4FH gi; mnX Uͦc@}F_rRvj- >KjaY� ^˴~M3m, aQj Oo5N:+Y~롊M`Kݎ[S4 ӹ(Kgv)WtPB/hJܦ~:ƞ9QVG4Vs?5*5T/ Y]dPqϟ]i%[L[ n;{<x,4r J: P1XKE&xe6fC}T@ɵ+j:̮$Y }BʝEj( -#h3/{늨G6$d"`rL-QYVHB.&FsTXkRRV|]a'D )6jS`XH/j}z ႄ]ix 4�$H AA)����IENDB`��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/module.py����������������������������������������������������������������0000664�0000000�0000000�00000004662�12657170273�0017674�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import CapVideo, BaseVideo from weboob.tools.backend import Module from weboob.capabilities.collection import CapCollection, CollectionNotFound from .browser import YoupornBrowser from .video import YoupornVideo __all__ = ['YoupornModule'] class YoupornModule(Module, CapVideo, CapCollection): NAME = 'youporn' MAINTAINER = u'Romain Bignon' EMAIL = 'romain@weboob.org' VERSION = '1.1' DESCRIPTION = 'YouPorn pornographic video streaming website' LICENSE = 'AGPLv3+' BROWSER = YoupornBrowser def get_video(self, _id): return self.browser.get_video(_id) SORTBY = ['relevance', 'rating', 'views', 'time'] def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): if not nsfw: return set() return self.browser.search_videos(pattern, self.SORTBY[sortby]) def fill_video(self, video, fields): return self.browser.get_video(video.id) def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest_nsfw']) if collection.split_path == [u'latest_nsfw']: for video in self.browser.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest_nsfw']: collection.title = u'Latest YouPorn videos (NSFW)' return raise CollectionNotFound(collection.split_path) OBJECTS = {YoupornVideo: fill_video} ������������������������������������������������������������������������������weboob-1.1/modules/youporn/pages/�������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017124�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/pages/__init__.py��������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0021223�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/pages/index.py�����������������������������������������������������������0000664�0000000�0000000�00000003566�12657170273�0020617�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, ListElement, method from weboob.browser.filters.html import Attr, CSS from weboob.browser.filters.standard import CleanText, Duration, Regexp, Type from weboob.capabilities.base import NotAvailable from weboob.capabilities.image import BaseImage from ..video import YoupornVideo class IndexPage(HTMLPage): @method class iter_videos(ListElement): item_xpath = '//div[@id="content"]/div/div/ul/li/div/a' class item(ItemElement): klass = YoupornVideo def obj_thumbnail(self): thumbnail_url = Attr('./img', 'src')(self) thumbnail = BaseImage(thumbnail_url) thumbnail.url = thumbnail.id return thumbnail obj_author = NotAvailable obj_duration = CSS('span.duration') & CleanText() & Duration() obj_id = Attr('../..', 'data-video-id') obj_rating = CleanText('./span/i') & Regexp(pattern=r'(..)%') & Type(type=int) obj_rating_max = 100 obj_title = CleanText('./p') obj_url = NotAvailable ������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/pages/video.py�����������������������������������������������������������0000664�0000000�0000000�00000003174�12657170273�0020611�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.browser.pages import HTMLPage from weboob.browser.elements import ItemElement, method from weboob.browser.filters.html import Link from weboob.browser.filters.standard import CleanText, Env, Regexp, Type from weboob.capabilities.base import NotAvailable from ..video import YoupornVideo class VideoPage(HTMLPage): @method class get_video(ItemElement): klass = YoupornVideo obj_author = CleanText('//div[@class="author-block--line"][1]') & Regexp(pattern=r'By: (.*)') #obj_date = Date('//div[@id="stats-date"]') obj_duration = NotAvailable obj_ext = 'mp4' obj_id = Env('id') obj_rating = CleanText('//div[@class="rating-percentage"]') & Regexp(pattern=r'(..)%') & Type(type=int) obj_rating_max = 100 obj_thumbnail = NotAvailable obj_title = CleanText('//h1') obj_url = Link('//ul[@class="downloadList"]/li[2]/a') ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/test.py������������������������������������������������������������������0000664�0000000�0000000�00000003153�12657170273�0017360�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo class YoupornTest(BackendTest): MODULE = 'youporn' def test_search(self): self.assertTrue(len(self.backend.search_videos('ass to mouth', nsfw=False)) == 0) l = list(self.backend.search_videos('ass to mouth', nsfw=True)) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) self.backend.browser.openurl(v.url) def test_latest(self): l = list(self.backend.iter_resources([BaseVideo], [u'latest_nsfw'])) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youporn/video.py�����������������������������������������������������������������0000664�0000000�0000000�00000002156�12657170273�0017511�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Roger Philibert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo class YoupornVideo(BaseVideo): def __init__(self, *args, **kwargs): BaseVideo.__init__(self, *args, **kwargs) self.nsfw = True self.ext = u'flv' @classmethod def id2url(cls, _id): if _id.isdigit(): return u'http://www.youporn.com/watch/%d' % int(_id) else: return None ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youtube/�������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016006�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youtube/__init__.py��������������������������������������������������������������0000664�0000000�0000000�00000001440�12657170273�0020116�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .module import YoutubeModule __all__ = ['YoutubeModule'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youtube/browser.py���������������������������������������������������������������0000664�0000000�0000000�00000004435�12657170273�0020051�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz, Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.deprecated.browser import Browser from .pages import BaseYoutubePage, VideoPage, ForbiddenVideoPage, \ VerifyAgePage, VerifyControversyPage, \ LoginPage, LoginRedirectPage __all__ = ['YoutubeBrowser'] class YoutubeBrowser(Browser): DOMAIN = u'youtube.com' ENCODING = 'utf-8' PAGES = {r'https?://.*youtube\.com/': BaseYoutubePage, r'https?://.*youtube\.com/watch\?v=(?P<id>.+)': VideoPage, r'https?://.*youtube\.com/index\?ytsession=.+': ForbiddenVideoPage, r'https?://.*youtube\.com/verify_age\?next_url=(?P<next_url>.+)': VerifyAgePage, r'https?://.*youtube\.com/verify_controversy\?next_url(?P<next_url>.+)': VerifyControversyPage, r'https?://accounts.google.com/ServiceLogin.*': LoginPage, r'https?://accounts.google.fr/accounts/SetSID.*': LoginRedirectPage, } def is_logged(self): logged = not self.is_on_page(BaseYoutubePage) or self.page.is_logged() return logged def login(self): self.location('https://accounts.google.com/ServiceLogin?uilel=3&service=youtube&passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Den_US%26next%3D%252F&hl=en_US<mpl=sso') self.page.login(self.username, self.password) def get_video_url(self, video, player_url): self.location(player_url + '&has_verified=1&bpctr=9999999999') assert self.is_on_page(VideoPage) return self.page.get_video_url(video) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youtube/favicon.png��������������������������������������������������������������0000664�0000000�0000000�00000005451�12657170273�0020146�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������PNG  ��� IHDR���@���@���iq���sRGB���� pHYs�� �� ����tIME 4[���tEXtComment�Created with GIMPW�� IDATx[oKR%R,!˱M i..zhRžszl"@oR@^&H 8h&.RIa9DqZrggz,5HCr�˝~gx@?WB$"Y\Rz!�Yu= QT�AhS�L�'T�kճ,� =@.b �D�B�~ uKy /c ,W[b1Z,֛MKHɹqL(hX�0bo/ZLƚhrB…0~!H@Ř87;>�"k7oNBJY�keSAiB� 朧j}!{19O�@%ӑ� �^�?--[-'GٟO[z $�(Uj8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Sx <5�W ڻH|0 ` #rof-4Tw�M0b2b rDUn7g>o%b3P<%Oxa����IENDB`�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youtube/module.py����������������������������������������������������������������0000664�0000000�0000000�00000014642�12657170273�0017654�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Christophe Benz, Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. try: import gdata.youtube.service except ImportError: raise ImportError("Please install python-gdata") import datetime import re import urllib from weboob.capabilities.base import NotAvailable from weboob.capabilities.image import BaseImage from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.collection import CapCollection, CollectionNotFound from weboob.tools.backend import Module, BackendConfig from weboob.tools.misc import to_unicode from weboob.tools.value import ValueBackendPassword, Value from .browser import YoutubeBrowser from .video import YoutubeVideo __all__ = ['YoutubeModule'] class YoutubeModule(Module, CapVideo, CapCollection): NAME = 'youtube' MAINTAINER = u'Laurent Bachelier' EMAIL = 'laurent@bachelier.name' VERSION = '1.1' DESCRIPTION = 'YouTube video streaming website' LICENSE = 'AGPLv3+' BROWSER = YoutubeBrowser CONFIG = BackendConfig(Value('username', label='Email address', default=''), ValueBackendPassword('password', label='Password', default='')) URL_RE = re.compile(r'^https?://(?:\w*\.?youtube(?:|-nocookie)\.com/(?:watch\?v=|embed/|v/)|youtu\.be\/|\w*\.?youtube\.com\/user\/\w+#p\/u\/\d+\/)([^\?&]+)') def create_default_browser(self): password = None username = self.config['username'].get() if len(username) > 0: password = self.config['password'].get() return self.create_browser(username, password) def _entry2video(self, entry): """ Parse an entry returned by gdata and return a Video object. """ video = YoutubeVideo(to_unicode(entry.id.text.split('/')[-1].strip())) video.title = to_unicode(entry.media.title.text.strip()) video.duration = datetime.timedelta(seconds=int(entry.media.duration.seconds.strip())) video.thumbnail = BaseImage(entry.media.thumbnail[0].url.strip()) video.thumbnail.url = to_unicode(video.thumbnail.id) if entry.author[0].name.text: video.author = to_unicode(entry.author[0].name.text.strip()) if entry.media.name: video.author = to_unicode(entry.media.name.text.strip()) return video def _set_video_url(self, video): """ In the case of a download, if the user-chosen format is not available, the next available format will be used. Much of the code for this method is borrowed from youtubeservice.py of Cutetube http://maemo.org/packages/view/cutetube/. """ if video.url: return player_url = YoutubeVideo.id2url(video.id) with self.browser: url, ext = self.browser.get_video_url(video, player_url) video.url = unicode(url) video.ext = unicode(ext) def get_video(self, _id): m = self.URL_RE.match(_id) if m: _id = m.group(1) yt_service = gdata.youtube.service.YouTubeService() yt_service.ssl = True try: entry = yt_service.GetYouTubeVideoEntry(video_id=_id) except gdata.service.Error as e: if e.args[0]['status'] == 400: return None raise video = self._entry2video(entry) self._set_video_url(video) video.set_empty_fields(NotAvailable) # Youtube video url is https, using ssl encryption # so we need to use the "play_proxy" method using urllib2 proxy streaming to handle this video._play_proxy = True return video def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False): YOUTUBE_MAX_RESULTS = 50 YOUTUBE_MAX_START_INDEX = 500 yt_service = gdata.youtube.service.YouTubeService() yt_service.ssl = True start_index = 1 nb_yielded = 0 while True: query = gdata.youtube.service.YouTubeVideoQuery() if pattern is not None: if isinstance(pattern, unicode): pattern = pattern.encode('utf-8') query.vq = pattern query.orderby = ('relevance', 'rating', 'viewCount', 'published')[sortby] query.racy = 'include' if nsfw else 'exclude' query.max_results = YOUTUBE_MAX_RESULTS if start_index >= YOUTUBE_MAX_START_INDEX: return query.start_index = start_index start_index += YOUTUBE_MAX_RESULTS feed = yt_service.YouTubeQuery(query) for entry in feed.entry: yield self._entry2video(entry) nb_yielded += 1 if nb_yielded < YOUTUBE_MAX_RESULTS: return def latest_videos(self): return self.search_videos(None, CapVideo.SEARCH_DATE) def fill_video(self, video, fields): if 'thumbnail' in fields: video.thumbnail.data = urllib.urlopen(video.thumbnail.url).read() if 'url' in fields: self._set_video_url(video) return video def iter_resources(self, objs, split_path): if BaseVideo in objs: collection = self.get_collection(objs, split_path) if collection.path_level == 0: yield self.get_collection(objs, [u'latest']) if collection.split_path == [u'latest']: for video in self.latest_videos(): yield video def validate_collection(self, objs, collection): if collection.path_level == 0: return if BaseVideo in objs and collection.split_path == [u'latest']: collection.title = u'Latest YouTube videos' return raise CollectionNotFound(collection.split_path) OBJECTS = {YoutubeVideo: fill_video} ����������������������������������������������������������������������������������������������weboob-1.1/modules/youtube/pages.py�����������������������������������������������������������������0000664�0000000�0000000�00000145176�12657170273�0017475�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Christophe Benz, Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. # Some parts are taken from youtube-dl, licensed under the UNLICENSE. from urlparse import urlparse, parse_qs import codecs import zlib import re import os import string import struct import collections import traceback import urllib import io from weboob.capabilities.base import UserError from weboob.deprecated.browser import Page, BrokenPageError, BrowserIncorrectPassword from weboob.tools.json import json class LoginPage(Page): def on_loaded(self): errors = [] for errdiv in self.parser.select(self.document.getroot(), 'div.errormsg'): errors.append(errdiv.text.encode('utf-8').strip()) if len(errors) > 0: raise BrowserIncorrectPassword(', '.join(errors)) def login(self, username, password): self.browser.select_form(predicate=lambda form: form.attrs.get('id', '') == 'gaia_loginform') self.browser['Email'] = username.encode(self.browser.ENCODING) self.browser['Passwd'] = password.encode(self.browser.ENCODING) self.browser.submit() class LoginRedirectPage(Page): pass class ForbiddenVideo(UserError): pass class BaseYoutubePage(Page): def is_logged(self): try: self.parser.select(self.document.getroot(), 'span#yt-masthead-account-picker', 1) except BrokenPageError: return False else: return True class ForbiddenVideoPage(BaseYoutubePage): def on_loaded(self): element = self.parser.select(self.document.getroot(), '.yt-alert-content', 1) raise ForbiddenVideo(element.text.strip()) class VerifyAgePage(BaseYoutubePage): def on_loaded(self): if not self.is_logged(): raise ForbiddenVideo('This video or group may contain content that is inappropriate for some users') self.browser.select_form(predicate=lambda form: form.attrs.get('id', '') == 'confirm-age-form') self.browser.submit() class VerifyControversyPage(BaseYoutubePage): def on_loaded(self): self.browser.select_form(predicate=lambda form: 'verify_controversy' in form.attrs.get('action', '')) self.browser.submit() def determine_ext(url, default_ext=u'unknown_video'): guess = url.partition(u'?')[0].rpartition(u'.')[2] if re.match(r'^[A-Za-z0-9]+$', guess): return guess else: return default_ext def uppercase_escape(s): unicode_escape = codecs.getdecoder('unicode_escape') return re.sub( r'\\U[0-9a-fA-F]{8}', lambda m: unicode_escape(m.group(0))[0], s) _NO_DEFAULT = object() class VideoPage(BaseYoutubePage): _formats = { '5': {'ext': 'flv', 'width': 400, 'height': 240}, '6': {'ext': 'flv', 'width': 450, 'height': 270}, '13': {'ext': '3gp'}, '17': {'ext': '3gp', 'width': 176, 'height': 144}, '18': {'ext': 'mp4', 'width': 640, 'height': 360}, '22': {'ext': 'mp4', 'width': 1280, 'height': 720}, '34': {'ext': 'flv', 'width': 640, 'height': 360}, '35': {'ext': 'flv', 'width': 854, 'height': 480}, '36': {'ext': '3gp', 'width': 320, 'height': 240}, '37': {'ext': 'mp4', 'width': 1920, 'height': 1080}, '38': {'ext': 'mp4', 'width': 4096, 'height': 3072}, '43': {'ext': 'webm', 'width': 640, 'height': 360}, '44': {'ext': 'webm', 'width': 854, 'height': 480}, '45': {'ext': 'webm', 'width': 1280, 'height': 720}, '46': {'ext': 'webm', 'width': 1920, 'height': 1080}, # 3d videos '82': {'ext': 'mp4', 'height': 360, 'resolution': '360p', 'format_note': '3D', 'preference': -20}, '83': {'ext': 'mp4', 'height': 480, 'resolution': '480p', 'format_note': '3D', 'preference': -20}, '84': {'ext': 'mp4', 'height': 720, 'resolution': '720p', 'format_note': '3D', 'preference': -20}, '85': {'ext': 'mp4', 'height': 1080, 'resolution': '1080p', 'format_note': '3D', 'preference': -20}, '100': {'ext': 'webm', 'height': 360, 'resolution': '360p', 'format_note': '3D', 'preference': -20}, '101': {'ext': 'webm', 'height': 480, 'resolution': '480p', 'format_note': '3D', 'preference': -20}, '102': {'ext': 'webm', 'height': 720, 'resolution': '720p', 'format_note': '3D', 'preference': -20}, # Apple HTTP Live Streaming '92': {'ext': 'mp4', 'height': 240, 'resolution': '240p', 'format_note': 'HLS', 'preference': -10}, '93': {'ext': 'mp4', 'height': 360, 'resolution': '360p', 'format_note': 'HLS', 'preference': -10}, '94': {'ext': 'mp4', 'height': 480, 'resolution': '480p', 'format_note': 'HLS', 'preference': -10}, '95': {'ext': 'mp4', 'height': 720, 'resolution': '720p', 'format_note': 'HLS', 'preference': -10}, '96': {'ext': 'mp4', 'height': 1080, 'resolution': '1080p', 'format_note': 'HLS', 'preference': -10}, '132': {'ext': 'mp4', 'height': 240, 'resolution': '240p', 'format_note': 'HLS', 'preference': -10}, '151': {'ext': 'mp4', 'height': 72, 'resolution': '72p', 'format_note': 'HLS', 'preference': -10}, # DASH mp4 video '133': {'ext': 'mp4', 'height': 240, 'resolution': '240p', 'format_note': 'DASH video', 'preference': -40}, '134': {'ext': 'mp4', 'height': 360, 'resolution': '360p', 'format_note': 'DASH video', 'preference': -40}, '135': {'ext': 'mp4', 'height': 480, 'resolution': '480p', 'format_note': 'DASH video', 'preference': -40}, '136': {'ext': 'mp4', 'height': 720, 'resolution': '720p', 'format_note': 'DASH video', 'preference': -40}, '137': {'ext': 'mp4', 'height': 1080, 'resolution': '1080p', 'format_note': 'DASH video', 'preference': -40}, '138': {'ext': 'mp4', 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40}, # Height can vary (https://github.com/rg3/youtube-dl/issues/4559) '160': {'ext': 'mp4', 'height': 192, 'resolution': '192p', 'format_note': 'DASH video', 'preference': -40}, '264': {'ext': 'mp4', 'height': 1440, 'resolution': '1440p', 'format_note': 'DASH video', 'preference': -40}, '298': {'ext': 'mp4', 'height': 720, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'fps': 60, 'vcodec': 'h264'}, '299': {'ext': 'mp4', 'height': 1080, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'fps': 60, 'vcodec': 'h264'}, '266': {'ext': 'mp4', 'height': 2160, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'vcodec': 'h264'}, # Dash mp4 audio '139': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'vcodec': 'none', 'abr': 48, 'preference': -50, 'container': 'm4a_dash'}, '140': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'vcodec': 'none', 'abr': 128, 'preference': -50, 'container': 'm4a_dash'}, '141': {'ext': 'm4a', 'format_note': 'DASH audio', 'acodec': 'aac', 'vcodec': 'none', 'abr': 256, 'preference': -50, 'container': 'm4a_dash'}, # Dash webm '167': {'ext': 'webm', 'height': 360, 'width': 640, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'VP8', 'acodec': 'none', 'preference': -40}, '168': {'ext': 'webm', 'height': 480, 'width': 854, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'VP8', 'acodec': 'none', 'preference': -40}, '169': {'ext': 'webm', 'height': 720, 'width': 1280, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'VP8', 'acodec': 'none', 'preference': -40}, '170': {'ext': 'webm', 'height': 1080, 'width': 1920, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'VP8', 'acodec': 'none', 'preference': -40}, '218': {'ext': 'webm', 'height': 480, 'width': 854, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'VP8', 'acodec': 'none', 'preference': -40}, '219': {'ext': 'webm', 'height': 480, 'width': 854, 'format_note': 'DASH video', 'container': 'webm', 'vcodec': 'VP8', 'acodec': 'none', 'preference': -40}, '278': {'ext': 'webm', 'height': 144, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'container': 'webm', 'vcodec': 'VP9'}, '242': {'ext': 'webm', 'height': 240, 'resolution': '240p', 'format_note': 'DASH webm', 'preference': -40}, '243': {'ext': 'webm', 'height': 360, 'resolution': '360p', 'format_note': 'DASH webm', 'preference': -40}, '244': {'ext': 'webm', 'height': 480, 'resolution': '480p', 'format_note': 'DASH webm', 'preference': -40}, '245': {'ext': 'webm', 'height': 480, 'resolution': '480p', 'format_note': 'DASH webm', 'preference': -40}, '246': {'ext': 'webm', 'height': 480, 'resolution': '480p', 'format_note': 'DASH webm', 'preference': -40}, '247': {'ext': 'webm', 'height': 720, 'resolution': '720p', 'format_note': 'DASH webm', 'preference': -40}, '248': {'ext': 'webm', 'height': 1080, 'resolution': '1080p', 'format_note': 'DASH webm', 'preference': -40}, '271': {'ext': 'webm', 'height': 1440, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40}, '272': {'ext': 'webm', 'height': 2160, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40}, '302': {'ext': 'webm', 'height': 720, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'fps': 60, 'vcodec': 'VP9'}, '303': {'ext': 'webm', 'height': 1080, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'fps': 60, 'vcodec': 'VP9'}, '308': {'ext': 'webm', 'height': 1440, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'fps': 60, 'vcodec': 'VP9'}, '313': {'ext': 'webm', 'height': 2160, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'vcodec': 'VP9'}, '315': {'ext': 'webm', 'height': 2160, 'format_note': 'DASH video', 'acodec': 'none', 'preference': -40, 'fps': 60, 'vcodec': 'VP9'}, # Dash webm audio '171': {'ext': 'webm', 'vcodec': 'none', 'format_note': 'DASH audio', 'abr': 128, 'preference': -50}, '172': {'ext': 'webm', 'vcodec': 'none', 'format_note': 'DASH webm audio', 'abr': 256, 'preference': -50}, # Dash webm audio with opus inside '249': {'ext': 'webm', 'vcodec': 'none', 'format_note': 'DASH audio', 'acodec': 'opus', 'abr': 50, 'preference': -50}, '250': {'ext': 'webm', 'vcodec': 'none', 'format_note': 'DASH audio', 'acodec': 'opus', 'abr': 70, 'preference': -50}, '251': {'ext': 'webm', 'vcodec': 'none', 'format_note': 'DASH audio', 'acodec': 'opus', 'abr': 160, 'preference': -50}, # RTMP (unnamed) '_rtmp': {'protocol': 'rtmp'}, } def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self._player_cache = {} def _signature_cache_id(self, example_sig): """ Return a string representation of a signature """ return '.'.join(unicode(len(part)) for part in example_sig.split('.')) def _extract_signature_function(self, video_id, player_url, example_sig): id_m = re.match( r'.*?-(?P<id>[a-zA-Z0-9_-]+)(?:/watch_as3|/html5player)?\.(?P<ext>[a-z]+)$', player_url) if not id_m: raise BrokenPageError('Cannot identify player %r' % player_url) player_type = id_m.group('ext') player_id = id_m.group('id') # Read from filesystem cache func_id = '%s_%s_%s' % ( player_type, player_id, self._signature_cache_id(example_sig)) assert os.path.basename(func_id) == func_id if player_type == 'js': code = self.browser.readurl(player_url) res = self._parse_sig_js(code) elif player_type == 'swf': urlh = self.browser.openurl(player_url) code = urlh.read() res = self._parse_sig_swf(code) else: assert False, 'Invalid player type %r' % player_type return res def _parse_sig_js(self, jscode): funcname = self._search_regex( r'\.sig\|\|([a-zA-Z0-9$]+)\(', jscode, u'Initial JS player signature function name') functions = {} objects = {} code = jscode def argidx(varname): return string.lowercase.index(varname) def interpret_statement(stmt, local_vars, allow_recursion=20): if allow_recursion < 0: raise BrokenPageError(u'Recursion limit reached') if stmt.startswith(u'var '): stmt = stmt[len(u'var '):] ass_m = re.match(r'^(?P<out>[a-z]+)(?:\[(?P<index>[^\]]+)\])?' + r'=(?P<expr>.*)$', stmt) if ass_m: if ass_m.groupdict().get('index'): def assign(val): lvar = local_vars[ass_m.group('out')] idx = interpret_expression(ass_m.group('index'), local_vars, allow_recursion) assert isinstance(idx, int) lvar[idx] = val return val expr = ass_m.group('expr') else: def assign(val): local_vars[ass_m.group('out')] = val return val expr = ass_m.group('expr') elif stmt.startswith(u'return '): assign = lambda v: v expr = stmt[len(u'return '):] else: # Try interpreting it as an expression expr = stmt assign = lambda v: v v = interpret_expression(expr, local_vars, allow_recursion) return assign(v) def extract_object(objname): obj = {} obj_m = re.search( (r'(?:var\s+)?%s\s*=\s*\{' % re.escape(objname)) + r'\s*(?P<fields>([a-zA-Z$0-9]+\s*:\s*function\(.*?\)\s*\{.*?\})*)' + r'\}\s*;', code) fields = obj_m.group('fields') # Currently, it only supports function definitions fields_m = re.finditer( r'(?P<key>[a-zA-Z$0-9]+)\s*:\s*function' r'\((?P<args>[a-z,]+)\){(?P<code>[^}]+)}', fields) for f in fields_m: argnames = f.group('args').split(',') obj[f.group('key')] = build_function(argnames, f.group('code')) return obj def build_function(argnames, code): def resf(args): local_vars = dict(zip(argnames, args)) for stmt in code.split(';'): res = interpret_statement(stmt, local_vars) return res return resf def interpret_expression(expr, local_vars, allow_recursion): if expr.isdigit(): return int(expr) if expr.isalpha(): return local_vars[expr] try: return json.loads(expr) except ValueError: pass m = re.match(r'^(?P<var>[a-zA-Z0-9_]+)\.(?P<member>[^(]+)(?:\(+(?P<args>[^()]*)\))?$', expr) if m: variable = m.group('var') member = m.group('member') arg_str = m.group('args') if variable in local_vars: obj = local_vars[variable] else: if variable not in objects: objects[variable] = extract_object(variable) obj = objects[variable] if arg_str is None: # Member access if member == 'length': return len(obj) return obj[member] assert expr.endswith(')') # Function call if arg_str == '': argvals = tuple() else: argvals = tuple([ interpret_expression(v, local_vars, allow_recursion) for v in arg_str.split(',')]) if member == 'split': assert argvals == ('',) return list(obj) if member == 'join': assert len(argvals) == 1 return argvals[0].join(obj) if member == 'reverse': assert len(argvals) == 0 obj.reverse() return obj if member == 'slice': assert len(argvals) == 1 return obj[argvals[0]:] if member == 'splice': assert isinstance(obj, list) index, howMany = argvals res = [] for i in range(index, min(index + howMany, len(obj))): res.append(obj.pop(index)) return res return obj[member](argvals) m = re.match( r'^(?P<in>[a-z]+)\[(?P<idx>.+)\]$', expr) if m: val = local_vars[m.group('in')] idx = interpret_expression( m.group('idx'), local_vars, allow_recursion - 1) return val[idx] m = re.match(r'^(?P<a>.+?)(?P<op>[%])(?P<b>.+?)$', expr) if m: a = interpret_expression( m.group('a'), local_vars, allow_recursion) b = interpret_expression( m.group('b'), local_vars, allow_recursion) return a % b m = re.match( r'^(?P<func>[a-zA-Z$]+)\((?P<args>[a-z0-9,]+)\)$', expr) if m: fname = m.group('func') argvals = tuple([ int(v) if v.isdigit() else local_vars[v] for v in m.group('args').split(',')]) if fname not in functions: functions[fname] = extract_function(fname) return functions[fname](argvals) raise BrokenPageError(u'Unsupported JS expression %r' % expr) def extract_function(funcname): func_m = re.search( r'function ' + re.escape(funcname) + r'\((?P<args>[a-z,]+)\){(?P<code>[^}]+)}', jscode) argnames = func_m.group('args').split(',') def resf(args): local_vars = dict(zip(argnames, args)) for stmt in func_m.group('code').split(';'): res = interpret_statement(stmt, local_vars) return res return resf initial_function = extract_function(funcname) return lambda s: initial_function([s]) def _parse_sig_swf(self, file_contents): if file_contents[1:3] != b'WS': raise BrokenPageError( u'Not an SWF file; header is %r' % file_contents[:3]) if file_contents[:1] == b'C': content = zlib.decompress(file_contents[8:]) else: raise NotImplementedError(u'Unsupported compression format %r' % file_contents[:1]) def extract_tags(content): pos = 0 while pos < len(content): header16 = struct.unpack('<H', content[pos:pos+2])[0] pos += 2 tag_code = header16 >> 6 tag_len = header16 & 0x3f if tag_len == 0x3f: tag_len = struct.unpack('<I', content[pos:pos+4])[0] pos += 4 assert pos+tag_len <= len(content) yield (tag_code, content[pos:pos+tag_len]) pos += tag_len code_tag = next(tag for tag_code, tag in extract_tags(content) if tag_code == 82) p = code_tag.index(b'\0', 4) + 1 code_reader = io.BytesIO(code_tag[p:]) # Parse ABC (AVM2 ByteCode) def read_int(reader=None): if reader is None: reader = code_reader res = 0 shift = 0 for _ in range(5): buf = reader.read(1) assert len(buf) == 1 b = struct.unpack('<B', buf)[0] res = res | ((b & 0x7f) << shift) if b & 0x80 == 0: break shift += 7 return res def u30(reader=None): res = read_int(reader) assert res & 0xf0000000 == 0 return res u32 = read_int def s32(reader=None): v = read_int(reader) if v & 0x80000000 != 0: v = - ((v ^ 0xffffffff) + 1) return v def read_string(reader=None): if reader is None: reader = code_reader slen = u30(reader) resb = reader.read(slen) assert len(resb) == slen return resb.decode('utf-8') def read_bytes(count, reader=None): if reader is None: reader = code_reader resb = reader.read(count) assert len(resb) == count return resb def read_byte(reader=None): resb = read_bytes(1, reader=reader) res = struct.unpack('<B', resb)[0] return res # minor_version + major_version read_bytes(2 + 2) # Constant pool int_count = u30() for _c in range(1, int_count): s32() uint_count = u30() for _c in range(1, uint_count): u32() double_count = u30() read_bytes((double_count-1) * 8) string_count = u30() constant_strings = [u''] for _c in range(1, string_count): s = read_string() constant_strings.append(s) namespace_count = u30() for _c in range(1, namespace_count): read_bytes(1) # kind u30() # name ns_set_count = u30() for _c in range(1, ns_set_count): count = u30() for _c2 in range(count): u30() multiname_count = u30() MULTINAME_SIZES = { 0x07: 2, # QName 0x0d: 2, # QNameA 0x0f: 1, # RTQName 0x10: 1, # RTQNameA 0x11: 0, # RTQNameL 0x12: 0, # RTQNameLA 0x09: 2, # Multiname 0x0e: 2, # MultinameA 0x1b: 1, # MultinameL 0x1c: 1, # MultinameLA } multinames = [u''] for _c in range(1, multiname_count): kind = u30() assert kind in MULTINAME_SIZES, u'Invalid multiname kind %r' % kind if kind == 0x07: u30() # namespace_idx name_idx = u30() multinames.append(constant_strings[name_idx]) else: multinames.append('[MULTINAME kind: %d]' % kind) for _c2 in range(MULTINAME_SIZES[kind]): u30() # Methods method_count = u30() MethodInfo = collections.namedtuple( 'MethodInfo', ['NEED_ARGUMENTS', 'NEED_REST']) method_infos = [] for method_id in range(method_count): param_count = u30() u30() # return type for _ in range(param_count): u30() # param type u30() # name index (always 0 for youtube) flags = read_byte() if flags & 0x08 != 0: # Options present option_count = u30() for c in range(option_count): u30() # val read_bytes(1) # kind if flags & 0x80 != 0: # Param names present for _ in range(param_count): u30() # param name mi = MethodInfo(flags & 0x01 != 0, flags & 0x04 != 0) method_infos.append(mi) # Metadata metadata_count = u30() for _c in range(metadata_count): u30() # name item_count = u30() for _c2 in range(item_count): u30() # key u30() # value def parse_traits_info(): trait_name_idx = u30() kind_full = read_byte() kind = kind_full & 0x0f attrs = kind_full >> 4 methods = {} if kind in [0x00, 0x06]: # Slot or Const u30() # Slot id u30() # type_name_idx vindex = u30() if vindex != 0: read_byte() # vkind elif kind in [0x01, 0x02, 0x03]: # Method / Getter / Setter u30() # disp_id method_idx = u30() methods[multinames[trait_name_idx]] = method_idx elif kind == 0x04: # Class u30() # slot_id u30() # classi elif kind == 0x05: # Function u30() # slot_id function_idx = u30() methods[function_idx] = multinames[trait_name_idx] else: raise BrokenPageError(u'Unsupported trait kind %d' % kind) if attrs & 0x4 != 0: # Metadata present metadata_count = u30() for _c3 in range(metadata_count): u30() # metadata index return methods # Classes TARGET_CLASSNAME = u'SignatureDecipher' searched_idx = multinames.index(TARGET_CLASSNAME) searched_class_id = None class_count = u30() for class_id in range(class_count): name_idx = u30() if name_idx == searched_idx: # We found the class we're looking for! searched_class_id = class_id u30() # super_name idx flags = read_byte() if flags & 0x08 != 0: # Protected namespace is present u30() # protected_ns_idx intrf_count = u30() for _c2 in range(intrf_count): u30() u30() # iinit trait_count = u30() for _c2 in range(trait_count): parse_traits_info() if searched_class_id is None: raise BrokenPageError(u'Target class %r not found' % TARGET_CLASSNAME) method_names = {} method_idxs = {} for class_id in range(class_count): u30() # cinit trait_count = u30() for _c2 in range(trait_count): trait_methods = parse_traits_info() if class_id == searched_class_id: method_names.update(trait_methods.items()) method_idxs.update(dict( (idx, name) for name, idx in trait_methods.items())) # Scripts script_count = u30() for _c in range(script_count): u30() # init trait_count = u30() for _c2 in range(trait_count): parse_traits_info() # Method bodies method_body_count = u30() Method = collections.namedtuple('Method', ['code', 'local_count']) methods = {} for _c in range(method_body_count): method_idx = u30() u30() # max_stack local_count = u30() u30() # init_scope_depth u30() # max_scope_depth code_length = u30() code = read_bytes(code_length) if method_idx in method_idxs: m = Method(code, local_count) methods[method_idxs[method_idx]] = m exception_count = u30() for _c2 in range(exception_count): u30() # from u30() # to u30() # target u30() # exc_type u30() # var_name trait_count = u30() for _c2 in range(trait_count): parse_traits_info() assert p + code_reader.tell() == len(code_tag) assert len(methods) == len(method_idxs) method_pyfunctions = {} def extract_function(func_name): if func_name in method_pyfunctions: return method_pyfunctions[func_name] if func_name not in methods: raise BrokenPageError(u'Cannot find function %r' % func_name) m = methods[func_name] def resfunc(args): registers = ['(this)'] + list(args) + [None] * m.local_count stack = [] coder = io.BytesIO(m.code) while True: opcode = struct.unpack('!B', coder.read(1))[0] if opcode == 36: # pushbyte v = struct.unpack('!B', coder.read(1))[0] stack.append(v) elif opcode == 44: # pushstring idx = u30(coder) stack.append(constant_strings[idx]) elif opcode == 48: # pushscope # We don't implement the scope register, so we'll just # ignore the popped value stack.pop() elif opcode == 70: # callproperty index = u30(coder) mname = multinames[index] arg_count = u30(coder) args = list(reversed( [stack.pop() for _ in range(arg_count)])) obj = stack.pop() if mname == u'split': assert len(args) == 1 assert isinstance(args[0], unicode) assert isinstance(obj, unicode) if args[0] == u'': res = list(obj) else: res = obj.split(args[0]) stack.append(res) elif mname == u'slice': assert len(args) == 1 assert isinstance(args[0], int) assert isinstance(obj, list) res = obj[args[0]:] stack.append(res) elif mname == u'join': assert len(args) == 1 assert isinstance(args[0], unicode) assert isinstance(obj, list) res = args[0].join(obj) stack.append(res) elif mname in method_pyfunctions: stack.append(method_pyfunctions[mname](args)) else: raise NotImplementedError( u'Unsupported property %r on %r' % (mname, obj)) elif opcode == 72: # returnvalue res = stack.pop() return res elif opcode == 79: # callpropvoid index = u30(coder) mname = multinames[index] arg_count = u30(coder) args = list(reversed( [stack.pop() for _ in range(arg_count)])) obj = stack.pop() if mname == u'reverse': assert isinstance(obj, list) obj.reverse() else: raise NotImplementedError( u'Unsupported (void) property %r on %r' % (mname, obj)) elif opcode == 93: # findpropstrict index = u30(coder) mname = multinames[index] res = extract_function(mname) stack.append(res) elif opcode == 97: # setproperty index = u30(coder) value = stack.pop() idx = stack.pop() obj = stack.pop() assert isinstance(obj, list) assert isinstance(idx, int) obj[idx] = value elif opcode == 98: # getlocal index = u30(coder) stack.append(registers[index]) elif opcode == 99: # setlocal index = u30(coder) value = stack.pop() registers[index] = value elif opcode == 102: # getproperty index = u30(coder) pname = multinames[index] if pname == u'length': obj = stack.pop() assert isinstance(obj, list) stack.append(len(obj)) else: # Assume attribute access idx = stack.pop() assert isinstance(idx, int) obj = stack.pop() assert isinstance(obj, list) stack.append(obj[idx]) elif opcode == 128: # coerce u30(coder) elif opcode == 133: # coerce_s assert isinstance(stack[-1], (type(None), unicode)) elif opcode == 164: # modulo value2 = stack.pop() value1 = stack.pop() res = value1 % value2 stack.append(res) elif opcode == 208: # getlocal_0 stack.append(registers[0]) elif opcode == 209: # getlocal_1 stack.append(registers[1]) elif opcode == 210: # getlocal_2 stack.append(registers[2]) elif opcode == 211: # getlocal_3 stack.append(registers[3]) elif opcode == 214: # setlocal_2 registers[2] = stack.pop() elif opcode == 215: # setlocal_3 registers[3] = stack.pop() else: raise NotImplementedError( u'Unsupported opcode %d' % opcode) method_pyfunctions[func_name] = resfunc return resfunc initial_function = extract_function(u'decipher') return lambda s: initial_function([s]) def _decrypt_signature(self, s, video_id, player_url, age_gate=False): """Turn the encrypted s field into a working signature""" if player_url is not None: if player_url.startswith(u'//'): player_url = u'https:' + player_url try: player_id = (player_url, len(s)) if player_id not in self._player_cache: func = self._extract_signature_function( video_id, player_url, s ) self._player_cache[player_id] = func func = self._player_cache[player_id] return func(s) except Exception: tb = traceback.format_exc() raise BrokenPageError(u'Automatic signature extraction failed: %s' % tb) return self._static_decrypt_signature( s, video_id, player_url, age_gate) def _static_decrypt_signature(self, s, video_id, player_url, age_gate): if age_gate: # The videos with age protection use another player, so the # algorithms can be different. if len(s) == 86: return s[2:63] + s[82] + s[64:82] + s[63] if len(s) == 93: return s[86:29:-1] + s[88] + s[28:5:-1] elif len(s) == 92: return s[25] + s[3:25] + s[0] + s[26:42] + s[79] + s[43:79] + s[91] + s[80:83] elif len(s) == 91: return s[84:27:-1] + s[86] + s[26:5:-1] elif len(s) == 90: return s[25] + s[3:25] + s[2] + s[26:40] + s[77] + s[41:77] + s[89] + s[78:81] elif len(s) == 89: return s[84:78:-1] + s[87] + s[77:60:-1] + s[0] + s[59:3:-1] elif len(s) == 88: return s[7:28] + s[87] + s[29:45] + s[55] + s[46:55] + s[2] + s[56:87] + s[28] elif len(s) == 87: return s[6:27] + s[4] + s[28:39] + s[27] + s[40:59] + s[2] + s[60:] elif len(s) == 86: return s[80:72:-1] + s[16] + s[71:39:-1] + s[72] + s[38:16:-1] + s[82] + s[15::-1] elif len(s) == 85: return s[3:11] + s[0] + s[12:55] + s[84] + s[56:84] elif len(s) == 84: return s[78:70:-1] + s[14] + s[69:37:-1] + s[70] + s[36:14:-1] + s[80] + s[:14][::-1] elif len(s) == 83: return s[80:63:-1] + s[0] + s[62:0:-1] + s[63] elif len(s) == 82: return s[80:37:-1] + s[7] + s[36:7:-1] + s[0] + s[6:0:-1] + s[37] elif len(s) == 81: return s[56] + s[79:56:-1] + s[41] + s[55:41:-1] + s[80] + s[40:34:-1] + s[0] + s[33:29:-1] + s[34] + s[28:9:-1] + s[29] + s[8:0:-1] + s[9] elif len(s) == 80: return s[1:19] + s[0] + s[20:68] + s[19] + s[69:80] elif len(s) == 79: return s[54] + s[77:54:-1] + s[39] + s[53:39:-1] + s[78] + s[38:34:-1] + s[0] + s[33:29:-1] + s[34] + s[28:9:-1] + s[29] + s[8:0:-1] + s[9] else: raise BrokenPageError(u'Unable to decrypt signature, key length %d not supported; retrying might work' % (len(s))) def _parse_dash_manifest(self, video_id, dash_manifest_url, player_url, age_gate): def decrypt_sig(mobj): s = mobj.group(1) dec_s = self._decrypt_signature(s, video_id, player_url, age_gate) return '/signature/%s' % dec_s def int_or_none(v, default=None): try: return int(v) except (ValueError,TypeError): return default dash_manifest_url = re.sub(r'/s/([\w\.]+)', decrypt_sig, dash_manifest_url) dash_doc = self.browser.get_document(self.browser.openurl(dash_manifest_url)) formats = [] for r in dash_doc.findall('.//{urn:mpeg:DASH:schema:MPD:2011}Representation'): url_el = r.find('{urn:mpeg:DASH:schema:MPD:2011}BaseURL') if url_el is None: continue format_id = r.attrib['id'] video_url = url_el.text filesize = int_or_none(url_el.attrib.get('{http://youtube.com/yt/2012/10/10}contentLength')) f = { 'format_id': format_id, 'url': video_url, 'width': int_or_none(r.attrib.get('width')), 'height': int_or_none(r.attrib.get('height')), 'tbr': int_or_none(r.attrib.get('bandwidth'), 1000), 'asr': int_or_none(r.attrib.get('audioSamplingRate')), 'filesize': filesize, 'fps': int_or_none(r.attrib.get('frameRate')), } try: existing_format = next( fo for fo in formats if fo['format_id'] == format_id) except StopIteration: f.update(self._formats.get(format_id, {}).items()) formats.append(f) else: existing_format.update(f) return formats def _extract_from_m3u8(self, manifest_url, video_id): url_map = {} def _get_urls(_manifest): lines = _manifest.split('\n') urls = filter(lambda l: l and not l.startswith('#'), lines) return urls manifest = self.browser.readurl(manifest_url) formats_urls = _get_urls(manifest) for format_url in formats_urls: itag = self._search_regex(r'itag/(\d+?)/', format_url, 'itag') url_map[itag] = format_url return url_map def get_video_url(self, video): video_id = video.id video_webpage = ' '.join([self.parser.tocleanstring(el) for el in self.document.xpath('//script')]) # Attempt to extract SWF player URL mobj = re.search(r'swfConfig.*?"(https?:\\/\\/.*?watch.*?-.*?\.swf)"', video_webpage) if mobj is not None: player_url = re.sub(r'\\(.)', r'\1', mobj.group(1)) else: player_url = None # Get video info if re.search(r'player-age-gate-content">', video_webpage) is not None: age_gate = True # We simulate the access to the video from www.youtube.com/v/{video_id} # this can be viewed without login into Youtube url = 'https://www.youtube.com/embed/%s' % video_id embed_webpage = self.browser.readurl(url) data = urllib.urlencode({ 'video_id': video_id, 'eurl': 'https://youtube.googleapis.com/v/' + video_id, 'sts': self._search_regex( r'"sts"\s*:\s*(\d+)', embed_webpage, 'sts', default=''), }) video_info_url = 'https://www.youtube.com/get_video_info?' + data video_info_webpage = self.browser.readurl(video_info_url) video_info = parse_qs(video_info_webpage) else: age_gate = False try: # Try looking directly into the video webpage mobj = re.search(r';ytplayer\.config\s*=\s*({.*?});', video_webpage) if not mobj: raise ValueError('Could not find ytplayer.config') # caught below json_code = uppercase_escape(mobj.group(1)) ytplayer_config = json.loads(json_code) args = ytplayer_config['args'] # Convert to the same format returned by compat_parse_qs video_info = dict((k, [v]) for k, v in args.items()) if 'url_encoded_fmt_stream_map' not in args: raise ValueError('No stream_map present') # caught below except ValueError: # We fallback to the get_video_info pages (used by the embed page) for el_type in ['&el=embedded', '&el=detailpage', '&el=vevo', '']: video_info_url = ('https://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (video_id, el_type)) video_info_webpage = self.browser.readurl(video_info_url) video_info = parse_qs(video_info_webpage) if 'token' in video_info: break if 'token' not in video_info: if 'reason' in video_info: raise UserError(video_info['reason'][0]) else: raise BrokenPageError(u'"token" parameter not in video info for unknown reason') # Check for "rental" videos if 'ypc_video_rental_bar_text' in video_info and 'author' not in video_info: raise UserError(u'"rental" videos not supported') def _map_to_format_list(urlmap): formats = [] for itag, video_real_url in urlmap.items(): dct = { 'format_id': itag, 'url': video_real_url, 'player_url': player_url, } if itag in self._formats: dct.update(self._formats[itag]) formats.append(dct) return formats if 'conn' in video_info and video_info['conn'][0].startswith('rtmp'): formats = [{ 'format_id': '_rtmp', 'protocol': 'rtmp', 'url': video_info['conn'][0], 'player_url': player_url, }] elif len(video_info.get('url_encoded_fmt_stream_map', [''])[0]) >= 1 or len(video_info.get('adaptive_fmts', [''])[0]) >= 1: encoded_url_map = video_info.get('url_encoded_fmt_stream_map', [''])[0] + ',' + video_info.get('adaptive_fmts', [''])[0] if 'rtmpe%3Dyes' in encoded_url_map: raise BrokenPageError('rtmpe downloads are not supported, see https://github.com/rg3/youtube-dl/issues/343 for more information.', expected=True) url_map = {} for url_data_str in encoded_url_map.split(','): url_data = parse_qs(url_data_str) if 'itag' not in url_data or 'url' not in url_data: continue format_id = url_data['itag'][0] url = url_data['url'][0] if 'sig' in url_data: url += '&signature=' + url_data['sig'][0] elif 's' in url_data: encrypted_sig = url_data['s'][0] jsplayer_url_json = self._search_regex( r'"assets":.+?"js":\s*("[^"]+")', embed_webpage if age_gate else video_webpage, 'JS player URL') player_url = json.loads(jsplayer_url_json) if player_url is None: player_url_json = self._search_regex( r'ytplayer\.config.*?"url"\s*:\s*("[^"]+")', video_webpage, 'age gate player URL') player_url = json.loads(player_url_json) signature = self._decrypt_signature( encrypted_sig, video_id, player_url, age_gate) url += '&signature=' + signature if 'ratebypass' not in url: url += '&ratebypass=yes' url_map[format_id] = url formats = _map_to_format_list(url_map) elif video_info.get('hlsvp'): manifest_url = video_info['hlsvp'][0] url_map = self._extract_from_m3u8(manifest_url, video_id) formats = _map_to_format_list(url_map) else: raise BrokenPageError(u'no conn, hlsvp or url_encoded_fmt_stream_map information found in video info') dash_mpd = video_info.get('dashmpd') if dash_mpd: dash_manifest_url = dash_mpd[0] try: dash_formats = self._parse_dash_manifest( video_id, dash_manifest_url, player_url, age_gate) except (BrokenPageError, KeyError) as e: self.logger.info( 'Skipping DASH manifest: %r' % e) else: # Hide the formats we found through non-DASH dash_keys = set(df['format_id'] for df in dash_formats) for f in formats: if f['format_id'] in dash_keys: f['format_id'] = 'nondash-%s' % f['format_id'] f['preference'] = f.get('preference', 0) - 10000 formats.extend(dash_formats) # Check for malformed aspect ratio stretched_m = re.search( r'<meta\s+property="og:video:tag".*?content="yt:stretch=(?P<w>[0-9]+):(?P<h>[0-9]+)">', video_webpage) if stretched_m: ratio = float(stretched_m.group('w')) / float(stretched_m.group('h')) for f in formats: if f.get('vcodec') != 'none': f['stretched_ratio'] = ratio self._sort_formats(formats) best = formats[-1] return best['url'], best['ext'] def _sort_formats(self, formats): if not formats: raise BrokenPageError(u'No video formats found') def _formats_key(f): # TODO remove the following workaround if not f.get('ext') and 'url' in f: f['ext'] = determine_ext(f['url']) preference = f.get('preference') if preference is None: proto = f.get('protocol') if proto is None: proto = urlparse(f.get('url', '')).scheme preference = 0 if proto in ['http', 'https'] else -0.1 if f.get('ext') in ['f4f', 'f4m']: # Not yet supported preference -= 0.5 if f.get('vcodec') == 'none': # audio only ORDER = [u'webm', u'opus', u'ogg', u'mp3', u'aac', u'm4a'] ext_preference = 0 try: audio_ext_preference = ORDER.index(f['ext']) except ValueError: audio_ext_preference = -1 else: ORDER = [u'webm', u'flv', u'mp4'] try: ext_preference = ORDER.index(f['ext']) except ValueError: ext_preference = -1 audio_ext_preference = 0 return ( preference, f.get('quality') if f.get('quality') is not None else -1, f.get('height') if f.get('height') is not None else -1, f.get('width') if f.get('width') is not None else -1, ext_preference, f.get('tbr') if f.get('tbr') is not None else -1, f.get('vbr') if f.get('vbr') is not None else -1, f.get('abr') if f.get('abr') is not None else -1, audio_ext_preference, f.get('filesize') if f.get('filesize') is not None else -1, f.get('format_id'), ) formats.sort(key=_formats_key) def _search_regex(self, pattern, text, name, default=_NO_DEFAULT, fatal=True, flags=0): """ Perform a regex search on the given string, using a single or a list of patterns returning the first matching group. In case of failure return a default value or raise a WARNING or a RegexNotFoundError, depending on fatal, specifying the field name. """ if isinstance(pattern, (str, unicode, type(re.compile('')))): mobj = re.search(pattern, text, flags) else: for p in pattern: mobj = re.search(p, text, flags) if mobj: break if mobj: # return the first matching group return next(g for g in mobj.groups() if g is not None) elif default is not _NO_DEFAULT: return default elif fatal: raise BrokenPageError(u'Unable to extract %s' % name) else: self.logger.warning(u'unable to extract %s' % name) return None ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youtube/test.py������������������������������������������������������������������0000664�0000000�0000000�00000003540�12657170273�0017341�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.video import BaseVideo class YoutubeTest(BackendTest): MODULE = 'youtube' def test_search(self): l = list(self.backend.search_videos('lol')) self.assertTrue(len(l) > 0) v = l[0] self.backend.fillobj(v, ('url',)) self.assertTrue(v.url and v.url.startswith('https://'), 'URL for video "%s" not found: %s' % (v.id, v.url)) assert self.backend.get_video(v.shorturl) self.backend.browser.openurl(v.url) def test_latest(self): l = list(self.backend.iter_resources([BaseVideo], [u'latest'])) assert len(l) > 0 def test_drm(self): v = self.backend.get_video('http://youtu.be/UxxajLWwzqY') self.backend.fillobj(v, ('url',)) assert len(v.url) try: self.backend.browser.openurl(v.url) except: self.fail('can\'t open url') def test_weirdchars(self): v = self.backend.get_video('https://www.youtube.com/watch?v=BaW_jenozKc') self.backend.fillobj(v, ('title', 'url',)) assert unicode(v.title) ����������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/modules/youtube/video.py�����������������������������������������������������������������0000664�0000000�0000000�00000002015�12657170273�0017464�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.capabilities.video import BaseVideo class YoutubeVideo(BaseVideo): @classmethod def id2url(cls, _id): return 'https://www.youtube.com/watch?v=%s' % _id def _get_shorturl(self): return 'https://youtu.be/%s' % self.id shorturl = property(_get_shorturl) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/release.sh�������������������������������������������������������������������������������0000775�0000000�0000000�00000002762�12657170273�0014630�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/bash # This script is used to release a version. set -e function set_version { echo -n "Replacing version in source files to $1" for fl in $(find . -iname "*.py" ! -path "./contrib/*"); do sed "s/^\(\s*\)\(VERSION\|version\|release\)\( *\)=\( *\)[\"'][0-9]\+\..\+[\"']\(,\?\)$/\1\2\3=\4'$1'\5/g" $fl > $fl.new diff $fl.new $fl >/dev/null && echo -n "." || echo -n "+" cp -f $fl.new $fl rm -f $fl.new done echo -e " done.\n" } if [ "$1" = "" ]; then echo "Syntax: $0 VERSION" exit 1 fi VERSION=$1 export LANG=en_US.utf8 mv ChangeLog ChangeLog.old echo -e "Weboob $VERSION (`date +%Y-%m-%d`)\n\t \n\n" > ChangeLog cat ChangeLog.old >> ChangeLog rm -f ChangeLog.old vi +2 ChangeLog set_version $VERSION echo "Building Qt applications..." ./setup.py sdist bdist clean -a || exit 1 echo "Generating manpages..." tools/make_man.sh echo -e "done!\n" # in case there are new manpages not included in the git tree. git add man/* echo "Release commit:" git commit -a -m "Weboob $VERSION released" echo -ne "\n" echo "Release tag:" git tag $VERSION -s -m "Weboob $VERSION" echo -ne "\n" echo -n "Generating archive.. " git archive HEAD --prefix=weboob-$VERSION/ -o weboob-$VERSION.tar gzip -f weboob-$VERSION.tar md5sum weboob-$VERSION.tar.gz echo -ne "\nDo you want to change the version number (y/n) " read change_version if [ "$change_version" = "y" ]; then echo -n "Enter the new version number: " read NEW_VERSION set_version $NEW_VERSION git commit -a -m "bump to $NEW_VERSION" fi ��������������weboob-1.1/scripts/���������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0014331�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/boobank��������������������������������������������������������������������������0000775�0000000�0000000�00000001632�12657170273�0015674�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2009-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.boobank import Boobank if __name__ == '__main__': Boobank.run() ������������������������������������������������������������������������������������������������������weboob-1.1/scripts/boobathon������������������������������������������������������������������������0000775�0000000�0000000�00000001633�12657170273�0016235�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.boobathon import Boobathon if __name__ == '__main__': Boobathon.run() �����������������������������������������������������������������������������������������������������weboob-1.1/scripts/boobcoming�����������������������������������������������������������������������0000775�0000000�0000000�00000001525�12657170273�0016400�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.boobcoming import Boobcoming if __name__ == '__main__': Boobcoming.run() ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/boobill��������������������������������������������������������������������������0000775�0000000�0000000�00000001626�12657170273�0015706�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2012 Fourcot Florent # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.boobill import Boobill if __name__ == '__main__': Boobill.run() ����������������������������������������������������������������������������������������������������������weboob-1.1/scripts/booblyrics�����������������������������������������������������������������������0000775�0000000�0000000�00000001637�12657170273�0016435�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.booblyrics import Booblyrics if __name__ == '__main__': Booblyrics.run() �������������������������������������������������������������������������������������������������weboob-1.1/scripts/boobmsg��������������������������������������������������������������������������0000775�0000000�0000000�00000001634�12657170273�0015713�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.boobmsg import Boobmsg if __name__ == '__main__': Boobmsg.run() ����������������������������������������������������������������������������������������������������weboob-1.1/scripts/boobooks�������������������������������������������������������������������������0000775�0000000�0000000�00000001630�12657170273�0016074�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2012 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.boobooks import Boobooks if __name__ == '__main__': Boobooks.run() ��������������������������������������������������������������������������������������������������������weboob-1.1/scripts/boobsize�������������������������������������������������������������������������0000775�0000000�0000000�00000001632�12657170273�0016075�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.boobsize import Boobsize if __name__ == '__main__': Boobsize.run() ������������������������������������������������������������������������������������������������������weboob-1.1/scripts/boobtracker����������������������������������������������������������������������0000775�0000000�0000000�00000001534�12657170273�0016557�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.boobtracker import BoobTracker if __name__ == '__main__': BoobTracker.run() ��������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/cineoob��������������������������������������������������������������������������0000775�0000000�0000000�00000001626�12657170273�0015702�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.cineoob import Cineoob if __name__ == '__main__': Cineoob.run() ����������������������������������������������������������������������������������������������������������weboob-1.1/scripts/comparoob������������������������������������������������������������������������0000775�0000000�0000000�00000000330�12657170273�0016234�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai from weboob.applications.comparoob import Comparoob if __name__ == '__main__': Comparoob.run() ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/cookboob�������������������������������������������������������������������������0000775�0000000�0000000�00000001631�12657170273�0016055�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.cookboob import Cookboob if __name__ == '__main__': Cookboob.run() �������������������������������������������������������������������������������������������������������weboob-1.1/scripts/flatboob�������������������������������������������������������������������������0000775�0000000�0000000�00000001630�12657170273�0016047�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.flatboob import Flatboob if __name__ == '__main__': Flatboob.run() ��������������������������������������������������������������������������������������������������������weboob-1.1/scripts/galleroob������������������������������������������������������������������������0000775�0000000�0000000�00000001535�12657170273�0016231�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.galleroob import Galleroob if __name__ == '__main__': Galleroob.run() �������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/geolooc��������������������������������������������������������������������������0000775�0000000�0000000�00000001632�12657170273�0015710�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.geolooc import Geolooc if __name__ == '__main__': Geolooc.run() ������������������������������������������������������������������������������������������������������weboob-1.1/scripts/handjoob�������������������������������������������������������������������������0000775�0000000�0000000�00000001520�12657170273�0016041�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.handjoob import Handjoob if __name__ == '__main__': Handjoob.run() ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/havedate�������������������������������������������������������������������������0000775�0000000�0000000�00000001635�12657170273�0016045�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.havedate import HaveDate if __name__ == '__main__': HaveDate.run() ���������������������������������������������������������������������������������������������������weboob-1.1/scripts/masstransit����������������������������������������������������������������������0000775�0000000�0000000�00000001647�12657170273�0016637�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Julien Hébert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.masstransit import Masstransit if __name__ == '__main__': Masstransit.run() �����������������������������������������������������������������������������������������weboob-1.1/scripts/monboob��������������������������������������������������������������������������0000775�0000000�0000000�00000001632�12657170273�0015714�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.monboob import Monboob if __name__ == '__main__': Monboob.run() ������������������������������������������������������������������������������������������������������weboob-1.1/scripts/parceloob������������������������������������������������������������������������0000775�0000000�0000000�00000001633�12657170273�0016230�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.parceloob import Parceloob if __name__ == '__main__': Parceloob.run() �����������������������������������������������������������������������������������������������������weboob-1.1/scripts/pastoob��������������������������������������������������������������������������0000775�0000000�0000000�00000001630�12657170273�0015726�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.pastoob import Pastoob if __name__ == '__main__': Pastoob.run() ��������������������������������������������������������������������������������������������������������weboob-1.1/scripts/qboobmsg�������������������������������������������������������������������������0000775�0000000�0000000�00000001635�12657170273�0016075�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qboobmsg import QBoobMsg if __name__ == '__main__': QBoobMsg.run() ���������������������������������������������������������������������������������������������������weboob-1.1/scripts/qcineoob�������������������������������������������������������������������������0000775�0000000�0000000�00000001631�12657170273�0016057�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qcineoob import QCineoob if __name__ == '__main__': QCineoob.run() �������������������������������������������������������������������������������������������������������weboob-1.1/scripts/qcookboob������������������������������������������������������������������������0000775�0000000�0000000�00000001634�12657170273�0016241�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qcookboob import QCookboob if __name__ == '__main__': QCookboob.run() ����������������������������������������������������������������������������������������������������weboob-1.1/scripts/qflatboob������������������������������������������������������������������������0000775�0000000�0000000�00000001640�12657170273�0016231�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qflatboob import QFlatBoob if __name__ == '__main__': QFlatBoob.run() ������������������������������������������������������������������������������������������������weboob-1.1/scripts/qhandjoob������������������������������������������������������������������������0000775�0000000�0000000�00000001643�12657170273�0016230�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2012 Sébastien Monel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qhandjoob import QHandJoob if __name__ == '__main__': QHandJoob.run() ���������������������������������������������������������������������������������������������weboob-1.1/scripts/qhavedate������������������������������������������������������������������������0000775�0000000�0000000�00000001640�12657170273�0016222�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qhavedate import QHaveDate if __name__ == '__main__': QHaveDate.run() ������������������������������������������������������������������������������������������������weboob-1.1/scripts/qvideoob�������������������������������������������������������������������������0000775�0000000�0000000�00000001635�12657170273�0016074�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qvideoob import QVideoob if __name__ == '__main__': QVideoob.run() ���������������������������������������������������������������������������������������������������weboob-1.1/scripts/qwebcontentedit������������������������������������������������������������������0000775�0000000�0000000�00000001662�12657170273�0017463�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qwebcontentedit import QWebContentEdit if __name__ == '__main__': QWebContentEdit.run() ������������������������������������������������������������������������������weboob-1.1/scripts/radioob��������������������������������������������������������������������������0000775�0000000�0000000�00000001632�12657170273�0015700�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.radioob import Radioob if __name__ == '__main__': Radioob.run() ������������������������������������������������������������������������������������������������������weboob-1.1/scripts/shopoob��������������������������������������������������������������������������0000775�0000000�0000000�00000001627�12657170273�0015736�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/python2.7 # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.shopoob import Shopoob if __name__ == '__main__': Shopoob.run() ���������������������������������������������������������������������������������������������������������weboob-1.1/scripts/suboob���������������������������������������������������������������������������0000775�0000000�0000000�00000001624�12657170273�0015553�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.suboob import Suboob if __name__ == '__main__': Suboob.run() ������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/translaboob����������������������������������������������������������������������0000775�0000000�0000000�00000001535�12657170273�0016571�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.translaboob import Translaboob if __name__ == '__main__': Translaboob.run() �������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/traveloob������������������������������������������������������������������������0000775�0000000�0000000�00000001640�12657170273�0016255�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.traveloob import Traveloob if __name__ == '__main__': Traveloob.run() ������������������������������������������������������������������������������������������������weboob-1.1/scripts/videoob��������������������������������������������������������������������������0000775�0000000�0000000�00000001634�12657170273�0015712�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.videoob import Videoob if __name__ == '__main__': Videoob.run() ����������������������������������������������������������������������������������������������������weboob-1.1/scripts/webcontentedit�������������������������������������������������������������������0000775�0000000�0000000�00000001657�12657170273�0017306�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.webcontentedit import WebContentEdit if __name__ == '__main__': WebContentEdit.run() ���������������������������������������������������������������������������������weboob-1.1/scripts/weboob���������������������������������������������������������������������������0000775�0000000�0000000�00000013106�12657170273�0015535�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2009-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. import re import os import sys import inspect from datetime import datetime, timedelta import weboob.applications from weboob.tools.ordereddict import OrderedDict from weboob.tools.application.console import ConsoleApplication class Weboob(ConsoleApplication): UPDATE_DAYS_DELAY = 20 def __init__(self): super(Weboob, self).__init__() self.update() capApplicationDict = self.init_CapApplicationDict() if len(sys.argv) >= 2: cap = sys.argv.pop(1) if cap not in capApplicationDict: print('Unknown capability, please choose one in the following list') cap = self.choose_capability(capApplicationDict) else: cap = self.choose_capability(capApplicationDict) applications = capApplicationDict[cap] application = applications[0] if len(applications) == 1 else self.choose_application(applications) application.run() def update(self): for repository in self.weboob.repositories.repositories: update_date = datetime.strptime(str(repository.update), '%Y%m%d%H%M') if (datetime.now() - timedelta(days=self.UPDATE_DAYS_DELAY)) > update_date: update = self.ask('The repositories have not been updated for %s days, do you want to update them ? (y/n)' % self.UPDATE_DAYS_DELAY, default='n') if update.upper() == 'Y': self.weboob.repositories.update() break def choose_application(self, applications): application = None while not application: for app in applications: print(' %s%2d)%s %s: %s' % (self.BOLD, applications.index(app) + 1, self.NC, app.APPNAME, app.DESCRIPTION)) r = self.ask(' Select an application', regexp='(\d+|)', default='') if not r.isdigit(): continue r = int(r) if r <= 0 or r > len(applications): continue application = applications[r - 1] return application def choose_capability(self, capApplicationDict): cap = None while cap not in capApplicationDict.keys(): for _cap in capApplicationDict.keys(): print(' %s%2d)%s %s' % (self.BOLD, capApplicationDict.keys().index(_cap) + 1, self.NC, _cap)) r = self.ask(' Select a capability', regexp='(\d+|)', default='') if not r.isdigit(): continue r = int(r) if r <= 0 or r > len(capApplicationDict.keys()): continue cap = capApplicationDict.keys()[r - 1] return cap def init_CapApplicationDict(self): capApplicationDict = {} for path in weboob.applications.__path__: regexp = re.compile('^%s/([\w\d_]+)$' % path) for root, dirs, files in os.walk(path): m = regexp.match(root) if not (m and '__init__.py' in files): continue application = self.get_applicaction_from_filename(m.group(1)) if not application: continue capabilities = self.get_application_capabilities(application) if not capabilities: continue for capability in capabilities: if capability in capApplicationDict: capApplicationDict[capability].append(application) else: capApplicationDict[capability] = [application] return OrderedDict([(k, v) for k, v in sorted(capApplicationDict.iteritems())]) def get_application_capabilities(self, application): if hasattr(application, 'CAPS') and application.CAPS: _capabilities = list(application.CAPS) if isinstance(application.CAPS, tuple) else [application.CAPS] return [os.path.splitext(os.path.basename(inspect.getfile(x)))[0] for x in _capabilities] def get_applicaction_from_filename(self, name): module = 'weboob.applications.%s.%s' % (name, name) try: _module = __import__(module, fromlist=['*']) except ImportError: return _application = [x for x in dir(_module) if x.lower() == name] if _application: return getattr(_module, _application[0]) if __name__ == '__main__': try: Weboob() except KeyboardInterrupt: print('') ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/scripts/weboob-cli�����������������������������������������������������������������������0000775�0000000�0000000�00000001640�12657170273�0016302�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.weboobcli import WeboobCli if __name__ == '__main__': WeboobCli.run() ������������������������������������������������������������������������������������������������weboob-1.1/scripts/weboob-config��������������������������������������������������������������������0000775�0000000�0000000�00000001640�12657170273�0017000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.weboobcfg import WeboobCfg if __name__ == '__main__': WeboobCfg.run() ������������������������������������������������������������������������������������������������weboob-1.1/scripts/weboob-config-qt�����������������������������������������������������������������0000775�0000000�0000000�00000001643�12657170273�0017425�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.qweboobcfg import QWeboobCfg if __name__ == '__main__': QWeboobCfg.run() ���������������������������������������������������������������������������������������������weboob-1.1/scripts/weboob-debug���������������������������������������������������������������������0000775�0000000�0000000�00000001650�12657170273�0016622�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.weboobdebug import WeboobDebug if __name__ == '__main__': WeboobDebug.run() ����������������������������������������������������������������������������������������weboob-1.1/scripts/weboob-repos���������������������������������������������������������������������0000775�0000000�0000000�00000001641�12657170273�0016664�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.weboobrepos import WeboobRepos if __name__ == '__main__': WeboobRepos.run() �����������������������������������������������������������������������������������������������weboob-1.1/scripts/weboorrents����������������������������������������������������������������������0000775�0000000�0000000�00000001646�12657170273�0016637�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.weboorrents import Weboorrents if __name__ == '__main__': Weboorrents.run() ������������������������������������������������������������������������������������������weboob-1.1/scripts/wetboobs�������������������������������������������������������������������������0000775�0000000�0000000�00000001635�12657170273�0016110�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.applications.wetboobs import WetBoobs if __name__ == '__main__': WetBoobs.run() ���������������������������������������������������������������������������������������������������weboob-1.1/setup.cfg��������������������������������������������������������������������������������0000664�0000000�0000000�00000001261�12657170273�0014463�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������[nosetests] verbosity = 2 detailed-errors = 1 with-doctest = 1 where = weboob tests = weboob.tools.capabilities.bank.transactions, weboob.tools.capabilities.paste, weboob.tools.application.formatters.json, weboob.tools.application.formatters.table, weboob.tools.date, weboob.tools.misc, weboob.tools.path, weboob.tools.tokenizer, weboob.browser.browsers, weboob.browser.pages, weboob.browser.filters.standard, weboob.browser.tests.form, weboob.browser.tests.url [isort] known_first_party=weboob line_length=120 [flake8] max-line-length = 120 exclude = dist,*.egg-info,build,.git,__pycache__ �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/setup.py���������������������������������������������������������������������������������0000775�0000000�0000000�00000015674�12657170273�0014374�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Christophe Benz, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function import glob import os import subprocess import sys from setuptools import find_packages, setup def find_executable(name, names): envname = '%s_EXECUTABLE' % name.upper() if os.getenv(envname): return os.getenv(envname) paths = os.getenv('PATH', os.defpath).split(os.pathsep) exts = os.getenv('PATHEXT', os.pathsep).split(os.pathsep) for name in names: for path in paths: for ext in exts: fpath = os.path.join(path, name) + ext if os.path.exists(fpath) and os.access(fpath, os.X_OK): return fpath print('Could not find executable: %s' % name, file=sys.stderr) def build_qt(): print('Building Qt applications...', file=sys.stderr) make = find_executable('make', ('gmake', 'make')) pyuic4 = find_executable('pyuic4', ('python2-pyuic4', 'pyuic4-python2.7', 'pyuic4-python2.6', 'pyuic4')) if not pyuic4 or not make: print('Install missing component(s) (see above) or disable Qt applications (with --no-qt).', file=sys.stderr) sys.exit(1) subprocess.check_call( [make, '-f', 'build.mk', '-s', '-j2', 'all', 'PYUIC=%s%s' % (pyuic4, ' WIN32=1' if sys.platform == 'win32' else '')]) def install_weboob(): scripts = set(os.listdir('scripts')) packages = set(find_packages(exclude=['modules'])) hildon_scripts = set(('masstransit',)) qt_scripts = set(('qboobmsg', 'qhavedate', 'qvideoob', 'weboob-config-qt', 'qwebcontentedit', 'qflatboob', 'qcineoob', 'qcookboob', 'qhandjoob')) if not options.hildon: scripts = scripts - hildon_scripts if options.qt: build_qt() else: scripts = scripts - qt_scripts hildon_packages = set(( 'weboob.applications.masstransit', )) qt_packages = set(( 'weboob.applications.qboobmsg', 'weboob.applications.qboobmsg.ui', 'weboob.applications.qcineoob', 'weboob.applications.qcineoob.ui', 'weboob.applications.qcookboob', 'weboob.applications.qcookboob.ui', 'weboob.applications.qhandjoob', 'weboob.applications.qhandjoob.ui', 'weboob.applications.qhavedate', 'weboob.applications.qhavedate.ui', 'weboob.applications.qvideoob', 'weboob.applications.qvideoob.ui', 'weboob.applications.qweboobcfg', 'weboob.applications.qweboobcfg.ui', 'weboob.applications.qwebcontentedit', 'weboob.applications.qwebcontentedit.ui' 'weboob.applications.qflatboob', 'weboob.applications.qflatboob.ui' )) if not options.hildon: packages = packages - hildon_packages if not options.qt: packages = packages - qt_packages data_files = [ ('share/man/man1', glob.glob('man/*')), ] if options.xdg: data_files.extend([ ('share/applications', glob.glob('desktop/*')), ('share/icons/hicolor/64x64/apps', glob.glob('icons/*')), ]) # Do not put PyQt, it does not work properly. requirements = [ 'lxml', 'feedparser', 'requests', 'python-dateutil', 'PyYAML', 'prettytable', ] try: import Image except ImportError: requirements.append('Pillow') else: # detect Pillow-only feature, or weird Debian stuff if hasattr(Image, 'alpha_composite') or 'PILcompat' in Image.__file__: requirements.append('Pillow') else: requirements.append('PIL') if sys.version_info < (3, 0): requirements.append('gdata') requirements.append('mechanize') if sys.version_info < (3, 2): requirements.append('futures') if sys.version_info < (2, 6): print('Python older than 2.6 is not supported.', file=sys.stderr) sys.exit(1) if not options.deps: requirements = [] setup( name='weboob', version='1.1', description='Weboob, Web Outside Of Browsers', long_description=open('README').read(), author='Romain Bignon', author_email='weboob@weboob.org', maintainer='Romain Bignon', maintainer_email='romain@weboob.org', url='http://weboob.org/', license='GNU AGPL 3', classifiers=[ 'Environment :: Console', 'Environment :: X11 Applications :: Qt', 'License :: OSI Approved :: GNU Affero General Public License v3', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python', 'Topic :: Communications :: Email', 'Topic :: Internet :: WWW/HTTP', ], packages=packages, scripts=[os.path.join('scripts', script) for script in scripts], data_files=data_files, install_requires=requirements, ) class Options(object): hildon = False qt = False xdg = True deps = True options = Options() args = list(sys.argv) if '--hildon' in args and '--no-hildon' in args: print('--hildon and --no-hildon options are incompatible', file=sys.stderr) sys.exit(1) if '--qt' in args and '--no-qt' in args: print('--qt and --no-qt options are incompatible', file=sys.stderr) sys.exit(1) if '--xdg' in args and '--no-xdg' in args: print('--xdg and --no-xdg options are incompatible', file=sys.stderr) sys.exit(1) if '--hildon' in args or os.environ.get('HILDON') == 'true': options.hildon = True if '--hildon' in args: args.remove('--hildon') elif '--no-hildon' in args: options.hildon = False args.remove('--no-hildon') if '--qt' in args: options.qt = True args.remove('--qt') elif '--no-qt' in args: options.qt = False args.remove('--no-qt') if '--xdg' in args: options.xdg = True args.remove('--xdg') elif '--no-xdg' in args: options.xdg = False args.remove('--no-xdg') if '--nodeps' in args: options.deps = False args.remove('--nodeps') sys.argv = args install_weboob() ��������������������������������������������������������������������weboob-1.1/tools/�����������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0014002�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate.py���������������������������������������������������������������������0000775�0000000�0000000�00000017316�12657170273�0016671�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function import argparse import subprocess import datetime import importlib import os import sys import codecs from mako.lookup import TemplateLookup MODULE_PATH = os.getenv( 'MODULE_PATH', os.path.realpath(os.path.join(os.path.dirname(__file__), '../modules'))) TEMPLATE_PATH = os.getenv( 'TEMPLATE_PATH', os.path.realpath(os.path.join(os.path.dirname(__file__), 'boilerplate_data'))) VERSION = '1.1' TEMPLATES = TemplateLookup(directories=[TEMPLATE_PATH]) def u8(s): return s.decode('utf-8') def gitconfig(entry): return u8(subprocess.check_output('git config -z --get %s' % entry, shell=True)[:-1]) def write(target, contents): if not os.path.isdir(os.path.dirname(target)): os.makedirs(os.path.dirname(target)) if os.path.exists(target): print("%s already exists." % target, file=sys.stderr) sys.exit(4) with codecs.open(target, mode='w', encoding='utf-8') as f: f.write(contents) print('Created %s' % target) class Recipe(object): @classmethod def configure_subparser(cls, subparsers): subparser = subparsers.add_parser(cls.NAME) subparser.add_argument('name', help='Module name') subparser.set_defaults(recipe=cls) return subparser def __init__(self, args): self.name = args.name.lower().replace(' ', '') self.classname = args.name.title().replace(' ', '') self.year = datetime.date.today().year self.author = args.author self.email = args.email self.version = VERSION def write(self, filename, contents): return write(os.path.join(MODULE_PATH, self.name, filename), contents) def template(self, name, **kwargs): if '.' not in name: name += '.py' return TEMPLATES.get_template(name) \ .render(r=self, # workaround, as it's also a mako directive coding='# -*- coding: utf-8 -*-', **kwargs) def generate(self): raise NotImplementedError() class BaseRecipe(Recipe): NAME = 'base' def generate(self): self.write('__init__.py', self.template('init')) self.write('module.py', self.template('base_module')) self.write('browser.py', self.template('base_browser')) self.write('pages.py', self.template('base_pages')) self.write('test.py', self.template('base_test')) class CapRecipe(Recipe): NAME = 'cap' LINES = {'def' : ' def %s(%s):', 'docbound': ' """', 'docline': ' %s', 'body' : ' raise NotImplementedError()' } def __init__(self, args): super(CapRecipe, self).__init__(args) self.capname = args.capname @classmethod def configure_subparser(cls, subparsers): subparser = super(CapRecipe, cls).configure_subparser(subparsers) subparser.add_argument('capname', help='Capability name') return subparser def find_module_cap(self): if '.' not in self.capname: return self.search_cap() PREFIX = 'weboob.capabilities.' if not self.capname.startswith(PREFIX): self.capname = PREFIX + self.capname try: self.capmodulename, self.capname = self.capname.rsplit('.', 1) except ValueError: self.error('Cap name must be in format module.CapSomething or CapSomething') try: module = importlib.import_module(self.capmodulename) except ImportError: self.error('Module %r not found' % self.capmodulename) try: cap = getattr(module, self.capname) except AttributeError: self.error('Module %r has no such capability %r' % (self.capmodulename, self.capname)) return cap def search_cap(self): import pkgutil import weboob.capabilities modules = pkgutil.walk_packages(weboob.capabilities.__path__, prefix='weboob.capabilities.') for _, capmodulename, __ in modules: module = importlib.import_module(capmodulename) if hasattr(module, self.capname): self.capmodulename = capmodulename return getattr(module, self.capname) self.error('Capability %r not found' % self.capname) def error(self, message): print(message, file=sys.stderr) sys.exit(1) def methods_code(self, klass): import inspect import re codes = [] for name, member in inspect.getmembers(klass): if inspect.ismethod(member): argspec = inspect.getargspec(member) args = ', '.join(argspec[0]) code = [] code.append(self.LINES['def'] % (name, args)) doc = inspect.getdoc(member) if doc: code.append(self.LINES['docbound']) for line in doc.split('\n'): if line: line = re.sub('"""', '\\"\\"\\"', line) code.append(self.LINES['docline'] % line) else: code.append('') code.append(self.LINES['docbound']) code.append(self.LINES['body']) codes.append('\n'.join(code)) return '\n\n'.join(codes) def generate(self): cap = self.find_module_cap() self.methods_code = self.methods_code(cap) self.write('__init__.py', self.template('init')) self.write('module.py', self.template('cap_module')) self.write('browser.py', self.template('base_browser')) self.write('pages.py', self.template('base_pages')) self.write('test.py', self.template('base_test')) class ComicRecipe(Recipe): NAME = 'comic' def generate(self): self.write('__init__.py', self.template('init')) self.write('module.py', self.template('comic_module')) class ComicTestRecipe(Recipe): NAME = 'comic.test' @classmethod def configure_subparser(cls, subparsers): subparser = super(ComicTestRecipe, cls).configure_subparser(subparsers) subparser.add_argument('download_id', help='Download ID') return subparser def __init__(self, args): super(ComicTestRecipe, self).__init__(args) self.download_id = args.download_id def generate(self): self.write('test.py', self.template('comic_test')) def main(): parser = argparse.ArgumentParser() parser.add_argument( '-a', '--author', default=gitconfig('user.name'), type=u8) parser.add_argument( '-e', '--email', default=gitconfig('user.email'), type=u8) subparsers = parser.add_subparsers() recipes = [BaseRecipe, ComicRecipe, ComicTestRecipe, CapRecipe] for recipe in recipes: recipe.configure_subparser(subparsers) args = parser.parse_args() recipe = args.recipe(args) recipe.generate() if __name__ == '__main__': main() ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate_data/������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0017275�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate_data/base_browser.py���������������������������������������������������0000664�0000000�0000000�00000000743�12657170273�0022330�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<%inherit file="layout.py"/> from weboob.browser import PagesBrowser, URL from .pages import Page1, Page2 class ${r.classname}Browser(PagesBrowser): BASEURL = 'http://www.${r.name}.com' page1 = URL('/page1\?id=(?P<id>.+)', Page1) page2 = URL('/page2', Page2) def get_stuff(self, _id): self.page1.go(id=_id) assert self.page1.is_here() self.page.do_stuff(_id) assert self.page2.is_here() return self.page.do_more_stuff() �����������������������������weboob-1.1/tools/boilerplate_data/base_module.py����������������������������������������������������0000664�0000000�0000000�00000000614�12657170273�0022127�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<%inherit file="layout.py"/> from weboob.tools.backend import Module from .browser import ${r.classname}Browser __all__ = ['${r.classname}Module'] class ${r.classname}Module(Module): NAME = '${r.name}' DESCRIPTION = u'${r.name} website' MAINTAINER = u'${r.author}' EMAIL = '${r.email}' LICENSE = 'AGPLv3+' VERSION = '${r.version}' BROWSER = ${r.classname}Browser ��������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate_data/base_pages.py�����������������������������������������������������0000664�0000000�0000000�00000000373�12657170273�0021743�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<%inherit file="layout.py"/> from weboob.browser.pages import HTMLPage class Page1(HTMLPage): def do_stuff(self, _id): raise NotImplementedError() class Page2(HTMLPage): def do_more_stuff(self): raise NotImplementedError() ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate_data/base_test.py������������������������������������������������������0000664�0000000�0000000�00000000314�12657170273�0021616�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<%inherit file="layout.py"/> from weboob.tools.test import BackendTest class ${r.classname}Test(BackendTest): MODULE = '${r.name}' def test_${r.name}(self): raise NotImplementedError() ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate_data/cap_module.py�����������������������������������������������������0000664�0000000�0000000�00000000732�12657170273�0021761�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<%inherit file="layout.py"/> from weboob.tools.backend import Module from ${r.capmodulename} import ${r.capname} from .browser import ${r.classname}Browser __all__ = ['${r.classname}Module'] class ${r.classname}Module(Module, ${r.capname}): NAME = '${r.name}' DESCRIPTION = u'${r.name} website' MAINTAINER = u'${r.author}' EMAIL = '${r.email}' LICENSE = 'AGPLv3+' VERSION = '${r.version}' BROWSER = ${r.classname}Browser ${r.methods_code} ��������������������������������������weboob-1.1/tools/boilerplate_data/comic_module.py���������������������������������������������������0000664�0000000�0000000�00000001377�12657170273�0022316�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<%inherit file="layout.py"/> from weboob.tools.capabilities.gallery.genericcomicreader import GenericComicReaderModule, DisplayPage __all__ = ['${r.classname}Module'] class ${r.classname}Module(GenericComicReaderModule): NAME = '${r.name}' DESCRIPTION = u'${r.name} manga reading site' MAINTAINER = u'${r.author}' EMAIL = '${r.email}' VERSION = '${r.version}' LICENSE = 'AGPLv3+' DOMAIN = 'www.${r.name}.com' BROWSER_PARAMS = dict( img_src_xpath="//img[@id='comic_page']/@src", page_list_xpath="(//select[@id='page_select'])[1]/option/@value") ID_REGEXP = r'[^/]+/[^/]+' URL_REGEXP = r'.+${r.name}.com/(%s).+' % ID_REGEXP ID_TO_URL = 'http://www.${r.name}.com/%s' PAGES = {URL_REGEXP: DisplayPage} �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate_data/comic_test.py�����������������������������������������������������0000664�0000000�0000000�00000000442�12657170273�0022000�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<%inherit file="layout.py"/> from weboob.tools.capabilities.gallery.genericcomicreadertest import GenericComicReaderTest class ${r.classname}BackendTest(GenericComicReaderTest): MODULE = '${r.name}' def test_download(self): return self._test_download('${r.download_id}') ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate_data/init.py�����������������������������������������������������������0000664�0000000�0000000�00000000153�12657170273�0020611�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<%inherit file="layout.py"/> from .module import ${r.classname}Module __all__ = ['${r.classname}Module'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/boilerplate_data/layout.py���������������������������������������������������������0000664�0000000�0000000�00000001344�12657170273�0021166�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������${coding} # Copyright(C) ${r.year} ${r.author} # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. ${self.body()}\ ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/certhash.py������������������������������������������������������������������������0000775�0000000�0000000�00000000256�12657170273�0016163�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python from __future__ import print_function import sys from weboob.deprecated.browser import StandardBrowser print(StandardBrowser()._certhash(sys.argv[1])) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/debpydep.py������������������������������������������������������������������������0000775�0000000�0000000�00000002360�12657170273�0016154�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import os import subprocess import sys selection = set() dependencies = set() for root, dirs, files in os.walk(sys.argv[1]): for f in files: if f.endswith('.py') and f != '__init__.py': s = "from %s import %s" % (root.strip('/').replace('/', '.'), f[:-3]) try: exec(s) except ImportError as e: print(str(e), file=sys.stderr) else: m = eval(f[:-3]) for attrname in dir(m): try: attr = getattr(m, attrname) selection.add(attr.__file__) except AttributeError: pass for f in selection: f = f.replace('.pyc', '.py') try: f = os.path.abspath(os.path.join(os.path.split(f)[0], os.readlink(f))) except OSError: pass p = subprocess.Popen(['/usr/bin/dpkg', '-S', f], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if p.wait() == 0: for line in p.stdout.readlines(): dependencies.add(line.strip().split(':')[0]) else: print('not found: %s' % f) for d in dependencies: print(d) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/generate_changelog_modules.sh������������������������������������������������������0000775�0000000�0000000�00000001101�12657170273�0021663�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/bash # Usage: weboob$ tools/generate_changelog_modules.sh TAG "list of hash" [show] BEGIN=$1 EXCLUDE=$2 SHOW=$3 for a in modules/* do if [ -d $a ] then MODULE=`basename $a` LOG=`git log --format="%H:::* %s" --date-order --reverse "$BEGIN..HEAD" -- $a` for b in $EXCLUDE do LOG=$(echo "$LOG" |grep -v $b) done if [ -n "$LOG" ] then if [ -n "$SHOW" ] then echo "$LOG" | awk -F ":::" '{print $1}' | git show --stdin else echo -e "\tModules: $MODULE" echo "$LOG" | awk -F ":::" '{print "\t"$2}' echo "" fi fi fi done ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/local_install.py�������������������������������������������������������������������0000664�0000000�0000000�00000003255�12657170273�0017201�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import os import subprocess import sys if '--deps' in sys.argv: sys.argv.remove('--deps') deps = [] else: deps = ['--nodeps'] print("Weboob local installer") print() if len(sys.argv) < 2: print("This tool will install Weboob to be usuable without requiring") print("messing with your system, which should only be touched by a package manager.") print() print("Usage: %s DESTINATION [OPTIONS]" % sys.argv[0]) print() print("By default, no dependencies are installed, as you should try") print("to install them from your package manager as much as possible.") print("To install all the missing dependencies, add the option --deps") print("at the end of the command line.") print() print("Error: Please provide a destination, " "for example ‘%s/bin’" % os.getenv('HOME'), file=sys.stderr) sys.exit(1) else: dest = os.path.expanduser(sys.argv[1]) print("Installing weboob applications into ‘%s’." % dest) subprocess.check_call( [sys.executable, 'setup.py', 'install', '--user', '--install-scripts=%s' % dest] + sys.argv[2:] + deps, cwd=os.path.join(os.path.dirname(__file__), os.pardir)) subprocess.check_call([sys.executable, os.path.join(dest, 'weboob-config'), 'update']) print() print("Installation done. Applications are available in ‘%s’." % dest) print("You can remove the source files.") print() print("To have easy access to the Weboob applications,") print("you should add the following line to your ~/.bashrc or ~/.zshrc file:") print("export PATH=\"$PATH:%s\"" % dest) print("And then restart your shells.") ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/local_install.sh�������������������������������������������������������������������0000775�0000000�0000000�00000000512�12657170273�0017157�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh set -e if [ -z "${PYTHON}" ]; then which python >/dev/null 2>&1 && PYTHON=$(which python) which python2 >/dev/null 2>&1 && PYTHON=$(which python2) which python2.7 >/dev/null 2>&1 && PYTHON=$(which python2.7) fi ${PYTHON} "$(dirname $0)/stale_pyc.py" exec "${PYTHON}" "$(dirname $0)/local_install.py" "$@" ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/local_run.py�����������������������������������������������������������������������0000664�0000000�0000000�00000003063�12657170273�0016334�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import subprocess import sys import os if len(sys.argv) < 2: print("Usage: %s SCRIPTNAME [args]" % sys.argv[0]) sys.exit(1) else: script = sys.argv[1] args = sys.argv[2:] project = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)) wd = os.path.join(project, 'localconfig') if not os.path.isdir(wd): os.makedirs(wd) paths = os.getenv('PYTHONPATH', '').split(':') if project not in paths: paths.insert(0, project) env = os.environ.copy() env['PYTHONPATH'] = ':'.join(p for p in paths if p) env['WEBOOB_WORKDIR'] = wd env['WEBOOB_DATADIR'] = wd env['WEBOOB_BACKENDS'] = os.getenv('WEBOOB_LOCAL_BACKENDS', os.getenv('WEBOOB_BACKENDS', os.path.join(os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), '.config')), 'weboob', 'backends'))) modpath = os.getenv('WEBOOB_MODULES', os.path.join(project, 'modules')) with open(os.path.join(wd, 'sources.list'), 'w') as f: f.write("file://%s\n" % modpath) # Hide output unless there is an error p = subprocess.Popen( [sys.executable, os.path.join(project, 'scripts', 'weboob-config'), 'update'], env=env, stdout=subprocess.PIPE) s = p.communicate() if p.returncode != 0: print(s[0]) sys.exit(p.returncode) if os.path.exists(script): spath = script else: spath = os.path.join(project, 'scripts', script) os.execvpe( sys.executable, ['-Wall', '-s', spath] + args, env) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/local_run.sh�����������������������������������������������������������������������0000775�0000000�0000000�00000000506�12657170273�0016320�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh set -e if [ -z "${PYTHON}" ]; then which python >/dev/null 2>&1 && PYTHON=$(which python) which python2 >/dev/null 2>&1 && PYTHON=$(which python2) which python2.7 >/dev/null 2>&1 && PYTHON=$(which python2.7) fi ${PYTHON} "$(dirname $0)/stale_pyc.py" exec "${PYTHON}" "$(dirname $0)/local_run.py" "$@" ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/make_man.py������������������������������������������������������������������������0000775�0000000�0000000�00000022225�12657170273�0016132�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function import imp import inspect import optparse import os import re import sys import tempfile import time from datetime import datetime from weboob.tools.application.base import Application BASE_PATH = os.path.join(os.path.dirname(__file__), os.pardir) DEST_DIR = 'man' class ManpageHelpFormatter(optparse.HelpFormatter): def __init__(self, app, indent_increment=0, max_help_position=0, width=80, short_first=1): optparse.HelpFormatter.__init__(self, indent_increment, max_help_position, width, short_first) self.app = app def format_heading(self, heading): return ".SH %s\n" % heading.upper() def format_usage(self, usage): txt = '' for line in usage.split('\n'): line = line.lstrip().split(' ', 1) if len(txt) > 0: txt += '.br\n' txt += '.B %s\n' % line[0] arg_re = re.compile(r'([\[\s])([\w_]+)') args = re.sub(arg_re, r"\1\\fI\2\\fR", line[1]) txt += args txt += '\n' return '.SH SYNOPSIS\n%s' % txt def format_description(self, description): desc = u'.SH DESCRIPTION\n.LP\n\n%s\n' % description if hasattr(self.app, 'CAPS'): self.app.weboob.modules_loader.load_all() backends = [] for name, backend in self.app.weboob.modules_loader.loaded.iteritems(): if backend.has_caps(self.app.CAPS): backends.append(u'* %s (%s)' % (name, backend.description)) if len(backends) > 0: desc += u'\n.SS Supported websites:\n' desc += u'\n.br\n'.join(sorted(backends)) return desc def format_commands(self, commands): s = u'' for section, cmds in commands.iteritems(): if len(cmds) == 0: continue s += '.SH %s COMMANDS\n' % section.upper() for cmd in sorted(cmds): s += '.TP\n' h = cmd.split('\n') if ' ' in h[0]: cmdname, args = h[0].split(' ', 1) arg_re = re.compile(r'([A-Z_]+)') args = re.sub(arg_re, r"\\fI\1\\fR", args) s += '\\fB%s\\fR %s' % (cmdname, args) else: s += '\\fB%s\\fR' % h[0] s += '%s\n' % '\n.br\n'.join(h[1:]) return s def format_option_strings(self, option): opts = optparse.HelpFormatter.format_option_strings(self, option).split(", ") return ".TP\n" + ", ".join("\\fB%s\\fR" % opt for opt in opts) def main(): scripts_path = os.path.join(BASE_PATH, "scripts") files = os.listdir(scripts_path) # Create a fake "scripts" modules to import the scripts into sys.modules["scripts"] = imp.new_module("scripts") for fname in files: fpath = os.path.join(scripts_path, fname) if os.path.isfile(fpath) and os.access(fpath, os.X_OK): with open(fpath) as f: # Python will likely want create a compiled file, we provide a place tmpdir = os.path.join(tempfile.gettempdir(), "weboob", "make_man") if not os.path.isdir(tmpdir): os.makedirs(tmpdir) tmpfile = os.path.join(tmpdir, fname) desc = ("", "U", imp.PY_SOURCE) try: script = imp.load_module("scripts.%s" % fname, f, tmpfile, desc) except ImportError as e: print("Unable to load the %s script (%s)" % (fname, e), file=sys.stderr) else: print("Loaded %s" % fname) # Find the applications we can handle for klass in script.__dict__.itervalues(): if inspect.isclass(klass) and issubclass(klass, Application): analyze_application(klass, fname) finally: # Cleanup compiled files if needed if (os.path.isfile(tmpfile + "c")): os.unlink(tmpfile + "c") def format_title(title): return re.sub(r'^(.+):$', r'.SH \1\n.TP', title.group().upper()) # XXX useful because the PyQt QApplication destructor crashes sometimes. By # keeping every applications until program end, it prevents to stop before # every manpages have been generated. If it crashes at exit, it's not a # really a problem. applications = [] def analyze_application(app, script_name): application = app() applications.append(application) formatter = ManpageHelpFormatter(application) # patch the application application._parser.prog = "%s" % script_name application._parser.formatter = formatter helptext = application._parser.format_help(formatter) cmd_re = re.compile(r'^.+ Commands:$', re.MULTILINE) helptext = re.sub(cmd_re, format_title, helptext) helptext = helptext.replace("-", r"\-") coding = r'.\" -*- coding: utf-8 -*-' comment = r'.\" This file was generated automatically by tools/make_man.sh.' header = '.TH %s 1 "%s" "%s %s"' % (script_name.upper(), time.strftime("%d %B %Y"), script_name, app.VERSION.replace('.', '\\&.')) name = ".SH NAME\n%s \- %s" % (script_name, application.SHORT_DESCRIPTION) condition = """.SH CONDITION The \-c and \-\-condition is a flexible way to filter and get only interesting results. It supports conditions on numerical values, dates, durations and strings. Dates are given in YYYY\-MM\-DD or YYYY\-MM\-DD HH:MM format. Durations look like XhYmZs where X, Y and Z are integers. Any of them may be omitted. For instance, YmZs, XhZs or Ym are accepted. The syntax of one expression is "\\fBfield operator value\\fR". The field to test is always the left member of the expression. .LP The field is a member of the objects returned by the command. For example, a bank account has "balance", "coming" or "label" fields. .SS The following operators are supported: .TP = Test if object.field is equal to the value. .TP != Test if object.field is not equal to the value. .TP > Test if object.field is greater than the value. If object.field is date, return true if value is before that object.field. .TP < Test if object.field is less than the value. If object.field is date, return true if value is after that object.field. .TP | This operator is available only for string fields. It works like the Unix standard \\fBgrep\\fR command, and returns True if the pattern specified in the value is in object.field. .SS Expression combination .LP You can make a expression combinations with the keywords \\fB" AND "\\fR, \\fB" OR "\\fR an \\fB" LIMIT "\\fR. .LP The \\fBLIMIT\\fR keyword can be used to limit the number of items upon which running the expression. \\fBLIMIT\\fR can only be placed at the end of the expression followed by the number of elements you want. .SS Examples: .nf .B boobank ls \-\-condition 'label=Livret A' .fi Display only the "Livret A" account. .PP .nf .B boobank ls \-\-condition 'balance>10000' .fi Display accounts with a lot of money. .PP .nf .B boobank history account@backend \-\-condition 'label|rewe' .fi Get transactions containing "rewe". .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 AND date<2013\-12\-09' .fi Get transactions betweens the 2th December and 8th December 2013. .PP .nf .B boobank history account@backend \-\-condition 'date>2013\-12\-01 LIMIT 10' .fi Get transactions after the 2th December in the last 10 transactions """ footer = """.SH COPYRIGHT %s .LP For full copyright information see the COPYING file in the weboob package. .LP .RE .SH FILES "~/.config/weboob/backends" """ % application.COPYRIGHT.replace('YEAR', '%d' % datetime.today().year) if len(app.CONFIG) > 0: footer += '\n\n "~/.config/weboob/%s"' % app.APPNAME # Skip internal applications. footer += "\n\n.SH SEE ALSO\nHome page: http://weboob.org/applications/%s" % application.APPNAME mantext = u"%s\n%s\n%s\n%s\n%s\n%s\n%s" % (coding, comment, header, name, helptext, condition, footer) with open(os.path.join(BASE_PATH, DEST_DIR, "%s.1" % script_name), 'w+') as manfile: for line in mantext.split('\n'): manfile.write('%s\n' % line.lstrip().encode('utf-8')) print("wrote %s/%s.1" % (DEST_DIR, script_name)) if __name__ == '__main__': sys.exit(main()) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/make_man.sh������������������������������������������������������������������������0000775�0000000�0000000�00000001432�12657170273�0016111�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh # stop on failure set -e # Use C local to avoid local dates in headers export LANG=en_US.utf8 # disable termcolor export ANSI_COLORS_DISABLED=1 [ -z "${TMPDIR}" ] && TMPDIR="/tmp" # do not allow undefined variables anymore set -u WEBOOB_TMPDIR=$(mktemp -d "${TMPDIR}/weboob_man.XXXXX") # path to sources WEBOOB_DIR=$(cd $(dirname $0)/.. && pwd -P) touch "${WEBOOB_TMPDIR}/backends" chmod 600 "${WEBOOB_TMPDIR}/backends" echo "file://$WEBOOB_DIR/modules" > "${WEBOOB_TMPDIR}/sources.list" export WEBOOB_WORKDIR="${WEBOOB_TMPDIR}" export WEBOOB_DATADIR="${WEBOOB_TMPDIR}" export PYTHONPATH="${WEBOOB_DIR}" "${WEBOOB_DIR}/scripts/weboob-config" update "${WEBOOB_DIR}/tools/make_man.py" # allow failing commands past this point STATUS=$? rm -rf "${WEBOOB_TMPDIR}" exit $STATUS ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/pyflakes.sh������������������������������������������������������������������������0000775�0000000�0000000�00000004116�12657170273�0016161�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/bash -u cd $(dirname $0) cd .. PYFILES=$(git ls-files|grep '^scripts\|\.py$'|grep -v boilerplate_data|tr '\n' ' ') grep -n 'class [^( ]\+:$' ${PYFILES} && echo 'Error: old class style found, always inherit object' && exit 3 grep -n $'\t\|\s$' $PYFILES && echo 'Error: tabs or trailing whitespace found, remove them' && exit 4 grep -Fn '.setlocale' ${PYFILES} && echo 'Error: do not use setlocale' && exit 5 grep -Fn '__future__ import with_statement' ${PYFILES} && echo 'Error: with_statement useless as we do not support Python 2.5' && exit 6 grep -nE '^[[:space:]]+except [[:alnum:] ]+,[[:alnum:] ]+' ${PYFILES} && echo 'Error: use new "as" way of naming exceptions' && exit 7 grep -nE "^ *print " ${PYFILES} && echo 'Error: Use the print function' && exit 8 grep -Fn ".has_key" ${PYFILES} && echo 'Error: Deprecated, use operator "in"' && exit 9 grep -Fn "os.isatty" ${PYFILES} && echo 'Error: Use stream.isatty() instead of os.isatty(stream.fileno())' && exit 10 grep -Fn "raise StopIteration" ${PYFILES} && echo 'Error: PEP 479' && exit 11 MODULE_FILES=$(git ls-files|grep '^modules/.*\.py$'|tr '\n' ' ') grep -nE "^ *print(\(| )" ${MODULE_FILES} && echo 'Error: Use of print in modules is forbidden, use logger instead' && exit 20 FLAKE8="" if which flake8 >/dev/null 2>&1; then FLAKE8=flake8 fi if which flake8-python2 >/dev/null 2>&1; then FLAKE8=flake8-python2 fi if [ -n "${FLAKE8}" ]; then exec ${FLAKE8} --select=E9,F *.py $PYFILES else PYFLAKES="" if which pyflakes >/dev/null 2>&1; then PYFLAKES=pyflakes fi if which pyflakes-python2 >/dev/null 2>&1; then PYFLAKES=pyflakes-python2 fi if [ -z "${PYFLAKES}" ] then echo "pyflakes not found" exit 1 fi # check for modern pyflakes if ${PYFLAKES} --version >/dev/null 2>&1; then exec ${PYFLAKES} $PYFILES else # hide error reported by mistake. # grep will return 0 only if it founds something, but our script # wants to return 0 when it founds nothing! ${PYFLAKES} $PYFILES | grep -v redefinition && exit 1 || exit 0 fi fi ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/pyreverse.sh�����������������������������������������������������������������������0000775�0000000�0000000�00000000433�12657170273�0016365�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/bash # # Examples: # pyreverse.sh weboob.backends.aum # # pyreverse is included in pylint Debian package function usage() { echo "pyreverse.sh <package_name>" exit } [ -z "$1" ] && usage PYTHONPATH="$(dirname $0)/../modules/$1" pyreverse -p "$1" -o pdf -a1 -s1 "." �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/run_tests.sh�����������������������������������������������������������������������0000775�0000000�0000000�00000006171�12657170273�0016374�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh # stop on failure set -e # path to sources WEBOOB_DIR=$(cd $(dirname $0)/.. && pwd -P) BACKEND="${1}" if [ -z "${WEBOOB_WORKDIR}" ]; then # use the old workdir by default WEBOOB_WORKDIR="${HOME}/.weboob" # but if we can find a valid xdg workdir, switch to it [ "${XDG_CONFIG_HOME}" != "" ] || XDG_CONFIG_HOME="${HOME}/.config" [ -d "${XDG_CONFIG_HOME}/weboob" ] && WEBOOB_WORKDIR="${XDG_CONFIG_HOME}/weboob" fi [ -z "${TMPDIR}" ] && TMPDIR="/tmp" [ -z "${WEBOOB_BACKENDS}" ] && WEBOOB_BACKENDS="${WEBOOB_WORKDIR}/backends" [ -z "${WEBOOB_MODULES}" ] && WEBOOB_MODULES="${WEBOOB_DIR}/modules" [ -z "${PYTHONPATH}" ] && PYTHONPATH="" # allow private environment setup [ -f "${WEBOOB_WORKDIR}/pre-test.sh" ] && source "${WEBOOB_WORKDIR}/pre-test.sh" # setup xunit reporting (buildbot slaves only) if [ -n "${RSYNC_TARGET}" ]; then # by default, builder name is containing directory name [ -z "${BUILDER_NAME}" ] && BUILDER_NAME=$(basename $(readlink -e $(dirname $0)/../..)) else RSYNC_TARGET="" fi # find executables if [ -z "${PYTHON}" ]; then which python >/dev/null 2>&1 && PYTHON=$(which python) which python2 >/dev/null 2>&1 && PYTHON=$(which python2) which python2.7 >/dev/null 2>&1 && PYTHON=$(which python2.7) fi if [ -z "${NOSE}" ]; then which nosetests >/dev/null 2>&1 && NOSE=$(which nosetests) which nosetests2 >/dev/null 2>&1 && NOSE=$(which nosetests2) which nosetests-python2.7 >/dev/null 2>&1 && NOSE=$(which nosetests-python2.7) fi if [ -z "${PYTHON}" ]; then echo "Python required" exit 1 fi if [ -z "${NOSE}" ]; then echo "python-nose required" exit 1 fi # do not allow undefined variables anymore set -u WEBOOB_TMPDIR=$(mktemp -d "${TMPDIR}/weboob_test.XXXXX") cp "${WEBOOB_BACKENDS}" "${WEBOOB_TMPDIR}/backends" # xunit nose setup if [ -n "${RSYNC_TARGET}" ]; then XUNIT_ARGS="--with-xunit --xunit-file=${WEBOOB_TMPDIR}/xunit.xml" else XUNIT_ARGS="" fi ${PYTHON} "$(dirname $0)/stale_pyc.py" echo "file://${WEBOOB_MODULES}" > "${WEBOOB_TMPDIR}/sources.list" export WEBOOB_WORKDIR="${WEBOOB_TMPDIR}" export WEBOOB_DATADIR="${WEBOOB_TMPDIR}" export PYTHONPATH="${WEBOOB_DIR}:${PYTHONPATH}" export NOSE_NOPATH="1" ${PYTHON} "${WEBOOB_DIR}/scripts/weboob-config" update # allow failing commands past this point set +e if [ -n "${BACKEND}" ]; then ${PYTHON} ${NOSE} -c /dev/null -sv "${WEBOOB_MODULES}/${BACKEND}/test.py" ${XUNIT_ARGS} STATUS_CORE=0 else echo "=== Weboob ===" ${PYTHON} ${NOSE} -c ${WEBOOB_DIR}/setup.cfg -sv STATUS_CORE=$? echo "=== Modules ===" find "${WEBOOB_MODULES}" -name "test.py" | sort | xargs ${PYTHON} ${NOSE} -c /dev/null -sv ${XUNIT_ARGS} fi STATUS=$? # xunit transfer if [ -n "${RSYNC_TARGET}" ]; then rsync -iz "${WEBOOB_TMPDIR}/xunit.xml" "${RSYNC_TARGET}/${BUILDER_NAME}-$(date +%s).xml" rm "${WEBOOB_TMPDIR}/xunit.xml" fi # safe removal rm -r "${WEBOOB_TMPDIR}/icons" "${WEBOOB_TMPDIR}/repositories" "${WEBOOB_TMPDIR}/modules" "${WEBOOB_TMPDIR}/keyrings" rm "${WEBOOB_TMPDIR}/backends" "${WEBOOB_TMPDIR}/sources.list" rmdir "${WEBOOB_TMPDIR}" [ $STATUS_CORE -gt 0 ] && exit $STATUS_CORE exit $STATUS �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/stale_pyc.py�����������������������������������������������������������������������0000775�0000000�0000000�00000001324�12657170273�0016342�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python from __future__ import print_function import os import sys root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)) verbose = '-v' in sys.argv excludes = ('.git', '.svn', '__pycache__') for dirpath, dirnames, filenames in os.walk(root): for exclude in excludes: try: dirnames.remove(exclude) except ValueError: pass for filename in filenames: if filename.endswith('.pyc') or filename.endswith('pyo'): if not os.path.exists(os.path.join(dirpath, filename[:-1])): os.unlink(os.path.join(dirpath, filename)) if verbose: print(os.path.join(dirpath, filename)) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/weboob_bash_completion�������������������������������������������������������������0000664�0000000�0000000�00000002422�12657170273�0020430�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Weboob completion for Bash # # vim: filetype=sh expandtab softtabstop=4 shiftwidth=4 # # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. # # This script can be distributed under the same license as the # weboob or bash packages. _weboob() { local cur args COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} args="$(${COMP_WORDS[0]} --shell-completion)" COMPREPLY=( $(compgen -o default -W "${args}" -- "$cur" ) ) } hash weboob-config 2>/dev/null && weboob_applications=$(weboob-config applications 2>/dev/null) hash -d weboob-config for application in $weboob_applications do complete -F _weboob $application done ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/tools/weboob_lint.py���������������������������������������������������������������������0000775�0000000�0000000�00000001670�12657170273�0016666�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/env python from __future__ import print_function # Hint: use this script with file:///path/to/local/modules/ in sources.list # if you want to correctly check all modules. from weboob.core import Weboob import os weboob = Weboob() weboob.modules_loader.load_all() backends_without_tests = [] backends_without_icons = [] for name, backend in weboob.modules_loader.loaded.iteritems(): path = backend.package.__path__[0] if not os.path.exists(os.path.join(path, 'test.py')): backends_without_tests.append(name) if not os.path.exists(os.path.join(path, 'favicon.png')) and \ not os.path.exists(os.path.join(weboob.repositories.icons_dir, '%s.png' % name)) and \ not backend.icon: backends_without_icons.append(name) if backends_without_tests: print('Modules without tests: %s' % backends_without_tests) if backends_without_icons: print('Modules without icons: %s' % backends_without_icons) ������������������������������������������������������������������������weboob-1.1/tools/weboob_lint.sh���������������������������������������������������������������������0000775�0000000�0000000�00000001245�12657170273�0016646�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh # stop on failure set -e [ -z "${TMPDIR}" ] && TMPDIR="/tmp" # do not allow undefined variables anymore set -u WEBOOB_TMPDIR=$(mktemp -d "${TMPDIR}/weboob_lint.XXXXX") # path to sources WEBOOB_DIR=$(cd $(dirname $0)/.. && pwd -P) touch "${WEBOOB_TMPDIR}/backends" chmod 600 "${WEBOOB_TMPDIR}/backends" echo "file://$WEBOOB_DIR/modules" > "${WEBOOB_TMPDIR}/sources.list" export WEBOOB_WORKDIR="${WEBOOB_TMPDIR}" export WEBOOB_DATADIR="${WEBOOB_TMPDIR}" export PYTHONPATH="${WEBOOB_DIR}" "${WEBOOB_DIR}/scripts/weboob-config" update "${WEBOOB_DIR}/tools/weboob_lint.py" # allow failing commands past this point STATUS=$? rm -rf "${WEBOOB_TMPDIR}" exit $STATUS �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/����������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0014117�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/__init__.py�����������������������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0016216�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0016605�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/__init__.py����������������������������������������������������������0000664�0000000�0000000�00000000000�12657170273�0020704�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobank/�������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020220�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobank/__init__.py��������������������������������������������������0000664�0000000�0000000�00000001426�12657170273�0022334�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .boobank import Boobank __all__ = ['Boobank'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobank/boobank.py���������������������������������������������������0000664�0000000�0000000�00000053666�12657170273�0022225�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2009-2011 Romain Bignon, Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function import datetime import uuid from dateutil.relativedelta import relativedelta from dateutil.parser import parse as parse_date from decimal import Decimal, InvalidOperation from weboob.browser.browsers import APIBrowser from weboob.browser.profiles import Weboob from weboob.exceptions import BrowserHTTPError from weboob.capabilities.base import empty from weboob.capabilities.bank import CapBank, Account, Transaction from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter __all__ = ['Boobank'] class OfxFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'date', 'raw', 'amount', 'category') TYPES_ACCTS = ['', 'CHECKING', 'SAVINGS', 'DEPOSIT', 'LOAN', 'MARKET', 'JOINT', 'CARD'] TYPES_TRANS = ['', 'DIRECTDEP', 'PAYMENT', 'CHECK', 'DEP', 'OTHER', 'ATM', 'POS', 'INT', 'FEE'] TYPES_CURRS = ['', 'EUR', 'CHF', 'USD'] balance = Decimal(0) coming = Decimal(0) def start_format(self, **kwargs): account = kwargs['account'] self.balance = account.balance self.coming = account.coming self.output(u'OFXHEADER:100') self.output(u'DATA:OFXSGML') self.output(u'VERSION:102') self.output(u'SECURITY:NONE') self.output(u'ENCODING:USASCII') self.output(u'CHARSET:1252') self.output(u'COMPRESSION:NONE') self.output(u'OLDFILEUID:NONE') self.output(u'NEWFILEUID:%s\n' % uuid.uuid1()) self.output(u'<OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>0<SEVERITY>INFO</STATUS>') self.output(u'<DTSERVER>%s113942<LANGUAGE>ENG</SONRS></SIGNONMSGSRSV1>' % datetime.date.today().strftime('%Y%m%d')) self.output(u'<BANKMSGSRSV1><STMTTRNRS><TRNUID>%s' % uuid.uuid1()) self.output(u'<STATUS><CODE>0<SEVERITY>INFO</STATUS><CLTCOOKIE>null<STMTRS>') self.output(u'<CURDEF>%s<BANKACCTFROM>' % (account.currency or 'EUR')) self.output(u'<BANKID>null') self.output(u'<BRANCHID>null') self.output(u'<ACCTID>%s' % account.id) try: account_type = self.TYPES_ACCTS[account.type] except IndexError: account_type = '' self.output(u'<ACCTTYPE>%s' % (account_type or 'CHECKING')) self.output(u'<ACCTKEY>null</BANKACCTFROM>') self.output(u'<BANKTRANLIST>') self.output(u'<DTSTART>%s' % datetime.date.today().strftime('%Y%m%d')) self.output(u'<DTEND>%s' % datetime.date.today().strftime('%Y%m%d')) def format_obj(self, obj, alias): # special case of coming operations with card ID if hasattr(obj, '_coming') and obj._coming and hasattr(obj, 'obj._cardid') and not empty(obj._cardid): result = u'<STMTTRN><TRNTYPE>%s\n' % obj._cardid elif obj.type != 0: result = u'<STMTTRN><TRNTYPE>%s\n' % self.TYPES_TRANS[obj.type] else: result = u'<STMTTRN><TRNTYPE>%s\n' % ('DEBIT' if obj.amount < 0 else 'CREDIT') result += u'<DTPOSTED>%s\n' % obj.date.strftime('%Y%m%d') result += u'<TRNAMT>%s\n' % obj.amount result += u'<FITID>%s\n' % obj.unique_id() if hasattr(obj, 'label') and not empty(obj.label): result += u'<NAME>%s</STMTTRN>' % obj.label.replace('&', '&') else: result += u'<NAME>%s</STMTTRN>' % obj.raw.replace('&', '&') return result def flush(self): self.output(u'</BANKTRANLIST>') self.output(u'<LEDGERBAL><BALAMT>%s' % self.balance) self.output(u'<DTASOF>%s</LEDGERBAL>' % datetime.date.today().strftime('%Y%m%d')) try: self.output(u'<AVAILBAL><BALAMT>%s' % (self.balance + self.coming)) except TypeError: self.output(u'<AVAILBAL><BALAMT>%s' % self.balance) self.output(u'<DTASOF>%s</AVAILBAL>' % datetime.date.today().strftime('%Y%m%d')) self.output(u'</STMTRS></STMTTRNRS></BANKMSGSRSV1></OFX>') class QifFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'date', 'raw', 'amount') def start_format(self, **kwargs): self.output(u'!Type:Bank') def format_obj(self, obj, alias): result = u'D%s\n' % obj.date.strftime('%d/%m/%y') result += u'T%s\n' % obj.amount if hasattr(obj, 'category') and not empty(obj.category): result += u'N%s\n' % obj.category result += u'M%s\n' % obj.raw result += u'^' return result class PrettyQifFormatter(QifFormatter): MANDATORY_FIELDS = ('id', 'date', 'raw', 'amount', 'category') def start_format(self, **kwargs): self.output(u'!Type:Bank') def format_obj(self, obj, alias): if hasattr(obj, 'rdate') and not empty(obj.rdate): result = u'D%s\n' % obj.rdate.strftime('%d/%m/%y') else: result = u'D%s\n' % obj.date.strftime('%d/%m/%y') result += u'T%s\n' % obj.amount if hasattr(obj, 'category') and not empty(obj.category): result += u'N%s\n' % obj.category if hasattr(obj, 'label') and not empty(obj.label): result += u'M%s\n' % obj.label else: result += u'M%s\n' % obj.raw result += u'^' return result class TransactionsFormatter(IFormatter): MANDATORY_FIELDS = ('date', 'label', 'amount') TYPES = ['', 'Transfer', 'Order', 'Check', 'Deposit', 'Payback', 'Withdrawal', 'Card', 'Loan', 'Bank'] def start_format(self, **kwargs): self.output(' Date Category Label Amount ') self.output('------------+------------+---------------------------------------------------+-----------') def format_obj(self, obj, alias): if hasattr(obj, 'category') and obj.category: _type = obj.category else: try: _type = self.TYPES[obj.type] except (IndexError, AttributeError): _type = '' label = obj.label if not label and hasattr(obj, 'raw'): label = obj.raw date = obj.date.strftime('%Y-%m-%d') if not empty(obj.date) else '' amount = obj.amount or Decimal('0') return ' %s %s %s %s' % (self.colored('%-10s' % date, 'blue'), self.colored('%-12s' % _type[:12], 'magenta'), self.colored('%-50s' % label[:50], 'yellow'), self.colored('%10.2f' % amount, 'green' if amount >= 0 else 'red')) class TransferFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'date', 'origin', 'recipient', 'amount') DISPLAYED_FIELDS = ('reason', ) def format_obj(self, obj, alias): result = u'------- Transfer %s -------\n' % obj.fullid result += u'Date: %s\n' % obj.date result += u'Origin: %s\n' % obj.origin result += u'Recipient: %s\n' % obj.recipient result += u'Amount: %.2f\n' % obj.amount if obj.reason: result += u'Reason: %s\n' % obj.reason return result class InvestmentFormatter(IFormatter): MANDATORY_FIELDS = ('label', 'quantity', 'unitvalue') DISPLAYED_FIELDS = ('code', 'diff') tot_valuation = Decimal(0) tot_diff = Decimal(0) def start_format(self, **kwargs): self.output(' Label Code Quantity Unit Value Valuation diff ') self.output('-------------------------------+--------------+------------+------------+------------+---------') def check_emptyness(self, obj): if not empty(obj): return (obj, '%11.2f') return ('---', '%11s') def format_obj(self, obj, alias): label = obj.label if not empty(obj.diff): diff = obj.diff elif not empty(obj.quantity) and not empty(obj.unitprice): diff = obj.valuation - (obj.quantity * obj.unitprice) else: diff = '---' format_diff = '%8s' if isinstance(diff, Decimal): format_diff = '%8.2f' self.tot_diff += diff if not empty(obj.quantity): quantity = obj.quantity format_quantity = '%11.2f' if obj.quantity._isinteger(): format_quantity = '%11d' else: format_quantity = '%11s' quantity = '---' unitvalue, format_unitvalue = self.check_emptyness(obj.unitvalue) valuation, format_valuation = self.check_emptyness(obj.valuation) if isinstance(valuation, Decimal): self.tot_valuation += obj.valuation if empty(obj.code) and not empty(obj.description): code = obj.description else: code = obj.code return u' %s %s %s %s %s %s' % \ (self.colored('%-30s' % label[:30], 'red'), self.colored('%-12s' % code[:12], 'yellow') if not empty(code) else ' ' * 12, self.colored(format_quantity % quantity, 'yellow'), self.colored(format_unitvalue % unitvalue, 'yellow'), self.colored(format_valuation % valuation, 'yellow'), self.colored(format_diff % diff, 'green' if diff >= 0 else 'red') ) def flush(self): self.output(u'-------------------------------+--------------+------------+------------+------------+---------') self.output(u' Total %s %s' % (self.colored('%11.2f' % self.tot_valuation, 'yellow'), self.colored('%9.2f' % self.tot_diff, 'green' if self.tot_diff >= 0 else 'red')) ) self.tot_valuation = Decimal(0) self.tot_diff = Decimal(0) class RecipientListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'label') def start_format(self, **kwargs): self.output('Available recipients:') def get_title(self, obj): return obj.label class AccountListFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'label', 'balance', 'coming') tot_balance = Decimal(0) tot_coming = Decimal(0) def start_format(self, **kwargs): self.output(' %s Account Balance Coming ' % ((' ' * 15) if not self.interactive else '')) self.output('------------------------------------------%s+----------+----------' % (('-' * 15) if not self.interactive else '')) def format_obj(self, obj, alias): if alias is not None: id = '%s (%s)' % (self.colored('%3s' % ('#' + alias), 'red', 'bold'), self.colored(obj.backend, 'blue', 'bold')) clean = '#%s (%s)' % (alias, obj.backend) if len(clean) < 15: id += (' ' * (15 - len(clean))) else: id = self.colored('%30s' % obj.fullid, 'red', 'bold') balance = obj.balance or Decimal('0') coming = obj.coming or Decimal('0') result = u'%s %s %s %s' % (id, self.colored('%-25s' % obj.label[:25], 'yellow'), self.colored('%9.2f' % obj.balance, 'green' if balance >= 0 else 'red') if not empty(obj.balance) else ' ' * 9, self.colored('%9.2f' % obj.coming, 'green' if coming >= 0 else 'red') if not empty(obj.coming) else '') self.tot_balance += balance self.tot_coming += coming return result def flush(self): self.output(u'------------------------------------------%s+----------+----------' % (('-' * 15) if not self.interactive else '')) self.output(u'%s Total %s %s' % ( (' ' * 15) if not self.interactive else '', self.colored('%8.2f' % self.tot_balance, 'green' if self.tot_balance >= 0 else 'red'), self.colored('%8.2f' % self.tot_coming, 'green' if self.tot_coming >= 0 else 'red')) ) self.tot_balance = Decimal(0) self.tot_coming = Decimal(0) class Boobank(ReplApplication): APPNAME = 'boobank' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon, Christophe Benz' CAPS = CapBank DESCRIPTION = "Console application allowing to list your bank accounts and get their balance, " \ "display accounts history and coming bank operations, and transfer money from an account to " \ "another (if available)." SHORT_DESCRIPTION = "manage bank accounts" EXTRA_FORMATTERS = {'account_list': AccountListFormatter, 'recipient_list': RecipientListFormatter, 'transfer': TransferFormatter, 'qif': QifFormatter, 'pretty_qif': PrettyQifFormatter, 'ofx': OfxFormatter, 'ops_list': TransactionsFormatter, 'investment_list': InvestmentFormatter, } DEFAULT_FORMATTER = 'table' COMMANDS_FORMATTERS = {'ls': 'account_list', 'list': 'account_list', 'transfer': 'transfer', 'history': 'ops_list', 'coming': 'ops_list', 'investment': 'investment_list', } COLLECTION_OBJECTS = (Account, Transaction, ) def load_default_backends(self): self.load_backends(CapBank, storage=self.create_storage()) def _complete_account(self, exclude=None): if exclude: exclude = '%s@%s' % self.parse_id(exclude) return [s for s in self._complete_object() if s != exclude] def do_list(self, line): """ list [-U] List accounts. Use -U to disable sorting of results. """ return self.do_ls(line) def show_history(self, command, line): id, end_date = self.parse_command_args(line, 2, 1) account = self.get_object(id, 'get_account', []) if not account: print('Error: account "%s" not found (Hint: try the command "list")' % id, file=self.stderr) return 2 if end_date is not None: try: end_date = parse_date(end_date) except ValueError: print('"%s" is an incorrect date format (for example "%s")' % (end_date, (datetime.date.today() - relativedelta(months=1)).strftime('%Y-%m-%d')), file=self.stderr) return 3 old_count = self.options.count self.options.count = None self.start_format(account=account) for transaction in self.do(command, account, backends=account.backend): if end_date is not None and transaction.date < end_date: break self.format(transaction) if end_date is not None: self.options.count = old_count def complete_history(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_account() @defaultcount(10) def do_history(self, line): """ history ID [END_DATE] Display history of transactions. If END_DATE is supplied, list all transactions until this date. """ return self.show_history('iter_history', line) def complete_coming(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_account() @defaultcount(10) def do_coming(self, line): """ coming ID [END_DATE] Display future transactions. If END_DATE is supplied, show all transactions until this date. """ return self.show_history('iter_coming', line) def complete_transfer(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_account() if len(args) == 3: return self._complete_account(args[1]) def do_transfer(self, line): """ transfer ACCOUNT [RECIPIENT AMOUNT [REASON]] Make a transfer beetwen two account - ACCOUNT the source account - RECIPIENT the recipient - AMOUNT amount to transfer - REASON reason of transfer If you give only the ACCOUNT parameter, it lists all the available recipients for this account. """ id_from, id_to, amount, reason = self.parse_command_args(line, 4, 1) account = self.get_object(id_from, 'get_account', []) if not account: print('Error: account %s not found' % id_from, file=self.stderr) return 1 if not id_to: self.objects = [] self.set_formatter('recipient_list') self.set_formatter_header(u'Available recipients') self.start_format() for recipient in self.do('iter_transfer_recipients', account.id, backends=account.backend): self.cached_format(recipient) return 0 id_to, backend_name_to = self.parse_id(id_to) if account.backend != backend_name_to: print("Transfer between different backends is not implemented", file=self.stderr) return 4 try: amount = Decimal(amount) except (TypeError, ValueError, InvalidOperation): print('Error: please give a decimal amount to transfer', file=self.stderr) return 2 if self.interactive: # Try to find the recipient label. It can be missing from # recipients list, for example for banks which allow transfers to # arbitrary recipients. to = id_to for recipient in self.do('iter_transfer_recipients', account.id, backends=account.backend): if recipient.id == id_to: to = recipient.label break print('Amount: %s%s' % (amount, account.currency_text)) print('From: %s' % account.label) print('To: %s' % to) print('Reason: %s' % (reason or '')) if not self.ask('Are you sure to do this transfer?', default=True): return self.start_format() for transfer in self.do('transfer', account.id, id_to, amount, reason, backends=account.backend): self.format(transfer) def do_investment(self, id): """ investment ID Display investments of an account. """ account = self.get_object(id, 'get_account', []) if not account: print('Error: account "%s" not found (Hint: try the command "list")' % id, file=self.stderr) return 2 self.start_format() for investment in self.do('iter_investment', account, backends=account.backend): self.format(investment) def do_budgea(self, line): """ budgea USERNAME PASSWORD Export your bank accounts and transactions to Budgea. Budgea is an online web and mobile application to manage your bank accounts. To avoid giving your credentials to this service, you can use this command. https://www.budgea.com """ username, password = self.parse_command_args(line, 2, 2) client = APIBrowser(baseurl='https://budgea.biapi.pro/2.0/') client.set_profile(Weboob(self.VERSION)) try: r = client.request('auth/token', data={'username': username, 'password': password, 'application': 'weboob'}) except BrowserHTTPError as r: error = r.response.json() print('Error: %s' % (error['message'] or error['code']), file=self.stderr) return 1 client.session.headers['Authorization'] = 'Bearer %s' % r['token'] accounts = {} for account in client.request('users/me/accounts')['accounts']: if account['id_connection'] is None: accounts[account['number']] = account for account in self.do('iter_accounts'): if account.id not in accounts: r = client.request('users/me/accounts', data={'name': account.label, 'balance': account.balance, 'number': account.id, }) self.logger.debug(r) account_id = r['id'] else: account_id = accounts[account.id]['id'] transactions = [] for tr in self.do('iter_history', account, backends=account.backend): transactions.append({'original_wording': tr.raw, 'simplified_wording': tr.label, 'value': tr.amount, 'date': tr.date.strftime('%Y-%m-%d'), }) r = client.request('users/me/accounts/%s/transactions' % account_id, data={'transactions': transactions}) client.request('users/me/accounts/%s' % account_id, data={'balance': account.balance}) print('- %s (%s%s): %s new transactions' % (account.label, account.balance, account.currency_text, len(r))) ��������������������������������������������������������������������������weboob-1.1/weboob/applications/boobathon/�����������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020560�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobathon/__init__.py������������������������������������������������0000664�0000000�0000000�00000001426�12657170273�0022674�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .boobathon import Boobathon __all__ = ['Boobathon'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobathon/boobathon.py�����������������������������������������������0000664�0000000�0000000�00000066013�12657170273�0023113�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function from datetime import datetime, timedelta import re import sys from urlparse import urlsplit from random import choice from weboob.capabilities.content import CapContent from weboob.tools.application.repl import ReplApplication from weboob.tools.ordereddict import OrderedDict __all__ = ['Boobathon'] class Task(object): STATUS_NONE = 0 STATUS_PROGRESS = 1 STATUS_DONE = 2 def __init__(self, backend, capability): self.backend = backend self.capability = capability self.status = self.STATUS_NONE self.date = None self.branch = u'' def __repr__(self): return '<Task (%s,%s)>' % (self.backend, self.capability) class Member(object): def __init__(self, id, name): self.name = name self.id = id self.tasks = [] self.availabilities = u'' self.repository = None self.hardware = u'' self.is_me = False def shortname(self): name = self.name if len(name) > 20: name = '%s..' % name[:18] return name class Event(object): def __init__(self, name, backend): self.my_id = backend.browser.get_userid() self.name = 'wiki/weboob/%s' % name self.description = None self.date = None self.begin = None self.end = None self.location = None self.winner = None self.backend = backend self.members = OrderedDict() self.load() def get_me(self): return self.members.get(self.backend.browser.get_userid(), None) def currently_in_event(self): if not self.date or not self.begin or not self.end: return False return self.begin < datetime.now() < self.end def is_closed(self): return self.end < datetime.now() def format_duration(self): if not self.begin or not self.end: return None delta = self.end - self.begin return '%02d:%02d' % (delta.seconds/3600, delta.seconds%3600) def check_time_coherence(self): """ Check if the end's day is before the begin's one, in case it stops at the next day (eg. 15h->1h). If it occures, add a day. """ if self.begin > self.end: self.end = self.end + timedelta(1) def load(self): self.content = self.backend.get_content(self.name) self.members.clear() member = None for line in self.content.content.split('\n'): line = line.strip() if line.startswith('h1. '): self.title = line[4:] elif line.startswith('h3=. '): m = re.match('h3=. Event finished. Winner is "(.*)":/users/(\d+)\!', line) if not m: print('Unable to parse h3=: %s' % line, file=self.stderr) continue self.winner = Member(int(m.group(2)), m.group(1)) elif line.startswith('h2. '): continue elif line.startswith('h3. '): m = re.match('h3. "(.*)":/users/(\d+)', line) if not m: print('Unable to parse user "%s"' % line, file=self.stderr) continue member = Member(int(m.group(2)), m.group(1)) if member.id == self.my_id: member.is_me = True if self.winner is not None and member.id == self.winner.id: self.winner = member self.members[member.id] = member elif self.description is None and len(line) > 0 and line != '{{TOC}}': self.description = line elif line.startswith('* '): m = re.match('\* \*(\w+)\*: (.*)', line) if not m: continue key, value = m.group(1), m.group(2) if member is None: if key == 'Date': self.date = self.parse_date(value) elif key == 'Start' or key == 'Begin': self.begin = self.parse_time(value) elif key == 'End': self.end = self.parse_time(value) self.check_time_coherence() elif key == 'Location': self.location = value else: if key == 'Repository': m = re.match('"(.*.git)":.*', value) if m: member.repository = m.group(1) else: member.repository = value elif key == 'Hardware': member.hardware = value elif key == 'Availabilities': member.availabilities = value elif line.startswith('[['): m = re.match('\[\[(\w+)\]\]\|\[\[(\w+)\]\]\|(.*)\|', line) if not m: print('Unable to parse task: "%s"' % line, file=self.stderr) continue task = Task(m.group(1), m.group(2)) member.tasks.append(task) if m.group(3) == '!/img/weboob/_progress.png!': task.status = task.STATUS_PROGRESS continue mm = re.match('!/img/weboob/_done.png! (\d+):(\d+) (\w+)', m.group(3)) if mm and self.date: task.status = task.STATUS_DONE task.date = datetime(self.date.year, self.date.month, self.date.day, int(mm.group(1)), int(mm.group(2))) task.branch = mm.group(3) def parse_date(self, value): try: return datetime.strptime(value, '%Y-%m-%d') except ValueError: return None def parse_time(self, value): m = re.match('(\d+):(\d+)', value) if not m: return try: return self.date.replace(hour=int(m.group(1)), minute=int(m.group(2))) except ValueError: return None def save(self, message): if self.winner: finished = u'\nh3=. Event finished. Winner is "%s":/users/%d!\n' % (self.winner.name, self.winner.id) else: finished = u'' s = u"""h1. %s {{TOC}} %s h2. Event %s * *Date*: %s * *Begin*: %s * *End*: %s * *Duration*: %s * *Location*: %s h2. Attendees """ % (self.title, finished, self.description, self.date.strftime('%Y-%m-%d') if self.date else '_Unknown_', self.begin.strftime('%H:%M') if self.begin else '_Unknown_', self.end.strftime('%H:%M') if self.end else '_Unknown_', self.format_duration() or '_Unknown_', self.location or '_Unknown_') for member in self.members.itervalues(): if self.date: availabilities = '' else: availabilities = '* *Availabilities*: %s' % member.availabilities if member.repository is None: repository = '_Unknown_' elif member.repository.endswith('.git'): repository = '"%s":git://git.symlink.me/pub/%s ("http":http://git.symlink.me/?p=%s;a=summary)' repository = repository.replace('%s', member.repository) else: repository = member.repository s += u"""h3. "%s":/users/%d * *Repository*: %s * *Hardware*: %s %s |_.Backend|_.Capabilities|_.Status|""" % (member.name, member.id, repository, member.hardware, availabilities) for task in member.tasks: if task.status == task.STATUS_DONE: status = '!/img/weboob/_done.png! %02d:%02d %s' % (task.date.hour, task.date.minute, task.branch) elif task.status == task.STATUS_PROGRESS: status = '!/img/weboob/_progress.png!' else: status = ' ' s += u""" |=.!/img/weboob/%s.png!:/projects/weboob/wiki/%s [[%s]]|[[%s]]|%s|""" % (task.backend.lower(), task.backend, task.backend, task.capability, status) s += '\n\n' self.content.content = s self.backend.push_content(self.content, message) class Boobathon(ReplApplication): APPNAME = 'boobathon' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2011-YEAR Romain Bignon' DESCRIPTION = 'Console application to participate to a Boobathon.' SHORT_DESCRIPTION = "participate in a Boobathon" CAPS = CapContent SYNOPSIS = 'Usage: %prog [-dqv] [-b backends] [-cnfs] boobathon\n' SYNOPSIS += ' %prog [--help] [--version]' radios = [] def __init__(self, *args, **kwargs): ReplApplication.__init__(self, *args, **kwargs) def main(self, argv): if len(argv) < 2: print('Please give the name of the boobathon', file=self.stderr) return 1 self.event = Event(argv[1], choice(self.weboob.backend_instances.values())) if self.event.description is None: if not self.ask("This event doesn't seem to exist. Do you want to create it?", default=True): return 1 self.edit_event() self.save_event('Event created') return ReplApplication.main(self, [argv[0]]) def save_event(self, message): if self.ask("Do you confirm your changes?", default=True): self.event.save(message) return True return False def edit_event(self): self.event.title = self.ask('Enter a title', default=self.event.title) self.event.description = self.ask('Enter a description', default=self.event.description) self.event.date = self.ask('Enter a date (yyyy-mm-dd)', default=self.event.date.strftime('%Y-%m-%d') if self.event.date else '', regexp='^(\d{4}-\d{2}-\d{2})?$') if self.event.date: self.event.date = datetime.strptime(self.event.date, '%Y-%m-%d') s = self.ask('Begin at (HH:MM)', default=self.event.begin.strftime('%H:%M') if self.event.begin else '', regexp='^(\d{2}:\d{2})?$') if s: h, m = s.split(':') self.event.begin = self.event.date.replace(hour=int(h), minute=int(m)) s = self.ask('End at (HH:MM)', default=self.event.end.strftime('%H:%M') if self.event.end else '', regexp='^(\d{2}:\d{2})?$') if s: h, m = s.split(':') self.event.end = self.event.date.replace(hour=int(h), minute=int(m)) self.event.check_time_coherence() self.event.location = self.ask('Enter a location', default=self.event.location) def edit_member(self, member): if member.name is None: firstname = self.ask('Enter your firstname') lastname = self.ask('Enter your lastname') member.name = '%s %s' % (firstname, lastname) else: member.name = self.ask('Enter your name', default=member.name) if self.event.date is None: member.availabilities = self.ask('Enter availabilities', default=member.availabilities) member.repository = self.ask('Enter your repository (ex. romain/weboob.git)', default=member.repository) member.hardware = self.ask('Enter your hardware', default=member.hardware) def do_progress(self, line): """ progress Display progress of members. """ self.event.load() for member in self.event.members.itervalues(): if member.is_me and member is self.event.winner: status = '\o/ ->' elif member.is_me: status = ' ->' elif member is self.event.winner: status = ' \o/' else: status = ' ' s = u' %s%20s %s|' % (status, member.shortname(), self.BOLD) for task in member.tasks: if task.status == task.STATUS_DONE: s += '##' elif task.status == task.STATUS_PROGRESS: s += u'=>' else: s += ' ' s += '|%s' % self.NC print(s) print('') now = datetime.now() if self.event.begin > now: d = self.event.begin - now msg = 'The event will start in %d days, %02d:%02d:%02d' elif self.event.end < now: d = now - self.event.end msg = 'The event is finished since %d days, %02d:%02d:%02d' else: tot = (self.event.end - self.event.begin).seconds cur = (datetime.now() - self.event.begin).seconds pct = cur*20/tot progress = '' for i in xrange(20): if i < pct: progress += '=' elif i == pct: progress += '>' else: progress += ' ' print('Event started: %s |%s| %s' % (self.event.begin.strftime('%H:%M'), progress, self.event.end.strftime('%H:%M'))) d = self.event.end - now msg = 'The event will be finished in %d days, %02d:%02d:%02d' print(msg % (d.days, d.seconds/3600, d.seconds%3600/60, d.seconds%60)) def do_tasks(self, line): """ tasks Display all tasks of members. """ self.event.load() stop = False i = -2 while not stop: if i >= 0 and not i%2: self.stdout.write(' #%-2d' % (i/2)) else: self.stdout.write(' ') if i >= 0 and i%2: # second line of task, see if we'll stop stop = True for mem in self.event.members.itervalues(): if len(mem.tasks) > (i/2+1): # there are more tasks, don't stop now stop = False if i == -2: self.stdout.write(' %s%-20s%s' % (self.BOLD, mem.shortname().encode('utf-8'), self.NC)) elif i == -1: self.stdout.write(' %s%-20s%s' % (self.BOLD, '-' * len(mem.shortname()), self.NC)) elif len(mem.tasks) <= (i/2): self.stdout.write(' ' * (20+1)) else: task = mem.tasks[i/2] if task.status == task.STATUS_DONE: status = u'#' elif task.status == task.STATUS_PROGRESS: if not i%2: status = u'|' #1st line else: status = u'v' #2nd line else: status = u' ' if not i%2: #1st line line = u'%s %s' % (status, task.backend) else: #2nd line line = u'%s `-%s' % (status, task.capability[3:]) self.stdout.write((u' %-20s' % line).encode('utf-8')) self.stdout.write('\n') i += 1 def complete_close(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: self.event.load() return [member.name for member in self.event.members.itervalues()] def do_close(self, name): """ close WINNER Close the event and set the winner. """ self.event.load() for member in self.event.members.itervalues(): if member.name == name: self.event.winner = member if self.save_event('Close event'): print('Event is now closed. Winner is %s!' % self.event.winner.name) return print('"%s" not found' % name, file=self.stderr) return 3 def complete_edit(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return ['event', 'me'] def do_edit(self, line): """ edit [event | me] Edit information about you or about event. """ if not line: print('Syntax: edit [event | me]', file=self.stderr) return 2 self.event.load() if line == 'event': self.edit_event() self.save_event('Event edited') elif line == 'me': mem = self.event.get_me() if not mem: print('You haven\'t joined the event.', file=self.stderr) return 1 self.edit_member(mem) self.save_event('Member edited') else: print('Unable to edit "%s"' % line, file=self.stderr) return 1 def do_info(self, line): """ info Display information about this event. """ self.event.load() print(self.event.title) print('-' * len(self.event.title)) print(self.event.description) print('') print('Date:', self.event.date.strftime('%Y-%m-%d') if self.event.date else 'Unknown') print('Begin:', self.event.begin.strftime('%H:%M') if self.event.begin else 'Unknown') print('End:', self.event.end.strftime('%H:%M') if self.event.end else 'Unknown') print('Duration:', self.event.format_duration() or 'Unknown') print('Location:', self.event.location or 'Unknown') print('') print('There are %d members, use the "members" command to list them' % len(self.event.members)) if self.event.get_me() is None: print('To join this event, use the command "join".') def do_members(self, line): """ members Display members information. """ self.event.load() for member in self.event.members.itervalues(): print(member.name) print('-' * len(member.name)) print('Repository:', member.repository) if self.event.date is None: print('Availabilities:', member.availabilities) print('Hardware:', member.hardware) accompl = 0 for task in member.tasks: if task.status == task.STATUS_DONE: accompl += 1 print('%d tasks (%d accomplished)' % (len(member.tasks), accompl)) if member is self.event.winner: print('=== %s is the winner!' % member.name) print('') print('Use the "tasks" command to display all tasks') def do_join(self, line): """ join Join this event. """ self.event.load() if self.event.backend.browser.get_userid() in self.event.members: print('You have already joined this event.', file=self.stderr) return 1 if self.event.is_closed(): print("Boobathon is closed.", file=self.stderr) return 1 m = Member(self.event.backend.browser.get_userid(), None) self.edit_member(m) self.event.members[m.id] = m self.save_event('Joined the event') def do_leave(self, line): """ leave Leave this event. """ self.event.load() if self.event.currently_in_event(): print('Unable to leave during the event, loser!', file=self.stderr) return 1 if self.event.is_closed(): print("Boobathon is closed.", file=self.stderr) return 1 try: self.event.members.pop(self.event.backend.browser.get_userid()) except KeyError: print("You have not joined this event.", file=self.stderr) return 1 else: self.save_event('Left the event') def do_remtask(self, line): """ remtask TASK_ID Remove a task. """ self.event.load() mem = self.event.get_me() if not mem: print("You have not joined this event.", file=self.stderr) return 1 if self.event.is_closed(): print("Boobathon is closed.", file=self.stderr) return 1 try: task_id = int(line) except ValueError: print('The task ID should be a number', file=self.stderr) return 2 try: task = mem.tasks.pop(task_id) except IndexError: print('Unable to find task #%d' % task_id, file=self.stderr) return 1 else: print('Removing task #%d (%s,%s).' % (task_id, task.backend, task.capability)) self.save_event('Remove task') def do_addtask(self, line): """ addtask BACKEND CAPABILITY Add a new task. """ self.event.load() mem = self.event.get_me() if not mem: print("You have not joined this event.", file=self.stderr) return 1 if self.event.is_closed(): print("Boobathon is closed.", file=self.stderr) return 1 backend, capability = self.parse_command_args(line, 2, 2) if not backend[0].isupper(): print('The backend name "%s" needs to start with a capital.' % backend, file=self.stderr) return 2 if not capability.startswith('Cap') or not capability[3].isupper(): print('"%s" is not a proper capability name (must start with Cap).' % capability, file=self.stderr) return 2 for task in mem.tasks: if (task.backend,task.capability) == (backend,capability): print("A task already exists for that.", file=self.stderr) return 1 task = Task(backend, capability) mem.tasks.append(task) self.save_event('New task') def do_start(self, line): """ start [TASK_ID] Start a task. If you don't give a task ID, the first available task will be taken. """ self.event.load() mem = self.event.get_me() if not mem: print("You have not joined this event.", file=self.stderr) return 1 if len(mem.tasks) == 0: print("You don't have any task to do.", file=self.stderr) return 1 if not self.event.currently_in_event(): print("You can't start a task, we are not in event.", file=self.stderr) return 1 if line.isdigit(): task_id = int(line) else: task_id = -1 last_done = -1 for i, task in enumerate(mem.tasks): if task.status == task.STATUS_DONE: last_done = i elif task.status == task.STATUS_PROGRESS: task.status = task.STATUS_NONE print('Task #%s (%s,%s) canceled.' % (i, task.backend, task.capability)) if (i == task_id or task_id < 0) and task.status == task.STATUS_NONE: break else: print('Task not found.', file=self.stderr) return 3 if task.status == task.STATUS_DONE: print('Task is already done.', file=self.stderr) return 1 task.status = task.STATUS_PROGRESS mem.tasks.remove(task) mem.tasks.insert(last_done + 1, task) self.save_event('Started a task') def do_done(self, line): """ done Set the current task as done. """ self.event.load() mem = self.event.get_me() if not mem: print("You have not joined this event.", file=self.stderr) return 1 if self.event.is_closed(): print("Boobathon is closed.", file=self.stderr) return 1 for i, task in enumerate(mem.tasks): if task.status == task.STATUS_PROGRESS: print('Task (%s,%s) done! (%d%%)' % (task.backend, task.capability, (i+1)*100/len(mem.tasks))) if self.event.currently_in_event(): task.status = task.STATUS_DONE task.date = datetime.now() task.branch = self.ask('Enter name of branch') self.save_event('Task accomplished') else: task.status = task.STATUS_NONE print('Oops, you are out of event. Canceling the task...', file=self.stderr) self.save_event('Cancel task') return 1 return print("There isn't any task in progress.", file=self.stderr) return 1 def do_cancel(self, line): """ cancel Cancel the current task. """ self.event.load() mem = self.event.get_me() if not mem: print("You have not joined this event.", file=self.stderr) return 1 if self.event.is_closed(): print("Boobathon is closed.", file=self.stderr) return 1 for task in mem.tasks: if task.status == task.STATUS_PROGRESS: print('Task (%s,%s) canceled.' % (task.backend, task.capability)) task.status = task.STATUS_NONE self.save_event('Cancel task') return print("There isn't any task in progress.", file=self.stderr) return 1 def load_default_backends(self): """ Overload a Application method. """ for backend_name, module_name, params in self.weboob.backends_config.iter_backends(): if module_name != 'redmine': continue v = urlsplit(params['url']) if v.netloc == 'symlink.me': self.load_backends(names=[backend_name]) return if not self.check_loaded_backends({'url': 'https://symlink.me'}): print("Ok, so leave now, fag.") sys.exit(0) def is_module_loadable(self, module): """ Overload a ConsoleApplication method. """ return module.name == 'redmine' ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobcoming/����������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020723�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobcoming/__init__.py�����������������������������������������������0000664�0000000�0000000�00000001423�12657170273�0023034�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .boobcoming import Boobcoming __all__ = ['Boobcoming'] ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobcoming/boobcoming.py���������������������������������������������0000664�0000000�0000000�00000037573�12657170273�0023432�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function from datetime import time, datetime from dateutil import tz from weboob.tools.date import parse_date from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter from weboob.capabilities.base import empty from weboob.capabilities.calendar import CapCalendarEvent, Query, CATEGORIES, BaseCalendarEvent, TICKET from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.config.yamlconfig import YamlConfig __all__ = ['Boobcoming'] class UpcomingSimpleFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'start_date', 'category', 'summary') def format_obj(self, obj, alias): result = u'%s - %s' % (obj.backend, obj.category) if not empty(obj.start_date): result += u' - %s' % obj.start_date.strftime('%H:%M') result += u' - %s' % obj.summary return result class ICalFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'start_date', 'end_date', 'summary', 'status') def start_format(self, **kwargs): result = u'BEGIN:VCALENDAR\r\n' result += u'VERSION:2.0\r\n' result += u'PRODID:-//hacksw/handcal//NONSGML v1.0//EN\r\n' self.output(result) def format_obj(self, obj, alias): result = u'BEGIN:VEVENT\r\n' utc_zone = tz.gettz('UTC') event_timezone = tz.gettz(obj.timezone) start_date = obj.start_date if not empty(obj.start_date) else datetime.now() start_date = start_date.replace(tzinfo=event_timezone) utc_start_date = start_date.astimezone(utc_zone) result += u'DTSTART:%s\r\n' % utc_start_date.strftime("%Y%m%dT%H%M%SZ") end_date = obj.end_date if not empty(obj.end_date) else datetime.combine(start_date, time.max) end_date = end_date.replace(tzinfo=event_timezone) utc_end_date = end_date.astimezone(utc_zone) result += u'DTEND:%s\r\n' % utc_end_date.strftime("%Y%m%dT%H%M%SZ") result += u'SUMMARY:%s\r\n' % obj.summary result += u'UID:%s\r\n' % obj.id result += u'STATUS:%s\r\n' % obj.status location = '' if hasattr(obj, 'location') and not empty(obj.location): location += obj.location + ' ' if hasattr(obj, 'city') and not empty(obj.city): location += obj.city + ' ' if not empty(location): result += u'LOCATION:%s\r\n' % location if hasattr(obj, 'categories') and not empty(obj.categories): result += u'CATEGORIES:%s\r\n' % obj.categories if hasattr(obj, 'description') and not empty(obj.description): result += u'DESCRIPTION:%s\r\n' % obj.description.strip(' \t\n\r')\ .replace('\r', '')\ .replace('\n', r'\n')\ .replace(',', '\,') if hasattr(obj, 'transp') and not empty(obj.transp): result += u'TRANSP:%s\r\n' % obj.transp if hasattr(obj, 'sequence') and not empty(obj.sequence): result += u'SEQUENCE:%s\r\n' % obj.sequence if hasattr(obj, 'url') and not empty(obj.url): result += u'URL:%s\r\n' % obj.url result += u'END:VEVENT\r\n' return result def flush(self, **kwargs): self.output(u'END:VCALENDAR') class UpcomingListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'start_date', 'end_date', 'summary', 'category') def get_title(self, obj): return ' %s - %s ' % (obj.category, obj.summary) def get_description(self, obj): result = u'' if not empty(obj.start_date): result += u'\tDate: %s\n' % obj.start_date.strftime('%A %d %B %Y') result += u'\tHour: %s' % obj.start_date.strftime('%H:%M') if not empty(obj.end_date): result += ' - %s' % obj.end_date.strftime('%H:%M') days_diff = (obj.end_date - obj.start_date).days if days_diff >= 1: result += ' (%i day(s) later)' % (days_diff) result += '\n' return result.strip('\n\t') class UpcomingFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'start_date', 'end_date', 'summary', 'category') def format_obj(self, obj, alias): result = u'%s%s - %s%s\n' % (self.BOLD, obj.category, obj.summary, self.NC) if not empty(obj.start_date): if not empty(obj.end_date): days_diff = (obj.end_date - obj.start_date).days if days_diff >= 1: result += u'From: %s to %s ' % (obj.start_date.strftime('%A %d %B %Y'), obj.end_date.strftime('%A %d %B %Y')) else: result += u'Date: %s\n' % obj.start_date.strftime('%A %d %B %Y') result += u'Hour: %s' % obj.start_date.strftime('%H:%M') result += ' - %s' % obj.end_date.strftime('%H:%M') else: result += u'Date: %s\n' % obj.start_date.strftime('%A %d %B %Y') result += u'Hour: %s' % obj.start_date.strftime('%H:%M') result += '\n' if hasattr(obj, 'location') and not empty(obj.location): result += u'Location: %s\n' % obj.location if hasattr(obj, 'city') and not empty(obj.city): result += u'City: %s\n' % obj.city if hasattr(obj, 'event_planner') and not empty(obj.event_planner): result += u'Event planner: %s\n' % obj.event_planner if hasattr(obj, 'booked_entries') and not empty(obj.booked_entries) and \ hasattr(obj, 'max_entries') and not empty(obj.max_entries): result += u'Entry: %s/%s \n' % (obj.booked_entries, obj.max_entries) elif hasattr(obj, 'booked_entries') and not empty(obj.booked_entries): result += u'Entry: %s \n' % (obj.booked_entries) elif hasattr(obj, 'max_entries') and not empty(obj.max_entries): result += u'Max entries: %s \n' % (obj.max_entries) if hasattr(obj, 'description') and not empty(obj.description): result += u'Description:\n %s\n\n' % obj.description if hasattr(obj, 'price') and not empty(obj.price): result += u'Price: %.2f\n' % obj.price if hasattr(obj, 'ticket') and not empty(obj.ticket): result += u'Ticket: %s\n' % obj.ticket if hasattr(obj, 'url') and not empty(obj.url): result += u'url: %s\n' % obj.url return result class Boobcoming(ReplApplication): APPNAME = 'boobcoming' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2012-YEAR Bezleputh' DESCRIPTION = "Console application to see upcoming events." SHORT_DESCRIPTION = "see upcoming events" CAPS = CapCalendarEvent EXTRA_FORMATTERS = {'upcoming_list': UpcomingListFormatter, 'upcoming': UpcomingFormatter, 'simple_upcoming': UpcomingSimpleFormatter, 'ical_formatter': ICalFormatter, } COMMANDS_FORMATTERS = {'list': 'upcoming_list', 'search': 'upcoming_list', 'load': 'upcoming_list', 'ls': 'upcoming_list', 'info': 'upcoming', 'export': 'ical_formatter' } def main(self, argv): self.load_config(klass=YamlConfig) return ReplApplication.main(self, argv) def comp_object(self, obj1, obj2): if isinstance(obj1, BaseCalendarEvent) and isinstance(obj2, BaseCalendarEvent): if obj1.start_date == obj2.start_date: return 0 if obj1.start_date > obj2.start_date: return 1 return -1 else: return super(Boobcoming, self).comp_object(obj1, obj2) def select_values(self, values_from, values_to, query_str): r = 'notempty' while r != '': for value in values_from.values: print(' %s%2d)%s [%s] %s' % (self.BOLD, values_from.index[value] + 1, self.NC, 'x' if value in values_to else ' ', value)) r = self.ask(query_str, regexp='(\d+|)', default='') if not r.isdigit(): continue r = int(r) if r <= 0 or r > len(values_from.values): continue value = values_from.values[r - 1] if value in values_to: values_to.remove(value) else: values_to.append(value) @defaultcount(10) def do_search(self, line): """ search search for an event. Parameters interactively asked """ query = Query() self.select_values(CATEGORIES, query.categories, ' Select categorie (or empty to stop)') self.select_values(TICKET, query.ticket, ' Select tickets status (or empty to stop)') if query.categories and len(query.categories) > 0 and query.ticket and len(query.ticket) > 0: query.city = self.ask('Enter a city', default='') query.summary = self.ask('Enter a title', default='') start_date = self.ask_date('Enter a start date', default='today') end_date = self.ask_date('Enter a end date', default='') if end_date: if end_date == start_date: end_date = datetime.combine(start_date, time.max) else: end_date = datetime.combine(end_date, time.max) query.start_date = datetime.combine(start_date, time.min) query.end_date = end_date save_query = self.ask('Save query (y/n)', default='n') if save_query.upper() == 'Y': name = '' while not name: name = self.ask('Query name') self.config.set('queries', name, query) self.config.save() self.complete_search(query) def complete_search(self, query): self.change_path([u'events']) self.start_format() for event in self.do('search_events', query): if event: self.cached_format(event) def ask_date(self, txt, default=''): r = self.ask(txt, default=default) return parse_date(r) @defaultcount(10) def do_load(self, query_name): """ load [query name] without query name : list loadable queries with query name laod query """ queries = self.config.get('queries') if not queries: print('There is no saved queries', file=self.stderr) return 2 if not query_name: for name in queries.keys(): print(' %s* %s %s' % (self.BOLD, self.NC, name)) query_name = self.ask('Which one') if query_name in queries: self.complete_search(queries.get(query_name)) else: print('Unknown query', file=self.stderr) return 2 @defaultcount(10) def do_list(self, line): """ list [PATTERN] List upcoming events, pattern can be an english or french week day, 'today' or a date (dd/mm/yy[yy]) """ self.change_path([u'events']) if line: _date = parse_date(line) if not _date: print('Invalid argument: %s' % self.get_command_help('list'), file=self.stderr) return 2 date_from = datetime.combine(_date, time.min) date_to = datetime.combine(_date, time.max) else: date_from = datetime.now() date_to = None for event in self.do('list_events', date_from, date_to): self.cached_format(event) def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info(self, _id): """ info ID Get information about an event. """ if not _id: print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr) return 2 event = self.get_object(_id, 'get_event') if not event: print('Upcoming event not found: %s' % _id, file=self.stderr) return 3 self.start_format() self.format(event) def do_export(self, line): """ export FILENAME [ID1 ID2 ID3 ...] ID is the identifier of the event. If no ID every events are exported FILENAME is where to write the file. If FILENAME is '-', the file is written to stdout. Export event in ICALENDAR format """ if not line: print('This command takes at leat one argument: %s' % self.get_command_help('export'), file=self.stderr) return 2 _file, args = self.parse_command_args(line, 2, req_n=1) l = self.retrieve_events(args) if l == 3: return 3 if not _file == "-": dest = self.check_file_ext(_file) self.formatter.outfile = dest self.formatter.start_format() for item in l: self.format(item) def retrieve_events(self, args): l = [] if not args: _ids = [] for event in self.do('list_events', datetime.now(), None): _ids.append(event.id) else: _ids = args.strip().split(' ') for _id in _ids: event = self.get_object(_id, 'get_event') if not event: print('Upcoming event not found: %s' % _id, file=self.stderr) return 3 l.append(event) return l def check_file_ext(self, _file): splitted_file = _file.split('.') if splitted_file[-1] != 'ics': return "%s.ics" % _file else: return _file def do_attends(self, line): """ attends ID1 [ID2 ID3 ...] Register as participant of an event. ID is the identifier of the event. """ if not line: print('This command takes at leat one argument: %s' % self.get_command_help('attends'), file=self.stderr) return 2 args = self.parse_command_args(line, 1, req_n=1) l = self.retrieve_events(args[0]) for event in l: # we wait till the work be done, else the errors are not handled self.do('attends_event', event, True).wait() def do_unattends(self, line): """ unattends ID1 [ID2 ID3 ...] Unregister you participation for an event. ID is the identifier of the event. """ if not line: print('This command takes at leat one argument: %s' % self.get_command_help('unattends'), file=self.stderr) return 2 args = self.parse_command_args(line, 1, req_n=1) l = self.retrieve_events(args[0]) for event in l: self.do('attends_event', event, False) �������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobill/�������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020227�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobill/__init__.py��������������������������������������������������0000664�0000000�0000000�00000001424�12657170273�0022341�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .boobill import Boobill __all__ = ['Boobill'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobill/boobill.py���������������������������������������������������0000664�0000000�0000000�00000017617�12657170273�0022237�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2012-2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function from decimal import Decimal from weboob.capabilities.bill import CapBill, Detail, Subscription from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import PrettyFormatter from weboob.tools.application.base import MoreResultsAvailable from weboob.core import CallErrors __all__ = ['Boobill'] class SubscriptionsFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'label') def get_title(self, obj): if obj.renewdate: return u"%s - %s" % (obj.label, obj.renewdate.strftime('%d/%m/%y')) return obj.label class Boobill(ReplApplication): APPNAME = 'boobill' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2012-YEAR Florent Fourcot' DESCRIPTION = 'Console application allowing to get and download bills.' SHORT_DESCRIPTION = "get and download bills" CAPS = CapBill COLLECTION_OBJECTS = (Subscription, ) EXTRA_FORMATTERS = {'subscriptions': SubscriptionsFormatter, } DEFAULT_FORMATTER = 'table' COMMANDS_FORMATTERS = {'subscriptions': 'subscriptions', 'ls': 'subscriptions', } def main(self, argv): self.load_config() return ReplApplication.main(self, argv) def exec_method(self, id, method): l = [] id, backend_name = self.parse_id(id) if not id: for subscrib in self.get_object_list('iter_subscription'): l.append((subscrib.id, subscrib.backend)) else: l.append((id, backend_name)) more_results = [] not_implemented = [] self.start_format() for id, backend in l: names = (backend,) if backend is not None else None try: for result in self.do(method, id, backends=names): self.format(result) except CallErrors as errors: for backend, error, backtrace in errors: if isinstance(error, MoreResultsAvailable): more_results.append(id + u'@' + backend.name) elif isinstance(error, NotImplementedError): if backend not in not_implemented: not_implemented.append(backend) else: self.bcall_error_handler(backend, error, backtrace) if len(more_results) > 0: print('Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results)), file=self.stderr) for backend in not_implemented: print(u'Error(%s): This feature is not supported yet by this backend.' % backend.name, file=self.stderr) def do_subscriptions(self, line): """ subscriptions List all subscriptions. """ return self.do_ls(line) def do_details(self, id): """ details [ID] Get details of subscriptions. If no ID given, display all details of all backends. """ l = [] id, backend_name = self.parse_id(id) if not id: for subscrib in self.get_object_list('iter_subscription'): l.append((subscrib.id, subscrib.backend)) else: l.append((id, backend_name)) for id, backend in l: names = (backend,) if backend is not None else None # XXX: should be generated by backend? -Flo # XXX: no, but you should do it in a specific formatter -romain # TODO: do it, and use exec_method here. Code is obsolete mysum = Detail() mysum.label = u"Sum" mysum.infos = u"Generated by boobill" mysum.price = Decimal("0.") self.start_format() for detail in self.do('get_details', id, backends=names): self.format(detail) mysum.price = detail.price + mysum.price self.format(mysum) def do_balance(self, id): """ balance [ID] Get balance of subscriptions. If no ID given, display balance of all backends. """ self.exec_method(id, 'get_balance') @defaultcount(10) def do_history(self, id): """ history [ID] Get the history of subscriptions. If no ID given, display histories of all backends. """ self.exec_method(id, 'iter_bills_history') @defaultcount(10) def do_bills(self, id): """ bills [ID] Get the list of bills documents for subscriptions. If no ID given, display bills of all backends """ self.exec_method(id, 'iter_bills') def do_download(self, line): """ download [ID | all] [FILENAME] download ID [FILENAME] download the bill id is the identifier of the bill (hint: try bills command) FILENAME is where to write the file. If FILENAME is '-', the file is written to stdout. download all [ID] You can use special word "all" and download all bills of subscription identified by ID. If Id not given, download bills of all subscriptions. """ id, dest = self.parse_command_args(line, 2, 1) id, backend_name = self.parse_id(id) if not id: print('Error: please give a bill ID (hint: use bills command)', file=self.stderr) return 2 names = (backend_name,) if backend_name is not None else None # Special keywords, download all bills of all subscriptions if id == "all": if dest is None: for subscription in self.do('iter_subscription', backends=names): self.download_all(subscription.id, names) return else: self.download_all(dest, names) return if dest is None: for bill in self.do('get_bill', id, backends=names): dest = id + "." + bill.format for buf in self.do('download_bill', id, backends=names): if buf: if dest == "-": print(buf) else: try: with open(dest, 'wb') as f: f.write(buf) except IOError as e: print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr) return 1 return def download_all(self, id, names): id, backend_name = self.parse_id(id) for bill in self.do('iter_bills', id, backends=names): dest = bill.id + "." + bill.format for buf in self.do('download_bill', bill.id, backends=names): if buf: if dest == "-": print(buf) else: try: with open(dest, 'wb') as f: f.write(buf) except IOError as e: print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr) return 1 return �����������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/booblyrics/����������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020754�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/booblyrics/__init__.py�����������������������������������������������0000664�0000000�0000000�00000001432�12657170273�0023065�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .booblyrics import Booblyrics __all__ = ['Booblyrics'] ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/booblyrics/booblyrics.py���������������������������������������������0000664�0000000�0000000�00000007037�12657170273�0023504�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function from weboob.capabilities.lyrics import CapLyrics from weboob.capabilities.base import empty from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter __all__ = ['Booblyrics', 'LyricsGetFormatter', 'LyricsListFormatter'] class LyricsGetFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'title', 'artist', 'content') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.title, self.NC) result += 'ID: %s\n' % obj.fullid result += 'Title: %s\n' % obj.title result += 'Artist: %s\n' % obj.artist result += '\n%sContent%s\n' % (self.BOLD, self.NC) result += '%s' % obj.content return result class LyricsListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title', 'artist') def get_title(self, obj): return obj.title def get_description(self, obj): artist = u'' if not empty(obj.artist): artist = obj.artist return '%s' % artist class Booblyrics(ReplApplication): APPNAME = 'booblyrics' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2013-YEAR Julien Veyssier' DESCRIPTION = "Console application allowing to search for song lyrics on various websites." SHORT_DESCRIPTION = "search and display song lyrics" CAPS = CapLyrics EXTRA_FORMATTERS = {'lyrics_list': LyricsListFormatter, 'lyrics_get': LyricsGetFormatter, } COMMANDS_FORMATTERS = {'search': 'lyrics_list', 'get': 'lyrics_get', } SEARCH_CRITERIAS = ['artist', 'song'] def complete_get(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_get(self, id): """ get ID Display lyrics of the song. """ songlyrics = self.get_object(id, 'get_lyrics') if not songlyrics: print('Song lyrics not found: %s' % id, file=self.stderr) return 3 self.start_format() self.format(songlyrics) def complete_search(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self.SEARCH_CRITERIAS @defaultcount(10) def do_search(self, line): """ search [artist | song] [PATTERN] Search lyrics by artist name or by song title. """ criteria, pattern = self.parse_command_args(line, 2, 2) self.change_path([u'search']) if not pattern: pattern = None self.start_format(pattern=pattern) for songlyrics in self.do('iter_lyrics', criteria, pattern): self.cached_format(songlyrics) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobmsg/�������������������������������������������������������������0000775�0000000�0000000�00000000000�12657170273�0020235�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobmsg/__init__.py��������������������������������������������������0000664�0000000�0000000�00000001426�12657170273�0022351�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from .boobmsg import Boobmsg __all__ = ['Boobmsg'] ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������weboob-1.1/weboob/applications/boobmsg/boobmsg.py���������������������������������������������������0000664�0000000�0000000�00000043130�12657170273�0022240�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function import os import datetime import hashlib from tempfile import NamedTemporaryFile from lxml import etree from weboob.core import CallErrors from weboob.capabilities.base import empty from weboob.capabilities.messages import CapMessages, Message, Thread from weboob.capabilities.account import CapAccount from weboob.capabilities.contact import CapContact from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter from weboob.tools.html import html2text __all__ = ['Boobmsg'] class AtomFormatter(IFormatter): MANDATORY_FIELDS = ('title', 'date', 'sender', 'content') def start_format(self, **kwargs): self.output(u'<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"') self.output(u'xmlns:dc="http://purl.org/dc/elements/1.1/">\n') self.output(u'<title type="text">Atom feed by Weboob') # TODO : get backend name self.output(u'%s' % datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")) m = hashlib.md5() m.update(datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")) self.output(u'urn:md5:%s' % m.hexdigest()) def format_obj(self, obj, alias): elem = etree.Element('entry') title = etree.Element('title') title.text = obj.title elem.append(title) id = etree.Element('id') m = hashlib.md5() m.update(obj.content.encode('utf8', 'ascii')) id.text = "urn:md5:%s" % m.hexdigest() elem.append(id) link = etree.Element('link') link.attrib["href"] = obj.thread.id link.attrib["title"] = obj.title link.attrib["type"] = "text/html" elem.append(link) author = etree.Element('author') name = etree.Element('name') if obj.sender: name.text = obj.sender else: name.text = obj.backend author.append(name) elem.append(author) date = etree.Element('updated') date.text = obj.date.strftime("%Y-%m-%dT%H:%M:%SZ") elem.append(date) content = etree.Element('content') content.text = obj.content content.attrib["type"] = "html" elem.append(content) return etree.tostring(elem, pretty_print=True) def flush(self): self.output(u'') class XHtmlFormatter(IFormatter): MANDATORY_FIELDS = ('title', 'date', 'sender', 'signature', 'content') def format_obj(self, obj, alias): result = "
\n" result += "

%s

" % (obj.title) result += "
" result += "
Date
%s
" % (obj.date.strftime('%Y-%m-%d %H:%M')) result += "
Sender
%s
" % (obj.sender) result += "
Signature
%s
" % (obj.signature) result += "
" result += "
%s
" % (obj.content) result += "
\n" return result class MessageFormatter(IFormatter): MANDATORY_FIELDS = ('title', 'date', 'sender', 'signature', 'content') def format_obj(self, obj, alias): result = u'%sTitle:%s %s\n' % (self.BOLD, self.NC, obj.title) result += u'%sDate:%s %s\n' % (self.BOLD, self.NC, obj.date.strftime('%Y-%m-%d %H:%M')) result += u'%sFrom:%s %s\n' % (self.BOLD, self.NC, obj.sender) if hasattr(obj, 'receivers') and obj.receivers: result += u'%sTo:%s %s\n' % (self.BOLD, self.NC, ', '.join(obj.receivers)) if obj.flags & Message.IS_HTML: content = html2text(obj.content) else: content = obj.content result += '\n%s' % content if obj.signature: if obj.flags & Message.IS_HTML: signature = html2text(obj.signature) else: signature = obj.signature result += '\n-- \n%s' % signature return result class MessagesListFormatter(IFormatter): MANDATORY_FIELDS = () count = 0 _list_messages = False def flush(self): self.count = 0 def format_obj(self, obj, alias): if not self._list_messages: return self.format_dict_thread(obj, alias) else: return self.format_dict_messages(obj, alias) def format_dict_thread(self, obj, alias): self.count += 1 if self.interactive: result = u'%s* (%d) %s (%s)%s' % (self.BOLD, self.count, obj.title, obj.backend, self.NC) else: result = u'%s* (%s) %s%s' % (self.BOLD, obj.id, obj.title, self.NC) if obj.date: result += u'\n %s' % obj.date return result def format_dict_messages(self, obj, alias): if obj.flags == Thread.IS_THREADS: depth = 0 else: depth = -1 result = self.format_message(obj.backend, obj.root, depth) return result def format_message(self, backend, message, depth=0): if not message: return u'' self.count += 1 flags = '[' if message.flags & message.IS_UNREAD: flags += 'N' else: flags += '-' if message.flags & message.IS_NOT_RECEIVED: flags += 'U' elif message.flags & message.IS_RECEIVED: flags += 'R' else: flags += '-' flags += ']' if self.interactive: result = u'%s%s* (%d)%s %s <%s> %s (%s)\n' % (depth * ' ', self.BOLD, self.count, self.NC, flags, message.sender, message.title, backend) else: result = u'%s%s* (%s.%s@%s)%s %s <%s> %s\n' % (depth * ' ', self.BOLD, message.thread.id, message.id, backend, self.NC, flags, message.sender, message.title) if message.children: if depth >= 0: depth += 1 for m in message.children: result += self.format_message(backend, m, depth) return result class ProfileFormatter(IFormatter): def flush(self): pass def format_obj(self, obj, alias=None): return obj.get_text() class Boobmsg(ReplApplication): APPNAME = 'boobmsg' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Christophe Benz' DESCRIPTION = "Console application allowing to send messages on various websites and " \ "to display message threads and contents." SHORT_DESCRIPTION = "send and receive message threads" CAPS = CapMessages EXTRA_FORMATTERS = {'msglist': MessagesListFormatter, 'msg': MessageFormatter, 'xhtml': XHtmlFormatter, 'atom': AtomFormatter, 'profile' : ProfileFormatter, } COMMANDS_FORMATTERS = {'list': 'msglist', 'show': 'msg', 'export_thread': 'msg', 'export_all': 'msg', 'ls': 'msglist', 'profile': 'profile', } def add_application_options(self, group): group.add_option('-E', '--accept-empty', action='store_true', help='Send messages with an empty body.') group.add_option('-t', '--title', action='store', help='For the "post" command, set a title to message', type='string', dest='title') def load_default_backends(self): self.load_backends(CapMessages, storage=self.create_storage()) def main(self, argv): self.load_config() return ReplApplication.main(self, argv) def do_status(self, line): """ status Display status information about a backend. """ if len(line) > 0: backend_name = line else: backend_name = None results = {} for field in self.do('get_account_status', backends=backend_name, caps=CapAccount): if field.backend in results: results[field.backend].append(field) else: results[field.backend] = [field] for name, fields in results.iteritems(): print(':: %s ::' % name) for f in fields: if f.flags & f.FIELD_HTML: value = html2text(f.value) else: value = f.value print('%s: %s' % (f.label, value)) print('') def do_post(self, line): """ post RECEIVER@BACKEND[,RECEIVER@BACKEND[...]] [TEXT] Post a message to the specified receivers. Multiple receivers are separated by a comma. If no text is supplied on command line, the content of message is read on stdin. """ receivers, text = self.parse_command_args(line, 2, 1) if text is None: text = self.acquire_input() if not self.options.accept_empty and not text.strip(): self.logger.warning(u'The message body is empty, use option --accept_empty to send empty messages') return for receiver in receivers.strip().split(','): receiver, backend_name = self.parse_id(receiver.strip(), unique_backend=True) if not backend_name and len(self.enabled_backends) > 1: self.logger.warning(u'No backend specified for receiver "%s": message will be sent with all the ' 'enabled backends (%s)' % (receiver, ','.join(backend.name for backend in self.enabled_backends))) if '.' in receiver: # It's a reply thread_id, parent_id = receiver.rsplit('.', 1) else: # It's an original message thread_id = receiver parent_id = None try: thread_id = self.threads[int(thread_id) - 1].id except (IndexError,ValueError): pass thread = Thread(thread_id) message = Message(thread, 0, title=self.options.title, parent=Message(thread, parent_id) if parent_id else None, content=text) try: self.do('post_message', message, backends=backend_name).wait() except CallErrors as errors: self.bcall_errors_handler(errors) else: if self.interactive: print('Message sent sucessfully to %s' % receiver) threads = [] messages = [] @defaultcount(10) def do_list(self, arg): """ list Display all threads. """ if len(arg) > 0: try: thread = self.threads[int(arg) - 1] except (IndexError, ValueError): id, backend_name = self.parse_id(arg) else: id = thread.id backend_name = thread.backend self.messages = [] cmd = self.do('get_thread', id, backends=backend_name) self.formatter._list_messages = True else: self.threads = [] cmd = self.do('iter_threads') self.formatter._list_messages = False self.start_format() for thread in cmd: if not thread: continue if len(arg) > 0: for m in thread.iter_all_messages(): if not m.backend: m.backend = thread.backend self.messages.append(m) else: self.threads.append(thread) self.format(thread) def do_export_all(self, arg): """ export_all Export All threads """ def func(backend): for thread in backend.iter_threads(): if not thread: continue t = backend.fillobj(thread, None) for msg in t.iter_all_messages(): yield msg self.start_format() for msg in self.do(func): self.format(msg) def do_export_thread(self, arg): """ export_thread ID Export the thread identified by ID """ _id, backend_name = self.parse_id(arg) cmd = self.do('get_thread', _id, backends=backend_name) self.start_format() for thread in cmd: if thread is not None: for msg in thread.iter_all_messages(): self.format(msg) def do_show(self, arg): """ show MESSAGE Read a message """ message = None if len(arg) == 0: print('Please give a message ID.', file=self.stderr) return 2 try: message = self.messages[int(arg) - 1] except (IndexError, ValueError): # The message is not is the cache, we have now two cases: # 1) the user uses a number to get a thread in the cache # 2) the user gives a thread id try: thread = self.threads[int(arg) - 1] if not empty(thread.root): message = thread.root else: for thread in self.do('get_thread', thread.id, backends=thread.backend): if thread is not None: message = thread.root except (IndexError, ValueError): _id, backend_name = self.parse_id(arg) for thread in self.do('get_thread', _id, backends=backend_name): if thread is not None: message = thread.root if message is not None: self.start_format() self.format(message) self.weboob.do('set_message_read', message, backends=message.backend) return else: print('Message not found', file=self.stderr) return 3 def do_profile(self, id): """ profile ID Display a profile """ _id, backend_name = self.parse_id(id, unique_backend=True) found = 0 for contact in self.do('get_contact', _id, backends=backend_name, caps=CapContact): if contact: self.format(contact) found = 1 if not found: self.logger.error(u'Profile not found') def do_photos(self, id): """ photos ID Display photos of a profile """ photo_cmd = self.config.get('photo_viewer') if photo_cmd is None: print("Configuration error: photo_viewer is undefined", file=self.stderr) return _id, backend_name = self.parse_id(id, unique_backend=True) found = 0 for contact in self.do('get_contact', _id, backends=backend_name): if contact: # Write photo to temporary files tmp_files = [] for photo in contact.photos.values(): suffix = '.jpg' if '.' in photo.url.split('/')[-1]: suffix = '.%s' % photo.url.split('/')[-1].split('.')[-1] f = NamedTemporaryFile(suffix=suffix) photo = self.weboob[contact.backend].fillobj(photo, 'data') f.write(photo.data) tmp_files.append(f) os.system(photo_cmd % ' '.join([file.name for file in tmp_files])) found = 1 if not found: self.logger.error(u'Profile not found') weboob-1.1/weboob/applications/boobooks/000077500000000000000000000000001265717027300204225ustar00rootroot00000000000000weboob-1.1/weboob/applications/boobooks/__init__.py000066400000000000000000000014311265717027300225320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Jérémy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .boobooks import Boobooks __all__ = ['Boobooks'] weboob-1.1/weboob/applications/boobooks/boobooks.py000066400000000000000000000045731265717027300226220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2012 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.library import CapBook, Book from weboob.tools.application.repl import ReplApplication from weboob.tools.application.formatters.iformatter import PrettyFormatter __all__ = ['Boobooks'] class RentedListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'date', 'author', 'name', 'late') RED = '' def get_title(self, obj): s = u'%s — %s (%s)' % (obj.author, obj.name, obj.date) if obj.late: s += u' %sLATE!%s' % (self.RED, self.NC) return s class Boobooks(ReplApplication): APPNAME = 'boobooks' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2012-YEAR Jeremy Monnet' CAPS = CapBook DESCRIPTION = "Console application allowing to list your books rented or booked at the library, " \ "book and search new ones, get your booking history (if available)." SHORT_DESCRIPTION = "manage rented books" EXTRA_FORMATTERS = {'rented_list': RentedListFormatter, } DEFAULT_FORMATTER = 'table' COMMANDS_FORMATTERS = {'ls': 'rented_list', 'list': 'rented_list', } COLLECTION_OBJECTS = (Book, ) def do_renew(self, id): """ renew ID Renew a book """ id, backend_name = self.parse_id(id) if not id: print('Error: please give a book ID (hint: use ls command)', file=self.stderr) return 2 names = (backend_name,) if backend_name is not None else None for renew in self.do('renew_book', id, backends=names): self.format(renew) weboob-1.1/weboob/applications/boobsize/000077500000000000000000000000001265717027300204215ustar00rootroot00000000000000weboob-1.1/weboob/applications/boobsize/__init__.py000066400000000000000000000014251265717027300225340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .boobsize import Boobsize __all__ = ['Boobsize'] weboob-1.1/weboob/applications/boobsize/boobsize.py000066400000000000000000000156661265717027300226250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.base import empty from weboob.capabilities.gauge import CapGauge, SensorNotFound from weboob.tools.application.repl import ReplApplication from weboob.tools.application.formatters.iformatter import IFormatter __all__ = ['Boobsize'] class GaugeFormatter(IFormatter): MANDATORY_FIELDS = ('name', 'object', 'sensors') DISPLAYED_FIELDS = ('city', ) def start_format(self, **kwargs): # Name = 27 Object = 10 City = 10 Sensors = 33 self.output(' Name and ID Object City Sensors ') self.output('----------------------------+----------+----------+---------------------------------') def format_obj(self, obj, alias): name = obj.name city = u"" if not empty(obj.city): city = obj.city if not obj.sensors or (len(obj.sensors) == 0): result = u' %s %s %s \n' %\ (self.colored('%-27s' % name[:27], 'red'), self.colored('%-10s' % obj.object[:10], 'yellow'), self.colored('%-10s' % city[:10], 'yellow') ) result += u' %s \n' % self.colored('%-47s' % obj.fullid[:47], 'blue') else: first = True firstaddress = obj.sensors[0].address for sensor in obj.sensors: sensorname = sensor.name # This is a int value, do not display it as a float if not empty(sensor.lastvalue.level): if int(sensor.lastvalue.level) == sensor.lastvalue.level: lastvalue = "%d " % sensor.lastvalue.level else: lastvalue = "%r " % sensor.lastvalue.level if not empty(sensor.unit): lastvalue += "%s" % sensor.unit else: lastvalue = u"? " if first: result = u' %s %s %s ' %\ (self.colored('%-27s' % name[:27], 'red'), self.colored('%-10s' % obj.object[:10], 'yellow'), self.colored('%-10s' % city[:10], 'yellow'), ) if not empty(firstaddress): result += u'%s' % self.colored('%-33s' % sensor.address[:33], 'yellow') result += u'\n' result += u' %s' % self.colored('%-47s' % obj.fullid[:47], 'blue') result += u' %s %s\n' %\ (self.colored('%-20s' % sensorname[:20], 'magenta'), self.colored('%-13s' % lastvalue[:13], 'red') ) first = False else: result += u' %s %s\n' %\ (self.colored('%-20s' % sensorname[:20], 'magenta'), self.colored('%-13s' % lastvalue[:13], 'red') ) if not empty(sensor.address) and sensor.address != firstaddress: result += u' %s \n' %\ self.colored('%-33s' % sensor.address[:33], 'yellow') return result class Boobsize(ReplApplication): APPNAME = 'Boobsize' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2013-YEAR Florent Fourcot' DESCRIPTION = "Console application allowing to display various sensors and gauges values." SHORT_DESCRIPTION = "display sensors and gauges values" CAPS = (CapGauge) DEFAULT_FORMATTER = 'table' EXTRA_FORMATTERS = {'gauge_list': GaugeFormatter, } COMMANDS_FORMATTERS = {'search': 'gauge_list', } def main(self, argv): self.load_config() return ReplApplication.main(self, argv) def bcall_error_handler(self, backend, error, backtrace): if isinstance(error, SensorNotFound): msg = unicode(error) or 'Sensor not found (hint: try details command)' print('Error(%s): %s' % (backend.name, msg), file=self.stderr) else: return ReplApplication.bcall_error_handler(self, backend, error, backtrace) def do_search(self, pattern): """ search [PATTERN] Display all gauges. If PATTERN is specified, search on a pattern. """ self.change_path([u'gauges']) self.start_format() for gauge in self.do('iter_gauges', pattern or None, caps=CapGauge): self.cached_format(gauge) def complete_search(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_details(self, line): """ details GAUGE_ID Display details of all sensors of the gauge. """ gauge, pattern = self.parse_command_args(line, 2, 1) _id, backend_name = self.parse_id(gauge) self.start_format() for sensor in self.do('iter_sensors', _id, pattern=pattern, backends=backend_name, caps=CapGauge): self.format(sensor) def do_history(self, line): """ history SENSOR_ID Get history of a specific sensor (use 'search' to find a gauge, and sensors GAUGE_ID to list sensors attached to the gauge). """ gauge, = self.parse_command_args(line, 1, 1) _id, backend_name = self.parse_id(gauge) self.start_format() for measure in self.do('iter_gauge_history', _id, backends=backend_name, caps=CapGauge): self.format(measure) def complete_last_sensor_measure(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_last_sensor_measure(self, line): """ last_sensor_measure SENSOR_ID Get last measure of a sensor. """ gauge, = self.parse_command_args(line, 1, 1) _id, backend_name = self.parse_id(gauge) self.start_format() for measure in self.do('get_last_measure', _id, backends=backend_name, caps=CapGauge): self.format(measure) weboob-1.1/weboob/applications/boobtracker/000077500000000000000000000000001265717027300211025ustar00rootroot00000000000000weboob-1.1/weboob/applications/boobtracker/__init__.py000066400000000000000000000014331265717027300232140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .boobtracker import BoobTracker __all__ = ['BoobTracker'] weboob-1.1/weboob/applications/boobtracker/boobtracker.py000066400000000000000000000426561265717027300237660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from datetime import timedelta from email import message_from_string, message_from_file from email.Header import decode_header from email.mime.text import MIMEText from smtplib import SMTP import os import re import unicodedata from weboob.capabilities.base import empty, BaseObject from weboob.capabilities.bugtracker import CapBugTracker, Query, Update, Project, Issue, IssueError from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter from weboob.tools.html import html2text from weboob.tools.date import parse_french_date __all__ = ['BoobTracker'] class IssueFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'project', 'title', 'body', 'author') def format_attr(self, obj, attr): if not hasattr(obj, attr) or empty(getattr(obj, attr)): return u'' value = getattr(obj, attr) if isinstance(value, BaseObject): value = value.name return self.format_key(attr.capitalize(), value) def format_key(self, key, value): return '%s %s\n' % (self.colored('%s:' % key, 'green'), value) def format_obj(self, obj, alias): result = u'%s %s %s %s %s\n' % (self.colored(obj.project.name, 'blue', 'bold'), self.colored(u'—', 'cyan', 'bold'), self.colored(obj.fullid, 'red', 'bold'), self.colored(u'—', 'cyan', 'bold'), self.colored(obj.title, 'yellow', 'bold')) result += '\n%s\n\n' % obj.body result += self.format_key('Author', '%s (%s)' % (obj.author.name, obj.creation)) result += self.format_attr(obj, 'status') result += self.format_attr(obj, 'priority') result += self.format_attr(obj, 'version') result += self.format_attr(obj, 'tracker') result += self.format_attr(obj, 'category') result += self.format_attr(obj, 'assignee') if hasattr(obj, 'fields') and not empty(obj.fields): for key, value in obj.fields.iteritems(): result += self.format_key(key.capitalize(), value) if hasattr(obj, 'attachments') and obj.attachments: result += '\n%s\n' % self.colored('Attachments:', 'green') for a in obj.attachments: result += '* %s%s%s <%s>\n' % (self.BOLD, a.filename, self.NC, a.url) if hasattr(obj, 'history') and obj.history: result += '\n%s\n' % self.colored('History:', 'green') for u in obj.history: result += '%s %s %s %s\n' % (self.colored('*', 'red', 'bold'), self.colored(u.date, 'yellow', 'bold'), self.colored(u'—', 'cyan', 'bold'), self.colored(u.author.name, 'blue', 'bold')) for change in u.changes: result += ' - %s %s %s %s\n' % (self.colored(change.field, 'green'), change.last, self.colored('->', 'magenta'), change.new) if u.message: result += ' %s\n' % html2text(u.message).strip().replace('\n', '\n ') return result class IssuesListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'project', 'status', 'title', 'category') def get_title(self, obj): return '%s - [%s] %s' % (obj.project.name, obj.status.name, obj.title) def get_description(self, obj): return obj.category class BoobTracker(ReplApplication): APPNAME = 'boobtracker' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2011-YEAR Romain Bignon' DESCRIPTION = "Console application allowing to create, edit, view bug tracking issues." SHORT_DESCRIPTION = "manage bug tracking issues" CAPS = CapBugTracker EXTRA_FORMATTERS = {'issue_info': IssueFormatter, 'issues_list': IssuesListFormatter, } COMMANDS_FORMATTERS = {'get': 'issue_info', 'post': 'issue_info', 'edit': 'issue_info', 'search': 'issues_list', 'ls': 'issues_list', } COLLECTION_OBJECTS = (Project, Issue, ) def add_application_options(self, group): group.add_option('--author') group.add_option('--title') group.add_option('--assignee') group.add_option('--target-version', dest='version') group.add_option('--tracker') group.add_option('--category') group.add_option('--status') group.add_option('--priority') group.add_option('--start') group.add_option('--due') @defaultcount(10) def do_search(self, line): """ search PROJECT List issues for a project. You can use these filters from command line: --author AUTHOR --title TITLE_PATTERN --assignee ASSIGNEE --target-version VERSION --category CATEGORY --status STATUS """ query = Query() path = self.working_path.get() backends = [] if line.strip(): query.project, backends = self.parse_id(line, unique_backend=True) elif len(path) > 0: query.project = path[0] else: print('Please enter a project name', file=self.stderr) return 1 query.author = self.options.author query.title = self.options.title query.assignee = self.options.assignee query.version = self.options.version query.category = self.options.category query.status = self.options.status self.change_path([query.project, u'search']) for issue in self.do('iter_issues', query, backends=backends): self.add_object(issue) self.format(issue) def complete_get(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_get(self, line): """ get ISSUE Get an issue and display it. """ if not line: print('This command takes an argument: %s' % self.get_command_help('get', short=True), file=self.stderr) return 2 issue = self.get_object(line, 'get_issue') if not issue: print('Issue not found: %s' % line, file=self.stderr) return 3 self.format(issue) def complete_comment(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_comment(self, line): """ comment ISSUE [TEXT] Comment an issue. If no text is given, enter it in standard input. """ id, text = self.parse_command_args(line, 2, 1) if text is None: text = self.acquire_input() id, backend_name = self.parse_id(id, unique_backend=True) update = Update(0) update.message = text self.do('update_issue', id, update, backends=backend_name).wait() def do_logtime(self, line): """ logtime ISSUE HOURS [TEXT] Log spent time on an issue. """ id, hours, text = self.parse_command_args(line, 3, 2) if text is None: text = self.acquire_input() try: hours = float(hours) except ValueError: print('Error: HOURS parameter may be a float', file=self.stderr) return 1 id, backend_name = self.parse_id(id, unique_backend=True) update = Update(0) update.message = text update.hours = timedelta(hours=hours) self.do('update_issue', id, update, backends=backend_name).wait() def complete_remove(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_remove(self, line): """ remove ISSUE Remove an issue. """ id, backend_name = self.parse_id(line, unique_backend=True) self.do('remove_issue', id, backends=backend_name).wait() ISSUE_FIELDS = (('title', (None, False)), ('assignee', ('members', True)), ('version', ('versions', True)), ('tracker', (None, False)),#XXX ('category', ('categories', False)), ('status', ('statuses', True)), ('priority', (None, False)),#XXX ('start', (None, False)), ('due', (None, False)), ) def get_list_item(self, objects_list, name): if name is None: return None for obj in objects_list: if obj.name.lower() == name.lower(): return obj if not name: return None raise ValueError('"%s" is not found' % name) def sanitize_key(self, key): if isinstance(key, str): key = unicode(key, "utf8") key = unicodedata.normalize('NFKD', key).encode("ascii", "ignore") return key.replace(' ', '-').capitalize() def issue2text(self, issue, backend=None): if backend is not None and 'username' in backend.config: sender = backend.config['username'].get() else: sender = os.environ.get('USERNAME', 'boobtracker') output = u'From: %s\n' % sender for key, (list_name, is_list_object) in self.ISSUE_FIELDS: value = None if not self.interactive: value = getattr(self.options, key) if not value: value = getattr(issue, key) if not value: value = '' elif hasattr(value, 'name'): value = value.name if list_name is not None: objects_list = getattr(issue.project, list_name) if len(objects_list) == 0: continue output += '%s: %s\n' % (self.sanitize_key(key), value) if list_name is not None: availables = ', '.join(['<%s>' % (o if isinstance(o, basestring) else o.name) for o in objects_list]) output += 'X-Available-%s: %s\n' % (self.sanitize_key(key), availables) for key, value in issue.fields.iteritems(): output += '%s: %s\n' % (self.sanitize_key(key), value or '') # TODO: Add X-Available-* for lists output += '\n%s' % (issue.body or 'Please write your bug report here.') return output def text2issue(self, issue, m): # XXX HACK to support real incoming emails if 'Subject' in m: m['Title'] = m['Subject'] for key, (list_name, is_list_object) in self.ISSUE_FIELDS: value = m.get(key) if value is None: continue new_value = u'' for part in decode_header(value): if part[1]: new_value += unicode(part[0], part[1]) else: new_value += part[0].decode('utf-8') value = new_value if is_list_object: objects_list = getattr(issue.project, list_name) value = self.get_list_item(objects_list, value) # FIXME: autodetect if key in ['start', 'due']: if len(value) > 0: #value = datetime.strptime(value, "%Y-%m-%d %H:%M:%S") value = parse_french_date(value) else: value = None setattr(issue, key, value) for key in issue.fields.keys(): value = m.get(self.sanitize_key(key)) if value is not None: issue.fields[key] = value.decode('utf-8') content = u'' for part in m.walk(): if part.get_content_type() == 'text/plain': s = part.get_payload(decode=True) charsets = part.get_charsets() + m.get_charsets() for charset in charsets: try: if charset is not None: content += unicode(s, charset) else: content += unicode(s, encoding='utf-8') except UnicodeError as e: self.logger.warning('Unicode error: %s' % e) continue except Exception as e: self.logger.exception(e) continue else: break issue.body = content m = re.search('([^< ]+@[^ >]+)', m['From'] or '') if m: return m.group(1) def edit_issue(self, issue, edit=True): backend = self.weboob.get_backend(issue.backend) content = self.issue2text(issue, backend) while True: if self.stdin.isatty(): content = self.acquire_input(content, {'vim': "-c 'set ft=mail'"}) m = message_from_string(content.encode('utf-8')) else: m = message_from_file(self.stdin) try: email_to = self.text2issue(issue, m) except ValueError as e: if not self.stdin.isatty(): raise raw_input("%s -- Press Enter to continue..." % unicode(e).encode("utf-8")) continue try: issue = backend.post_issue(issue) print('Issue %s %s' % (self.formatter.colored(issue.fullid, 'red', 'bold'), 'updated' if edit else 'created')) if edit: self.format(issue) elif email_to: self.send_notification(email_to, issue) return 0 except IssueError as e: if not self.stdin.isatty(): raise raw_input("%s -- Press Enter to continue..." % unicode(e).encode("utf-8")) def send_notification(self, email_to, issue): text = """Hi, You have successfuly created this ticket on the Weboob tracker: %s You can follow your bug report on this page: https://symlink.me/issues/%s Regards, Weboob Team """ % (issue.title, issue.id) msg = MIMEText(text, 'plain', 'utf-8') msg['Subject'] = 'Issue #%s reported' % issue.id msg['From'] = 'Weboob ' msg['To'] = email_to s = SMTP('localhost') s.sendmail('weboob@weboob.org', [email_to], msg.as_string()) s.quit() def do_post(self, line): """ post PROJECT Post a new issue. If you are not in interactive mode, you can use these parameters: --title TITLE --assignee ASSIGNEE --target-version VERSION --category CATEGORY --status STATUS """ if not line.strip(): print('Please give the project name') return 1 project, backend_name = self.parse_id(line, unique_backend=True) backend = self.weboob.get_backend(backend_name) issue = backend.create_issue(project) issue.backend = backend.name return self.edit_issue(issue, edit=False) def complete_edit(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() if len(args) == 3: return dict(self.ISSUE_FIELDS).keys() def do_edit(self, line): """ edit ISSUE [KEY [VALUE]] Edit an issue. If you are not in interactive mode, you can use these parameters: --title TITLE --assignee ASSIGNEE --target-version VERSION --category CATEGORY --status STATUS """ _id, key, value = self.parse_command_args(line, 3, 1) issue = self.get_object(_id, 'get_issue') if not issue: print('Issue not found: %s' % _id, file=self.stderr) return 3 return self.edit_issue(issue, edit=True) def complete_attach(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() elif len(args) >= 3: return self.path_completer(args[2]) def do_attach(self, line): """ attach ISSUE FILENAME Attach a file to an issue (Not implemented yet). """ print('Not implemented yet.', file=self.stderr) weboob-1.1/weboob/applications/cineoob/000077500000000000000000000000001265717027300202235ustar00rootroot00000000000000weboob-1.1/weboob/applications/cineoob/__init__.py000066400000000000000000000014211265717027300223320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .cineoob import Cineoob __all__ = ['Cineoob'] weboob-1.1/weboob/applications/cineoob/cineoob.py000066400000000000000000000640111265717027300222150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from datetime import datetime from weboob.applications.weboorrents.weboorrents import TorrentInfoFormatter, TorrentListFormatter from weboob.applications.suboob.suboob import SubtitleInfoFormatter, SubtitleListFormatter from weboob.capabilities.torrent import CapTorrent, MagnetOnly from weboob.capabilities.cinema import CapCinema from weboob.capabilities.subtitle import CapSubtitle from weboob.capabilities.base import empty, NotAvailable from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter from weboob.core import CallErrors __all__ = ['Cineoob'] ROLE_LIST = ['actor', 'director', 'writer', 'composer', 'producer'] COUNTRY_LIST = ['us', 'fr', 'de', 'jp'] class MovieInfoFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'original_title', 'release_date', 'other_titles', 'duration', 'pitch', 'note', 'roles', 'country') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.original_title, self.NC) result += 'ID: %s\n' % obj.fullid if not empty(obj.release_date): result += 'Released: %s\n' % obj.release_date.strftime('%Y-%m-%d') result += 'Country: %s\n' % obj.country if not empty(obj.duration): result += 'Duration: %smin\n' % obj.duration result += 'Note: %s\n' % obj.note if not empty(obj.genres): result += '\n%sGenres%s\n' % (self.BOLD, self.NC) for g in obj.genres: result += ' * %s\n' % g if not empty(obj.roles): result += '\n%sRelated persons%s\n' % (self.BOLD, self.NC) for role, lpersons in obj.roles.items(): result += ' -- %s\n' % role for person in lpersons: result += ' * %s\n' % person[1] if not empty(obj.other_titles): result += '\n%sOther titles%s\n' % (self.BOLD, self.NC) for t in obj.other_titles: result += ' * %s\n' % t if not empty(obj.pitch): result += '\n%sStory%s\n' % (self.BOLD, self.NC) result += '%s' % obj.pitch return result class MovieListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'original_title', 'short_description') def get_title(self, obj): return obj.original_title def get_description(self, obj): result = u'' if not empty(obj.short_description): result = obj.short_description return result class MovieReleasesFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'original_title', 'all_release_dates') def get_title(self, obj): return u'Releases of %s' % obj.original_title def get_description(self, obj): return u'\n%s' % obj.all_release_dates def yearsago(years, from_date=None): if from_date is None: from_date = datetime.now() try: return from_date.replace(year=from_date.year - years) except: # Must be 2/29 assert from_date.month == 2 and from_date.day == 29 return from_date.replace(month=2, day=28, year=from_date.year-years) def num_years(begin, end=None): if end is None: end = datetime.now() num_years = int((end - begin).days / 365.25) if begin > yearsago(num_years, end): return num_years - 1 else: return num_years class PersonInfoFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'name', 'birth_date', 'birth_place', 'short_biography') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC) result += 'ID: %s\n' % obj.fullid if not empty(obj.real_name): result += 'Real name: %s\n' % obj.real_name if not empty(obj.birth_place): result += 'Birth place: %s\n' % obj.birth_place if not empty(obj.birth_date): result += 'Birth date: %s\n' % obj.birth_date.strftime('%Y-%m-%d') if not empty(obj.death_date): age = num_years(obj.birth_date, obj.death_date) result += 'Death date: %s at %s years old\n' % (obj.death_date.strftime('%Y-%m-%d'), age) else: age = num_years(obj.birth_date) result += 'Age: %s\n' % age if not empty(obj.gender): result += 'Gender: %s\n' % obj.gender if not empty(obj.nationality): result += 'Nationality: %s\n' % obj.nationality if not empty(obj.roles): result += '\n%sRelated movies%s\n' % (self.BOLD, self.NC) for role, lmovies in obj.roles.items(): result += ' -- %s\n' % role for movie in lmovies: result += ' * %s\n' % movie[1] if not empty(obj.short_biography): result += '\n%sShort biography%s\n' % (self.BOLD, self.NC) result += '%s' % obj.short_biography return result class PersonListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'name', 'short_description') def get_title(self, obj): return obj.name def get_description(self, obj): result = u'' if not empty(obj.short_description): result = obj.short_description return result class PersonBiographyFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'name', 'biography') def get_title(self, obj): return u'Biography of %s' % obj.name def get_description(self, obj): result = u'\n%s' % obj.biography return result class Cineoob(ReplApplication): APPNAME = 'cineoob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2013-YEAR Julien Veyssier' DESCRIPTION = "Console application allowing to search for movies and persons on various cinema databases " \ ", list persons related to a movie, list movies related to a person and list common movies " \ "of two persons." SHORT_DESCRIPTION = "search movies and persons around cinema" CAPS = (CapCinema, CapTorrent, CapSubtitle) EXTRA_FORMATTERS = {'movie_list': MovieListFormatter, 'movie_info': MovieInfoFormatter, 'movie_releases': MovieReleasesFormatter, 'person_list': PersonListFormatter, 'person_info': PersonInfoFormatter, 'person_bio': PersonBiographyFormatter, 'torrent_list': TorrentListFormatter, 'torrent_info': TorrentInfoFormatter, 'subtitle_list': SubtitleListFormatter, 'subtitle_info': SubtitleInfoFormatter } COMMANDS_FORMATTERS = {'search_movie': 'movie_list', 'info_movie': 'movie_info', 'search_person': 'person_list', 'info_person': 'person_info', 'casting': 'person_list', 'filmography': 'movie_list', 'biography': 'person_bio', 'releases': 'movie_releases', 'movies_in_common': 'movie_list', 'persons_in_common': 'person_list', 'search_torrent': 'torrent_list', 'search_movie_torrent': 'torrent_list', 'info_torrent': 'torrent_info', 'search_subtitle': 'subtitle_list', 'search_movie_subtitle': 'subtitle_list', 'info_subtitle': 'subtitle_info' } def complete_filmography(self, text, line, *ignored): args = line.split(' ') if len(args) == 3: return ROLE_LIST def complete_casting(self, text, line, *ignored): return self.complete_filmography(text, line, ignored) def do_movies_in_common(self, line): """ movies_in_common person_ID person_ID Get the list of common movies between two persons. """ id1, id2 = self.parse_command_args(line, 2, 1) person1 = self.get_object(id1, 'get_person', caps=CapCinema) if not person1: print('Person not found: %s' % id1, file=self.stderr) return 3 person2 = self.get_object(id2, 'get_person', caps=CapCinema) if not person2: print('Person not found: %s' % id2, file=self.stderr) return 3 initial_count = self.options.count self.options.count = None lid1 = [] for id in self.do('iter_person_movies_ids', person1.id, caps=CapCinema): lid1.append(id) lid2 = [] for id in self.do('iter_person_movies_ids', person2.id, caps=CapCinema): lid2.append(id) self.options.count = initial_count inter = list(set(lid1) & set(lid2)) chrono_list = [] for common in inter: movie = self.get_object(common, 'get_movie', caps=CapCinema) role1 = movie.get_roles_by_person_id(person1.id) if not role1: role1 = movie.get_roles_by_person_name(person1.name) role2 = movie.get_roles_by_person_id(person2.id) if not role2: role2 = movie.get_roles_by_person_name(person2.name) if (movie.release_date != NotAvailable): year = movie.release_date.year else: year = '????' movie.short_description = '(%s) %s as %s ; %s as %s'%(year, person1.name, ', '.join(role1), person2.name, ', '.join(role2)) if movie: i = 0 while (i chrono_list[i].release_date.year)): i += 1 chrono_list.insert(i, movie) for movie in chrono_list: self.cached_format(movie) def do_persons_in_common(self, line): """ persons_in_common movie_ID movie_ID Get the list of common persons between two movies. """ id1, id2 = self.parse_command_args(line, 2, 1) movie1 = self.get_object(id1, 'get_movie', caps=CapCinema) if not movie1: print('Movie not found: %s' % id1, file=self.stderr) return 3 movie2 = self.get_object(id2, 'get_movie', caps=CapCinema) if not movie2: print('Movie not found: %s' % id2, file=self.stderr) return 3 initial_count = self.options.count self.options.count = None lid1 = [] for id in self.do('iter_movie_persons_ids', movie1.id, caps=CapCinema): lid1.append(id) lid2 = [] for id in self.do('iter_movie_persons_ids', movie2.id, caps=CapCinema): lid2.append(id) self.options.count = initial_count inter = list(set(lid1) & set(lid2)) for common in inter: person = self.get_object(common, 'get_person', caps=CapCinema) role1 = person.get_roles_by_movie_id(movie1.id) if not role1: role1 = person.get_roles_by_movie_title(movie1.original_title) role2 = person.get_roles_by_movie_id(movie2.id) if not role2: role2 = person.get_roles_by_movie_title(movie2.original_title) person.short_description = '%s in %s ; %s in %s'%(', '.join(role1), movie1.original_title, ', '.join(role2), movie2.original_title) self.cached_format(person) def do_info_movie(self, id): """ info_movie movie_ID Get information about a movie. """ movie = self.get_object(id, 'get_movie', caps=CapCinema) if not movie: print('Movie not found: %s' % id, file=self.stderr) return 3 self.start_format() self.format(movie) def do_info_person(self, id): """ info_person person_ID Get information about a person. """ person = self.get_object(id, 'get_person', caps=CapCinema) if not person: print('Person not found: %s' % id, file=self.stderr) return 3 self.start_format() self.format(person) @defaultcount(10) def do_search_movie(self, pattern): """ search_movie [PATTERN] Search movies. """ self.change_path([u'search movies']) if not pattern: pattern = None self.start_format(pattern=pattern) for movie in self.do('iter_movies', pattern=pattern, caps=CapCinema): self.cached_format(movie) @defaultcount(10) def do_search_person(self, pattern): """ search_person [PATTERN] Search persons. """ self.change_path([u'search persons']) if not pattern: pattern = None self.start_format(pattern=pattern) for person in self.do('iter_persons', pattern=pattern, caps=CapCinema): self.cached_format(person) def do_casting(self, line): """ casting movie_ID [ROLE] List persons related to a movie. If ROLE is given, filter by ROLE """ movie_id, role = self.parse_command_args(line, 2, 1) movie = self.get_object(movie_id, 'get_movie', caps=CapCinema) if not movie: print('Movie not found: %s' % id, file=self.stderr) return 3 for person in self.do('iter_movie_persons', movie.id, role, backends=movie.backend, caps=CapCinema): self.cached_format(person) def do_filmography(self, line): """ filmography person_ID [ROLE] List movies of a person. If ROLE is given, filter by ROLE """ person_id, role = self.parse_command_args(line, 2, 1) person = self.get_object(person_id, 'get_person', caps=CapCinema) if not person: print('Person not found: %s' % id, file=self.stderr) return 3 for movie in self.do('iter_person_movies', person.id, role, backends=person.backend, caps=CapCinema): self.cached_format(movie) def do_biography(self, person_id): """ biography person_ID Show the complete biography of a person. """ person = self.get_object(person_id, 'get_person', ('name', 'biography'), caps=CapCinema) if not person: print('Person not found: %s' % person_id, file=self.stderr) return 3 self.start_format() self.format(person) def complete_releases(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() if len(args) == 3: return COUNTRY_LIST def do_releases(self, line): """ releases movie_ID [COUNTRY] Get releases dates of a movie. If COUNTRY is given, show release in this country. """ id, country = self.parse_command_args(line, 2, 1) movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema) if not movie: print('Movie not found: %s' % id, file=self.stderr) return 3 # i would like to clarify with fillobj but how could i fill the movie AND choose the country ? for release in self.do('get_movie_releases', movie.id, country, caps=CapCinema, backends=movie.backend): if not empty(release): movie.all_release_dates = u'%s' % (release) else: print('Movie releases not found for %s' % movie.original_title, file=self.stderr) return 3 self.start_format() self.format(movie) # ================== TORRENT ================== def complete_info_torrent(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info_torrent(self, id): """ info_torrent ID Get information about a torrent. """ torrent = self.get_object(id, 'get_torrent', caps=CapTorrent) if not torrent: print('Torrent not found: %s' % id, file=self.stderr) return 3 self.start_format() self.format(torrent) def complete_getfile_torrent(self, text, line, *ignored): args = line.split(' ', 2) if len(args) == 2: return self._complete_object() elif len(args) >= 3: return self.path_completer(args[2]) def do_getfile_torrent(self, line): """ getfile_torrent ID [FILENAME] Get the .torrent file. FILENAME is where to write the file. If FILENAME is '-', the file is written to stdout. """ id, dest = self.parse_command_args(line, 2, 1) _id, backend_name = self.parse_id(id) if dest is None: dest = '%s.torrent' % _id try: for buf in self.do('get_torrent_file', _id, backends=backend_name, caps=CapTorrent): if buf: if dest == '-': print(buf) else: try: with open(dest, 'wb') as f: f.write(buf) except IOError as e: print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr) return 1 return except CallErrors as errors: for backend, error, backtrace in errors: if isinstance(error, MagnetOnly): print(u'Error(%s): No direct URL available, ' u'please provide this magnet URL ' u'to your client:\n%s' % (backend, error.magnet), file=self.stderr) return 4 else: self.bcall_error_handler(backend, error, backtrace) print('Torrent "%s" not found' % id, file=self.stderr) return 3 @defaultcount(10) def do_search_torrent(self, pattern): """ search_torrent [PATTERN] Search torrents. """ self.change_path([u'search torrent']) if not pattern: pattern = None self.start_format(pattern=pattern) for torrent in self.do('iter_torrents', pattern=pattern, caps=CapTorrent): self.cached_format(torrent) @defaultcount(10) def do_search_movie_torrent(self, id): """ search_movie_torrent movie_ID Search torrents of movie_ID. """ movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema) if not movie: print('Movie not found: %s' % id, file=self.stderr) return 3 pattern = movie.original_title self.change_path([u'search torrent']) if not pattern: pattern = None self.start_format(pattern=pattern) for torrent in self.do('iter_torrents', pattern=pattern, caps=CapTorrent): self.cached_format(torrent) # ================== SUBTITLE ================== def complete_info_subtitle(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info_subtitle(self, id): """ info_subtitle subtitle_ID Get information about a subtitle. """ subtitle = self.get_object(id, 'get_subtitle', caps=CapCinema) if not subtitle: print('Subtitle not found: %s' % id, file=self.stderr) return 3 self.start_format() self.format(subtitle) def complete_getfile_subtitle(self, text, line, *ignored): args = line.split(' ', 2) if len(args) == 2: return self._complete_object() elif len(args) >= 3: return self.path_completer(args[2]) def do_getfile_subtitle(self, line): """ getfile_subtitle subtitle_ID [FILENAME] Get the subtitle or archive file. FILENAME is where to write the file. If FILENAME is '-', the file is written to stdout. """ id, dest = self.parse_command_args(line, 2, 1) _id, backend_name = self.parse_id(id) if dest is None: dest = '%s' % _id for buf in self.do('get_subtitle_file', _id, backends=backend_name, caps=CapSubtitle): if buf: if dest == '-': print(buf) else: try: with open(dest, 'w') as f: f.write(buf) except IOError as e: print('Unable to write file in "%s": %s' % (dest, e), file=self.stderr) return 1 return print('Subtitle "%s" not found' % id, file=self.stderr) return 3 @defaultcount(10) def do_search_subtitle(self, line): """ search_subtitle language [PATTERN] Search subtitles. Language Abbreviation ---------------------- Arabic ar Esperanto eo Irish ga Russian ru Afrikaans af Estonian et Italian it Serbian sr Albanian sq Filipino tl Japanese ja Slovak sk Armenian hy Finnish fi Kannada kn Slovenian sl Azerbaijani az French fr Korean ko Spanish es Basque eu Galician gl Latin la Swahili sw Belarusian be Georgian ka Latvian lv Swedish sv Bengali bn German de Lithuanian lt Tamil ta Bulgarian bg Greek gr Macedonian mk Telugu te Catalan ca Gujarati gu Malay ms Thai th Chinese zh Haitian ht Maltese mt Turkish tr Croatian hr Hebrew iw Norwegian no Ukrainian uk Czech cz Hindi hi Persian fa Urdu ur Danish da Hungaric hu Polish pl Vietnamese vi Dutch nl Icelandic is Portuguese pt Welsh cy English en Indonesian id Romanian ro Yiddish yi ---------------------- """ language, pattern = self.parse_command_args(line, 2, 1) self.change_path([u'search subtitle']) if not pattern: pattern = None self.start_format(pattern=pattern) for subtitle in self.do('iter_subtitles', language=language, pattern=pattern, caps=CapSubtitle): self.cached_format(subtitle) @defaultcount(10) def do_search_movie_subtitle(self, line): """ search_movie_subtitle language movie_ID Search subtitles of movie_ID. Language Abbreviation ---------------------- Arabic ar Esperanto eo Irish ga Russian ru Afrikaans af Estonian et Italian it Serbian sr Albanian sq Filipino tl Japanese ja Slovak sk Armenian hy Finnish fi Kannada kn Slovenian sl Azerbaijani az French fr Korean ko Spanish es Basque eu Galician gl Latin la Swahili sw Belarusian be Georgian ka Latvian lv Swedish sv Bengali bn German de Lithuanian lt Tamil ta Bulgarian bg Greek gr Macedonian mk Telugu te Catalan ca Gujarati gu Malay ms Thai th Chinese zh Haitian ht Maltese mt Turkish tr Croatian hr Hebrew iw Norwegian no Ukrainian uk Czech cz Hindi hi Persian fa Urdu ur Danish da Hungaric hu Polish pl Vietnamese vi Dutch nl Icelandic is Portuguese pt Welsh cy English en Indonesian id Romanian ro Yiddish yi ---------------------- """ language, id = self.parse_command_args(line, 2, 2) movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema) if not movie: print('Movie not found: %s' % id, file=self.stderr) return 3 pattern = movie.original_title self.change_path([u'search subtitle']) if not pattern: pattern = None self.start_format(pattern=pattern) for subtitle in self.do('iter_subtitles', language=language, pattern=pattern, caps=CapSubtitle): self.cached_format(subtitle) weboob-1.1/weboob/applications/comparoob/000077500000000000000000000000001265717027300205665ustar00rootroot00000000000000weboob-1.1/weboob/applications/comparoob/__init__.py000066400000000000000000000001231265717027300226730ustar00rootroot00000000000000# -*- coding: utf-8 -*- from .comparoob import Comparoob __all__ = ['Comparoob'] weboob-1.1/weboob/applications/comparoob/comparoob.py000066400000000000000000000123431265717027300231240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.pricecomparison import CapPriceComparison from weboob.tools.html import html2text from weboob.tools.application.repl import ReplApplication from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter __all__ = ['Comparoob'] class PriceFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'cost', 'currency', 'shop', 'product') def format_obj(self, obj, alias): if hasattr(obj, 'message') and obj.message: message = obj.message else: message = u'%s (%s)' % (obj.shop.name, obj.shop.location) result = u'%s%s%s\n' % (self.BOLD, message, self.NC) result += u'ID: %s\n' % obj.fullid result += u'Product: %s\n' % obj.product.name result += u'Cost: %s%s\n' % (obj.cost, obj.currency) if hasattr(obj, 'date') and obj.date: result += u'Date: %s\n' % obj.date.strftime('%Y-%m-%d') result += u'\n%sShop:%s\n' % (self.BOLD, self.NC) result += u'\tName: %s\n' % obj.shop.name if obj.shop.location: result += u'\tLocation: %s\n' % obj.shop.location if obj.shop.info: result += u'\n\t' + html2text(obj.shop.info).replace('\n', '\n\t').strip() return result class PricesFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'cost', 'currency') def get_title(self, obj): if hasattr(obj, 'message') and obj.message: message = obj.message elif hasattr(obj, 'shop') and obj.shop: message = '%s (%s)' % (obj.shop.name, obj.shop.location) else: return u'%s%s' % (obj.cost, obj.currency) return u'%s%s - %s' % (obj.cost, obj.currency, message) def get_description(self, obj): if obj.date: return obj.date.strftime('%Y-%m-%d') class Comparoob(ReplApplication): APPNAME = 'comparoob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2012-YEAR Romain Bignon' DESCRIPTION = "Console application to compare products." SHORT_DESCRIPTION = "compare products" DEFAULT_FORMATTER = 'table' EXTRA_FORMATTERS = {'prices': PricesFormatter, 'price': PriceFormatter, } COMMANDS_FORMATTERS = {'prices': 'prices', 'info': 'price', } CAPS = CapPriceComparison def do_prices(self, pattern): """ prices [PATTERN] Display prices for a product. If a pattern is supplied, do not prompt what product to compare. """ products = [] for product in self.do('search_products', pattern): double = False for prod in products: if product.name == prod.name: double = True break if not double: products.append(product) product = None if len(products) == 0: print('Error: no product found with this pattern', file=self.stderr) return 1 elif len(products) == 1: product = products[0] else: print('What product do you want to compare?') for i, p in enumerate(products): print(' %s%2d)%s %s' % (self.BOLD, i+1, self.NC, p.name)) r = int(self.ask(' Select a product', regexp='\d+')) while product is None: if r <= 0 or r > len(products): print('Error: Please enter a valid ID') continue product = products[r-1] self.change_path([u'prices']) self.start_format() products = [] for price in self.do('iter_prices', product): products.append(price) for price in sorted(products, key=self._get_price): self.cached_format(price) def _get_price(self, price): return price.cost def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info(self, _id): """ info ID Get information about a product. """ if not _id: print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr) return 2 price = self.get_object(_id, 'get_price') if not price: print('Price not found: %s' % _id, file=self.stderr) return 3 self.start_format() self.format(price) weboob-1.1/weboob/applications/cookboob/000077500000000000000000000000001265717027300204025ustar00rootroot00000000000000weboob-1.1/weboob/applications/cookboob/__init__.py000066400000000000000000000014231265717027300225130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .cookboob import Cookboob __all__ = ['Cookboob'] weboob-1.1/weboob/applications/cookboob/cookboob.py000066400000000000000000000124721265717027300225570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import codecs from weboob.capabilities.recipe import CapRecipe from weboob.capabilities.base import empty from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter __all__ = ['Cookboob'] class RecipeInfoFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'title', 'preparation_time', 'ingredients', 'instructions') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.title, self.NC) result += 'ID: %s\n' % obj.fullid if not empty(obj.author): result += 'Author: %s\n' % obj.author if not empty(obj.preparation_time): result += 'Preparation time: %smin\n' % obj.preparation_time if not empty(obj.cooking_time): result += 'Cooking time: %smin\n' % obj.cooking_time if not empty(obj.nb_person): nbstr = '-'.join(str(num) for num in obj.nb_person) result += 'Amount of people: %s\n' % nbstr result += '\n%sIngredients%s\n' % (self.BOLD, self.NC) for i in obj.ingredients: result += ' * %s\n' % i result += '\n%sInstructions%s\n' % (self.BOLD, self.NC) result += '%s\n' % obj.instructions if not empty(obj.comments): result += '\n%sComments%s\n' % (self.BOLD, self.NC) for c in obj.comments: result += ' * %s\n' % c return result class RecipeListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title', 'short_description', 'preparation_time') def get_title(self, obj): return obj.title def get_description(self, obj): result = u'' if not empty(obj.preparation_time): result += 'prep time: %smin' % obj.preparation_time if not empty(obj.short_description): result += 'description: %s\n' % obj.short_description return result.strip() class Cookboob(ReplApplication): APPNAME = 'cookboob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2013-YEAR Julien Veyssier' DESCRIPTION = "Console application allowing to search for recipes on various websites." SHORT_DESCRIPTION = "search and consult recipes" CAPS = CapRecipe EXTRA_FORMATTERS = {'recipe_list': RecipeListFormatter, 'recipe_info': RecipeInfoFormatter } COMMANDS_FORMATTERS = {'search': 'recipe_list', 'info': 'recipe_info' } def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info(self, id): """ info ID Get information about a recipe. """ recipe = self.get_object(id, 'get_recipe') if not recipe: print('Recipe not found: %s' % id, file=self.stderr) return 3 self.start_format() self.format(recipe) def complete_export(self, text, line, *ignored): args = line.split(' ', 2) if len(args) == 2: return self._complete_object() elif len(args) >= 3: return self.path_completer(args[2]) def do_export(self, line): """ export ID [FILENAME] Export the recipe to a KRecipes XML file FILENAME is where to write the file. If FILENAME is '-', the file is written to stdout. """ id, dest = self.parse_command_args(line, 2, 1) _id, backend_name = self.parse_id(id) if dest is None: dest = '%s.kreml' % _id recipe = self.get_object(id, 'get_recipe') if recipe: xmlstring = recipe.toKrecipesXml(backend_name or None) if dest == '-': print(xmlstring) else: if not dest.endswith('.kreml'): dest += '.kreml' try: with codecs.open(dest, 'w', 'utf-8') as f: f.write(xmlstring) except IOError as e: print('Unable to write .kreml in "%s": %s' % (dest, e), file=self.stderr) return 1 return print('Recipe "%s" not found' % id, file=self.stderr) return 3 @defaultcount(10) def do_search(self, pattern): """ search [PATTERN] Search recipes. """ self.change_path([u'search']) self.start_format(pattern=pattern) for recipe in self.do('iter_recipes', pattern=pattern): self.cached_format(recipe) weboob-1.1/weboob/applications/flatboob/000077500000000000000000000000001265717027300203755ustar00rootroot00000000000000weboob-1.1/weboob/applications/flatboob/__init__.py000066400000000000000000000000671265717027300225110ustar00rootroot00000000000000from .flatboob import Flatboob __all__ = ['Flatboob'] weboob-1.1/weboob/applications/flatboob/flatboob.py000066400000000000000000000220611265717027300225400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.housing import CapHousing, Query from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter from weboob.tools.config.yamlconfig import YamlConfig __all__ = ['Flatboob'] class HousingFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'title', 'cost', 'currency', 'area', 'date', 'text') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.title, self.NC) result += 'ID: %s\n' % obj.fullid if hasattr(obj, 'url') and obj.url: result += 'URL: %s\n' % obj.url result += 'Cost: %s%s\n' % (obj.cost, obj.currency) result += u'Area: %sm²\n' % (obj.area) if obj.date: result += 'Date: %s\n' % obj.date.strftime('%Y-%m-%d') result += 'Phone: %s\n' % obj.phone if hasattr(obj, 'location') and obj.location: result += 'Location: %s\n' % obj.location if hasattr(obj, 'station') and obj.station: result += 'Station: %s\n' % obj.station if hasattr(obj, 'photos') and obj.photos: result += '\n%sPhotos%s\n' % (self.BOLD, self.NC) for photo in obj.photos: result += ' * %s\n' % photo.url result += '\n%sDescription%s\n' % (self.BOLD, self.NC) result += obj.text if hasattr(obj, 'details') and obj.details: result += '\n\n%sDetails%s\n' % (self.BOLD, self.NC) for key, value in obj.details.iteritems(): result += ' %s: %s\n' % (key, value) return result class HousingListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title', 'cost', 'text') def get_title(self, obj): return '%s%s - %s' % (obj.cost, obj.currency, obj.title) def get_description(self, obj): result = u'' if hasattr(obj, 'date') and obj.date: result += '%s - ' % obj.date.strftime('%Y-%m-%d') result += obj.text return result class Flatboob(ReplApplication): APPNAME = 'flatboob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2012-YEAR Romain Bignon' DESCRIPTION = "Console application to search for housing." SHORT_DESCRIPTION = "search for housing" CAPS = CapHousing CONFIG = {'queries': {}} EXTRA_FORMATTERS = {'housing_list': HousingListFormatter, 'housing': HousingFormatter, } COMMANDS_FORMATTERS = {'search': 'housing_list', 'info': 'housing', 'load': 'housing_list' } def main(self, argv): self.load_config(klass=YamlConfig) return ReplApplication.main(self, argv) @defaultcount(10) def do_search(self, line): """ search Search for housing. Parameters are interactively asked. """ pattern = 'notempty' query = Query() query.cities = [] while pattern: if len(query.cities) > 0: print('\n%sSelected cities:%s %s' % (self.BOLD, self.NC, ', '.join([c.name for c in query.cities]))) pattern = self.ask('Enter a city pattern (or empty to stop)', default='') if not pattern: break cities = [] for city in self.weboob.do('search_city', pattern): cities.append(city) if len(cities) == 0: print(' Not found!') continue if len(cities) == 1: if city in query.cities: query.cities.remove(city) else: query.cities.append(city) continue r = 'notempty' while r != '': for i, city in enumerate(cities): print(' %s%2d)%s [%s] %s (%s)' % (self.BOLD, i+1, self.NC, 'x' if city in query.cities else ' ', city.name, city.backend)) r = self.ask(' Select cities (or empty to stop)', regexp='(\d+|)', default='') if not r.isdigit(): continue r = int(r) if r <= 0 or r > len(cities): continue city = cities[r-1] if city in query.cities: query.cities.remove(city) else: query.cities.append(city) r = 'notempty' while r != '': for good in Query.HOUSE_TYPES.values: print(' %s%2d)%s [%s] %s' % (self.BOLD, Query.HOUSE_TYPES.index[good] + 1, self.NC, 'x' if good in query.house_types else ' ', good)) r = self.ask(' Select type of house (or empty to stop)', regexp='(\d+|)', default='') if not r.isdigit(): continue r = int(r) if r <= 0 or r > len(Query.HOUSE_TYPES.values): continue value = Query.HOUSE_TYPES.values[r - 1] if value in query.house_types: query.house_types.remove(value) else: query.house_types.append(value) _type = None while _type not in [query.TYPE_RENT, query.TYPE_SALE, query.TYPE_SHARING]: print(' %s%2d)%s %s' % (self.BOLD, query.TYPE_RENT, self.NC, "Rent")) print(' %s%2d)%s %s' % (self.BOLD, query.TYPE_SALE, self.NC, "Sale")) print(' %s%2d)%s %s' % (self.BOLD, query.TYPE_SHARING, self.NC, "Sharing")) _type = self.ask_int('Type of query') query.type = _type query.area_min = self.ask_int('Enter min area') query.area_max = self.ask_int('Enter max area') query.cost_min = self.ask_int('Enter min cost') query.cost_max = self.ask_int('Enter max cost') query.nb_rooms = self.ask_int('Enter number of rooms') save_query = self.ask('Save query (y/n)', default='n') if save_query.upper() == 'Y': name = '' while not name: name = self.ask('Query name') self.config.set('queries', name, query) self.config.save() self.complete_search(query) def complete_search(self, query): self.change_path([u'housings']) self.start_format() for housing in self.do('search_housings', query): self.cached_format(housing) def ask_int(self, txt): r = self.ask(txt, default='', regexp='(\d+|)') if r: return int(r) return None @defaultcount(10) def do_load(self, query_name): """ load [query name] without query name : list loadable queries with query name laod query """ queries = self.config.get('queries') if not queries: print('There is no saved queries', file=self.stderr) return 2 if not query_name: for name in queries.keys(): print(' %s* %s %s' % (self.BOLD, self.NC, name)) query_name = self.ask('Which one') if query_name in queries: self.complete_search(queries.get(query_name)) else: print('Unknown query', file=self.stderr) return 2 def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info(self, _id): """ info ID Get information about a housing. """ if not _id: print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr) return 2 housing = self.get_object(_id, 'get_housing') if not housing: print('Housing not found: %s' % _id, file=self.stderr) return 3 self.start_format() self.format(housing) weboob-1.1/weboob/applications/galleroob/000077500000000000000000000000001265717027300205535ustar00rootroot00000000000000weboob-1.1/weboob/applications/galleroob/__init__.py000066400000000000000000000014341265717027300226660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .galleroob import Galleroob __all__ = ['Galleroob'] weboob-1.1/weboob/applications/galleroob/galleroob.py000066400000000000000000000112711265717027300230750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import os from re import search, sub from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.capabilities.base import empty from weboob.capabilities.gallery import CapGallery, BaseGallery, BaseImage from weboob.tools.application.formatters.iformatter import PrettyFormatter __all__ = ['Galleroob'] class GalleryListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title') def get_title(self, obj): s = obj.title if hasattr(obj, 'cardinality') and not empty(obj.cardinality): s += u' (%d pages)' % obj.cardinality return s def get_description(self, obj): if hasattr(obj, 'description') and obj.description: return obj.description class Galleroob(ReplApplication): APPNAME = 'galleroob' VERSION = '1.1' COPYRIGHT = u'Copyright(C) 2011-2014 Noé Rubinstein' DESCRIPTION = 'galleroob browses and downloads web image galleries' SHORT_DESCRIPTION = 'browse and download web image galleries' CAPS = CapGallery EXTRA_FORMATTERS = {'gallery_list': GalleryListFormatter} COMMANDS_FORMATTERS = {'search': 'gallery_list', 'ls': 'gallery_list'} COLLECTION_OBJECTS = (BaseGallery, BaseImage, ) def __init__(self, *args, **kwargs): ReplApplication.__init__(self, *args, **kwargs) @defaultcount(10) def do_search(self, pattern): """ search PATTERN List galleries matching a PATTERN. """ if not pattern: print('This command takes an argument: %s' % self.get_command_help('search', short=True), file=self.stderr) return 2 self.start_format(pattern=pattern) for gallery in self.do('search_galleries', pattern=pattern): self.cached_format(gallery) def do_download(self, line): """ download ID [FIRST [FOLDER]] Download a gallery. Begins at page FIRST (default: 0) and saves to FOLDER (default: title) """ _id, first, dest = self.parse_command_args(line, 3, 1) if first is None: first = 0 else: first = int(first) gallery = None _id, backend = self.parse_id(_id) for result in self.do('get_gallery', _id, backends=backend): if result: gallery = result if not gallery: print('Gallery not found: %s' % _id, file=self.stderr) return 3 self.weboob[backend].fillobj(gallery, ('title',)) if dest is None: dest = sub('/', ' ', gallery.title) print("Downloading to %s" % dest) try: os.mkdir(dest) except OSError: pass # ignore error on existing directory os.chdir(dest) # fail here if dest couldn't be created i = 0 for img in self.weboob[backend].iter_gallery_images(gallery): i += 1 if i < first: continue self.weboob[backend].fillobj(img, ('url', 'data')) if img.data is None: self.weboob[backend].fillobj(img, ('url', 'data')) if img.data is None: print("Couldn't get page %d, exiting" % i, file=self.stderr) break ext = search(r"\.([^\.]{1,5})$", img.url) if ext: ext = ext.group(1) else: ext = "jpg" name = '%03d.%s' % (i, ext) print('Writing file %s' % name) with open(name, 'wb') as f: f.write(img.data) os.chdir(os.path.pardir) def do_info(self, line): """ info ID Get information about a gallery. """ _id, = self.parse_command_args(line, 1, 1) gallery = self.get_object(_id, 'get_gallery') if not gallery: print('Gallery not found: %s' % _id, file=self.stderr) return 3 self.start_format() self.format(gallery) weboob-1.1/weboob/applications/geolooc/000077500000000000000000000000001265717027300202345ustar00rootroot00000000000000weboob-1.1/weboob/applications/geolooc/__init__.py000066400000000000000000000014241265717027300223460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .geolooc import Geolooc __all__ = ['Geolooc'] weboob-1.1/weboob/applications/geolooc/geolooc.py000066400000000000000000000031301265717027300222320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.geolocip import CapGeolocIp from weboob.tools.application.repl import ReplApplication __all__ = ['Geolooc'] class Geolooc(ReplApplication): APPNAME = 'geolooc' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' DESCRIPTION = "Console application allowing to geolocalize IP addresses." SHORT_DESCRIPTION = "geolocalize IP addresses" CAPS = CapGeolocIp def main(self, argv): if len(argv) < 2: print('Syntax: %s ipaddr' % argv[0], file=self.stderr) return 2 for location in self.do('get_location', argv[1]): if location.lt and location.lg: location.osmlink = u'http://www.openstreetmap.org/?mlat=%s&mlon=%s#map=13/%s/%s' % (location.lt, location.lg, location.lt, location.lg) self.format(location) weboob-1.1/weboob/applications/handjoob/000077500000000000000000000000001265717027300203715ustar00rootroot00000000000000weboob-1.1/weboob/applications/handjoob/__init__.py000066400000000000000000000014151265717027300225030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .handjoob import Handjoob __all__ = ['Handjoob'] weboob-1.1/weboob/applications/handjoob/handjoob.py000066400000000000000000000115461265717027300225360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.job import CapJob from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter __all__ = ['Handjoob'] class JobAdvertFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'url', 'publication_date', 'title') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.title, self.NC) result += 'url: %s\n' % obj.url if hasattr(obj, 'publication_date') and obj.publication_date: result += 'Publication date : %s\n' % obj.publication_date.strftime('%Y-%m-%d') if hasattr(obj, 'place') and obj.place: result += 'Location: %s\n' % obj.place if hasattr(obj, 'society_name') and obj.society_name: result += 'Society : %s\n' % obj.society_name if hasattr(obj, 'job_name') and obj.job_name: result += 'Job name : %s\n' % obj.job_name if hasattr(obj, 'contract_type') and obj.contract_type: result += 'Contract : %s\n' % obj.contract_type if hasattr(obj, 'pay') and obj.pay: result += 'Pay : %s\n' % obj.pay if hasattr(obj, 'formation') and obj.formation: result += 'Formation : %s\n' % obj.formation if hasattr(obj, 'experience') and obj.experience: result += 'Experience : %s\n' % obj.experience if hasattr(obj, 'description') and obj.description: result += 'Description : %s\n' % obj.description return result class JobAdvertListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title') def get_title(self, obj): return '%s' % (obj.title) def get_description(self, obj): result = u'' if hasattr(obj, 'publication_date') and obj.publication_date: result += '\tPublication date : %s\n' % obj.publication_date.strftime('%Y-%m-%d') if hasattr(obj, 'place') and obj.place: result += '\tLocation: %s\n' % obj.place if hasattr(obj, 'society_name') and obj.society_name: result += '\tSociety : %s\n' % obj.society_name if hasattr(obj, 'contract_type') and obj.contract_type: result += '\tContract : %s\n' % obj.contract_type return result.strip('\n\t') class Handjoob(ReplApplication): APPNAME = 'handjoob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2012-YEAR Bezleputh' DESCRIPTION = "Console application to search for a job." SHORT_DESCRIPTION = "search for a job" CAPS = CapJob EXTRA_FORMATTERS = {'job_advert_list': JobAdvertListFormatter, 'job_advert': JobAdvertFormatter, } COMMANDS_FORMATTERS = {'search': 'job_advert_list', 'ls': 'job_advert_list', 'info': 'job_advert', } @defaultcount(10) def do_search(self, pattern): """ search PATTERN Search for an advert matching a PATTERN. """ self.change_path([u'search']) self.start_format(pattern=pattern) for job_advert in self.do('search_job', pattern): self.cached_format(job_advert) @defaultcount(10) def do_ls(self, line): """ advanced search Search for an advert matching to advanced filters. """ self.change_path([u'advanced']) for job_advert in self.do('advanced_search_job'): self.cached_format(job_advert) def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info(self, _id): """ info ID Get information about an advert. """ if not _id: print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr) return 2 job_advert = self.get_object(_id, 'get_job_advert') if not job_advert: print('Job advert not found: %s' % _id, file=self.stderr) return 3 self.start_format() self.format(job_advert) weboob-1.1/weboob/applications/havedate/000077500000000000000000000000001265717027300203665ustar00rootroot00000000000000weboob-1.1/weboob/applications/havedate/__init__.py000066400000000000000000000014271265717027300225030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .havedate import HaveDate __all__ = ['HaveDate'] weboob-1.1/weboob/applications/havedate/havedate.py000066400000000000000000000242021265717027300225210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from copy import copy from weboob.core import CallErrors from weboob.tools.application.repl import ReplApplication from weboob.applications.boobmsg import Boobmsg from weboob.capabilities.dating import CapDating, OptimizationNotFound from weboob.tools.application.formatters.iformatter import PrettyFormatter __all__ = ['HaveDate'] class EventListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('date', 'type') def get_title(self, event): s = u'(%s) %s' % (event.date, event.type) if hasattr(event, 'contact') and event.contact: s += u' — %s (%s)' % (event.contact.name, event.contact.id) return s def get_description(self, event): if hasattr(event, 'message'): return event.message class HaveDate(Boobmsg): APPNAME = 'havedate' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' DESCRIPTION = "Console application allowing to interact with various dating websites " \ "and to optimize seduction algorithmically." SHORT_DESCRIPTION = "interact with dating websites" STORAGE_FILENAME = 'dating.storage' STORAGE = {'optims': {}} CAPS = CapDating EXTRA_FORMATTERS = copy(Boobmsg.EXTRA_FORMATTERS) EXTRA_FORMATTERS['events'] = EventListFormatter COMMANDS_FORMATTERS = copy(Boobmsg.COMMANDS_FORMATTERS) COMMANDS_FORMATTERS['optim'] = 'table' COMMANDS_FORMATTERS['events'] = 'events' def load_default_backends(self): self.load_backends(CapDating, storage=self.create_storage(self.STORAGE_FILENAME)) def main(self, argv): self.load_config() try: self.do('init_optimizations').wait() except CallErrors as e: self.bcall_errors_handler(e) optimizations = self.storage.get('optims') for optim, backends in optimizations.iteritems(): self.optims('start', backends, optim, store=False) return ReplApplication.main(self, argv) def do_query(self, id): """ query ID Send a query to someone. """ _id, backend_name = self.parse_id(id, unique_backend=True) for query in self.do('send_query', _id, backends=backend_name): print('%s' % query.message) def edit_optims(self, backend_names, optims_names, stop=False): if optims_names is None: print('Error: missing parameters.', file=self.stderr) return 2 for optim_name in optims_names.split(): backends_optims = {} for optim in self.do('get_optimization', optim_name, backends=backend_names): if optim: backends_optims[optim.backend] = optim for backend_name, optim in backends_optims.iteritems(): if len(optim.CONFIG) == 0: print('%s.%s does not require configuration.' % (backend_name, optim_name)) continue was_running = optim.is_running() if stop and was_running: print('Stopping %s: %s' % (optim_name, backend_name)) optim.stop() params = optim.get_config() if params is None: params = {} print('Configuration of %s.%s' % (backend_name, optim_name)) print('-----------------%s-%s' % ('-' * len(backend_name), '-' * len(optim_name))) for key, value in optim.CONFIG.iteritems(): params[key] = self.ask(value, default=params[key] if (key in params) else value.default) optim.set_config(params) if stop and was_running: print('Starting %s: %s' % (optim_name, backend_name)) optim.start() def optims(self, function, backend_names, optims, store=True): if optims is None: print('Error: missing parameters.', file=self.stderr) return 2 for optim_name in optims.split(): try: if store: storage_optim = set(self.storage.get('optims', optim_name, default=[])) self.stdout.write('%sing %s:' % (function.capitalize(), optim_name)) for optim in self.do('get_optimization', optim_name, backends=backend_names): if optim: # It's useless to start a started optim, or to stop a stopped one. if (function == 'start' and optim.is_running()) or \ (function == 'stop' and not optim.is_running()): continue # Optim is not configured and would be, ask user to do it. if function == 'start' and len(optim.CONFIG) > 0 and optim.get_config() is None: self.edit_optims(optim.backend, optim_name) ret = getattr(optim, function)() self.stdout.write(' ' + optim.backend) if not ret: self.stdout.write('(failed)') self.stdout.flush() if store: if function == 'start' and ret: storage_optim.add(optim.backend) elif function == 'stop': try: storage_optim.remove(optim.backend) except KeyError: pass self.stdout.write('.\n') except CallErrors as errors: for backend, error, backtrace in errors: if isinstance(error, OptimizationNotFound): self.logger.error(u'Error(%s): Optimization "%s" not found' % (backend.name, optim_name)) else: self.bcall_error_handler(backend, error, backtrace) if store: if len(storage_optim) > 0: self.storage.set('optims', optim_name, list(storage_optim)) else: self.storage.delete('optims', optim_name) if store: self.storage.save() def complete_optim(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return ['list', 'start', 'stop', 'edit'] elif len(args) == 3: return [backend.name for backend in self.enabled_backends] elif len(args) >= 4: if args[2] == '*': backend = None else: backend = args[2] optims = set() for optim in self.do('iter_optimizations', backends=backend): optims.add(optim.id) return sorted(optims - set(args[3:])) def do_optim(self, line): """ optim [list | start | edit | stop] BACKEND [OPTIM1 [OPTIM2 ...]] All dating backends offer optimization services. This command can be manage them. Use * us BACKEND value to apply command to all backends. Commands: * list list all available optimizations of a backend * start start optimization services on a backend * edit configure an optimization service for a backend * stop stop optimization services on a backend """ cmd, backend_name, optims_names = self.parse_command_args(line, 3) if backend_name == '*': backend_name = None elif backend_name is not None and backend_name not in [b.name for b in self.enabled_backends]: print('Error: No such backend "%s"' % backend_name, file=self.stderr) return 1 if cmd == 'start': return self.optims('start', backend_name, optims_names) if cmd == 'stop': return self.optims('stop', backend_name, optims_names) if cmd == 'edit': self.edit_optims(backend_name, optims_names, stop=True) return if cmd == 'list' or cmd is None: if optims_names is not None: optims_names = optims_names.split() optims = {} backends = set() for optim in self.do('iter_optimizations', backends=backend_name): if optims_names is not None and optim.id not in optims_names: continue if optim.is_running(): status = 'RUNNING' else: status = '-------' if optim.id not in optims: optims[optim.id] = {optim.backend: status} else: optims[optim.id][optim.backend] = status backends.add(optim.backend) backends = sorted(backends) for name, backends_status in optims.iteritems(): line = [('name', name)] for b in backends: try: status = backends_status[b] except KeyError: status = '' line.append((b, status)) self.format(tuple(line)) return print("No such command '%s'" % cmd, file=self.stderr) return 1 def do_events(self, line): """ events Display dating events. """ self.change_path([u'events']) self.start_format() for event in self.do('iter_events'): self.cached_format(event) weboob-1.1/weboob/applications/masstransit/000077500000000000000000000000001265717027300211555ustar00rootroot00000000000000weboob-1.1/weboob/applications/masstransit/__init__.py000066400000000000000000000014401265717027300232650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .masstransit import Masstransit __all__ = ['Masstransit'] weboob-1.1/weboob/applications/masstransit/masstransit.py000066400000000000000000000243441265717027300241060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Julien Hébert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.travel import CapTravel from weboob.tools.application.base import Application from logging import warning import gtk class FakeConic(object): STATUS_CONNECTED = None STATUS_DISCONNECTED = None CONNECT_FLAG_NONE = None def Connection(self): raise NotImplementedError() try: import hildon except ImportError: toolkit = gtk else: toolkit = hildon try: import conic except ImportError: warning("conic is not found") conic = FakeConic() from logging import debug __all__ = ['Masstransit'] class MasstransitHildon(): "hildon interface" def connect_event(self, connection, event=None, c=None, d=None): debug("DBUS-DEBUG a: %s, b:%s, c:%s,d: %s" % (connection, event, c, d)) status = event.get_status() if status == conic.STATUS_CONNECTED: self.connected = True if not self.touch_selector_entry_filled: debug("connected, now fill") self.fill_touch_selector_entry() if self.refresh_in_progress: self.refresh() elif status == conic.STATUS_DISCONNECTED: self.connected = False def __init__(self, weboob): self.touch_selector_entry_filled = False self.refresh_in_progress = False self.connected = False self.weboob = weboob try: self.connection = conic.Connection() self.connection.connect("connection-event", self.connect_event) self.connection.set_property("automatic-connection-events", True) self.connection.request_connection(conic.CONNECT_FLAG_NONE) except NotImplementedError: pass horizontal_box = gtk.HBox() self.main_window = toolkit.Window() try: self.refresh_button = toolkit.Button( gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_HORIZONTAL, "Actualiser" ) self.retour_button = hildon.Button( gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_HORIZONTAL, "Retour" ) self.combo_source = hildon.TouchSelectorEntry(text=True) self.combo_dest = hildon.TouchSelectorEntry(text=True) self.picker_button_source = hildon.PickerButton( gtk.HILDON_SIZE_AUTO, hildon.BUTTON_ARRANGEMENT_VERTICAL) self.picker_button_dest = hildon.PickerButton( gtk.HILDON_SIZE_AUTO, hildon.BUTTON_ARRANGEMENT_VERTICAL ) self.picker_button_source.set_sensitive(False) self.picker_button_dest.set_sensitive(False) self.picker_button_source.set_title("Gare de Depart") self.picker_button_dest.set_title("Gare d'arrivee") self.picker_button_source.set_selector(self.combo_source) self.picker_button_dest.set_selector(self.combo_dest) horizontal_box.pack_start(self.picker_button_source) horizontal_box.pack_start(self.picker_button_dest) except AttributeError: self.refresh_button = gtk.Button("Actualiser") self.retour_button = gtk.Button("Retour") self.combo_source = gtk.combo_box_entry_new_text() self.combo_dest = gtk.combo_box_entry_new_text() horizontal_box.pack_start(self.combo_source) horizontal_box.pack_start(self.combo_dest) self.main_window.set_title("Horaires des Prochains Trains") self.main_window.connect("destroy", self.on_main_window_destroy) self.refresh_button.connect("clicked", self.on_refresh_button_clicked) self.retour_button.set_sensitive(False) self.retour_button.connect("clicked", self.on_retour_button_clicked) self.treestore = gtk.TreeStore(str, str, str, str, str) treeview = gtk.TreeView(self.treestore) treeview.append_column( gtk.TreeViewColumn( 'Train', gtk.CellRendererText(), text=0 )) treeview.append_column( gtk.TreeViewColumn( 'Horaire', gtk.CellRendererText(), text=1 )) treeview.append_column( gtk.TreeViewColumn( 'Destination', gtk.CellRendererText(), text=2 )) treeview.append_column( gtk.TreeViewColumn( 'Voie', gtk.CellRendererText(), text=3 )) treeview.append_column( gtk.TreeViewColumn( 'Information', gtk.CellRendererText(), text=4 )) vertical_box = gtk.VBox() vertical_box.pack_start(horizontal_box) horizontal_box.pack_start(self.retour_button) vertical_box.pack_start(treeview) vertical_box.pack_start(self.refresh_button) self.main_window.add(vertical_box) self.main_window.show_all() self.fill_touch_selector_entry() if toolkit != gtk: self.picker_button_source.connect("value-changed", self.check_station_input, self.picker_button_source) self.picker_button_dest.connect("value-changed", self.check_station_input, self.picker_button_dest) def fill_touch_selector_entry(self): liste = [] for backend in self.weboob.iter_backends(): for station in backend.iter_station_search(""): liste.append(station.name.capitalize()) liste.sort() for station in liste: self.combo_source.append_text(station) self.combo_dest.append_text(station) self.touch_selector_entry_filled = True if toolkit != gtk: self.picker_button_source.set_sensitive(True) def on_main_window_destroy(self, widget): "exit application at the window close" gtk.main_quit() def on_main_window_show(self, param): self.fill_touch_selector_entry() def on_retour_button_clicked(self, widget): "the button is clicked" debug("on_retour_button_clicked") self.refresh_in_progress = True col_source = self.combo_source.get_active(0) col_dest = self.combo_dest.get_active(0) self.combo_source.set_active(0, col_dest) self.combo_dest.set_active(0, col_source) self.refresh() def on_refresh_button_clicked(self, widget): "the refresh button is clicked" debug("on_refresh_button_clicked") self.refresh_in_progress = True try: self.connection.request_connection(conic.CONNECT_FLAG_NONE) except AttributeError: if isinstance(conic, FakeConic): self.refresh() else: raise def check_station_input(self, widget, user_data): if self.combo_source.get_current_text() is None: self.picker_button_dest.set_sensitive(False) self.refresh_button.set_sensitive(False) self.retour_button.set_sensitive(False) else: self.picker_button_dest.set_sensitive(True) if self.combo_dest.get_current_text() is None: self.refresh_button.set_sensitive(False) self.retour_button.set_sensitive(False) else: self.refresh_button.set_sensitive(True) self.retour_button.set_sensitive(True) def refresh(self): "update departures" banner = hildon.hildon_banner_show_information(self.main_window, "", "Chargement en cours") banner.set_timeout(10000) hildon.hildon_gtk_window_set_progress_indicator(self.main_window, 1) self.treestore.clear() try: source_text = self.combo_source.get_current_text() dest_text = self.combo_dest.get_current_text() except AttributeError: source_text = self.combo_source.child.get_text() dest_text = self.combo_dest.child.get_text() for backend in self.weboob.iter_backends(): for station in backend.iter_station_search(source_text): for arrival in \ backend.iter_station_search(dest_text): for departure in \ backend.iter_station_departures(station.id, arrival.id): self.treestore.append(None, [departure.type, departure.time, departure.arrival_station, departure.plateform, departure.information]) self.refresh_in_progress = False banner.set_timeout(1) hildon.hildon_gtk_window_set_progress_indicator(self.main_window, 0) class Masstransit(Application): "Application Class" APPNAME = 'masstransit' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Julien Hébert' DESCRIPTION = "Maemo application allowing to search for train stations and get departure times." SHORT_DESCRIPTION = "search for train stations and departures" def main(self, argv): self.load_backends(CapTravel) MasstransitHildon(self.weboob) gtk.main() weboob-1.1/weboob/applications/monboob/000077500000000000000000000000001265717027300202405ustar00rootroot00000000000000weboob-1.1/weboob/applications/monboob/__init__.py000066400000000000000000000014241265717027300223520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .monboob import Monboob __all__ = ['Monboob'] weboob-1.1/weboob/applications/monboob/monboob.py000066400000000000000000000322561265717027300222550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2011 Romain Bignon, Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from email.mime.text import MIMEText from smtplib import SMTP from email.Header import Header, decode_header from email.Utils import parseaddr, formataddr, formatdate from email import message_from_file, message_from_string from smtpd import SMTPServer import time import re import logging import asyncore import subprocess import socket from weboob.core import Weboob, CallErrors from weboob.core.scheduler import Scheduler from weboob.capabilities.messages import CapMessages, CapMessagesPost, Thread, Message from weboob.tools.application.repl import ReplApplication from weboob.tools.date import utc2local from weboob.tools.html import html2text from weboob.tools.misc import get_backtrace, to_unicode __all__ = ['Monboob'] class FakeSMTPD(SMTPServer): def __init__(self, app, bindaddr, port): SMTPServer.__init__(self, (bindaddr, port), None) self.app = app def process_message(self, peer, mailfrom, rcpttos, data): msg = message_from_string(data) self.app.process_incoming_mail(msg) class MonboobScheduler(Scheduler): def __init__(self, app): Scheduler.__init__(self) self.app = app def run(self): if self.app.options.smtpd: if ':' in self.app.options.smtpd: host, port = self.app.options.smtpd.split(':', 1) else: host = '127.0.0.1' port = self.app.options.smtpd try: FakeSMTPD(self.app, host, int(port)) except socket.error as e: self.logger.error('Unable to start the SMTP daemon: %s' % e) return False # XXX Fuck, we shouldn't copy this piece of code from # weboob.scheduler.Scheduler.run(). try: while True: self.stop_event.wait(0.1) if self.app.options.smtpd: asyncore.loop(timeout=0.1, count=1) except KeyboardInterrupt: self._wait_to_stop() raise else: self._wait_to_stop() return True class Monboob(ReplApplication): APPNAME = 'monboob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' DESCRIPTION = 'Daemon allowing to regularly check for new messages on various websites, ' \ 'and send an email for each message, and post a reply to a message on a website.' SHORT_DESCRIPTION = "daemon to send and check messages" CONFIG = {'interval': 300, 'domain': 'weboob.example.org', 'recipient': 'weboob@example.org', 'smtp': 'localhost', 'pipe': '', 'html': 0} CAPS = CapMessages DISABLE_REPL = True def add_application_options(self, group): group.add_option('-S', '--smtpd', help='run a fake smtpd server and set the port') def create_weboob(self): return Weboob(scheduler=MonboobScheduler(self)) def load_default_backends(self): self.load_backends(CapMessages, storage=self.create_storage()) def main(self, argv): self.load_config() try: self.config.set('interval', int(self.config.get('interval'))) if self.config.get('interval') < 1: raise ValueError() except ValueError: print('Configuration error: interval must be an integer >0.', file=self.stderr) return 1 try: self.config.set('html', int(self.config.get('html'))) if self.config.get('html') not in (0, 1): raise ValueError() except ValueError: print('Configuration error: html must be 0 or 1.', file=self.stderr) return 2 return ReplApplication.main(self, argv) def get_email_address_ident(self, msg, header): s = msg.get(header) if not s: return None m = re.match('.*<([^@]*)@(.*)>', s) if m: return m.group(1) else: try: return s.split('@')[0] except IndexError: return s def do_post(self, line): """ post Pipe with a mail to post message. """ msg = message_from_file(self.stdin) return self.process_incoming_mail(msg) def process_incoming_mail(self, msg): to = self.get_email_address_ident(msg, 'To') sender = msg.get('From') reply_to = self.get_email_address_ident(msg, 'In-Reply-To') title = msg.get('Subject') if title: new_title = u'' for part in decode_header(title): if part[1]: new_title += unicode(part[0], part[1]) else: new_title += unicode(part[0]) title = new_title content = u'' for part in msg.walk(): if part.get_content_type() == 'text/plain': s = part.get_payload(decode=True) charsets = part.get_charsets() + msg.get_charsets() for charset in charsets: try: if charset is not None: content += unicode(s, charset) else: content += unicode(s) except UnicodeError as e: self.logger.warning('Unicode error: %s' % e) continue except Exception as e: self.logger.exception(e) continue else: break if len(content) == 0: print('Unable to send an empty message', file=self.stderr) return 1 # remove signature content = content.split(u'\n-- \n')[0] parent_id = None if reply_to is None: # This is a new message if '.' in to: backend_name, thread_id = to.split('.', 1) else: backend_name = to thread_id = None else: # This is a reply try: backend_name, id = reply_to.split('.', 1) thread_id, parent_id = id.rsplit('.', 1) except ValueError: print('In-Reply-To header might be in form ', file=self.stderr) return 1 # Default use the To header field to know the backend to use. if to and backend_name != to: backend_name = to try: backend = self.weboob.backend_instances[backend_name] except KeyError: print('Backend %s not found' % backend_name, file=self.stderr) return 1 if not backend.has_caps(CapMessagesPost): print('The backend %s does not implement CapMessagesPost' % backend_name, file=self.stderr) return 1 thread = Thread(thread_id) message = Message(thread, 0, title=title, sender=sender, receivers=[to], parent=Message(thread, parent_id) if parent_id else None, content=content) try: backend.post_message(message) except Exception as e: content = u'Unable to send message to %s:\n' % thread_id content += u'\n\t%s\n' % to_unicode(e) if logging.root.level <= logging.DEBUG: content += u'\n%s\n' % to_unicode(get_backtrace(e)) self.send_email(backend.name, Message(thread, 0, title='Unable to send message', sender='Monboob', parent=Message(thread, parent_id) if parent_id else None, content=content)) def do_run(self, line): """ run Run the fetching daemon. """ self.weboob.repeat(self.config.get('interval'), self.process) self.weboob.loop() def do_once(self, line): """ once Send mails only once, then exit. """ return self.process() def process(self): try: for message in self.weboob.do('iter_unread_messages'): if self.send_email(message.backend, message): self.weboob[message.backend].set_message_read(message) except CallErrors as e: self.bcall_errors_handler(e) def send_email(self, backend_name, mail): domain = self.config.get('domain') recipient = self.config.get('recipient') reply_id = '' if mail.parent: reply_id = u'<%s.%s@%s>' % (backend_name, mail.parent.full_id, domain) subject = mail.title sender = u'"%s" <%s@%s>' % (mail.sender.replace('"', '""') if mail.sender else '', backend_name, domain) # assume that .date is an UTC datetime date = formatdate(time.mktime(utc2local(mail.date).timetuple()), localtime=True) msg_id = u'<%s.%s@%s>' % (backend_name, mail.full_id, domain) if self.config.get('html') and mail.flags & mail.IS_HTML: body = mail.content content_type = 'html' else: if mail.flags & mail.IS_HTML: body = html2text(mail.content) else: body = mail.content content_type = 'plain' if body is None: body = '' if mail.signature: if self.config.get('html') and mail.flags & mail.IS_HTML: body += u'

--
%s

' % mail.signature else: body += u'\n\n-- \n' if mail.flags & mail.IS_HTML: body += html2text(mail.signature) else: body += mail.signature # Header class is smart enough to try US-ASCII, then the charset we # provide, then fall back to UTF-8. header_charset = 'ISO-8859-1' # We must choose the body charset manually for body_charset in 'US-ASCII', 'ISO-8859-1', 'UTF-8': try: body.encode(body_charset) except UnicodeError: pass else: break # Split real name (which is optional) and email address parts sender_name, sender_addr = parseaddr(sender) recipient_name, recipient_addr = parseaddr(recipient) # We must always pass Unicode strings to Header, otherwise it will # use RFC 2047 encoding even on plain ASCII strings. sender_name = str(Header(unicode(sender_name), header_charset)) recipient_name = str(Header(unicode(recipient_name), header_charset)) # Make sure email addresses do not contain non-ASCII characters sender_addr = sender_addr.encode('ascii') recipient_addr = recipient_addr.encode('ascii') # Create the message ('plain' stands for Content-Type: text/plain) msg = MIMEText(body.encode(body_charset), content_type, body_charset) msg['From'] = formataddr((sender_name, sender_addr)) msg['To'] = formataddr((recipient_name, recipient_addr)) msg['Subject'] = Header(unicode(subject), header_charset) msg['Message-Id'] = msg_id msg['Date'] = date if reply_id: msg['In-Reply-To'] = reply_id self.logger.info('Send mail from <%s> to <%s>' % (sender, recipient)) if len(self.config.get('pipe')) > 0: p = subprocess.Popen(self.config.get('pipe'), shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.stdin.write(msg.as_string()) p.stdin.close() if p.wait() != 0: self.logger.error('Unable to deliver mail: %s' % p.stdout.read().strip()) return False else: # Send the message via SMTP to localhost:25 try: smtp = SMTP(self.config.get('smtp')) smtp.sendmail(sender, recipient, msg.as_string()) except Exception as e: self.logger.error('Unable to deliver mail: %s' % e) return False else: smtp.quit() return True weboob-1.1/weboob/applications/parceloob/000077500000000000000000000000001265717027300205535ustar00rootroot00000000000000weboob-1.1/weboob/applications/parceloob/__init__.py000066400000000000000000000014251265717027300226660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .parceloob import Parceloob __all__ = ['Parceloob'] weboob-1.1/weboob/applications/parceloob/parceloob.py000066400000000000000000000156541265717027300231060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.base import empty from weboob.capabilities.parcel import CapParcel, Parcel, ParcelNotFound from weboob.tools.application.repl import ReplApplication from weboob.tools.application.formatters.iformatter import IFormatter __all__ = ['Parceloob'] STATUS = {Parcel.STATUS_PLANNED: ('PLANNED', 'red'), Parcel.STATUS_IN_TRANSIT: ('IN TRANSIT', 'yellow'), Parcel.STATUS_ARRIVED: ('ARRIVED', 'green'), Parcel.STATUS_UNKNOWN: ('', 'white'), } def get_backend_name(backend): return backend.name class HistoryFormatter(IFormatter): MANDATORY_FIELDS = () def format_obj(self, obj, alias): if isinstance(obj, Parcel): result = u'Parcel %s (%s)\n' % (self.colored(obj.id, 'red', 'bold'), self.colored(obj.backend, 'blue', 'bold')) result += u'%sArrival:%s %s\n' % (self.BOLD, self.NC, obj.arrival) status, status_color = STATUS[obj.status] result += u'%sStatus:%s %s\n' % (self.BOLD, self.NC, self.colored(status, status_color)) result += u'%sInfo:%s %s\n\n' % (self.BOLD, self.NC, obj.info) result += u' Date Location Activity \n' result += u'---------------------+-----------------+---------------------------------------------------' return result return ' %s %s %s' % (self.colored('%-19s' % obj.date, 'blue'), self.colored('%-17s' % (obj.location or ''), 'magenta'), self.colored(obj.activity or '', 'yellow')) class StatusFormatter(IFormatter): MANDATORY_FIELDS = ('id',) def format_obj(self, obj, alias): if alias is not None: id = '%s (%s)' % (self.colored('%3s' % ('#' + alias), 'red', 'bold'), self.colored(obj.backend, 'blue', 'bold')) clean = '#%s (%s)' % (alias, obj.backend) if len(clean) < 15: id += (' ' * (15 - len(clean))) else: id = self.colored('%30s' % obj.fullid, 'red', 'bold') status, status_color = STATUS[obj.status] arrival = obj.arrival.strftime('%Y-%m-%d') if not empty(obj.arrival) else '' result = u'%s %s %s %s %s' % (id, self.colored(u'—', 'cyan'), self.colored('%-10s' % status, status_color), self.colored('%-10s' % arrival, 'blue'), self.colored('%-20s' % obj.info, 'yellow')) return result class Parceloob(ReplApplication): APPNAME = 'parceloob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2013-YEAR Romain Bignon' CAPS = CapParcel DESCRIPTION = "Console application to track your parcels." SHORT_DESCRIPTION = "manage your parcels" EXTRA_FORMATTERS = {'status': StatusFormatter, 'history': HistoryFormatter, } DEFAULT_FORMATTER = 'table' COMMANDS_FORMATTERS = {'status': 'status', 'info': 'history', } STORAGE = {'tracking': []} def do_track(self, line): """ track ID Track a parcel. """ parcel = self.get_object(line, 'get_parcel_tracking') if not parcel: print('Error: the parcel "%s" is not found' % line, file=self.stderr) return 2 parcels = set(self.storage.get('tracking', default=[])) parcels.add(parcel.fullid) self.storage.set('tracking', list(parcels)) self.storage.save() print('Parcel "%s" has been tracked.' % parcel.fullid) def do_untrack(self, line): """ untrack ID Stop tracking a parcel. """ removed = False # Always try to first remove the parcel, the untrack should always success parcels = set(self.storage.get('tracking', default=[])) try: parcels.remove(line) removed = True except KeyError: pass if not removed: try: parcel = self.get_object(line, 'get_parcel_tracking') except ParcelNotFound: parcel = False if not parcel: print('Error: the parcel "%s" is not found. Did you provide the full id@backend parameter?' % line, file=self.stderr) return 2 try: parcels.remove(parcel.fullid) except KeyError: print("Error: parcel \"%s\" wasn't tracked" % parcel.fullid, file=self.stderr) return 2 self.storage.set('tracking', list(parcels)) self.storage.save() if removed: print("Parcel \"%s\" isn't tracked anymore." % line) else: print("Parcel \"%s\" isn't tracked anymore." % parcel.fullid) def do_status(self, line): """ status Display status for all of the tracked parcels. """ backends = map(get_backend_name, self.enabled_backends) self.start_format() # XXX cleaning of cached objects may be by start_format()? self.objects = [] for id in self.storage.get('tracking', default=[]): # It should be safe to do it here, since all objects in storage # are stored with the fullid _id, backend_name = id.rsplit('@', 1) # If the user use the -b or -e option, do not try to get # the status of parcel of not loaded backends if backend_name not in backends: continue p = self.get_object(id, 'get_parcel_tracking') if p is None: continue self.cached_format(p) def do_info(self, id): """ info ID Get information about a parcel. """ parcel = self.get_object(id, 'get_parcel_tracking', []) if not parcel: print('Error: parcel not found', file=self.stderr) return 2 self.start_format() self.format(parcel) for event in parcel.history: self.format(event) weboob-1.1/weboob/applications/pastoob/000077500000000000000000000000001265717027300202545ustar00rootroot00000000000000weboob-1.1/weboob/applications/pastoob/__init__.py000066400000000000000000000014231265717027300223650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .pastoob import Pastoob __all__ = ['Pastoob'] weboob-1.1/weboob/applications/pastoob/pastoob.py000066400000000000000000000166161265717027300223070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import os import codecs import re from random import choice from weboob.capabilities.paste import CapPaste, PasteNotFound from weboob.tools.application.repl import ReplApplication __all__ = ['Pastoob'] class Pastoob(ReplApplication): APPNAME = 'pastoob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2011-YEAR Laurent Bachelier' DESCRIPTION = "Console application allowing to post and get pastes from pastebins." SHORT_DESCRIPTION = "post and get pastes from pastebins" CAPS = CapPaste def main(self, argv): self.load_config() return ReplApplication.main(self, argv) def do_info(self, line): """ info ID [ID2 [...]] Get information about pastes. """ if not line: print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr) return 2 self.start_format() for _id in line.split(' '): paste = self.get_object(_id, 'get_paste', ['id', 'title', 'language', 'public', 'contents']) if not paste: print('Paste not found: %s' % _id, file=self.stderr) self.format(paste) def do_get(self, line): """ get ID Get a paste contents. """ return self._get_op(line, binary=False, command='get') def do_get_bin(self, line): """ get_bin ID Get a paste contents. File will be downloaded from binary services. """ return self._get_op(line, binary=True, command='get_bin') def _get_op(self, _id, binary, command='get'): if not _id: print('This command takes an argument: %s' % self.get_command_help(command, short=True), file=self.stderr) return 2 try: paste = self.get_object(_id, 'get_paste', ['contents']) except PasteNotFound: print('Paste not found: %s' % _id, file=self.stderr) return 3 if not paste: print('Unable to handle paste: %s' % _id, file=self.stderr) return 1 if binary: if self.interactive: if not self.ask('The console may become messed up. Are you sure you want to show a binary file on your terminal?', default=False): print('Aborting.', file=self.stderr) return 1 output = self.stdout output.write(paste.contents.decode('base64')) else: output = codecs.getwriter(self.encoding)(self.stdout) output.write(paste.contents) # add a newline unless we are writing # in a file or in a pipe if output.isatty(): output.write('\n') def do_post(self, line): """ post [FILENAME] Submit a new paste. The filename can be '-' for reading standard input (pipe). If 'bin' is passed, file will be uploaded to binary services. """ return self._post(line, binary=False) def do_post_bin(self, line): """ post_bin [FILENAME] Submit a new paste. The filename can be '-' for reading standard input (pipe). File will be uploaded to binary services. """ return self._post(line, binary=True) def _post(self, filename, binary): use_stdin = (not filename or filename == '-') if use_stdin: if binary: contents = self.stdin.read() else: contents = self.acquire_input() if not len(contents): print('Empty paste, aborting.', file=self.stderr) return 1 else: try: if binary: m = open(filename) else: m = codecs.open(filename, encoding=self.options.encoding or self.encoding) with m as fp: contents = fp.read() except IOError as e: print('Unable to open file "%s": %s' % (filename, e.strerror), file=self.stderr) return 1 if binary: contents = contents.encode('base64') # get and sort the backends able to satisfy our requirements params = self.get_params() backends = {} for backend in self.weboob.iter_backends(): score = backend.can_post(contents, **params) if score: backends.setdefault(score, []).append(backend) # select a random backend from the best scores if len(backends): backend = choice(backends[max(backends.keys())]) else: print('No suitable backend found.', file=self.stderr) return 1 p = backend.new_paste(_id=None) p.public = params['public'] if self.options.title is not None: p.title = self.options.title else: p.title = os.path.basename(filename) p.contents = contents backend.post_paste(p, max_age=params['max_age']) print('Successfuly posted paste: %s' % p.page_url) def get_params(self): return {'public': self.options.public, 'max_age': self.str_to_duration(self.options.max_age), 'title': self.options.title} def str_to_duration(self, s): if s.strip().lower() == 'never': return False parts = re.findall(r'(\d*(?:\.\d+)?)\s*([A-z]+)', s) argsmap = {'Y|y|year|years|yr|yrs': 365.25 * 24 * 3600, 'M|o|month|months': 30.5 * 24 * 3600, 'W|w|week|weeks': 7 * 24 * 3600, 'D|d|day|days': 24 * 3600, 'H|h|hours|hour|hr|hrs': 3600, 'm|i|minute|minutes|min|mins': 60, 'S|s|second|seconds|sec|secs': 1} seconds = 0 for number, unit in parts: for rx, secs in argsmap.iteritems(): if re.match('^(%s)$' % rx, unit): seconds += float(number) * float(secs) return int(seconds) def add_application_options(self, group): group.add_option('-p', '--public', action='store_true', help='Make paste public.') group.add_option('-t', '--title', action='store', help='Paste title', type='string') group.add_option('-m', '--max-age', action='store', help='Maximum age (duration), default "1 month", "never" for infinite', type='string', default='1 month') group.add_option('-E', '--encoding', action='store', help='Input encoding', type='string') weboob-1.1/weboob/applications/qboobmsg/000077500000000000000000000000001265717027300204165ustar00rootroot00000000000000weboob-1.1/weboob/applications/qboobmsg/__init__.py000066400000000000000000000000671265717027300225320ustar00rootroot00000000000000from .qboobmsg import QBoobMsg __all__ = ['QBoobMsg'] weboob-1.1/weboob/applications/qboobmsg/main_window.py000066400000000000000000000035771265717027300233170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtCore import SIGNAL from weboob.tools.application.qt import QtMainWindow from weboob.tools.application.qt.backendcfg import BackendCfg from weboob.capabilities.messages import CapMessages from .ui.main_window_ui import Ui_MainWindow from .messages_manager import MessagesManager class MainWindow(QtMainWindow): def __init__(self, config, weboob, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.weboob = weboob self.manager = MessagesManager(weboob, self) self.setCentralWidget(self.manager) self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) self.connect(self.ui.actionRefresh, SIGNAL("triggered()"), self.refresh) if self.weboob.count_backends() == 0: self.backendsConfig() else: self.centralWidget().load() def backendsConfig(self): bckndcfg = BackendCfg(self.weboob, (CapMessages,), self) if bckndcfg.run(): self.centralWidget().load() def refresh(self): self.centralWidget().refreshThreads() weboob-1.1/weboob/applications/qboobmsg/messages_manager.py000066400000000000000000000246121265717027300242760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import time import logging from PyQt4.QtGui import QWidget, QTreeWidgetItem, QListWidgetItem, QMessageBox, QBrush from PyQt4.QtCore import SIGNAL, Qt from weboob.capabilities.messages import CapMessages, CapMessagesPost, Message from weboob.tools.application.qt import QtDo from weboob.tools.misc import to_unicode from .ui.messages_manager_ui import Ui_MessagesManager class MessagesManager(QWidget): def __init__(self, weboob, parent=None): QWidget.__init__(self, parent) self.ui = Ui_MessagesManager() self.ui.setupUi(self) self.weboob = weboob self.ui.backendsList.setCurrentRow(0) self.backend = None self.thread = None self.message = None self.ui.replyButton.setEnabled(False) self.ui.replyWidget.hide() self.connect(self.ui.backendsList, SIGNAL('itemSelectionChanged()'), self._backendChanged) self.connect(self.ui.threadsList, SIGNAL('itemSelectionChanged()'), self._threadChanged) self.connect(self.ui.messagesTree, SIGNAL('itemClicked(QTreeWidgetItem *, int)'), self._messageSelected) self.connect(self.ui.messagesTree, SIGNAL('itemActivated(QTreeWidgetItem *, int)'), self._messageSelected) self.connect(self.ui.profileButton, SIGNAL('clicked()'), self._profilePressed) self.connect(self.ui.replyButton, SIGNAL('clicked()'), self._replyPressed) self.connect(self.ui.sendButton, SIGNAL('clicked()'), self._sendPressed) def load(self): self.ui.backendsList.clear() self.ui.backendsList.addItem('(All)') for backend in self.weboob.iter_backends(): if not backend.has_caps(CapMessages): continue item = QListWidgetItem(backend.name.capitalize()) item.setData(Qt.UserRole, backend) self.ui.backendsList.addItem(item) self.refreshThreads() def _backendChanged(self): selection = self.ui.backendsList.selectedItems() if not selection: self.backend = None return self.backend = selection[0].data(Qt.UserRole).toPyObject() self.refreshThreads() def refreshThreads(self): self.ui.messagesTree.clear() self.ui.threadsList.clear() self.hideReply() self.ui.profileButton.hide() self.ui.replyButton.setEnabled(False) self.ui.backendsList.setEnabled(False) self.ui.threadsList.setEnabled(False) self.process_threads = QtDo(self.weboob, self._gotThread, fb=self._gotThreadsEnd) self.process_threads.do('iter_threads', backends=self.backend, caps=CapMessages) def _gotThreadsEnd(self): self.process_threads = None self.ui.backendsList.setEnabled(True) self.ui.threadsList.setEnabled(True) def _gotThread(self, thread): item = QListWidgetItem(thread.title) item.setData(Qt.UserRole, (thread.backend, thread.id)) self.ui.threadsList.addItem(item) def _threadChanged(self): self.ui.messagesTree.clear() selection = self.ui.threadsList.selectedItems() if not selection: return t = selection[0].data(Qt.UserRole).toPyObject() self.refreshThreadMessages(*t) def refreshThreadMessages(self, backend, id): self.ui.messagesTree.clear() self.ui.messageBody.clear() self.ui.backendsList.setEnabled(False) self.ui.threadsList.setEnabled(False) self.ui.replyButton.setEnabled(False) self.ui.profileButton.hide() self.hideReply() self.process = QtDo(self.weboob, self._gotThreadMessages, fb=self._gotThreadMessagesEnd) self.process.do('get_thread', id, backends=backend) def _gotThreadMessagesEnd(self): self.ui.backendsList.setEnabled(True) self.ui.threadsList.setEnabled(True) self.process = None def _gotThreadMessages(self, thread): self.thread = thread if thread.flags & thread.IS_THREADS: top = self.ui.messagesTree.invisibleRootItem() else: top = None self._insert_message(thread.root, top) self.showMessage(thread.root) self.ui.messagesTree.expandAll() def _insert_message(self, message, top): item = QTreeWidgetItem(None, [message.title or '', message.sender or 'Unknown', time.strftime('%Y-%m-%d %H:%M:%S', message.date.timetuple())]) item.setData(0, Qt.UserRole, message) if message.flags & message.IS_UNREAD: item.setForeground(0, QBrush(Qt.darkYellow)) item.setForeground(1, QBrush(Qt.darkYellow)) item.setForeground(2, QBrush(Qt.darkYellow)) if top is not None: # threads top.addChild(item) else: # discussion self.ui.messagesTree.invisibleRootItem().insertChild(0, item) if message.children is not None: for child in message.children: self._insert_message(child, top and item) def _messageSelected(self, item, column): message = item.data(0, Qt.UserRole).toPyObject() self.showMessage(message, item) def showMessage(self, message, item=None): backend = self.weboob.get_backend(message.thread.backend) if backend.has_caps(CapMessagesPost): self.ui.replyButton.setEnabled(True) self.message = message if message.title.startswith('Re:'): self.ui.titleEdit.setText(message.title) else: self.ui.titleEdit.setText('Re: %s' % message.title) if message.flags & message.IS_HTML: content = message.content else: content = message.content.replace('&', '&').replace('<', '<').replace('>', '>').replace('\n', '
') extra = u'' if message.flags & message.IS_NOT_RECEIVED: extra += u'Status: Unread
' elif message.flags & message.IS_RECEIVED: extra += u'Status: Read
' elif message.flags & message.IS_UNREAD: extra += u'Status: New
' self.ui.messageBody.setText("

%s

" "Date: %s
" "From: %s
" "%s" "

%s

" % (message.title, str(message.date), message.sender, extra, content)) if item and message.flags & message.IS_UNREAD: backend.set_message_read(message) message.flags &= ~message.IS_UNREAD item.setForeground(0, QBrush()) item.setForeground(1, QBrush()) item.setForeground(2, QBrush()) if message.thread.flags & message.thread.IS_DISCUSSION: self.ui.profileButton.show() else: self.ui.profileButton.hide() def _profilePressed(self): print(self.thread.id) self.emit(SIGNAL('display_contact'), self.thread.id) def displayReply(self): self.ui.replyButton.setText(self.tr('Cancel')) self.ui.replyWidget.show() def hideReply(self): self.ui.replyButton.setText(self.tr('Reply')) self.ui.replyWidget.hide() self.ui.replyEdit.clear() self.ui.titleEdit.clear() def _replyPressed(self): if self.ui.replyWidget.isVisible(): self.hideReply() else: self.displayReply() def _sendPressed(self): if not self.ui.replyWidget.isVisible(): return text = unicode(self.ui.replyEdit.toPlainText()) title = unicode(self.ui.titleEdit.text()) self.ui.backendsList.setEnabled(False) self.ui.threadsList.setEnabled(False) self.ui.messagesTree.setEnabled(False) self.ui.replyButton.setEnabled(False) self.ui.replyWidget.setEnabled(False) self.ui.sendButton.setText(self.tr('Sending...')) flags = 0 if self.ui.htmlBox.currentIndex() == 0: flags = Message.IS_HTML m = Message(thread=self.thread, id=0, title=title, sender=None, receivers=None, content=text, parent=self.message, flags=flags) self.process_reply = QtDo(self.weboob, None, self._postReply_eb, self._postReply_fb) self.process_reply.do('post_message', m, backends=self.thread.backend) def _postReply_fb(self): self.ui.backendsList.setEnabled(True) self.ui.threadsList.setEnabled(True) self.ui.messagesTree.setEnabled(True) self.ui.replyButton.setEnabled(True) self.ui.replyWidget.setEnabled(True) self.ui.sendButton.setEnabled(True) self.ui.sendButton.setText(self.tr('Send')) self.hideReply() self.process_reply = None self.refreshThreadMessages(self.thread.backend, self.thread.id) def _postReply_eb(self, backend, error, backtrace): content = unicode(self.tr('Unable to send message:\n%s\n')) % to_unicode(error) if logging.root.level <= logging.DEBUG: content += '\n%s\n' % to_unicode(backtrace) QMessageBox.critical(self, self.tr('Error while posting reply'), content, QMessageBox.Ok) self.ui.backendsList.setEnabled(True) self.ui.threadsList.setEnabled(True) self.ui.messagesTree.setEnabled(True) self.ui.replyButton.setEnabled(True) self.ui.replyWidget.setEnabled(True) self.ui.sendButton.setText(self.tr('Send')) self.process_reply = None weboob-1.1/weboob/applications/qboobmsg/qboobmsg.py000066400000000000000000000026201265717027300226010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.messages import CapMessages from weboob.tools.application.qt import QtApplication from .main_window import MainWindow class QBoobMsg(QtApplication): APPNAME = 'qboobmsg' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' DESCRIPTION = "Qt application allowing to read messages on various websites and reply to them." SHORT_DESCRIPTION = "send and receive message threads" CAPS = CapMessages def main(self, argv): self.load_backends(CapMessages, storage=self.create_storage()) self.main_window = MainWindow(self.config, self.weboob) self.main_window.show() return self.weboob.loop() weboob-1.1/weboob/applications/qboobmsg/ui/000077500000000000000000000000001265717027300210335ustar00rootroot00000000000000weboob-1.1/weboob/applications/qboobmsg/ui/Makefile000066400000000000000000000002651265717027300224760ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/applications/qboobmsg/ui/__init__.py000066400000000000000000000000001265717027300231320ustar00rootroot00000000000000weboob-1.1/weboob/applications/qboobmsg/ui/main_window.ui000066400000000000000000000043061265717027300237100ustar00rootroot00000000000000 MainWindow 0 0 763 580 QBoobMsg 0 0 763 20 File toolBar TopToolBarArea false Backends Quit Quit Ctrl+Q Refresh actionQuit triggered() MainWindow close() -1 -1 381 289 weboob-1.1/weboob/applications/qboobmsg/ui/messages_manager.ui000066400000000000000000000212041265717027300246720ustar00rootroot00000000000000 MessagesManager 0 0 696 591 Qt::Horizontal 0 0 150 16777215 Qt::Horizontal Qt::Vertical 0 0 5 0 QFrame::StyledPanel QFrame::Raised 9 2 9 2 0 0 + 0 0 Qt::Horizontal 40 20 QAbstractItemView::NoEditTriggers true true true true 150 true Title From Date Qt::Vertical 0 5 true Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse QFrame::StyledPanel QFrame::Raised Profile Reply 0 With HTML Without HTML Send expandButton clicked() messagesTree expandAll() 733 31 527 150 collapseButton clicked() messagesTree collapseAll() 733 60 527 150 weboob-1.1/weboob/applications/qcineoob/000077500000000000000000000000001265717027300204045ustar00rootroot00000000000000weboob-1.1/weboob/applications/qcineoob/__init__.py000066400000000000000000000000671265717027300225200ustar00rootroot00000000000000from .qcineoob import QCineoob __all__ = ['QCineoob'] weboob-1.1/weboob/applications/qcineoob/main_window.py000066400000000000000000000574211265717027300233020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import os import codecs from PyQt4.QtCore import SIGNAL, Qt, QStringList from PyQt4.QtGui import QApplication, QCompleter, QFrame, QShortcut, QKeySequence from weboob.capabilities.base import NotAvailable from weboob.capabilities.cinema import CapCinema from weboob.capabilities.torrent import CapTorrent from weboob.capabilities.subtitle import CapSubtitle from weboob.tools.application.qt import QtMainWindow, QtDo from weboob.tools.application.qt.backendcfg import BackendCfg from weboob.applications.suboob.suboob import LANGUAGE_CONV from weboob.applications.qcineoob.ui.main_window_ui import Ui_MainWindow from weboob.applications.qcineoob.ui.result_ui import Ui_Result from .minimovie import MiniMovie from .miniperson import MiniPerson from .minitorrent import MiniTorrent from .minisubtitle import MiniSubtitle from .movie import Movie from .person import Person from .torrent import Torrent from .subtitle import Subtitle class Result(QFrame): def __init__(self, weboob, app, parent=None): QFrame.__init__(self, parent) self.ui = Ui_Result() self.ui.setupUi(self) self.parent = parent self.weboob = weboob self.app = app self.minis = [] self.current_info_widget = None # action history is composed by the last action and the action list # An action is a function, a list of arguments and a description string self.action_history = {'last_action': None, 'action_list': []} self.connect(self.ui.backButton, SIGNAL("clicked()"), self.doBack) self.ui.backButton.hide() def doAction(self, description, fun, args): ''' Call fun with args as arguments and save it in the action history ''' self.ui.currentActionLabel.setText(description) if self.action_history['last_action'] is not None: self.action_history['action_list'].append(self.action_history['last_action']) self.ui.backButton.setToolTip(self.action_history['last_action']['description']) self.ui.backButton.show() self.action_history['last_action'] = {'function': fun, 'args': args, 'description': description} return fun(*args) def doBack(self): ''' Go back in action history Basically call previous function and update history ''' if len(self.action_history['action_list']) > 0: todo = self.action_history['action_list'].pop() self.ui.currentActionLabel.setText(todo['description']) self.action_history['last_action'] = todo if len(self.action_history['action_list']) == 0: self.ui.backButton.hide() else: self.ui.backButton.setToolTip(self.action_history['action_list'][-1]['description']) return todo['function'](*todo['args']) def castingAction(self, backend_name, id, role): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) self.process = QtDo(self.weboob, self.addPerson, fb=self.processFinished) self.process.do('iter_movie_persons', id, role, backends=backend_name, caps=CapCinema) self.parent.ui.stopButton.show() def moviesInCommonAction(self, backend_name, id1, id2): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) for a_backend in self.weboob.iter_backends(): if (backend_name and a_backend.name == backend_name): backend = a_backend person1 = backend.get_person(id1) person2 = backend.get_person(id2) lid1 = [] for p in backend.iter_person_movies_ids(id1): lid1.append(p) lid2 = [] for p in backend.iter_person_movies_ids(id2): lid2.append(p) inter = list(set(lid1) & set(lid2)) chrono_list = [] for common in inter: movie = backend.get_movie(common) movie.backend = backend_name role1 = movie.get_roles_by_person_id(person1.id) role2 = movie.get_roles_by_person_id(person2.id) if (movie.release_date != NotAvailable): year = movie.release_date.year else: year = '????' movie.short_description = '(%s) %s as %s ; %s as %s'%(year , person1.name, ', '.join(role1), person2.name, ', '.join(role2)) i = 0 while (i chrono_list[i].release_date.year)): i += 1 chrono_list.insert(i, movie) for movie in chrono_list: self.addMovie(movie) self.processFinished() def personsInCommonAction(self, backend_name, id1, id2): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) for a_backend in self.weboob.iter_backends(): if (backend_name and a_backend.name == backend_name): backend = a_backend movie1 = backend.get_movie(id1) movie2 = backend.get_movie(id2) lid1 = [] for p in backend.iter_movie_persons_ids(id1): lid1.append(p) lid2 = [] for p in backend.iter_movie_persons_ids(id2): lid2.append(p) inter = list(set(lid1) & set(lid2)) for common in inter: person = backend.get_person(common) person.backend = backend_name role1 = movie1.get_roles_by_person_id(person.id) role2 = movie2.get_roles_by_person_id(person.id) person.short_description = '%s in %s ; %s in %s'%(', '.join(role1), movie1.original_title, ', '.join(role2), movie2.original_title) self.addPerson(person) self.processFinished() def filmographyAction(self, backend_name, id, role): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) self.process = QtDo(self.weboob, self.addMovie, fb=self.processFinished) self.process.do('iter_person_movies', id, role, backends=backend_name, caps=CapCinema) self.parent.ui.stopButton.show() def search(self, tosearch, pattern, lang): if tosearch == 'person': self.searchPerson(pattern) elif tosearch == 'movie': self.searchMovie(pattern) elif tosearch == 'torrent': self.searchTorrent(pattern) elif tosearch == 'subtitle': self.searchSubtitle(lang, pattern) def searchMovie(self, pattern): if not pattern: return self.doAction(u'Search movie "%s"' % pattern, self.searchMovieAction, [pattern]) def searchMovieAction(self, pattern): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString()) self.process = QtDo(self.weboob, self.addMovie, fb=self.processFinished) #self.process.do('iter_movies', pattern, backends=backend_name, caps=CapCinema) self.process.do(self.app._do_complete, self.parent.getCount(), ('original_title'), 'iter_movies', pattern, backends=backend_name, caps=CapCinema) self.parent.ui.stopButton.show() def stopProcess(self): self.process.process.finish_event.set() def addMovie(self, movie): minimovie = MiniMovie(self.weboob, self.weboob[movie.backend], movie, self) self.ui.list_content.layout().insertWidget(self.ui.list_content.layout().count()-1,minimovie) self.minis.append(minimovie) def displayMovie(self, movie, backend): self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) if self.current_info_widget is not None: self.ui.info_content.layout().removeWidget(self.current_info_widget) self.current_info_widget.hide() self.current_info_widget.deleteLater() wmovie = Movie(movie, backend, self) self.ui.info_content.layout().addWidget(wmovie) self.current_info_widget = wmovie QApplication.restoreOverrideCursor() def searchPerson(self, pattern): if not pattern: return self.doAction(u'Search person "%s"' % pattern, self.searchPersonAction, [pattern]) def searchPersonAction(self, pattern): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString()) self.process = QtDo(self.weboob, self.addPerson, fb=self.processFinished) #self.process.do('iter_persons', pattern, backends=backend_name, caps=CapCinema) self.process.do(self.app._do_complete, self.parent.getCount(), ('name'), 'iter_persons', pattern, backends=backend_name, caps=CapCinema) self.parent.ui.stopButton.show() def addPerson(self, person): miniperson = MiniPerson(self.weboob, self.weboob[person.backend], person, self) self.ui.list_content.layout().insertWidget(self.ui.list_content.layout().count()-1,miniperson) self.minis.append(miniperson) def displayPerson(self, person, backend): self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) if self.current_info_widget is not None: self.ui.info_content.layout().removeWidget(self.current_info_widget) self.current_info_widget.hide() self.current_info_widget.deleteLater() wperson = Person(person, backend, self) self.ui.info_content.layout().addWidget(wperson) self.current_info_widget = wperson QApplication.restoreOverrideCursor() def searchTorrent(self, pattern): if not pattern: return self.doAction(u'Search torrent "%s"' % pattern, self.searchTorrentAction, [pattern]) def searchTorrentAction(self, pattern): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString()) self.process = QtDo(self.weboob, self.addTorrent, fb=self.processFinished) #self.process.do('iter_torrents', pattern, backends=backend_name, caps=CapTorrent) self.process.do(self.app._do_complete, self.parent.getCount(), ('name'), 'iter_torrents', pattern, backends=backend_name, caps=CapTorrent) self.parent.ui.stopButton.show() def processFinished(self): self.parent.ui.searchEdit.setEnabled(True) QApplication.restoreOverrideCursor() self.process = None self.parent.ui.stopButton.hide() def addTorrent(self, torrent): minitorrent = MiniTorrent(self.weboob, self.weboob[torrent.backend], torrent, self) self.ui.list_content.layout().insertWidget(self.ui.list_content.layout().count()-1,minitorrent) self.minis.append(minitorrent) def displayTorrent(self, torrent, backend): self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) if self.current_info_widget is not None: self.ui.info_content.layout().removeWidget(self.current_info_widget) self.current_info_widget.hide() self.current_info_widget.deleteLater() wtorrent = Torrent(torrent, backend, self) self.ui.info_content.layout().addWidget(wtorrent) self.current_info_widget = wtorrent def searchSubtitle(self, lang, pattern): if not pattern: return self.doAction(u'Search subtitle "%s" (lang:%s)' % (pattern, lang), self.searchSubtitleAction, [lang, pattern]) def searchSubtitleAction(self, lang, pattern): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString()) self.process = QtDo(self.weboob, self.addSubtitle, fb=self.processFinished) #self.process.do('iter_subtitles', lang, pattern, backends=backend_name, caps=CapSubtitle) self.process.do(self.app._do_complete, self.parent.getCount(), ('name'), 'iter_subtitles', lang, pattern, backends=backend_name, caps=CapSubtitle) self.parent.ui.stopButton.show() def addSubtitle(self, subtitle): minisubtitle = MiniSubtitle(self.weboob, self.weboob[subtitle.backend], subtitle, self) self.ui.list_content.layout().insertWidget(self.ui.list_content.layout().count()-1,minisubtitle) self.minis.append(minisubtitle) def displaySubtitle(self, subtitle, backend): self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) if self.current_info_widget is not None: self.ui.info_content.layout().removeWidget(self.current_info_widget) self.current_info_widget.hide() self.current_info_widget.deleteLater() wsubtitle = Subtitle(subtitle, backend, self) self.ui.info_content.layout().addWidget(wsubtitle) self.current_info_widget = wsubtitle def searchId(self, id, stype): QApplication.setOverrideCursor(Qt.WaitCursor) title_field = 'name' if stype == 'movie': cap = CapCinema title_field = 'original_title' elif stype == 'person': cap = CapCinema elif stype == 'torrent': cap = CapTorrent elif stype == 'subtitle': cap = CapSubtitle if '@' in id: backend_name = id.split('@')[1] id = id.split('@')[0] else: backend_name = None for backend in self.weboob.iter_backends(): if backend.has_caps(cap) and ((backend_name and backend.name == backend_name) or not backend_name): exec('object = backend.get_%s(id)' % (stype)) if object: func_display = 'self.display' + stype[0].upper() + stype[1:] exec("self.doAction('Details of %s \"%%s\"' %% object.%s, %s, [object, backend])" % (stype, title_field, func_display)) QApplication.restoreOverrideCursor() class MainWindow(QtMainWindow): def __init__(self, config, weboob, app, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.weboob = weboob self.app = app # search history is a list of patterns which have been searched self.search_history = self.loadSearchHistory() self.updateCompletion() self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search) self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId) self.connect(self.ui.typeCombo, SIGNAL("currentIndexChanged(QString)"), self.typeComboChanged) count = self.config.get('settings', 'maxresultsnumber') self.ui.countSpin.setValue(int(count)) showT = self.config.get('settings', 'showthumbnails') self.ui.showTCheck.setChecked(showT == '1') self.connect(self.ui.stopButton, SIGNAL("clicked()"), self.stopProcess) self.ui.stopButton.hide() self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) q = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self) self.connect(q, SIGNAL("activated()"), self.close) n = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageDown), self) self.connect(n, SIGNAL("activated()"), self.nextTab) p = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageUp), self) self.connect(p, SIGNAL("activated()"), self.prevTab) w = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self) self.connect(w, SIGNAL("activated()"), self.closeCurrentTab) l = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_L), self) self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.setFocus) self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.selectAll) self.connect(self.ui.resultsTab, SIGNAL("tabCloseRequested(int)"), self.closeTab) self.loadBackendsList() if self.ui.backendEdit.count() == 0: self.backendsConfig() langs = sorted(LANGUAGE_CONV.keys()) for lang in langs: self.ui.langCombo.addItem(lang) self.ui.langCombo.hide() self.ui.langLabel.hide() def stopProcess(self): self.ui.resultsTab.currentWidget().stopProcess() def closeTab(self, index): if self.ui.resultsTab.widget(index) != 0: tabToClose = self.ui.resultsTab.widget(index) self.ui.resultsTab.removeTab(index) del(tabToClose) def closeCurrentTab(self): self.closeTab(self.ui.resultsTab.currentIndex()) def prevTab(self): index = self.ui.resultsTab.currentIndex() - 1 size = self.ui.resultsTab.count() if size != 0: self.ui.resultsTab.setCurrentIndex(index % size) def nextTab(self): index = self.ui.resultsTab.currentIndex() + 1 size = self.ui.resultsTab.count() if size != 0: self.ui.resultsTab.setCurrentIndex(index % size) def newTab(self, txt, backend, person=None, movie=None, torrent=None, subtitle=None): id = '' if person is not None: id = person.id stype = 'person' elif movie is not None: id = movie.id stype = 'movie' elif subtitle is not None: id = subtitle.id stype = 'subtitle' elif torrent is not None: id = torrent.id stype = 'torrent' new_res = Result(self.weboob, self.app, self) self.ui.resultsTab.addTab(new_res, txt) new_res.searchId(id, stype) def search(self): pattern = unicode(self.ui.searchEdit.text()) # arbitrary max number of completion word if len(self.search_history) > 50: self.search_history.pop(0) if pattern not in self.search_history: self.search_history.append(pattern) self.updateCompletion() tosearch = unicode(self.ui.typeCombo.currentText()) lang = unicode(self.ui.langCombo.currentText()) new_res = Result(self.weboob, self.app, self) self.ui.resultsTab.addTab(new_res, pattern) self.ui.resultsTab.setCurrentWidget(new_res) new_res.search(tosearch, pattern, lang) def searchId(self): id = unicode(self.ui.idEdit.text()) stype = unicode(self.ui.idTypeCombo.currentText()) new_res = Result(self.weboob, self.app, self) self.ui.resultsTab.addTab(new_res, id) self.ui.resultsTab.setCurrentWidget(new_res) new_res.searchId(id, stype) def backendsConfig(self): bckndcfg = BackendCfg(self.weboob, (CapCinema, CapTorrent, CapSubtitle,), self) if bckndcfg.run(): self.loadBackendsList() def loadBackendsList(self): self.ui.backendEdit.clear() for i, backend in enumerate(self.weboob.iter_backends()): if i == 0: self.ui.backendEdit.addItem('All backends', '') self.ui.backendEdit.addItem(backend.name, backend.name) if backend.name == self.config.get('settings', 'backend'): self.ui.backendEdit.setCurrentIndex(i+1) if self.ui.backendEdit.count() == 0: self.ui.searchEdit.setEnabled(False) else: self.ui.searchEdit.setEnabled(True) def loadSearchHistory(self): ''' Return search string history list loaded from history file ''' result = [] history_path = os.path.join(self.weboob.workdir, 'qcineoob_history') if os.path.exists(history_path): f = codecs.open(history_path, 'r', 'utf-8') conf_hist = f.read() f.close() if conf_hist is not None and conf_hist.strip() != '': result = conf_hist.strip().split('\n') return result def saveSearchHistory(self): ''' Save search history in history file ''' if len(self.search_history) > 0: history_path = os.path.join(self.weboob.workdir, 'qcineoob_history') f = codecs.open(history_path, 'w', 'utf-8') f.write('\n'.join(self.search_history)) f.close() def updateCompletion(self): qc = QCompleter(QStringList(self.search_history), self) qc.setCaseSensitivity(Qt.CaseInsensitive) self.ui.searchEdit.setCompleter(qc) def typeComboChanged(self, value): if unicode(value) == 'subtitle': self.ui.langCombo.show() self.ui.langLabel.show() else: self.ui.langCombo.hide() self.ui.langLabel.hide() def getCount(self): num = self.ui.countSpin.value() if num == 0: return None else: return num def closeEvent(self, ev): self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData( self.ui.backendEdit.currentIndex()).toString())) self.saveSearchHistory() self.config.set('settings', 'maxresultsnumber', self.ui.countSpin.value()) self.config.set('settings', 'showthumbnails', '1' if self.ui.showTCheck.isChecked() else '0') self.config.save() ev.accept() weboob-1.1/weboob/applications/qcineoob/minimovie.py000066400000000000000000000062711265717027300227600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication from PyQt4.QtCore import Qt, SIGNAL from weboob.applications.qcineoob.ui.minimovie_ui import Ui_MiniMovie from weboob.capabilities.base import empty, NotAvailable class MiniMovie(QFrame): def __init__(self, weboob, backend, movie, parent=None): QFrame.__init__(self, parent) self.parent = parent self.ui = Ui_MiniMovie() self.ui.setupUi(self) self.weboob = weboob self.backend = backend self.movie = movie self.ui.titleLabel.setText(movie.original_title) self.ui.shortDescLabel.setText(movie.short_description) self.ui.backendLabel.setText(backend.name) self.connect(self.ui.newTabButton, SIGNAL("clicked()"), self.newTabPressed) self.connect(self.ui.viewButton, SIGNAL("clicked()"), self.viewPressed) self.connect(self.ui.viewThumbnailButton, SIGNAL("clicked()"), self.gotThumbnail) if self.parent.parent.ui.showTCheck.isChecked(): self.gotThumbnail() def gotThumbnail(self): if empty(self.movie.thumbnail_url) and self.movie.thumbnail_url != NotAvailable: self.backend.fill_movie(self.movie, ('thumbnail_url')) if not empty(self.movie.thumbnail_url): data = urllib.urlopen(self.movie.thumbnail_url).read() img = QImage.fromData(data) self.ui.imageLabel.setPixmap(QPixmap.fromImage(img).scaledToHeight(100,Qt.SmoothTransformation)) def viewPressed(self): QApplication.setOverrideCursor(Qt.WaitCursor) movie = self.backend.get_movie(self.movie.id) if movie: self.parent.doAction('Details of movie "%s"' % movie.original_title, self.parent.displayMovie, [movie, self.backend]) def newTabPressed(self): movie = self.backend.get_movie(self.movie.id) self.parent.parent.newTab(u'Details of movie "%s"' % movie.original_title, self.backend, movie=movie) def enterEvent(self, event): self.setFrameShadow(self.Sunken) QFrame.enterEvent(self, event) def leaveEvent(self, event): self.setFrameShadow(self.Raised) QFrame.leaveEvent(self, event) def mousePressEvent(self, event): QFrame.mousePressEvent(self, event) if event.button() == 2: self.gotThumbnail() elif event.button() == 4: self.newTabPressed() else: self.viewPressed() weboob-1.1/weboob/applications/qcineoob/miniperson.py000066400000000000000000000067671265717027300231610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication from PyQt4.QtCore import Qt, SIGNAL from weboob.applications.qcineoob.ui.miniperson_ui import Ui_MiniPerson from weboob.capabilities.base import empty, NotAvailable class MiniPerson(QFrame): def __init__(self, weboob, backend, person, parent=None): QFrame.__init__(self, parent) self.parent = parent self.ui = Ui_MiniPerson() self.ui.setupUi(self) self.weboob = weboob self.backend = backend self.person = person self.ui.nameLabel.setText('%s' % person.name) if not empty(person.short_description): if unicode(self.parent.ui.currentActionLabel.text()).startswith('Casting'): self.ui.shortDescTitleLabel.setText(u'Role') self.ui.shortDescLabel.setText('%s' % person.short_description) else: self.ui.shortDescTitleLabel.hide() self.ui.shortDescLabel.hide() self.ui.backendLabel.setText(backend.name) self.connect(self.ui.newTabButton, SIGNAL("clicked()"), self.newTabPressed) self.connect(self.ui.viewButton, SIGNAL("clicked()"), self.viewPressed) self.connect(self.ui.viewThumbnailButton, SIGNAL("clicked()"), self.gotThumbnail) if self.parent.parent.ui.showTCheck.isChecked(): self.gotThumbnail() def gotThumbnail(self): if empty(self.person.thumbnail_url) and self.person.thumbnail_url != NotAvailable: self.backend.fill_person(self.person, ('thumbnail_url')) if not empty(self.person.thumbnail_url): data = urllib.urlopen(self.person.thumbnail_url).read() img = QImage.fromData(data) self.ui.imageLabel.setPixmap(QPixmap.fromImage(img).scaledToHeight(100,Qt.SmoothTransformation)) def viewPressed(self): QApplication.setOverrideCursor(Qt.WaitCursor) person = self.backend.get_person(self.person.id) if person: self.parent.doAction(u'Details of person "%s"' % person.name, self.parent.displayPerson, [person, self.backend]) def newTabPressed(self): person = self.backend.get_person(self.person.id) self.parent.parent.newTab(u'Details of person "%s"' % person.name, self.backend, person=person) def enterEvent(self, event): self.setFrameShadow(self.Sunken) QFrame.enterEvent(self, event) def leaveEvent(self, event): self.setFrameShadow(self.Raised) QFrame.leaveEvent(self, event) def mousePressEvent(self, event): QFrame.mousePressEvent(self, event) if event.button() == 2: self.gotThumbnail() elif event.button() == 4: self.newTabPressed() else: self.viewPressed() weboob-1.1/weboob/applications/qcineoob/minisubtitle.py000066400000000000000000000047261265717027300234770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QFrame from PyQt4.QtCore import SIGNAL from weboob.applications.qcineoob.ui.minisubtitle_ui import Ui_MiniSubtitle from weboob.capabilities.base import empty class MiniSubtitle(QFrame): def __init__(self, weboob, backend, subtitle, parent=None): QFrame.__init__(self, parent) self.parent = parent self.ui = Ui_MiniSubtitle() self.ui.setupUi(self) self.weboob = weboob self.backend = backend self.subtitle = subtitle self.ui.nameLabel.setText(subtitle.name) if not empty(subtitle.nb_cd): self.ui.nbcdLabel.setText(u'%s' % subtitle.nb_cd) self.ui.backendLabel.setText(backend.name) self.connect(self.ui.newTabButton, SIGNAL("clicked()"), self.newTabPressed) self.connect(self.ui.viewButton, SIGNAL("clicked()"), self.viewPressed) def viewPressed(self): subtitle = self.backend.get_subtitle(self.subtitle.id) if subtitle: self.parent.doAction('Details of subtitle "%s"' % subtitle.name, self.parent.displaySubtitle, [subtitle, self.backend]) def newTabPressed(self): subtitle = self.backend.get_subtitle(self.subtitle.id) self.parent.parent.newTab(u'Details of subtitle "%s"' % subtitle.name, self.backend, subtitle=subtitle) def enterEvent(self, event): self.setFrameShadow(self.Sunken) QFrame.enterEvent(self, event) def leaveEvent(self, event): self.setFrameShadow(self.Raised) QFrame.leaveEvent(self, event) def mousePressEvent(self, event): QFrame.mousePressEvent(self, event) if event.button() == 4: self.newTabPressed() else: self.viewPressed() weboob-1.1/weboob/applications/qcineoob/minitorrent.py000066400000000000000000000052531265717027300233350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QFrame from PyQt4.QtCore import SIGNAL from weboob.applications.qcineoob.ui.minitorrent_ui import Ui_MiniTorrent from weboob.applications.weboorrents.weboorrents import sizeof_fmt from weboob.capabilities.base import empty class MiniTorrent(QFrame): def __init__(self, weboob, backend, torrent, parent=None): QFrame.__init__(self, parent) self.parent = parent self.ui = Ui_MiniTorrent() self.ui.setupUi(self) self.weboob = weboob self.backend = backend self.torrent = torrent self.ui.nameLabel.setText(torrent.name) if not empty(torrent.seeders) and not empty(torrent.leechers): self.ui.seedLeechLabel.setText('%s/%s' % (torrent.seeders, torrent.leechers)) if not empty(torrent.size): self.ui.sizeLabel.setText(u'%s' % sizeof_fmt(torrent.size)) self.ui.backendLabel.setText(backend.name) self.connect(self.ui.newTabButton, SIGNAL("clicked()"), self.newTabPressed) self.connect(self.ui.viewButton, SIGNAL("clicked()"), self.viewPressed) def viewPressed(self): torrent = self.backend.get_torrent(self.torrent.id) if torrent: self.parent.doAction('Details of torrent "%s"' % torrent.name, self.parent.displayTorrent, [torrent, self.backend]) def newTabPressed(self): torrent = self.backend.get_torrent(self.torrent.id) self.parent.parent.newTab(u'Details of torrent "%s"' % torrent.name, self.backend, torrent=torrent) def enterEvent(self, event): self.setFrameShadow(self.Sunken) QFrame.enterEvent(self, event) def leaveEvent(self, event): self.setFrameShadow(self.Raised) QFrame.leaveEvent(self, event) def mousePressEvent(self, event): QFrame.mousePressEvent(self, event) if event.button() == 4: self.newTabPressed() else: self.viewPressed() weboob-1.1/weboob/applications/qcineoob/movie.py000066400000000000000000000136421265717027300221030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from PyQt4.QtCore import Qt, SIGNAL from PyQt4.QtGui import QFrame, QImage, QPixmap, QMessageBox from weboob.applications.qcineoob.ui.movie_ui import Ui_Movie from weboob.capabilities.base import empty from weboob.applications.suboob.suboob import LANGUAGE_CONV class Movie(QFrame): def __init__(self, movie, backend, parent=None): QFrame.__init__(self, parent) self.parent = parent self.ui = Ui_Movie() self.ui.setupUi(self) langs = sorted(LANGUAGE_CONV.keys()) for lang in langs: self.ui.langCombo.addItem(lang) self.connect(self.ui.castingButton, SIGNAL("clicked()"), self.casting) self.connect(self.ui.torrentButton, SIGNAL("clicked()"), self.searchTorrent) self.connect(self.ui.subtitleButton, SIGNAL("clicked()"), self.searchSubtitle) self.connect(self.ui.personsInCommonButton, SIGNAL("clicked()"), self.personsInCommon) self.movie = movie self.backend = backend self.ui.titleLabel.setText(movie.original_title) self.ui.durationLabel.setText(unicode(movie.duration)) self.gotThumbnail() self.putReleases() self.ui.idEdit.setText(u'%s@%s' % (movie.id, backend.name)) if not empty(movie.other_titles): self.ui.otherTitlesPlain.setPlainText('\n'.join(movie.other_titles)) else: self.ui.otherTitlesPlain.parent().hide() if not empty(movie.genres): genres = u'' for g in movie.genres: genres += '%s, ' % g genres = genres[:-2] self.ui.genresLabel.setText(genres) else: self.ui.genresLabel.parent().hide() if not empty(movie.release_date): self.ui.releaseDateLabel.setText(movie.release_date.strftime('%Y-%m-%d')) else: self.ui.releaseDateLabel.parent().hide() if not empty(movie.duration): self.ui.durationLabel.setText('%s min' % movie.duration) else: self.ui.durationLabel.parent().hide() if not empty(movie.pitch): self.ui.pitchPlain.setPlainText('%s' % movie.pitch) else: self.ui.pitchPlain.parent().hide() if not empty(movie.country): self.ui.countryLabel.setText('%s' % movie.country) else: self.ui.countryLabel.parent().hide() if not empty(movie.note): self.ui.noteLabel.setText('%s' % movie.note) else: self.ui.noteLabel.parent().hide() for role in movie.roles.keys(): self.ui.castingCombo.addItem('%s' % role) self.ui.verticalLayout.setAlignment(Qt.AlignTop) self.ui.verticalLayout_2.setAlignment(Qt.AlignTop) def putReleases(self): rel = self.backend.get_movie_releases(self.movie.id) if not empty(rel): self.ui.allReleasesPlain.setPlainText(rel) else: self.ui.allReleasesPlain.parent().hide() def gotThumbnail(self): if not empty(self.movie.thumbnail_url): data = urllib.urlopen(self.movie.thumbnail_url).read() img = QImage.fromData(data) self.ui.imageLabel.setPixmap(QPixmap.fromImage(img).scaledToWidth(220,Qt.SmoothTransformation)) def searchSubtitle(self): tosearch = unicode(self.movie.original_title) lang = unicode(self.ui.langCombo.currentText()) desc = 'Search subtitles for "%s" (lang:%s)' % (tosearch, lang) self.parent.doAction(desc, self.parent.searchSubtitleAction, [lang, tosearch]) def searchTorrent(self): tosearch = self.movie.original_title if not empty(self.movie.release_date): tosearch += ' %s' % self.movie.release_date.year desc = 'Search torrents for "%s"' % tosearch self.parent.doAction(desc, self.parent.searchTorrentAction, [tosearch]) def casting(self): role = None tosearch = unicode(self.ui.castingCombo.currentText()) role_desc = '' if tosearch != 'all': role = tosearch role_desc = ' as %s' % role self.parent.doAction('Casting%s of movie "%s"' % (role_desc, self.movie.original_title), self.parent.castingAction, [self.backend.name, self.movie.id, role]) def personsInCommon(self): my_id = self.movie.id my_title = self.movie.original_title other_id = unicode(self.ui.personsInCommonEdit.text()).split('@')[0] other_movie = self.backend.get_movie(other_id) if other_id == self.movie.id: QMessageBox.critical(None, self.tr('"Persons in common" error'), unicode(self.tr('Nice try\nThe movies must be different')), QMessageBox.Ok) elif not other_movie: QMessageBox.critical(None, self.tr('"Persons in common" error'), unicode(self.tr('Movie not found: %s' % other_id)), QMessageBox.Ok) else: other_title = other_movie.original_title desc = 'Persons in common %s, %s'%(my_title, other_title) self.parent.doAction(desc, self.parent.personsInCommonAction, [self.backend.name, my_id, other_id]) weboob-1.1/weboob/applications/qcineoob/person.py000066400000000000000000000110541265717027300222650ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from PyQt4.QtCore import SIGNAL, Qt from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication, QMessageBox from weboob.applications.qcineoob.ui.person_ui import Ui_Person from weboob.capabilities.base import empty class Person(QFrame): def __init__(self, person, backend, parent=None): QFrame.__init__(self, parent) self.parent = parent self.ui = Ui_Person() self.ui.setupUi(self) self.connect(self.ui.filmographyButton, SIGNAL("clicked()"), self.filmography) self.connect(self.ui.biographyButton, SIGNAL("clicked()"), self.biography) self.connect(self.ui.moviesInCommonButton, SIGNAL("clicked()"), self.moviesInCommon) self.person = person self.backend = backend self.gotThumbnail() self.ui.nameLabel.setText(person.name) self.ui.idEdit.setText(u'%s@%s' % (person.id, backend.name)) if not empty(person.real_name): self.ui.realNameLabel.setText('%s' % person.real_name) else: self.ui.realNameLabel.parent().hide() if not empty(person.birth_place): self.ui.birthPlaceLabel.setText('%s' % person.birth_place) else: self.ui.birthPlaceLabel.parent().hide() if not empty(person.birth_date): self.ui.birthDateLabel.setText(person.birth_date.strftime('%Y-%m-%d')) else: self.ui.birthDateLabel.parent().hide() if not empty(person.death_date): self.ui.deathDateLabel.setText(person.death_date.strftime('%Y-%m-%d')) else: self.ui.deathDateLabel.parent().hide() self.ui.shortBioPlain.setPlainText('%s' % person.short_biography) for role in person.roles.keys(): self.ui.filmographyCombo.addItem(role) self.ui.verticalLayout_2.setAlignment(Qt.AlignTop) def gotThumbnail(self): if not empty(self.person.thumbnail_url): data = urllib.urlopen(self.person.thumbnail_url).read() img = QImage.fromData(data) self.ui.imageLabel.setPixmap(QPixmap.fromImage(img).scaledToWidth(220,Qt.SmoothTransformation)) def filmography(self): role = None tosearch = unicode(self.ui.filmographyCombo.currentText()) role_desc = '' if tosearch != 'all': role = tosearch role_desc = ' as %s' % role self.parent.doAction('Filmography of "%s"%s' % (self.person.name, role_desc), self.parent.filmographyAction, [self.backend.name, self.person.id, role]) def biography(self): QApplication.setOverrideCursor(Qt.WaitCursor) self.backend.fill_person(self.person, 'biography') bio = self.person.biography self.ui.shortBioPlain.setPlainText(u'%s' % bio) self.ui.biographyLabel.setText('Full biography:') self.ui.biographyButton.hide() QApplication.restoreOverrideCursor() def moviesInCommon(self): my_id = self.person.id my_name = self.person.name other_id = unicode(self.ui.moviesInCommonEdit.text()).split('@')[0] other_person = self.backend.get_person(other_id) if other_id == self.person.id: QMessageBox.critical(None, self.tr('"Moviess in common" error'), unicode(self.tr('Nice try\nThe persons must be different')), QMessageBox.Ok) elif not other_person: QMessageBox.critical(None, self.tr('"Movies in common" error'), unicode(self.tr('Person not found: %s' % other_id)), QMessageBox.Ok) else: other_name = other_person.name desc = 'Movies in common %s, %s'%(my_name, other_name) self.parent.doAction(desc, self.parent.moviesInCommonAction, [self.backend.name, my_id, other_id]) weboob-1.1/weboob/applications/qcineoob/qcineoob.py000066400000000000000000000033471265717027300225640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.cinema import CapCinema from weboob.capabilities.torrent import CapTorrent from weboob.capabilities.subtitle import CapSubtitle from weboob.tools.application.qt import QtApplication from .main_window import MainWindow class QCineoob(QtApplication): APPNAME = 'qcineoob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2013-YEAR Julien Veyssier' DESCRIPTION = "Qt application allowing to search movies, people, torrent and subtitles." SHORT_DESCRIPTION = "search movies, people, torrent and subtitles" CAPS = CapCinema, CapTorrent, CapSubtitle CONFIG = {'settings': {'backend': '', 'maxresultsnumber': '10', 'showthumbnails': '0' } } def main(self, argv): self.load_backends([CapCinema, CapTorrent, CapSubtitle]) self.load_config() self.main_window = MainWindow(self.config, self.weboob, self) self.main_window.show() return self.weboob.loop() weboob-1.1/weboob/applications/qcineoob/subtitle.py000066400000000000000000000065371265717027300226240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from PyQt4.QtCore import Qt, SIGNAL from PyQt4.QtGui import QFrame, QFileDialog from weboob.applications.qcineoob.ui.subtitle_ui import Ui_Subtitle from weboob.capabilities.base import empty class Subtitle(QFrame): def __init__(self, subtitle, backend, parent=None): QFrame.__init__(self, parent) self.parent = parent self.backend = backend self.ui = Ui_Subtitle() self.ui.setupUi(self) self.connect(self.ui.downloadButton, SIGNAL("clicked()"), self.download) self.subtitle = subtitle self.ui.idEdit.setText(u'%s@%s' % (subtitle.id, backend.name)) self.ui.nameLabel.setText(u'%s' % subtitle.name) if not empty(subtitle.nb_cd): self.ui.nbcdLabel.setText(u'%s' % subtitle.nb_cd) else: self.ui.nbcdLabel.parent().hide() if not empty(subtitle.language): self.ui.langLabel.setText(u'%s' % subtitle.language) else: self.ui.langLabel.parent().hide() if not empty(subtitle.description): self.ui.descriptionPlain.setPlainText(u'%s' % subtitle.description) else: self.ui.descriptionPlain.parent().hide() if not empty(subtitle.url): self.ui.urlEdit.setText(u'%s' % subtitle.url) else: self.ui.downloadButton.setDisabled(True) self.ui.downloadButton.setText('Impossible to download this subtitle') self.ui.verticalLayout.setAlignment(Qt.AlignTop) def download(self): if not empty(self.subtitle.url): if self.subtitle.url.endswith('.rar'): ext = '.rar' elif self.subtitle.url.endswith('.srt'): ext = '.srt' else: ext = '.zip' fileDial = QFileDialog(self, 'Save "%s" subtitle file' % self.subtitle.name, '%s%s' % (self.subtitle.name, ext), 'all files (*)') fileDial.setAcceptMode(QFileDialog.AcceptSave) fileDial.setLabelText(QFileDialog.Accept, 'Save subtitle file') fileDial.setLabelText(QFileDialog.FileName, 'Subtitle file name') ok = (fileDial.exec_() == 1) if not ok: return result = fileDial.selectedFiles() if len(result) > 0: dest = result[0] data = self.backend.get_subtitle_file(self.subtitle.id) try: with open(dest, 'w') as f: f.write(data) except IOError as e: print('Unable to write subtitle file in "%s": %s' % (dest, e), file=self.stderr) return 1 return weboob-1.1/weboob/applications/qcineoob/torrent.py000066400000000000000000000072571265717027300224660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from PyQt4.QtCore import Qt, SIGNAL from PyQt4.QtGui import QFrame, QFileDialog from weboob.applications.qcineoob.ui.torrent_ui import Ui_Torrent from weboob.applications.weboorrents.weboorrents import sizeof_fmt from weboob.capabilities.base import empty class Torrent(QFrame): def __init__(self, torrent, backend, parent=None): QFrame.__init__(self, parent) self.parent = parent self.backend = backend self.ui = Ui_Torrent() self.ui.setupUi(self) self.connect(self.ui.downloadButton, SIGNAL("clicked()"), self.download) self.torrent = torrent self.ui.idEdit.setText(u'%s@%s' % (torrent.id, backend.name)) self.ui.nameLabel.setText(u'%s' % torrent.name) if not empty(torrent.url): self.ui.urlEdit.setText(u'%s' % torrent.url) else: self.ui.urlFrame.hide() self.ui.downloadButton.setDisabled(True) if not empty(torrent.magnet): self.ui.downloadButton.setText(u'Download not available\nbut magnet link provided') self.ui.downloadButton.setToolTip(u'Use the magnet link') if not empty(torrent.description): self.ui.descriptionPlain.setText(u'%s' % torrent.description) else: self.ui.descriptionPlain.parent().hide() if not empty(torrent.files): files = u'' for f in torrent.files: files += '%s\n' % f self.ui.filesPlain.setText(u'%s' % files) else: self.ui.filesPlain.parent().hide() if not empty(torrent.magnet): self.ui.magnetEdit.setText(u'%s' % torrent.magnet) else: self.ui.magnetFrame.hide() if not empty(torrent.seeders) and not empty(torrent.leechers): self.ui.seedLeechLabel.setText(u'%s/%s' % (torrent.seeders, torrent.leechers)) if not empty(torrent.size): self.ui.sizeLabel.setText(u'%s' % sizeof_fmt(torrent.size)) self.ui.verticalLayout.setAlignment(Qt.AlignTop) def download(self): fileDial = QFileDialog(self, 'Save "%s" torrent file' % self.torrent.name, '%s.torrent' % self.torrent.name, 'Torrent file (*.torrent);;all files (*)') fileDial.setAcceptMode(QFileDialog.AcceptSave) fileDial.setLabelText(QFileDialog.Accept, 'Save torrent file') fileDial.setLabelText(QFileDialog.FileName, 'Torrent file name') ok = (fileDial.exec_() == 1) if not ok: return result = fileDial.selectedFiles() if len(result) > 0: dest = result[0] data = self.backend.get_torrent_file(self.torrent.id) try: with open(unicode(dest), 'w') as f: f.write(data) except IOError as e: print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr) return 1 return weboob-1.1/weboob/applications/qcineoob/ui/000077500000000000000000000000001265717027300210215ustar00rootroot00000000000000weboob-1.1/weboob/applications/qcineoob/ui/Makefile000066400000000000000000000002651265717027300224640ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/applications/qcineoob/ui/__init__.py000066400000000000000000000000001265717027300231200ustar00rootroot00000000000000weboob-1.1/weboob/applications/qcineoob/ui/main_window.ui000066400000000000000000000137141265717027300237010ustar00rootroot00000000000000 MainWindow 0 0 748 463 QCineoob 4 QFrame::StyledPanel QFrame::Raised 0 0 Search: 45 16777215 75 true background-color: qlineargradient(spread:pad, x1:1, y1:1, x2:1, y2:1, stop:0 rgba(255, 0, 0, 255), stop:0.479904 rgba(255, 0, 0, 255), stop:0.522685 rgba(255, 255, 255, 255), stop:1 rgba(255, 255, 255, 255)); stop movie person torrent subtitle 8 language <html><head/><body><p>Maximum results by backend</p><p>0 = no limit</p></body></html> max results <html><head/><body><p>Maximum results by backend</p><p>0 = no limit</p></body></html> -1 true true Show thumbnails Search by id: movie person torrent subtitle 0 0 748 23 toolBar TopToolBarArea false Backends weboob-1.1/weboob/applications/qcineoob/ui/minimovie.ui000066400000000000000000000114211265717027300233530ustar00rootroot00000000000000 MiniMovie 0 0 563 138 Form QFrame::StyledPanel QFrame::Raised 9 5 5 0 0 TextLabel 75 true Title 75 true Short description: 0 0 50 true false TextLabel true 75 true Where TextLabel false 120 20 View 120 20 View in new tab 120 20 View thumbnail Qt::Horizontal 40 20 weboob-1.1/weboob/applications/qcineoob/ui/miniperson.ui000066400000000000000000000115561265717027300235530ustar00rootroot00000000000000 MiniPerson 0 0 594 136 Form QFrame::StyledPanel QFrame::Raised 9 5 5 0 0 75 true Name 0 0 50 true false TextLabel true 75 true Short description TextLabel false 75 true Where TextLabel 0 120 20 View 120 20 View in new tab 120 20 View thumbnail Qt::Horizontal 40 20 weboob-1.1/weboob/applications/qcineoob/ui/minisubtitle.ui000066400000000000000000000077351265717027300241040ustar00rootroot00000000000000 MiniSubtitle 0 0 464 136 Form QFrame::StyledPanel QFrame::Raised 9 5 5 0 0 QFormLayout::ExpandingFieldsGrow 75 true Name 0 0 50 true false TextLabel true 75 true Nb CD TextLabel 75 true Where TextLabel 16777215 20 View in new tab 16777215 20 View weboob-1.1/weboob/applications/qcineoob/ui/minitorrent.ui000066400000000000000000000106271265717027300237400ustar00rootroot00000000000000 MiniTorrent 0 0 464 136 Form QFrame::StyledPanel QFrame::Raised 9 5 5 0 0 QFormLayout::ExpandingFieldsGrow 75 true Name 0 0 50 true false TextLabel 75 true Seed/leech: TextLabel 75 true Where TextLabel TextLabel 75 true Size: 16777215 20 View in new tab 16777215 20 View weboob-1.1/weboob/applications/qcineoob/ui/movie.ui000066400000000000000000000430271265717027300225050ustar00rootroot00000000000000 Movie 0 0 655 733 0 0 10000 10000 Frame QFrame::StyledPanel QFrame::Raised 16777215 3000 QFrame::NoFrame QFrame::Raised QFrame::NoFrame QFrame::Raised 0 0 view casting all QFrame::NoFrame QFrame::Raised 0 0 search torrents QFrame::NoFrame QFrame::Raised 0 0 search subtitles QFrame::StyledPanel QFrame::Raised Search persons in common with 0 0 Movie ID : 0 0 16777215 9000 QFrame::NoFrame QFrame::Raised 16777215 40 QFrame::StyledPanel QFrame::Raised 3 3 75 true Id: Qt::AlignCenter true 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Title: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Duration: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Release date: 16777215 150 QFrame::StyledPanel QFrame::Raised 75 true Pitch: 0 0 Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Country: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Genres: true 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Note: 16777215 200 QFrame::StyledPanel QFrame::Raised 75 true All release dates: Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse 0 0 16777215 200 QFrame::StyledPanel QFrame::Raised 100 16777215 75 true Other titles: Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse weboob-1.1/weboob/applications/qcineoob/ui/person.ui000066400000000000000000000273021265717027300226720ustar00rootroot00000000000000 Person 0 0 857 629 Frame QFrame::StyledPanel QFrame::Raised QFrame::NoFrame QFrame::Raised QFrame::NoFrame QFrame::Raised view filmography as all QFrame::StyledPanel QFrame::Raised Search movies in common with 0 0 Person ID : 0 0 QFrame::NoFrame QFrame::Raised 16777215 40 QFrame::StyledPanel QFrame::Raised 3 3 75 true Id: Qt::AlignCenter true QFrame::StyledPanel QFrame::Raised 75 true name: QFrame::StyledPanel QFrame::Raised 75 true Birth date: QFrame::StyledPanel QFrame::Raised 75 true Real Name: QFrame::StyledPanel QFrame::Raised 75 true Birth place: QFrame::StyledPanel QFrame::Raised 75 true Death date: QFrame::StyledPanel QFrame::Raised QFrame::NoFrame QFrame::Raised 75 true Short biography: view full biography 0 0 16777215 250 Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse weboob-1.1/weboob/applications/qcineoob/ui/result.ui000066400000000000000000000111721265717027300227000ustar00rootroot00000000000000 Result 0 0 645 733 0 0 10000 10000 Frame QFrame::StyledPanel QFrame::Raised QFrame::NoFrame QFrame::Raised 0 0 Qt::Horizontal 40 20 60 20 <<back 75 true Qt::AlignCenter true Qt::Horizontal 40 20 true 0 0 605 667 Qt::Vertical 20 40 true 0 0 605 667 weboob-1.1/weboob/applications/qcineoob/ui/subtitle.ui000066400000000000000000000204361265717027300232200ustar00rootroot00000000000000 Subtitle 0 0 629 552 0 0 2000 600 Frame QFrame::StyledPanel QFrame::Raised 16777215 600 QFrame::NoFrame QFrame::Raised 16777215 40 QFrame::StyledPanel QFrame::Raised 3 3 75 true Id: Qt::AlignCenter true 16777215 1000 QFrame::StyledPanel QFrame::Raised 75 true Name: true 16777215 1000 QFrame::StyledPanel QFrame::Raised 75 true Nb CD: 16777215 1000 QFrame::StyledPanel QFrame::Raised 75 true Lang: 16777215 200 QFrame::StyledPanel QFrame::Raised 75 true Description: 16777215 120 16777215 40 QFrame::StyledPanel QFrame::Raised 3 3 75 true Url: Download weboob-1.1/weboob/applications/qcineoob/ui/torrent.ui000066400000000000000000000245621265717027300230660ustar00rootroot00000000000000 Torrent 0 0 629 571 0 0 10000 10000 Frame QFrame::StyledPanel QFrame::Raised 16777215 10000 QFrame::NoFrame QFrame::Raised 16777215 40 QFrame::StyledPanel QFrame::Raised 3 3 75 true Id: Qt::AlignCenter true 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Name: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Seed/leech: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Size: 0 150 16777215 500 QFrame::StyledPanel QFrame::Raised 75 true Description: 0 120 16777215 200 QFrame::StyledPanel QFrame::Raised 75 true Files: 16777215 40 QFrame::StyledPanel QFrame::Raised 3 3 75 true Url: 16777215 40 QFrame::StyledPanel QFrame::Raised 3 3 75 true Magnet: Download weboob-1.1/weboob/applications/qcookboob/000077500000000000000000000000001265717027300205635ustar00rootroot00000000000000weboob-1.1/weboob/applications/qcookboob/__init__.py000066400000000000000000000000721265717027300226730ustar00rootroot00000000000000from .qcookboob import QCookboob __all__ = ['QCookboob'] weboob-1.1/weboob/applications/qcookboob/main_window.py000066400000000000000000000270761265717027300234640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import os import codecs from PyQt4.QtCore import SIGNAL, Qt, QStringList from PyQt4.QtGui import QApplication, QCompleter, QFrame, QShortcut, QKeySequence from weboob.capabilities.recipe import CapRecipe from weboob.tools.application.qt import QtMainWindow, QtDo from weboob.tools.application.qt.backendcfg import BackendCfg from weboob.applications.qcookboob.ui.main_window_ui import Ui_MainWindow from weboob.applications.qcookboob.ui.result_ui import Ui_Result from .minirecipe import MiniRecipe from .recipe import Recipe class Result(QFrame): def __init__(self, weboob, app, parent=None): QFrame.__init__(self, parent) self.ui = Ui_Result() self.ui.setupUi(self) self.parent = parent self.weboob = weboob self.app = app self.minis = [] self.current_info_widget = None # action history is composed by the last action and the action list # An action is a function, a list of arguments and a description string self.action_history = {'last_action': None, 'action_list': []} self.connect(self.ui.backButton, SIGNAL("clicked()"), self.doBack) self.ui.backButton.hide() def doAction(self, description, fun, args): ''' Call fun with args as arguments and save it in the action history ''' self.ui.currentActionLabel.setText(description) if self.action_history['last_action'] is not None: self.action_history['action_list'].append(self.action_history['last_action']) self.ui.backButton.setToolTip(self.action_history['last_action']['description']) self.ui.backButton.show() self.action_history['last_action'] = {'function': fun, 'args': args, 'description': description} return fun(*args) def doBack(self): ''' Go back in action history Basically call previous function and update history ''' if len(self.action_history['action_list']) > 0: todo = self.action_history['action_list'].pop() self.ui.currentActionLabel.setText(todo['description']) self.action_history['last_action'] = todo if len(self.action_history['action_list']) == 0: self.ui.backButton.hide() else: self.ui.backButton.setToolTip(self.action_history['action_list'][-1]['description']) return todo['function'](*todo['args']) def processFinished(self): self.parent.ui.searchEdit.setEnabled(True) QApplication.restoreOverrideCursor() self.process = None self.parent.ui.stopButton.hide() def searchRecipe(self,pattern): if not pattern: return self.doAction(u'Search recipe "%s"' % pattern, self.searchRecipeAction, [pattern]) def searchRecipeAction(self, pattern): self.ui.stackedWidget.setCurrentWidget(self.ui.list_page) for mini in self.minis: self.ui.list_content.layout().removeWidget(mini) mini.hide() mini.deleteLater() self.minis = [] self.parent.ui.searchEdit.setEnabled(False) QApplication.setOverrideCursor(Qt.WaitCursor) backend_name = str(self.parent.ui.backendEdit.itemData(self.parent.ui.backendEdit.currentIndex()).toString()) self.process = QtDo(self.weboob, self.addRecipe, fb=self.processFinished) self.process.do(self.app._do_complete, self.parent.getCount(), ('title'), 'iter_recipes', pattern, backends=backend_name, caps=CapRecipe) self.parent.ui.stopButton.show() def addRecipe(self, recipe): minirecipe = MiniRecipe(self.weboob, self.weboob[recipe.backend], recipe, self) self.ui.list_content.layout().insertWidget(self.ui.list_content.layout().count()-1,minirecipe) self.minis.append(minirecipe) def displayRecipe(self, recipe, backend): self.ui.stackedWidget.setCurrentWidget(self.ui.info_page) if self.current_info_widget is not None: self.ui.info_content.layout().removeWidget(self.current_info_widget) self.current_info_widget.hide() self.current_info_widget.deleteLater() wrecipe = Recipe(recipe, backend, self) self.ui.info_content.layout().addWidget(wrecipe) self.current_info_widget = wrecipe QApplication.restoreOverrideCursor() def searchId(self, id): QApplication.setOverrideCursor(Qt.WaitCursor) if '@' in id: backend_name = id.split('@')[1] id = id.split('@')[0] else: backend_name = None for backend in self.weboob.iter_backends(): if (backend_name and backend.name == backend_name) or not backend_name: recipe = backend.get_recipe(id) if recipe: self.doAction('Details of recipe "%s"' % recipe.title, self.displayRecipe, [recipe, backend]) QApplication.restoreOverrideCursor() class MainWindow(QtMainWindow): def __init__(self, config, weboob, app, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.weboob = weboob self.app = app self.minis = [] self.current_info_widget = None # search history is a list of patterns which have been searched self.search_history = self.loadSearchHistory() self.updateCompletion() self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search) self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId) count = self.config.get('settings', 'maxresultsnumber') self.ui.countSpin.setValue(int(count)) showT = self.config.get('settings', 'showthumbnails') self.ui.showTCheck.setChecked(showT == '1') self.connect(self.ui.stopButton, SIGNAL("clicked()"), self.stopProcess) self.ui.stopButton.hide() self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) q = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self) self.connect(q, SIGNAL("activated()"), self.close) n = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageDown), self) self.connect(n, SIGNAL("activated()"), self.nextTab) p = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageUp), self) self.connect(p, SIGNAL("activated()"), self.prevTab) w = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self) self.connect(w, SIGNAL("activated()"), self.closeCurrentTab) l = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_L), self) self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.setFocus) self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.selectAll) self.connect(self.ui.resultsTab, SIGNAL("tabCloseRequested(int)"), self.closeTab) self.loadBackendsList() if self.ui.backendEdit.count() == 0: self.backendsConfig() def backendsConfig(self): bckndcfg = BackendCfg(self.weboob, (CapRecipe, ), self) if bckndcfg.run(): self.loadBackendsList() def loadBackendsList(self): self.ui.backendEdit.clear() for i, backend in enumerate(self.weboob.iter_backends()): if i == 0: self.ui.backendEdit.addItem('All backends', '') self.ui.backendEdit.addItem(backend.name, backend.name) if backend.name == self.config.get('settings', 'backend'): self.ui.backendEdit.setCurrentIndex(i+1) if self.ui.backendEdit.count() == 0: self.ui.searchEdit.setEnabled(False) else: self.ui.searchEdit.setEnabled(True) def loadSearchHistory(self): ''' Return search string history list loaded from history file ''' result = [] history_path = os.path.join(self.weboob.workdir, 'qcookboob_history') if os.path.exists(history_path): f = codecs.open(history_path, 'r', 'utf-8') conf_hist = f.read() f.close() if conf_hist is not None and conf_hist.strip() != '': result = conf_hist.strip().split('\n') return result def saveSearchHistory(self): ''' Save search history in history file ''' if len(self.search_history) > 0: history_path = os.path.join(self.weboob.workdir, 'qcookboob_history') f = codecs.open(history_path, 'w', 'utf-8') f.write('\n'.join(self.search_history)) f.close() def updateCompletion(self): qc = QCompleter(QStringList(self.search_history), self) qc.setCaseSensitivity(Qt.CaseInsensitive) self.ui.searchEdit.setCompleter(qc) def getCount(self): num = self.ui.countSpin.value() if num == 0: return None else: return num def stopProcess(self): self.process.process.finish_event.set() def closeTab(self, index): if self.ui.resultsTab.widget(index) != 0: tabToClose = self.ui.resultsTab.widget(index) self.ui.resultsTab.removeTab(index) del(tabToClose) def closeCurrentTab(self): self.closeTab(self.ui.resultsTab.currentIndex()) def prevTab(self): index = self.ui.resultsTab.currentIndex() - 1 size = self.ui.resultsTab.count() if size != 0: self.ui.resultsTab.setCurrentIndex(index % size) def nextTab(self): index = self.ui.resultsTab.currentIndex() + 1 size = self.ui.resultsTab.count() if size != 0: self.ui.resultsTab.setCurrentIndex(index % size) def newTab(self, txt, backend, recipe=None): id = '' if recipe is not None: id = recipe.id new_res = Result(self.weboob, self.app, self) self.ui.resultsTab.addTab(new_res, txt) new_res.searchId(id) def search(self): pattern = unicode(self.ui.searchEdit.text()) # arbitrary max number of completion word if len(self.search_history) > 50: self.search_history.pop(0) if pattern not in self.search_history: self.search_history.append(pattern) self.updateCompletion() new_res = Result(self.weboob, self.app, self) self.ui.resultsTab.addTab(new_res, pattern) self.ui.resultsTab.setCurrentWidget(new_res) new_res.searchRecipe(pattern) def searchId(self): id = unicode(self.ui.idEdit.text()) new_res = Result(self.weboob, self.app, self) self.ui.resultsTab.addTab(new_res, id) self.ui.resultsTab.setCurrentWidget(new_res) new_res.searchId(id) def closeEvent(self, ev): self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData( self.ui.backendEdit.currentIndex()).toString())) self.saveSearchHistory() self.config.set('settings', 'maxresultsnumber', self.ui.countSpin.value()) self.config.save() ev.accept() weboob-1.1/weboob/applications/qcookboob/minirecipe.py000066400000000000000000000064441265717027300232710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import urllib from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication from PyQt4.QtCore import Qt, SIGNAL from weboob.applications.qcookboob.ui.minirecipe_ui import Ui_MiniRecipe from weboob.capabilities.base import empty class MiniRecipe(QFrame): def __init__(self, weboob, backend, recipe, parent=None): QFrame.__init__(self, parent) self.parent = parent self.ui = Ui_MiniRecipe() self.ui.setupUi(self) self.weboob = weboob self.backend = backend self.recipe = recipe self.ui.titleLabel.setText(recipe.title) if not empty(recipe.short_description): if len(recipe.short_description) > 300: self.ui.shortDescLabel.setText('%s [...]'%recipe.short_description[:300]) else: self.ui.shortDescLabel.setText(recipe.short_description) else: self.ui.shortDescLabel.setText('') self.ui.backendLabel.setText(backend.name) self.connect(self.ui.newTabButton, SIGNAL("clicked()"), self.newTabPressed) self.connect(self.ui.viewButton, SIGNAL("clicked()"), self.viewPressed) self.connect(self.ui.viewThumbnailButton, SIGNAL("clicked()"), self.gotThumbnail) if self.parent.parent.ui.showTCheck.isChecked(): self.gotThumbnail() def gotThumbnail(self): if not empty(self.recipe.thumbnail_url): data = urllib.urlopen(self.recipe.thumbnail_url).read() img = QImage.fromData(data) self.ui.imageLabel.setPixmap(QPixmap.fromImage(img).scaledToHeight(100,Qt.SmoothTransformation)) def viewPressed(self): QApplication.setOverrideCursor(Qt.WaitCursor) recipe = self.backend.get_recipe(self.recipe.id) if recipe: self.parent.doAction('Details of recipe "%s"' % recipe.title, self.parent.displayRecipe, [recipe, self.backend]) def newTabPressed(self): recipe = self.backend.get_recipe(self.recipe.id) self.parent.parent.newTab(u'Details of recipe "%s"' % recipe.title, self.backend, recipe=recipe) def enterEvent(self, event): self.setFrameShadow(self.Sunken) QFrame.enterEvent(self, event) def leaveEvent(self, event): self.setFrameShadow(self.Raised) QFrame.leaveEvent(self, event) def mousePressEvent(self, event): QFrame.mousePressEvent(self, event) if event.button() == 2: self.gotThumbnail() elif event.button() == 4: self.newTabPressed() else: self.viewPressed() weboob-1.1/weboob/applications/qcookboob/qcookboob.py000066400000000000000000000027411265717027300231170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.recipe import CapRecipe from weboob.tools.application.qt import QtApplication from .main_window import MainWindow class QCookboob(QtApplication): APPNAME = 'qcookboob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2013-2014 Julien Veyssier' DESCRIPTION = "Qt application allowing to search recipes." SHORT_DESCRIPTION = "search recipes" CAPS = CapRecipe CONFIG = {'settings': {'backend': '', 'maxresultsnumber': '10' } } def main(self, argv): self.load_backends([CapRecipe]) self.load_config() self.main_window = MainWindow(self.config, self.weboob, self) self.main_window.show() return self.weboob.loop() weboob-1.1/weboob/applications/qcookboob/recipe.py000066400000000000000000000106101265717027300224020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import urllib import codecs from PyQt4.QtCore import Qt, SIGNAL from PyQt4.QtGui import QFrame, QImage, QPixmap, QFileDialog from weboob.applications.qcookboob.ui.recipe_ui import Ui_Recipe from weboob.capabilities.base import empty class Recipe(QFrame): def __init__(self, recipe, backend, parent=None): QFrame.__init__(self, parent) self.parent = parent self.ui = Ui_Recipe() self.ui.setupUi(self) self.connect(self.ui.exportButton, SIGNAL("clicked()"), self.export) self.recipe = recipe self.backend = backend self.gotThumbnail() self.ui.idEdit.setText(u'%s@%s' % (recipe.id, backend.name)) if not empty(recipe.title): self.ui.titleLabel.setText(recipe.title) if not empty(recipe.nb_person): nbstr = '-'.join(str(num) for num in recipe.nb_person) self.ui.nbPersonLabel.setText(nbstr) else: self.ui.nbPersonLabel.parent().hide() if not empty(recipe.preparation_time): self.ui.prepTimeLabel.setText('%s min' % recipe.preparation_time) else: self.ui.prepTimeLabel.parent().hide() if not empty(recipe.cooking_time): self.ui.cookingTimeLabel.setText('%s min' % recipe.cooking_time) else: self.ui.cookingTimeLabel.parent().hide() if not empty(recipe.ingredients): txt = u'' for ing in recipe.ingredients: txt += '* %s\n' % ing self.ui.ingredientsPlain.setPlainText('%s' % txt) else: self.ui.ingredientsPlain.parent().hide() if not empty(recipe.author): self.ui.authorLabel.setText('%s' % recipe.author) else: self.ui.authorLabel.parent().hide() if not empty(recipe.instructions): self.ui.instructionsPlain.setPlainText('%s' % recipe.instructions) else: self.ui.instructionsPlain.parent().hide() if not empty(recipe.comments): txt = u'' for com in recipe.comments: txt += '* %s\n' % com self.ui.commentsPlain.setPlainText('%s' % txt) else: self.ui.commentsPlain.parent().hide() self.ui.verticalLayout.setAlignment(Qt.AlignTop) self.ui.verticalLayout_2.setAlignment(Qt.AlignTop) def gotThumbnail(self): if self.recipe.picture_url and not empty(self.recipe.picture_url): data = urllib.urlopen(self.recipe.picture_url).read() img = QImage.fromData(data) self.ui.imageLabel.setPixmap(QPixmap.fromImage(img).scaledToWidth(250, Qt.SmoothTransformation)) def export(self): fileDial = QFileDialog(self, 'Export "%s" recipe' % self.recipe.title, '%s.kreml' % self.recipe.title.replace('/', ','), 'Krecipe file (*.kreml);;all files (*)') fileDial.setAcceptMode(QFileDialog.AcceptSave) fileDial.setLabelText(QFileDialog.Accept, 'Export recipe') fileDial.setLabelText(QFileDialog.FileName, 'Recipe file name') ok = (fileDial.exec_() == 1) if not ok: return result = fileDial.selectedFiles() if len(result) > 0: dest = unicode(result[0]) if not dest.endswith('.kreml'): dest += '.kreml' data = self.recipe.toKrecipesXml(author=self.backend.name) try: with codecs.open(dest, 'w', 'utf-8') as f: f.write(data) except IOError as e: print('Unable to write Krecipe file in "%s": %s' % (dest, e), file=self.stderr) return 1 return weboob-1.1/weboob/applications/qcookboob/ui/000077500000000000000000000000001265717027300212005ustar00rootroot00000000000000weboob-1.1/weboob/applications/qcookboob/ui/Makefile000066400000000000000000000002651265717027300226430ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/applications/qcookboob/ui/__init__.py000066400000000000000000000000001265717027300232770ustar00rootroot00000000000000weboob-1.1/weboob/applications/qcookboob/ui/main_window.ui000066400000000000000000000104461265717027300240570ustar00rootroot00000000000000 MainWindow 0 0 748 463 QCookboob 4 QFrame::StyledPanel QFrame::Raised 0 0 Search: 35 16777215 background-color: qlineargradient(spread:pad, x1:1, y1:1, x2:1, y2:1, stop:0 rgba(255, 0, 0, 255), stop:0.479904 rgba(255, 0, 0, 255), stop:0.522685 rgba(255, 255, 255, 255), stop:1 rgba(255, 255, 255, 255)); stop <html><head/><body><p>Maximum results by backend</p><p>0 = no limit</p></body></html> max results <html><head/><body><p>Maximum results by backend</p><p>0 = no limit</p></body></html> -1 true true Show thumbnails search by ID: 0 0 748 27 toolBar TopToolBarArea false Backends weboob-1.1/weboob/applications/qcookboob/ui/minirecipe.ui000066400000000000000000000114221265717027300236630ustar00rootroot00000000000000 MiniRecipe 0 0 578 136 Form QFrame::StyledPanel QFrame::Raised 9 5 5 0 0 TextLabel TextLabel true 0 0 50 true false TextLabel true 75 true Short description: 75 true Where 75 true Title 120 20 View 120 20 View in new tab 120 20 View thumbnail Qt::Horizontal 40 20 weboob-1.1/weboob/applications/qcookboob/ui/recipe.ui000066400000000000000000000325331265717027300230140ustar00rootroot00000000000000 Recipe 0 0 645 855 0 0 8000 5000 Frame QFrame::StyledPanel QFrame::Raised 16777215 3000 QFrame::NoFrame QFrame::Raised 16777215 4000 QFrame::NoFrame QFrame::Raised Export to KRecipesML file 16777215 40 QFrame::StyledPanel QFrame::Raised 3 3 75 true Id: Qt::AlignCenter true 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Title: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Author: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Number of people: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Preparation time: 16777215 35 QFrame::StyledPanel QFrame::Raised 75 true Cook time: 0 0 16777215 1000 QFrame::StyledPanel QFrame::Raised 75 true Ingredients: 0 200 Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse 0 0 16777215 1000 QFrame::StyledPanel QFrame::Raised 100 16777215 75 true Instructions: 0 200 Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse 0 0 16777215 1000 QFrame::StyledPanel QFrame::Raised 75 true Comments: 0 100 Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse weboob-1.1/weboob/applications/qcookboob/ui/result.ui000066400000000000000000000111721265717027300230570ustar00rootroot00000000000000 Result 0 0 645 733 0 0 10000 10000 Frame QFrame::StyledPanel QFrame::Raised QFrame::NoFrame QFrame::Raised 0 0 Qt::Horizontal 40 20 60 20 <<back 75 true Qt::AlignCenter true Qt::Horizontal 40 20 true 0 0 605 667 Qt::Vertical 20 40 true 0 0 605 667 weboob-1.1/weboob/applications/qflatboob/000077500000000000000000000000001265717027300205565ustar00rootroot00000000000000weboob-1.1/weboob/applications/qflatboob/__init__.py000066400000000000000000000000721265717027300226660ustar00rootroot00000000000000from .qflatboob import QFlatBoob __all__ = ['QFlatBoob'] weboob-1.1/weboob/applications/qflatboob/main_window.py000066400000000000000000000363651265717027300234600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QListWidgetItem, QImage, QPixmap, QLabel, QIcon, QBrush, QColor from PyQt4.QtCore import SIGNAL, Qt from decimal import Decimal from weboob.tools.application.qt import QtMainWindow, QtDo, HTMLDelegate from weboob.tools.application.qt.backendcfg import BackendCfg from weboob.capabilities.housing import CapHousing, Query, City from weboob.capabilities.base import NotLoaded, NotAvailable from .ui.main_window_ui import Ui_MainWindow from .query import QueryDialog class HousingListWidgetItem(QListWidgetItem): def __init__(self, housing, *args, **kwargs): QListWidgetItem.__init__(self, *args, **kwargs) self.housing = housing self.read = True def __lt__(self, other): return '%s%s' % (self.read, Decimal(self.housing.cost or 0) / Decimal(self.housing.area or 1)) < \ '%s%s' % (other.read, Decimal(other.housing.cost or 0) / Decimal(other.housing.area or 1)) def setAttrs(self, storage): text = u'

%s

' % self.housing.title text += u'%s — %sm² — %s%s (%s)' % (self.housing.date.strftime('%Y-%m-%d') if self.housing.date else 'Unknown', self.housing.area, self.housing.cost, self.housing.currency, self.housing.backend) text += u'
%s' % self.housing.text.strip() text += u'
%s' % storage.get('notes', self.housing.fullid, default='').strip().replace('\n', '
') self.setText(text) if self.housing.fullid not in storage.get('read'): self.setBackground(QBrush(QColor(200, 200, 255))) self.read = False elif self.housing.fullid in storage.get('bookmarks'): self.setBackground(QBrush(QColor(255, 200, 200))) elif self.background().color() != QColor(0,0,0): self.setBackground(QBrush()) class MainWindow(QtMainWindow): def __init__(self, config, storage, weboob, app, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.storage = storage self.weboob = weboob self.app = app self.process = None self.housing = None self.displayed_photo_idx = 0 self.process_photo = {} self.process_bookmarks = {} self.ui.housingsList.setItemDelegate(HTMLDelegate()) self.ui.housingFrame.hide() self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) self.connect(self.ui.queriesList, SIGNAL('currentIndexChanged(int)'), self.queryChanged) self.connect(self.ui.addQueryButton, SIGNAL('clicked()'), self.addQuery) self.connect(self.ui.editQueryButton, SIGNAL('clicked()'), self.editQuery) self.connect(self.ui.removeQueryButton, SIGNAL('clicked()'), self.removeQuery) self.connect(self.ui.bookmarksButton, SIGNAL('clicked()'), self.displayBookmarks) self.connect(self.ui.housingsList, SIGNAL('currentItemChanged(QListWidgetItem*, QListWidgetItem*)'), self.housingSelected) self.connect(self.ui.previousButton, SIGNAL('clicked()'), self.previousClicked) self.connect(self.ui.nextButton, SIGNAL('clicked()'), self.nextClicked) self.connect(self.ui.bookmark, SIGNAL('stateChanged(int)'), self.bookmarkChanged) self.reloadQueriesList() self.refreshHousingsList() if self.weboob.count_backends() == 0: self.backendsConfig() if len(self.config.get('queries')) == 0: self.addQuery() def closeEvent(self, event): self.setHousing(None) QtMainWindow.closeEvent(self, event) def backendsConfig(self): bckndcfg = BackendCfg(self.weboob, (CapHousing,), self) if bckndcfg.run(): pass def reloadQueriesList(self, select_name=None): self.disconnect(self.ui.queriesList, SIGNAL('currentIndexChanged(int)'), self.queryChanged) self.ui.queriesList.clear() for name in self.config.get('queries', default={}).iterkeys(): self.ui.queriesList.addItem(name) if name == select_name: self.ui.queriesList.setCurrentIndex(len(self.ui.queriesList)-1) self.connect(self.ui.queriesList, SIGNAL('currentIndexChanged(int)'), self.queryChanged) if select_name is not None: self.queryChanged() def removeQuery(self): name = unicode(self.ui.queriesList.itemText(self.ui.queriesList.currentIndex())) queries = self.config.get('queries') queries.pop(name, None) self.config.set('queries', queries) self.config.save() self.reloadQueriesList() self.queryChanged() def editQuery(self): name = unicode(self.ui.queriesList.itemText(self.ui.queriesList.currentIndex())) self.addQuery(name) def addQuery(self, name=None): querydlg = QueryDialog(self.weboob, self) if name is not None: query = self.config.get('queries', name) querydlg.ui.nameEdit.setText(name) querydlg.ui.nameEdit.setEnabled(False) for c in query['cities']: city = City(c['id']) city.backend = c['backend'] city.name = c['name'] item = querydlg.buildCityItem(city) querydlg.ui.citiesList.addItem(item) querydlg.ui.typeBox.setCurrentIndex(int(query.get('type', 0))) querydlg.ui.areaMin.setValue(query['area_min']) querydlg.ui.areaMax.setValue(query['area_max']) querydlg.ui.costMin.setValue(query['cost_min']) querydlg.ui.costMax.setValue(query['cost_max']) querydlg.selectComboValue(querydlg.ui.nbRooms, query['nb_rooms']) if querydlg.exec_(): name = unicode(querydlg.ui.nameEdit.text()) query = {} query['type'] = querydlg.ui.typeBox.currentIndex() query['cities'] = [] for i in xrange(len(querydlg.ui.citiesList)): item = querydlg.ui.citiesList.item(i) city = item.data(Qt.UserRole).toPyObject() query['cities'].append({'id': city.id, 'backend': city.backend, 'name': city.name}) query['area_min'] = querydlg.ui.areaMin.value() query['area_max'] = querydlg.ui.areaMax.value() query['cost_min'] = querydlg.ui.costMin.value() query['cost_max'] = querydlg.ui.costMax.value() try: query['nb_rooms'] = int(querydlg.ui.nbRooms.itemText(querydlg.ui.nbRooms.currentIndex())) except ValueError: query['nb_rooms'] = 0 self.config.set('queries', name, query) self.config.save() self.reloadQueriesList(name) def queryChanged(self, i=None): self.refreshHousingsList() def refreshHousingsList(self): name = unicode(self.ui.queriesList.itemText(self.ui.queriesList.currentIndex())) q = self.config.get('queries', name) if q is None: return q self.ui.housingsList.clear() self.ui.queriesList.setEnabled(False) self.ui.bookmarksButton.setEnabled(False) query = Query() query.type = int(q.get('type', 0)) query.cities = [] for c in q['cities']: city = City(c['id']) city.backend = c['backend'] city.name = c['name'] query.cities.append(city) query.area_min = int(q['area_min']) or None query.area_max = int(q['area_max']) or None query.cost_min = int(q['cost_min']) or None query.cost_max = int(q['cost_max']) or None query.nb_rooms = int(q['nb_rooms']) or None self.process = QtDo(self.weboob, self.addHousing, fb=self.addHousingEnd) self.process.do(self.app._do_complete, 20, (), 'search_housings', query) def displayBookmarks(self): self.ui.housingsList.clear() self.ui.queriesList.setEnabled(False) self.ui.queriesList.setCurrentIndex(-1) self.ui.bookmarksButton.setEnabled(False) self.processes = {} for id in self.storage.get('bookmarks'): _id, backend_name = id.rsplit('@', 1) self.process_bookmarks[id] = QtDo(self.weboob, self.addHousing, fb=self.addHousingEnd) self.process_bookmarks[id].do('get_housing', _id, backends=backend_name) def addHousingEnd(self): self.ui.queriesList.setEnabled(True) self.ui.bookmarksButton.setEnabled(True) self.process = None def addHousing(self, housing): if not housing: return item = HousingListWidgetItem(housing) item.setAttrs(self.storage) if housing.photos is NotLoaded: process = QtDo(self.weboob, lambda c: self.setPhoto(c, item)) process.do('fillobj', housing, ['photos'], backends=housing.backend) self.process_photo[housing.id] = process elif housing.photos is not NotAvailable and len(housing.photos) > 0: if not self.setPhoto(housing, item): photo = housing.photos[0] process = QtDo(self.weboob, lambda p: self.setPhoto(housing, item)) process.do('fillobj', photo, ['data'], backends=housing.backend) self.process_photo[housing.id] = process self.ui.housingsList.addItem(item) if housing.fullid in self.process_bookmarks: self.process_bookmarks.pop(housing.fullid) def housingSelected(self, item, prev): if item is not None: housing = item.housing self.ui.queriesFrame.setEnabled(False) read = set(self.storage.get('read')) read.add(housing.fullid) self.storage.set('read', list(read)) self.storage.save() self.process = QtDo(self.weboob, self.gotHousing) self.process.do('fillobj', housing, backends=housing.backend) else: housing = None self.setHousing(housing) if prev: prev.setAttrs(self.storage) def setPhoto(self, housing, item): if not housing: return False try: self.process_photo.pop(housing.id, None) except KeyError: pass if not housing.photos: return False img = None for photo in housing.photos: if photo.data: img = QImage.fromData(photo.data) break if img: item.setIcon(QIcon(QPixmap.fromImage(img))) return True return False def setHousing(self, housing, nottext='Loading...'): if self.housing is not None: self.saveNotes() self.housing = housing if self.housing is None: self.ui.housingFrame.hide() return self.ui.housingFrame.show() self.display_photo() self.ui.bookmark.setChecked(housing.fullid in self.storage.get('bookmarks')) self.ui.titleLabel.setText('

%s

' % housing.title) self.ui.areaLabel.setText(u'%s m²' % housing.area) self.ui.costLabel.setText(u'%s %s' % (housing.cost, housing.currency)) self.ui.dateLabel.setText(housing.date.strftime('%Y-%m-%d') if housing.date else nottext) self.ui.phoneLabel.setText(housing.phone or nottext) self.ui.locationLabel.setText(housing.location or nottext) self.ui.stationLabel.setText(housing.station or nottext) if housing.text: self.ui.descriptionEdit.setText(housing.text.replace('\n', '
')) else: self.ui.descriptionEdit.setText(nottext) self.ui.notesEdit.setText(self.storage.get('notes', housing.fullid, default='')) while self.ui.detailsFrame.layout().count() > 0: child = self.ui.detailsFrame.layout().takeAt(0) child.widget().hide() child.widget().deleteLater() if housing.details: for key, value in housing.details.iteritems(): label = QLabel(value) label.setTextInteractionFlags(Qt.TextSelectableByMouse|Qt.LinksAccessibleByMouse) self.ui.detailsFrame.layout().addRow('%s:' % key, label) def gotHousing(self, housing): self.setHousing(housing, nottext='') self.ui.queriesFrame.setEnabled(True) self.process = None def bookmarkChanged(self, state): bookmarks = set(self.storage.get('bookmarks')) if state == Qt.Checked: bookmarks.add(self.housing.fullid) elif self.housing.fullid in bookmarks: bookmarks.remove(self.housing.fullid) self.storage.set('bookmarks', list(bookmarks)) self.storage.save() def saveNotes(self): if not self.housing: return txt = unicode(self.ui.notesEdit.toPlainText()).strip() if len(txt) > 0: self.storage.set('notes', self.housing.fullid, txt) else: self.storage.delete('notes', self.housing.fullid) self.storage.save() def previousClicked(self): if not self.housing.photos or len(self.housing.photos) == 0: return self.displayed_photo_idx = (self.displayed_photo_idx - 1) % len(self.housing.photos) self.display_photo() def nextClicked(self): if not self.housing.photos or len(self.housing.photos) == 0: return self.displayed_photo_idx = (self.displayed_photo_idx + 1) % len(self.housing.photos) self.display_photo() def display_photo(self): if not self.housing.photos: self.ui.photosFrame.hide() return if self.displayed_photo_idx >= len(self.housing.photos): self.displayed_photo_idx = len(self.housing.photos) - 1 if self.displayed_photo_idx < 0: self.ui.photosFrame.hide() return self.ui.photosFrame.show() photo = self.housing.photos[self.displayed_photo_idx] if photo.data: data = photo.data if photo.id in self.process_photo: self.process_photo.pop(photo.id) else: self.process_photo[photo.id] = QtDo(self.weboob, lambda p: self.display_photo()) self.process_photo[photo.id].do('fillobj', photo, ['data'], backends=self.housing.backend) return img = QImage.fromData(data) img = img.scaledToWidth(self.width()/3) self.ui.photoLabel.setPixmap(QPixmap.fromImage(img)) if photo.url is not NotLoaded: text = '%s' % (photo.url, photo.url) self.ui.photoUrlLabel.setText(text) weboob-1.1/weboob/applications/qflatboob/qflatboob.py000066400000000000000000000030401265717027300230760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.housing import CapHousing from weboob.tools.application.qt import QtApplication from weboob.tools.config.yamlconfig import YamlConfig from .main_window import MainWindow class QFlatBoob(QtApplication): APPNAME = 'qflatboob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-2014 Romain Bignon' DESCRIPTION = "Qt application to search for housing." SHORT_DESCRIPTION = "search for housing" CAPS = CapHousing CONFIG = {'queries': {}} STORAGE = {'bookmarks': [], 'read': [], 'notes': {}} def main(self, argv): self.load_backends(CapHousing) self.create_storage() self.load_config(klass=YamlConfig) self.main_window = MainWindow(self.config, self.storage, self.weboob, self) self.main_window.show() return self.weboob.loop() weboob-1.1/weboob/applications/qflatboob/query.py000066400000000000000000000071221265717027300222770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QDialog, QListWidgetItem, QMessageBox from PyQt4.QtCore import SIGNAL, Qt from weboob.tools.application.qt import QtDo, HTMLDelegate from .ui.query_ui import Ui_QueryDialog class QueryDialog(QDialog): def __init__(self, weboob, parent=None): QDialog.__init__(self, parent) self.ui = Ui_QueryDialog() self.ui.setupUi(self) self.weboob = weboob self.ui.resultsList.setItemDelegate(HTMLDelegate()) self.ui.citiesList.setItemDelegate(HTMLDelegate()) self.search_process = None self.connect(self.ui.cityEdit, SIGNAL('returnPressed()'), self.searchCity) self.connect(self.ui.resultsList, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.insertCity) self.connect(self.ui.citiesList, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.removeCity) self.connect(self.ui.buttonBox, SIGNAL('accepted()'), self.okButton) if hasattr(self.ui.cityEdit, "setPlaceholderText"): self.ui.cityEdit.setPlaceholderText("Press enter to search city") def keyPressEvent(self, event): """ Disable handler and to prevent closing the window. """ event.ignore() def selectComboValue(self, box, value): for i in xrange(box.count()): if box.itemText(i) == str(value): box.setCurrentIndex(i) break def searchCity(self): pattern = unicode(self.ui.cityEdit.text()) self.ui.resultsList.clear() self.ui.cityEdit.clear() self.ui.cityEdit.setEnabled(False) self.search_process = QtDo(self.weboob, self.addResult, fb=self.addResultEnd) self.search_process.do('search_city', pattern) def addResultEnd(self): self.search_process = None self.ui.cityEdit.setEnabled(True) def addResult(self, city): if not city: return item = self.buildCityItem(city) self.ui.resultsList.addItem(item) self.ui.resultsList.sortItems() def buildCityItem(self, city): item = QListWidgetItem() item.setText('%s (%s)' % (city.name, city.backend)) item.setData(Qt.UserRole, city) return item def insertCity(self, i): item = QListWidgetItem() item.setText(i.text()) item.setData(Qt.UserRole, i.data(Qt.UserRole)) self.ui.citiesList.addItem(item) def removeCity(self, item): self.ui.citiesList.removeItemWidget(item) def okButton(self): if not self.ui.nameEdit.text(): QMessageBox.critical(self, self.tr('Error'), self.tr('Please enter a name to your query.'), QMessageBox.Ok) return if self.ui.citiesList.count() == 0: QMessageBox.critical(self, self.tr('Error'), self.tr('Please add at least one city.'), QMessageBox.Ok) return self.accept() weboob-1.1/weboob/applications/qflatboob/ui/000077500000000000000000000000001265717027300211735ustar00rootroot00000000000000weboob-1.1/weboob/applications/qflatboob/ui/Makefile000066400000000000000000000002651265717027300226360ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/applications/qflatboob/ui/__init__.py000066400000000000000000000000001265717027300232720ustar00rootroot00000000000000weboob-1.1/weboob/applications/qflatboob/ui/main_window.ui000066400000000000000000000444711265717027300240570ustar00rootroot00000000000000 MainWindow 0 0 709 572 QFlatBoob Qt::Horizontal 0 0 QFrame::StyledPanel QFrame::Raised + edit - 0 0 QAbstractItemView::NoEditTriggers 128 128 true Bookmarks Qt::Horizontal 1 0 QFrame::StyledPanel QFrame::Raised Qt::Vertical 0 0 20 0 <h1>Loading...</h1> QFormLayout::ExpandingFieldsGrow 75 true Cost Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse 75 true Area 75 true Date 75 true Phone 75 true Location 75 true Station Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Qt::Vertical QSizePolicy::Expanding 20 5 QFrame::StyledPanel QFrame::Raised 0 0 20 16777215 < Qt::AlignCenter 0 0 20 16777215 > Qt::AlignCenter Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Qt::Vertical QSizePolicy::Expanding 13 5 Qt::Horizontal Qt::Vertical 0 50 true 0 0 false QFrame::NoFrame QFrame::Plain QFormLayout::ExpandingFieldsGrow 20 0 0 709 24 toolBar TopToolBarArea false Backends addQueryButton queriesList editQueryButton removeQueryButton housingsList bookmarksButton bookmark previousButton nextButton descriptionEdit weboob-1.1/weboob/applications/qflatboob/ui/query.ui000066400000000000000000000214401265717027300227000ustar00rootroot00000000000000 QueryDialog 0 0 551 457 Add a query QFrame::StyledPanel QFrame::Raised Name of this query: Rent Sale Cities Number of rooms N/A 1 2 3 4 5 Area Min Max 9999 5 9999 5 Cost Min Max 99999999 100 99999999 100 Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok nameEdit cityEdit resultsList citiesList nbRooms areaMin areaMax costMin costMax buttonBox buttonBox rejected() QueryDialog reject() 316 260 286 274 weboob-1.1/weboob/applications/qhandjoob/000077500000000000000000000000001265717027300205525ustar00rootroot00000000000000weboob-1.1/weboob/applications/qhandjoob/__init__.py000066400000000000000000000000721265717027300226620ustar00rootroot00000000000000from .qhandjoob import QHandJoob __all__ = ['QHandJoob'] weboob-1.1/weboob/applications/qhandjoob/main_window.py000066400000000000000000000174121265717027300234440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Sébastien Monel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QListWidgetItem, QApplication, QCompleter from PyQt4.QtCore import SIGNAL, Qt, QStringList from weboob.tools.application.qt import QtMainWindow, QtDo from weboob.tools.application.qt.backendcfg import BackendCfg from weboob.capabilities.job import CapJob from .ui.main_window_ui import Ui_MainWindow import os import codecs class JobListWidgetItem(QListWidgetItem): def __init__(self, job, *args, **kwargs): QListWidgetItem.__init__(self, *args, **kwargs) self.job = job def __lt__(self, other): if self.job.publication_date and other.job.publication_date: return self.job.publication_date < other.job.publication_date else: return False def setAttrs(self, storage): text = u'%s - %s' % (self.job.backend, self.job.title) self.setText(text) class MainWindow(QtMainWindow): def __init__(self, config, storage, weboob, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.storage = storage self.weboob = weboob self.process = None self.displayed_photo_idx = 0 self.process_photo = {} self.process_bookmarks = {} # search history is a list of patterns which have been searched self.search_history = self.loadSearchHistory() self.updateCompletion() self.ui.jobFrame.hide() self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) self.connect(self.ui.searchEdit, SIGNAL('returnPressed()'), self.doSearch) self.connect(self.ui.jobList, SIGNAL('currentItemChanged(QListWidgetItem*, QListWidgetItem*)'), self.jobSelected) self.connect(self.ui.searchButton, SIGNAL('clicked()'), self.doSearch) self.connect(self.ui.refreshButton, SIGNAL('clicked()'), self.doAdvancedSearch) self.connect(self.ui.queriesTabWidget, SIGNAL('currentChanged(int)'), self.tabChange) self.connect(self.ui.jobListAdvancedSearch, SIGNAL('currentItemChanged(QListWidgetItem*, QListWidgetItem*)'), self.jobSelected) self.connect(self.ui.idEdit, SIGNAL('returnPressed()'), self.openJob) if self.weboob.count_backends() == 0: self.backendsConfig() def loadSearchHistory(self): ''' Return search string history list loaded from history file ''' result = [] history_path = os.path.join(self.weboob.workdir, 'qhandjoob_history') if os.path.exists(history_path): f = codecs.open(history_path, 'r', 'utf-8') conf_hist = f.read() f.close() if conf_hist is not None and conf_hist.strip() != '': result = conf_hist.strip().split('\n') return result def saveSearchHistory(self): ''' Save search history in history file ''' if len(self.search_history) > 0: history_path = os.path.join(self.weboob.workdir, 'qhandjoob_history') f = codecs.open(history_path, 'w', 'utf-8') f.write('\n'.join(self.search_history)) f.close() def updateCompletion(self): qc = QCompleter(QStringList(self.search_history), self) qc.setCaseSensitivity(Qt.CaseInsensitive) self.ui.searchEdit.setCompleter(qc) def tabChange(self, index): if index == 1: self.doAdvancedSearch() def searchFinished(self): self.process = None QApplication.restoreOverrideCursor() def doAdvancedSearch(self): QApplication.setOverrideCursor(Qt.WaitCursor) self.ui.jobListAdvancedSearch.clear() self.process = QtDo(self.weboob, self.addJobAdvancedSearch, fb=self.searchFinished) self.process.do('advanced_search_job') def doSearch(self): QApplication.setOverrideCursor(Qt.WaitCursor) pattern = unicode(self.ui.searchEdit.text()) # arbitrary max number of completion word if pattern: if len(self.search_history) > 50: self.search_history.pop(0) if pattern not in self.search_history: self.search_history.append(pattern) self.updateCompletion() self.ui.jobList.clear() self.process = QtDo(self.weboob, self.addJobSearch, fb=self.searchFinished) self.process.do('search_job', pattern) def addJobSearch(self, job): item = self.addJob(job) if item: self.ui.jobList.addItem(item) def addJobAdvancedSearch(self, job): item = self.addJob(job) if item: self.ui.jobListAdvancedSearch.addItem(item) def addJob(self, job): if not job: return item = JobListWidgetItem(job) item.setAttrs(self.storage) return item def closeEvent(self, event): self.saveSearchHistory() QtMainWindow.closeEvent(self, event) def backendsConfig(self): bckndcfg = BackendCfg(self.weboob, (CapJob,), self) if bckndcfg.run(): pass def jobSelected(self, item, prev): QApplication.setOverrideCursor(Qt.WaitCursor) if item is not None: job = item.job self.ui.queriesTabWidget.setEnabled(False) self.process = QtDo(self.weboob, self.gotJob) self.process.do('fillobj', job, backends=job.backend) else: job = None self.setJob(job) if prev: prev.setAttrs(self.storage) def openJob(self): QApplication.setOverrideCursor(Qt.WaitCursor) url = unicode(self.ui.idEdit.text()) if not url: return for backend in self.weboob.iter_backends(): job = backend.get_job_advert(url) if job: self.process = QtDo(self.weboob, self.gotJob) self.process.do('fillobj', job, backends=job.backend) break self.setJob(job) self.ui.idEdit.clear() QApplication.restoreOverrideCursor() def gotJob(self, job): self.setJob(job) self.ui.queriesTabWidget.setEnabled(True) self.process = None def setJob(self, job): if job: self.ui.descriptionEdit.setText("%s" % job.description) self.ui.titleLabel.setText("

%s

" % job.title) self.ui.idLabel.setText("%s" % job.id) self.ui.jobNameLabel.setText("%s" % job.job_name) self.ui.publicationDateLabel.setText("%s" % job.publication_date) self.ui.societyNameLabel.setText("%s" % job.society_name) self.ui.placeLabel.setText("%s" % job.place) self.ui.payLabel.setText("%s" % job.pay) self.ui.contractTypeLabel.setText("%s" % job.contract_type) self.ui.formationLabel.setText("%s" % job.formation) self.ui.experienceLabel.setText("%s" % job.experience) self.ui.urlLabel.setText("%s" % (job.url, job.url)) self.ui.jobFrame.show() else: self.ui.jobFrame.hide() QApplication.restoreOverrideCursor() weboob-1.1/weboob/applications/qhandjoob/qhandjoob.py000066400000000000000000000030041265717027300230660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Sébastien Monel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.job import CapJob from weboob.tools.application.qt import QtApplication from weboob.tools.config.yamlconfig import YamlConfig from .main_window import MainWindow class QHandJoob(QtApplication): APPNAME = 'qhandjoob' VERSION = '1.1' COPYRIGHT = u'Copyright(C) 2013-2014 Sébastien Monel' DESCRIPTION = "Qt application to search for job." SHORT_DESCRIPTION = "search for job" CAPS = CapJob CONFIG = {'queries': {}} STORAGE = {'bookmarks': [], 'read': [], 'notes': {}} def main(self, argv): self.load_backends(CapJob) self.create_storage() self.load_config(klass=YamlConfig) self.main_window = MainWindow(self.config, self.storage, self.weboob) self.main_window.show() return self.weboob.loop() weboob-1.1/weboob/applications/qhandjoob/ui/000077500000000000000000000000001265717027300211675ustar00rootroot00000000000000weboob-1.1/weboob/applications/qhandjoob/ui/Makefile000066400000000000000000000002651265717027300226320ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/applications/qhandjoob/ui/__init__.py000066400000000000000000000000001265717027300232660ustar00rootroot00000000000000weboob-1.1/weboob/applications/qhandjoob/ui/main_window.ui000066400000000000000000000415031265717027300240440ustar00rootroot00000000000000 MainWindow 0 0 709 572 QHandJoob Qt::Horizontal 0 0 1 Search search 0 0 QAbstractItemView::NoEditTriggers 128 128 true id : Advanced search 0 0 QAbstractItemView::NoEditTriggers 128 128 true Refresh Qt::Horizontal 1 0 QFrame::StyledPanel QFrame::Raised Qt::Vertical <h1>Loading...</h1> QFormLayout::ExpandingFieldsGrow 75 true Id Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse 75 true Job Name 75 true Publication Date 75 true Society Name 75 true Place 75 true Pay 75 true Contract Type 75 true Formation 75 true Experience 75 true URL Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Loading... true true Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Qt::Vertical QSizePolicy::Expanding 20 5 0 50 true 0 0 709 23 toolBar TopToolBarArea false Backends searchButton jobList weboob-1.1/weboob/applications/qhavedate/000077500000000000000000000000001265717027300205475ustar00rootroot00000000000000weboob-1.1/weboob/applications/qhavedate/__init__.py000066400000000000000000000000721265717027300226570ustar00rootroot00000000000000from .qhavedate import QHaveDate __all__ = ['QHaveDate'] weboob-1.1/weboob/applications/qhavedate/contacts.py000066400000000000000000000535041265717027300227460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import time import logging from PyQt4.QtGui import QWidget, QListWidgetItem, QImage, QIcon, QPixmap, \ QFrame, QMessageBox, QTabWidget, QVBoxLayout, \ QFormLayout, QLabel, QPushButton from PyQt4.QtCore import SIGNAL, Qt from weboob.tools.application.qt import QtDo, HTMLDelegate from weboob.tools.misc import to_unicode from weboob.capabilities.contact import CapContact, Contact from weboob.capabilities.chat import CapChat from weboob.capabilities.messages import CapMessages, CapMessagesPost, Message from weboob.capabilities.base import NotLoaded from .ui.contacts_ui import Ui_Contacts from .ui.contact_thread_ui import Ui_ContactThread from .ui.thread_message_ui import Ui_ThreadMessage from .ui.profile_ui import Ui_Profile from .ui.notes_ui import Ui_Notes class ThreadMessage(QFrame): """ This class represents a message in the thread tab. """ def __init__(self, message, parent=None): QFrame.__init__(self, parent) self.ui = Ui_ThreadMessage() self.ui.setupUi(self) self.set_message(message) def set_message(self, message): self.message = message self.ui.nameLabel.setText(message.sender) header = time.strftime('%Y-%m-%d %H:%M:%S', message.date.timetuple()) if message.flags & message.IS_NOT_RECEIVED: header += u' — Unread' elif message.flags & message.IS_RECEIVED: header += u' — Read' self.ui.headerLabel.setText(header) if message.flags & message.IS_HTML: content = message.content else: content = message.content.replace('&', '&').replace('<', '<').replace('>', '>').replace('\n', '
') self.ui.contentLabel.setText(content) def __eq__(self, m): if not isinstance(m, Message): return False return self.message == m.message class ContactThread(QWidget): """ The thread of the selected contact. """ def __init__(self, weboob, contact, support_reply, parent=None): QWidget.__init__(self, parent) self.ui = Ui_ContactThread() self.ui.setupUi(self) self.weboob = weboob self.contact = contact self.thread = None self.messages = [] self.process_msg = None self.connect(self.ui.refreshButton, SIGNAL('clicked()'), self.refreshMessages) if support_reply: self.connect(self.ui.sendButton, SIGNAL('clicked()'), self.postReply) else: self.ui.frame.hide() self.refreshMessages() def refreshMessages(self, fillobj=False): if self.process_msg: return self.ui.refreshButton.setEnabled(False) def finished(): #v = self.ui.scrollArea.verticalScrollBar() #print v.minimum(), v.value(), v.maximum(), v.sliderPosition() #self.ui.scrollArea.verticalScrollBar().setValue(self.ui.scrollArea.verticalScrollBar().maximum()) self.process_msg = None self.process_msg = QtDo(self.weboob, self.gotThread, self.gotError, finished) if fillobj and self.thread: self.process_msg.do('fillobj', self.thread, ['root'], backends=self.contact.backend) else: self.process_msg.do('get_thread', self.contact.id, backends=self.contact.backend) def gotError(self, backend, error, backtrace): self.ui.textEdit.setEnabled(False) self.ui.sendButton.setEnabled(False) self.ui.refreshButton.setEnabled(True) def gotThread(self, thread): self.ui.textEdit.setEnabled(True) self.ui.sendButton.setEnabled(True) self.ui.refreshButton.setEnabled(True) self.thread = thread if thread.root is NotLoaded: self._insert_load_button(0) else: for message in thread.iter_all_messages(): self._insert_message(message) def _insert_message(self, message): widget = ThreadMessage(message) if widget in self.messages: old_widget = self.messages[self.messages.index(widget)] if old_widget.message.flags != widget.message.flags: old_widget.set_message(widget.message) return for i, m in enumerate(self.messages): if widget.message.date > m.message.date: self.ui.scrollAreaContent.layout().insertWidget(i, widget) self.messages.insert(i, widget) if message.parent is NotLoaded: self._insert_load_button(i) return self.ui.scrollAreaContent.layout().addWidget(widget) self.messages.append(widget) if message.parent is NotLoaded: self._insert_load_button(-1) def _insert_load_button(self, pos): button = QPushButton(self.tr('More messages...')) self.connect(button, SIGNAL('clicked()'), lambda: self._load_button_pressed(button)) if pos >= 0: self.ui.scrollAreaContent.layout().insertWidget(pos, button) else: self.ui.scrollAreaContent.layout().addWidget(button) def _load_button_pressed(self, button): self.ui.scrollAreaContent.layout().removeWidget(button) button.hide() button.deleteLater() self.refreshMessages(fillobj=True) def postReply(self): text = unicode(self.ui.textEdit.toPlainText()) self.ui.textEdit.setEnabled(False) self.ui.sendButton.setEnabled(False) m = Message(thread=self.thread, id=0, title=u'', sender=None, receivers=None, content=text, parent=self.messages[0].message if len(self.messages) > 0 else None) self.process_reply = QtDo(self.weboob, None, self._postReply_eb, self._postReply_fb) self.process_reply.do('post_message', m, backends=self.contact.backend) def _postReply_fb(self): self.ui.textEdit.clear() self.ui.textEdit.setEnabled(True) self.ui.sendButton.setEnabled(True) self.refreshMessages() self.process_reply = None def _postReply_eb(self, backend, error, backtrace): content = unicode(self.tr('Unable to send message:\n%s\n')) % to_unicode(error) if logging.root.level <= logging.DEBUG: content += '\n%s\n' % to_unicode(backtrace) QMessageBox.critical(self, self.tr('Error while posting reply'), content, QMessageBox.Ok) self.process_reply = None class ContactProfile(QWidget): def __init__(self, weboob, contact, parent=None): QWidget.__init__(self, parent) self.ui = Ui_Profile() self.ui.setupUi(self) self.connect(self.ui.previousButton, SIGNAL('clicked()'), self.previousClicked) self.connect(self.ui.nextButton, SIGNAL('clicked()'), self.nextClicked) self.weboob = weboob self.contact = contact self.loaded_profile = False self.displayed_photo_idx = 0 self.process_photo = {} missing_fields = self.gotProfile(contact) if len(missing_fields) > 0: self.process_contact = QtDo(self.weboob, self.gotProfile, self.gotError) self.process_contact.do('fillobj', self.contact, missing_fields, backends=self.contact.backend) def gotError(self, backend, error, backtrace): self.ui.frame_photo.hide() self.ui.descriptionEdit.setText('

Unable to show profile

%s

' % to_unicode(error)) def gotProfile(self, contact): missing_fields = set() self.display_photo() self.ui.nicknameLabel.setText('

%s

' % contact.name) if contact.status == Contact.STATUS_ONLINE: status_color = 0x00aa00 elif contact.status == Contact.STATUS_OFFLINE: status_color = 0xff0000 elif contact.status == Contact.STATUS_AWAY: status_color = 0xffad16 else: status_color = 0xaaaaaa self.ui.statusLabel.setText('%s' % (status_color, contact.status_msg)) self.ui.contactUrlLabel.setText('URL: %s' % (contact.url, contact.url)) if contact.summary is NotLoaded: self.ui.descriptionEdit.setText('

Description

Receiving...

') missing_fields.add('summary') else: self.ui.descriptionEdit.setText('

Description

%s

' % contact.summary.replace('\n', '
')) if not contact.profile: missing_fields.add('profile') elif not self.loaded_profile: self.loaded_profile = True for head in contact.profile.itervalues(): if head.flags & head.HEAD: widget = self.ui.headWidget else: widget = self.ui.profileTab self.process_node(head, widget) return missing_fields def process_node(self, node, widget): # Set the value widget value = None if node.flags & node.SECTION: value = QWidget() value.setLayout(QFormLayout()) for sub in node.value.itervalues(): self.process_node(sub, value) elif isinstance(node.value, list): value = QLabel('
'.join(unicode(s) for s in node.value)) value.setWordWrap(True) elif isinstance(node.value, tuple): value = QLabel(', '.join(unicode(s) for s in node.value)) value.setWordWrap(True) elif isinstance(node.value, (basestring,int,long,float)): value = QLabel(unicode(node.value)) else: logging.warning('Not supported value: %r' % node.value) return if isinstance(value, QLabel): value.setTextInteractionFlags(Qt.TextSelectableByMouse|Qt.TextSelectableByKeyboard|Qt.LinksAccessibleByMouse) # Insert the value widget into the parent widget, depending # of its type. if isinstance(widget, QTabWidget): widget.addTab(value, node.label) elif isinstance(widget.layout(), QFormLayout): label = QLabel(u'%s: ' % node.label) widget.layout().addRow(label, value) elif isinstance(widget.layout(), QVBoxLayout): widget.layout().addWidget(QLabel(u'

%s

' % node.label)) widget.layout().addWidget(value) else: logging.warning('Not supported widget: %r' % widget) def previousClicked(self): if len(self.contact.photos) == 0: return self.displayed_photo_idx = (self.displayed_photo_idx - 1) % len(self.contact.photos) self.display_photo() def nextClicked(self): if len(self.contact.photos) == 0: return self.displayed_photo_idx = (self.displayed_photo_idx + 1) % len(self.contact.photos) self.display_photo() def display_photo(self): if self.displayed_photo_idx >= len(self.contact.photos) or self.displayed_photo_idx < 0: self.displayed_photo_idx = len(self.contact.photos) - 1 if self.displayed_photo_idx < 0: self.ui.photoUrlLabel.setText('') return photo = self.contact.photos.values()[self.displayed_photo_idx] if photo.data: data = photo.data if photo.id in self.process_photo: self.process_photo.pop(photo.id) else: self.process_photo[photo.id] = QtDo(self.weboob, lambda p: self.display_photo()) self.process_photo[photo.id].do('fillobj', photo, ['data'], backends=self.contact.backend) if photo.thumbnail_data: data = photo.thumbnail_data else: return img = QImage.fromData(data) img = img.scaledToWidth(self.width()/3) self.ui.photoLabel.setPixmap(QPixmap.fromImage(img)) if photo.url is not NotLoaded: text = '%s' % (photo.url, photo.url) if photo.hidden: text += '
(Hidden photo)' self.ui.photoUrlLabel.setText(text) class ContactNotes(QWidget): """ Widget for storing notes about a contact """ def __init__(self, weboob, contact, parent=None): QWidget.__init__(self, parent) self.ui = Ui_Notes() self.ui.setupUi(self) self.weboob = weboob self.contact = contact self.ui.textEdit.setEnabled(False) self.ui.saveButton.setEnabled(False) def finished(): self.process = None self.ui.textEdit.setEnabled(True) self.ui.saveButton.setEnabled(True) self.process = QtDo(self.weboob, self._getNotes_cb, self._getNotes_eb, finished) self.process.do('get_notes', self.contact.id, backends=(self.contact.backend,)) self.connect(self.ui.saveButton, SIGNAL('clicked()'), self.saveNotes) def _getNotes_cb(self, data): if data: self.ui.textEdit.setText(data) def _getNotes_eb(self, backend, error, backtrace): if isinstance(error, NotImplementedError): return self.ui.textEdit.setEnabled(True) self.ui.saveButton.setEnabled(True) content = unicode(self.tr('Unable to load notes:\n%s\n')) % to_unicode(error) if logging.root.level <= logging.DEBUG: content += '\n%s\n' % to_unicode(backtrace) QMessageBox.critical(self, self.tr('Error while loading notes'), content, QMessageBox.Ok) def saveNotes(self): text = unicode(self.ui.textEdit.toPlainText()) self.ui.saveButton.setEnabled(False) self.ui.textEdit.setEnabled(False) self.process = QtDo(self.weboob, None, self._saveNotes_eb, self._saveNotes_fb) self.process.do('save_notes', self.contact.id, text, backends=(self.contact.backend,)) def _saveNotes_fb(self): self.ui.saveButton.setEnabled(True) self.ui.textEdit.setEnabled(True) def _saveNotes_eb(self, backend, error, backtrace): content = unicode(self.tr('Unable to save notes:\n%s\n')) % to_unicode(error) if logging.root.level <= logging.DEBUG: content += '\n%s\n' % to_unicode(backtrace) QMessageBox.critical(self, self.tr('Error while saving notes'), content, QMessageBox.Ok) class IGroup(object): def __init__(self, weboob, id, name): self.id = id self.name = name self.weboob = weboob def iter_contacts(self, cb): raise NotImplementedError() class MetaGroup(IGroup): def iter_contacts(self, cb): if self.id == 'online': status = Contact.STATUS_ONLINE|Contact.STATUS_AWAY elif self.id == 'offline': status = Contact.STATUS_OFFLINE else: status = Contact.STATUS_ALL self.process = QtDo(self.weboob, lambda d: self.cb(cb, d), fb=lambda: self.fb(cb)) self.process.do('iter_contacts', status, caps=CapContact) def cb(self, cb, contact): if contact: cb(contact) def fb(self, fb): self.process = None if fb: fb(None) class ContactsWidget(QWidget): def __init__(self, weboob, parent=None): QWidget.__init__(self, parent) self.ui = Ui_Contacts() self.ui.setupUi(self) self.weboob = weboob self.contact = None self.ui.contactList.setItemDelegate(HTMLDelegate()) self.url_process = None self.photo_processes = {} self.ui.groupBox.addItem('All', MetaGroup(self.weboob, 'all', self.tr('All'))) self.ui.groupBox.addItem('Online', MetaGroup(self.weboob, 'online', self.tr('Online'))) self.ui.groupBox.addItem('Offline', MetaGroup(self.weboob, 'offline', self.tr('Offline'))) self.ui.groupBox.setCurrentIndex(1) self.connect(self.ui.groupBox, SIGNAL('currentIndexChanged(int)'), self.groupChanged) self.connect(self.ui.contactList, SIGNAL('itemClicked(QListWidgetItem*)'), self.contactChanged) self.connect(self.ui.refreshButton, SIGNAL('clicked()'), self.refreshContactList) self.connect(self.ui.urlButton, SIGNAL('clicked()'), self.urlClicked) def load(self): self.refreshContactList() self.ui.backendsList.clear() for backend in self.weboob.iter_backends(): self.ui.backendsList.addItem(backend.name) def groupChanged(self, i): self.refreshContactList() def refreshContactList(self): self.ui.contactList.clear() self.ui.refreshButton.setEnabled(False) i = self.ui.groupBox.currentIndex() group = self.ui.groupBox.itemData(i).toPyObject() group.iter_contacts(self.addContact) def setPhoto(self, contact, item): if not contact: return False try: self.photo_processes.pop(contact.id, None) except KeyError: pass img = None for photo in contact.photos.itervalues(): if photo.thumbnail_data: img = QImage.fromData(photo.thumbnail_data) break if img: item.setIcon(QIcon(QPixmap.fromImage(img))) return True return False def addContact(self, contact): if not contact: self.ui.refreshButton.setEnabled(True) return status = '' if contact.status == Contact.STATUS_ONLINE: status = u'Online' status_color = 0x00aa00 elif contact.status == Contact.STATUS_OFFLINE: status = u'Offline' status_color = 0xff0000 elif contact.status == Contact.STATUS_AWAY: status = u'Away' status_color = 0xffad16 else: status = u'Unknown' status_color = 0xaaaaaa if contact.status_msg: status += u' — %s' % contact.status_msg item = QListWidgetItem() item.setText('

%s

%s
%s' % (contact.name, status_color, status, contact.backend)) item.setData(Qt.UserRole, contact) if contact.photos is NotLoaded: process = QtDo(self.weboob, lambda c: self.setPhoto(c, item)) process.do('fillobj', contact, ['photos'], backends=contact.backend) self.photo_processes[contact.id] = process elif len(contact.photos) > 0: if not self.setPhoto(contact, item): photo = contact.photos.values()[0] process = QtDo(self.weboob, lambda p: self.setPhoto(contact, item)) process.do('fillobj', photo, ['thumbnail_data'], backends=contact.backend) self.photo_processes[contact.id] = process for i in xrange(self.ui.contactList.count()): if self.ui.contactList.item(i).data(Qt.UserRole).toPyObject().status > contact.status: self.ui.contactList.insertItem(i, item) return self.ui.contactList.addItem(item) def contactChanged(self, current): if not current: return contact = current.data(Qt.UserRole).toPyObject() self.setContact(contact) def setContact(self, contact): if not contact or contact == self.contact: return if not isinstance(contact, Contact): return self.retrieveContact(contact) self.ui.tabWidget.clear() self.contact = contact backend = self.weboob.get_backend(self.contact.backend) self.ui.tabWidget.addTab(ContactProfile(self.weboob, self.contact), self.tr('Profile')) if backend.has_caps(CapMessages): self.ui.tabWidget.addTab(ContactThread(self.weboob, self.contact, backend.has_caps(CapMessagesPost)), self.tr('Messages')) if backend.has_caps(CapChat): self.ui.tabWidget.setTabEnabled(self.ui.tabWidget.addTab(QWidget(), self.tr('Chat')), False) self.ui.tabWidget.setTabEnabled(self.ui.tabWidget.addTab(QWidget(), self.tr('Calendar')), False) self.ui.tabWidget.addTab(ContactNotes(self.weboob, self.contact), self.tr('Notes')) def urlClicked(self): url = unicode(self.ui.urlEdit.text()) if not url: return self.retrieveContact(url) def retrieveContact(self, url): backend_name = unicode(self.ui.backendsList.currentText()) self.ui.urlButton.setEnabled(False) def finished(): self.url_process = None self.ui.urlButton.setEnabled(True) self.url_process = QtDo(self.weboob, self.retrieveContact_cb, self.retrieveContact_eb, finished) self.url_process.do('get_contact', url, backends=backend_name) def retrieveContact_cb(self, contact): self.ui.urlEdit.clear() self.setContact(contact) def retrieveContact_eb(self, backend, error, backtrace): content = unicode(self.tr('Unable to get contact:\n%s\n')) % to_unicode(error) if logging.root.level <= logging.DEBUG: content += u'\n%s\n' % to_unicode(backtrace) QMessageBox.critical(self, self.tr('Error while getting contact'), content, QMessageBox.Ok) weboob-1.1/weboob/applications/qhavedate/events.py000066400000000000000000000134431265717027300224320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from PyQt4.QtGui import QWidget, QTreeWidgetItem, QImage, QIcon, QPixmap from PyQt4.QtCore import SIGNAL, Qt from weboob.capabilities.base import NotLoaded from weboob.tools.application.qt import QtDo, HTMLDelegate from .ui.events_ui import Ui_Events class EventsWidget(QWidget): def __init__(self, weboob, parent=None): QWidget.__init__(self, parent) self.ui = Ui_Events() self.ui.setupUi(self) self.weboob = weboob self.photo_processes = {} self.event_filter = None self.connect(self.ui.eventsList, SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.eventDoubleClicked) self.connect(self.ui.typeBox, SIGNAL('currentIndexChanged(int)'), self.typeChanged) self.connect(self.ui.refreshButton, SIGNAL('clicked()'), self.refreshEventsList) self.ui.eventsList.setItemDelegate(HTMLDelegate()) self.ui.eventsList.sortByColumn(1, Qt.DescendingOrder) def load(self): self.refreshEventsList() def typeChanged(self, i): if self.ui.refreshButton.isEnabled(): self.refreshEventsList() def refreshEventsList(self): self.ui.eventsList.clear() self.ui.refreshButton.setEnabled(False) if self.ui.typeBox.currentIndex() >= 0: # XXX strangely, in gotEvent() in the loop to check if there is already the # event type to try to introduce it in list, itemData() returns the right value. # But, I don't know why, here, it will ALWAYS return None... # So the filter does not work currently. self.events_filter = self.ui.typeBox.itemData(self.ui.typeBox.currentIndex()) else: self.event_filter = None self.ui.typeBox.setEnabled(False) self.ui.typeBox.clear() self.ui.typeBox.addItem('All', None) def finished(): self.ui.refreshButton.setEnabled(True) self.ui.typeBox.setEnabled(True) self.process = QtDo(self.weboob, self.gotEvent, fb=finished) self.process.do('iter_events') def setPhoto(self, contact, item): if not contact: return False try: self.photo_processes.pop(contact.id, None) except KeyError: pass img = None for photo in contact.photos.itervalues(): if photo.thumbnail_data: img = QImage.fromData(photo.thumbnail_data) break if img: item.setIcon(0, QIcon(QPixmap.fromImage(img))) self.ui.eventsList.resizeColumnToContents(0) return True return False def gotEvent(self, event): found = False for i in xrange(self.ui.typeBox.count()): s = self.ui.typeBox.itemData(i) if s == event.type: found = True if not found: print(event.type) self.ui.typeBox.addItem(event.type.capitalize(), event.type) if event.type == self.event_filter: self.ui.typeBox.setCurrentIndex(self.ui.typeBox.count()-1) if self.event_filter and self.event_filter != event.type: return if not event.contact: return contact = event.contact contact.backend = event.backend status = '' if contact.status == contact.STATUS_ONLINE: status = u'Online' status_color = 0x00aa00 elif contact.status == contact.STATUS_OFFLINE: status = u'Offline' status_color = 0xff0000 elif contact.status == contact.STATUS_AWAY: status = u'Away' status_color = 0xffad16 else: status = u'Unknown' status_color = 0xaaaaaa if contact.status_msg: status += u' — %s' % contact.status_msg name = '

%s

%s
%s' % (contact.name, status_color, status, event.backend) date = event.date.strftime('%Y-%m-%d %H:%M') type = event.type message = event.message item = QTreeWidgetItem(None, [name, date, type, message]) item.setData(0, Qt.UserRole, event) if contact.photos is NotLoaded: process = QtDo(self.weboob, lambda c: self.setPhoto(c, item)) process.do('fillobj', contact, ['photos'], backends=contact.backend) self.photo_processes[contact.id] = process elif len(contact.photos) > 0: if not self.setPhoto(contact, item): photo = contact.photos.values()[0] process = QtDo(self.weboob, lambda p: self.setPhoto(contact, item)) process.do('fillobj', photo, ['thumbnail_data'], backends=contact.backend) self.photo_processes[contact.id] = process self.ui.eventsList.addTopLevelItem(item) self.ui.eventsList.resizeColumnToContents(0) self.ui.eventsList.resizeColumnToContents(1) def eventDoubleClicked(self, item, col): event = item.data(0, Qt.UserRole).toPyObject() self.emit(SIGNAL('display_contact'), event.contact) weboob-1.1/weboob/applications/qhavedate/main_window.py000066400000000000000000000063271265717027300234440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QWidget from PyQt4.QtCore import SIGNAL from weboob.tools.application.qt import QtMainWindow from weboob.tools.application.qt.backendcfg import BackendCfg from weboob.capabilities.dating import CapDating try: from weboob.applications.qboobmsg.messages_manager import MessagesManager HAVE_BOOBMSG = True except ImportError: HAVE_BOOBMSG = False from .ui.main_window_ui import Ui_MainWindow from .status import AccountsStatus from .contacts import ContactsWidget from .events import EventsWidget from .search import SearchWidget class MainWindow(QtMainWindow): def __init__(self, config, weboob, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.weboob = weboob self.loaded_tabs = {} self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) self.connect(self.ui.tabWidget, SIGNAL('currentChanged(int)'), self.tabChanged) self.addTab(AccountsStatus(self.weboob), self.tr('Status')) self.addTab(MessagesManager(self.weboob) if HAVE_BOOBMSG else None, self.tr('Messages')) self.addTab(ContactsWidget(self.weboob), self.tr('Contacts')) self.addTab(EventsWidget(self.weboob), self.tr('Events')) self.addTab(SearchWidget(self.weboob), self.tr('Search')) self.addTab(None, self.tr('Calendar')) self.addTab(None, self.tr('Optimizations')) if self.weboob.count_backends() == 0: self.backendsConfig() def backendsConfig(self): bckndcfg = BackendCfg(self.weboob, (CapDating,), self) if bckndcfg.run(): self.loaded_tabs.clear() widget = self.ui.tabWidget.widget(self.ui.tabWidget.currentIndex()) widget.load() def addTab(self, widget, title): if widget: self.connect(widget, SIGNAL('display_contact'), self.display_contact) self.ui.tabWidget.addTab(widget, title) else: index = self.ui.tabWidget.addTab(QWidget(), title) self.ui.tabWidget.setTabEnabled(index, False) def tabChanged(self, i): widget = self.ui.tabWidget.currentWidget() if hasattr(widget, 'load') and i not in self.loaded_tabs: widget.load() self.loaded_tabs[i] = True def display_contact(self, contact): self.ui.tabWidget.setCurrentIndex(2) widget = self.ui.tabWidget.currentWidget() widget.setContact(contact) weboob-1.1/weboob/applications/qhavedate/qhavedate.py000066400000000000000000000026651265717027300230740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.dating import CapDating from weboob.tools.application.qt import QtApplication from .main_window import MainWindow class QHaveDate(QtApplication): APPNAME = 'qhavedate' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-2014 Romain Bignon' DESCRIPTION = "Qt application allowing to interact with various dating websites." SHORT_DESCRIPTION = "interact with dating websites" CAPS = CapDating STORAGE_FILENAME = 'dating.storage' def main(self, argv): self.create_storage(self.STORAGE_FILENAME) self.load_backends(CapDating) self.main_window = MainWindow(self.config, self.weboob) self.main_window.show() return self.weboob.loop() weboob-1.1/weboob/applications/qhavedate/search.py000066400000000000000000000062621265717027300223740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QWidget from PyQt4.QtCore import SIGNAL from weboob.tools.application.qt import QtDo from .ui.search_ui import Ui_Search from .contacts import ContactProfile from .status import Account class SearchWidget(QWidget): def __init__(self, weboob, parent=None): QWidget.__init__(self, parent) self.ui = Ui_Search() self.ui.setupUi(self) self.weboob = weboob self.contacts = [] self.accounts = [] self.current = None self.connect(self.ui.nextButton, SIGNAL('clicked()'), self.next) self.connect(self.ui.queryButton, SIGNAL('clicked()'), self.sendQuery) def load(self): while self.ui.statusFrame.layout().count() > 0: item = self.ui.statusFrame.layout().takeAt(0) if item.widget(): item.widget().deinit() item.widget().hide() item.widget().deleteLater() self.accounts = [] for backend in self.weboob.iter_backends(): account = Account(self.weboob, backend) account.title.setText(u'

%s

' % backend.name) self.accounts.append(account) self.ui.statusFrame.layout().addWidget(account) self.ui.statusFrame.layout().addStretch() self.getNewProfiles() def updateStats(self): for account in self.accounts: account.updateStats() def getNewProfiles(self): self.newprofiles_process = QtDo(self.weboob, self.retrieveNewContacts_cb) self.newprofiles_process.do('iter_new_contacts') def retrieveNewContacts_cb(self, contact): self.contacts.insert(0, contact) self.ui.queueLabel.setText('%d' % len(self.contacts)) if self.current is None: self.next() def next(self): try: contact = self.contacts.pop() except IndexError: contact = None self.ui.queueLabel.setText('%d' % len(self.contacts)) self.setContact(contact) self.updateStats() def setContact(self, contact): self.current = contact if contact is not None: widget = ContactProfile(self.weboob, contact) self.ui.scrollArea.setWidget(widget) else: self.ui.scrollArea.setWidget(None) def sendQuery(self): self.newprofiles_process = QtDo(self.weboob, None, fb=self.next) self.newprofiles_process.do('send_query', self.current.id, backends=[self.current.backend]) weboob-1.1/weboob/applications/qhavedate/status.py000066400000000000000000000107221265717027300224460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QScrollArea, QWidget, QHBoxLayout, QVBoxLayout, QFrame, QLabel, QImage, QPixmap from weboob.capabilities.account import CapAccount, StatusField from weboob.tools.application.qt import QtDo from weboob.tools.misc import to_unicode class Account(QFrame): def __init__(self, weboob, backend, parent=None): QFrame.__init__(self, parent) self.setFrameShape(QFrame.StyledPanel) self.setFrameShadow(QFrame.Raised) self.weboob = weboob self.backend = backend self.setLayout(QVBoxLayout()) self.timer = None head = QHBoxLayout() headw = QWidget() headw.setLayout(head) self.title = QLabel(u'

%s — %s

' % (backend.name, backend.DESCRIPTION)) self.body = QLabel() minfo = self.weboob.repositories.get_module_info(backend.NAME) icon_path = self.weboob.repositories.get_module_icon_path(minfo) if icon_path: self.icon = QLabel() img = QImage(icon_path) self.icon.setPixmap(QPixmap.fromImage(img)) head.addWidget(self.icon) head.addWidget(self.title) head.addStretch() self.layout().addWidget(headw) if backend.has_caps(CapAccount): self.body.setText(u'Waiting...') self.layout().addWidget(self.body) self.timer = self.weboob.repeat(60, self.updateStats) def deinit(self): if self.timer is not None: self.weboob.stop(self.timer) def updateStats(self): self.process = QtDo(self.weboob, self.updateStats_cb, self.updateStats_eb, self.updateStats_fb) self.process.body = u'' self.process.in_p = False self.process.do('get_account_status', backends=self.backend) def updateStats_fb(self): if self.process.in_p: self.process.body += u"

" self.body.setText(self.process.body) self.process = None def updateStats_cb(self, field): if field.flags & StatusField.FIELD_HTML: value = u'%s' % field.value else: value = (u'%s' % field.value).replace('&', '&').replace('<', '<').replace('>', '>') if field.flags & StatusField.FIELD_TEXT: if self.process.in_p: self.process.body += u'

' self.process.body += u'

%s

' % value self.process.in_p = False else: if not self.process.in_p: self.process.body += u"

" self.process.in_p = True else: self.process.body += u"
" self.process.body += u'%s: %s' % (field.label, field.value) def updateStats_eb(self, backend, err, backtrace): self.body.setText(u'Unable to connect: %s' % to_unicode(err)) self.title.setText(u'%s' % unicode(self.title.text())) class AccountsStatus(QScrollArea): def __init__(self, weboob, parent=None): QScrollArea.__init__(self, parent) self.weboob = weboob self.setFrameShadow(self.Plain) self.setFrameShape(self.NoFrame) self.setWidgetResizable(True) widget = QWidget(self) widget.setLayout(QVBoxLayout()) widget.show() self.setWidget(widget) def load(self): while self.widget().layout().count() > 0: item = self.widget().layout().takeAt(0) if item.widget(): item.widget().deinit() item.widget().hide() item.widget().deleteLater() for backend in self.weboob.iter_backends(): account = Account(self.weboob, backend) self.widget().layout().addWidget(account) self.widget().layout().addStretch() weboob-1.1/weboob/applications/qhavedate/ui/000077500000000000000000000000001265717027300211645ustar00rootroot00000000000000weboob-1.1/weboob/applications/qhavedate/ui/Makefile000066400000000000000000000002651265717027300226270ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/applications/qhavedate/ui/__init__.py000066400000000000000000000000001265717027300232630ustar00rootroot00000000000000weboob-1.1/weboob/applications/qhavedate/ui/contact_thread.ui000066400000000000000000000111211265717027300245010ustar00rootroot00000000000000 ContactThread 0 0 578 429 Form Qt::Vertical 0 0 QFrame::StyledPanel QFrame::Raised false false 0 0 Send 0 5 0 Qt::Horizontal 40 20 ../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../usr/share/icons/oxygen/16x16/actions/view-refresh.png../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../usr/share/icons/oxygen/16x16/actions/view-refresh.png 0 1 Qt::ScrollBarAsNeeded true Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft 0 0 556 154 QWidget#scrollAreaContent { background-color: rgb(255, 255, 255); } weboob-1.1/weboob/applications/qhavedate/ui/contacts.ui000066400000000000000000000073061265717027300233470ustar00rootroot00000000000000 Contacts 0 0 478 374 Form Qt::Horizontal 0 0 QFrame::StyledPanel QFrame::Raised ../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../usr/share/icons/oxygen/16x16/actions/view-refresh.png../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../usr/share/icons/oxygen/16x16/actions/view-refresh.png 120 120 1 true false true From URL Display 1 0 weboob-1.1/weboob/applications/qhavedate/ui/events.ui000066400000000000000000000045241265717027300230340ustar00rootroot00000000000000 Events 0 0 497 318 Form ../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../usr/share/icons/oxygen/16x16/actions/view-refresh.png../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../usr/share/icons/oxygen/16x16/actions/view-refresh.png QAbstractItemView::NoEditTriggers true 64 64 false true true Contact Date Type Message weboob-1.1/weboob/applications/qhavedate/ui/main_window.ui000066400000000000000000000041671265717027300240460ustar00rootroot00000000000000 MainWindow 0 0 763 580 QHaveDate -1 0 0 763 24 File toolBar TopToolBarArea false Backends Quit Quit actionQuit triggered() MainWindow close() -1 -1 381 289 weboob-1.1/weboob/applications/qhavedate/ui/notes.ui000066400000000000000000000012341265717027300226530ustar00rootroot00000000000000 Notes 0 0 430 323 Form Save weboob-1.1/weboob/applications/qhavedate/ui/profile.ui000066400000000000000000000212101265717027300231570ustar00rootroot00000000000000 Profile 0 0 755 647 Form 0 QFrame::NoFrame QFrame::Plain true 0 0 755 647 0 0 0 0 0 QFrame::StyledPanel QFrame::Raised <h1>Loading...</h1> Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse <b>URL:</b> true Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse 0 9 0 0 Qt::Vertical 20 0 QFrame::StyledPanel QFrame::Raised 0 0 20 16777215 < Qt::AlignCenter 0 0 20 16777215 > Qt::AlignCenter Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Qt::Vertical 13 0 Qt::Horizontal 0 0 true 2 0 -1 weboob-1.1/weboob/applications/qhavedate/ui/search.ui000066400000000000000000000063021265717027300227710ustar00rootroot00000000000000 Search 0 0 438 349 Form 4 0 300 16777215 QFrame::StyledPanel QFrame::Raised <b>Profiles in queue:</b> Qt::Horizontal 40 20 QFrame::StyledPanel QFrame::Raised Query Next true 0 0 178 235 weboob-1.1/weboob/applications/qhavedate/ui/thread_message.ui000066400000000000000000000053671265717027300245110ustar00rootroot00000000000000 ThreadMessage 0 0 552 76 Frame QFrame::StyledPanel QFrame::Raised Qt::Vertical 20 1 0 0 true Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse true Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse Qt::Vertical 20 1 weboob-1.1/weboob/applications/qvideoob/000077500000000000000000000000001265717027300204155ustar00rootroot00000000000000weboob-1.1/weboob/applications/qvideoob/__init__.py000066400000000000000000000000671265717027300225310ustar00rootroot00000000000000from .qvideoob import QVideoob __all__ = ['QVideoob'] weboob-1.1/weboob/applications/qvideoob/main_window.py000066400000000000000000000125021265717027300233020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtCore import SIGNAL from weboob.capabilities.video import CapVideo from weboob.tools.application.qt import QtMainWindow, QtDo from weboob.tools.application.qt.backendcfg import BackendCfg from weboob.applications.qvideoob.ui.main_window_ui import Ui_MainWindow from .video import Video from .minivideo import MiniVideo class MainWindow(QtMainWindow): def __init__(self, config, weboob, app, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.weboob = weboob self.minivideos = [] self.app = app self.ui.sortbyEdit.setCurrentIndex(int(self.config.get('settings', 'sortby'))) self.ui.nsfwCheckBox.setChecked(int(self.config.get('settings', 'nsfw'))) self.ui.sfwCheckBox.setChecked(int(self.config.get('settings', 'sfw'))) self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search) self.connect(self.ui.urlEdit, SIGNAL("returnPressed()"), self.openURL) self.connect(self.ui.nsfwCheckBox, SIGNAL("stateChanged(int)"), self.nsfwChanged) self.connect(self.ui.sfwCheckBox, SIGNAL("stateChanged(int)"), self.sfwChanged) self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) self.loadBackendsList() if self.ui.backendEdit.count() == 0: self.backendsConfig() def backendsConfig(self): bckndcfg = BackendCfg(self.weboob, (CapVideo,), self) if bckndcfg.run(): self.loadBackendsList() def loadBackendsList(self): self.ui.backendEdit.clear() for i, backend in enumerate(self.weboob.iter_backends()): if i == 0: self.ui.backendEdit.addItem('All backends', '') self.ui.backendEdit.addItem(backend.name, backend.name) if backend.name == self.config.get('settings', 'backend'): self.ui.backendEdit.setCurrentIndex(i+1) if self.ui.backendEdit.count() == 0: self.ui.searchEdit.setEnabled(False) self.ui.urlEdit.setEnabled(False) else: self.ui.searchEdit.setEnabled(True) self.ui.urlEdit.setEnabled(True) def nsfwChanged(self, state): self.config.set('settings', 'nsfw', int(self.ui.nsfwCheckBox.isChecked())) self.updateVideosDisplay() def sfwChanged(self, state): self.config.set('settings', 'sfw', int(self.ui.sfwCheckBox.isChecked())) self.updateVideosDisplay() def updateVideosDisplay(self): for minivideo in self.minivideos: if (minivideo.video.nsfw and self.ui.nsfwCheckBox.isChecked() or not minivideo.video.nsfw and self.ui.sfwCheckBox.isChecked()): minivideo.show() else: minivideo.hide() def search(self): pattern = unicode(self.ui.searchEdit.text()) if not pattern: return for minivideo in self.minivideos: self.ui.scrollAreaContent.layout().removeWidget(minivideo) minivideo.hide() minivideo.deleteLater() self.minivideos = [] self.ui.searchEdit.setEnabled(False) backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString()) def finished(): self.ui.searchEdit.setEnabled(True) self.process = None self.process = QtDo(self.weboob, self.addVideo, fb=finished) self.process.do(self.app._do_complete, 20, (), 'search_videos', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True, backends=backend_name) def addVideo(self, video): minivideo = MiniVideo(self.weboob, self.weboob[video.backend], video) self.ui.scrollAreaContent.layout().addWidget(minivideo) self.minivideos.append(minivideo) if (video.nsfw and not self.ui.nsfwCheckBox.isChecked() or not video.nsfw and not self.ui.sfwCheckBox.isChecked()): minivideo.hide() def openURL(self): url = unicode(self.ui.urlEdit.text()) if not url: return for backend in self.weboob.iter_backends(): video = backend.get_video(url) if video: video_widget = Video(video, self) video_widget.show() self.ui.urlEdit.clear() def closeEvent(self, ev): self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())) self.config.set('settings', 'sortby', self.ui.sortbyEdit.currentIndex()) self.config.save() ev.accept() weboob-1.1/weboob/applications/qvideoob/minivideo.py000066400000000000000000000047251265717027300227620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QFrame, QImage, QPixmap from weboob.tools.application.qt import QtDo from weboob.applications.qvideoob.ui.minivideo_ui import Ui_MiniVideo from .video import Video class MiniVideo(QFrame): def __init__(self, weboob, backend, video, parent=None): QFrame.__init__(self, parent) self.ui = Ui_MiniVideo() self.ui.setupUi(self) self.weboob = weboob self.backend = backend self.video = video self.ui.titleLabel.setText(video.title) self.ui.backendLabel.setText(backend.name) self.ui.durationLabel.setText(unicode(video.duration)) self.ui.authorLabel.setText(unicode(video.author)) self.ui.dateLabel.setText(video.date and unicode(video.date) or '') if video.rating_max: self.ui.ratingLabel.setText('%s / %s' % (video.rating, video.rating_max)) else: self.ui.ratingLabel.setText('%s' % video.rating) self.process_thumbnail = QtDo(self.weboob, self.gotThumbnail) self.process_thumbnail.do('fillobj', self.video, ['thumbnail'], backends=backend) def gotThumbnail(self, video): if video.thumbnail and video.thumbnail.data: img = QImage.fromData(video.thumbnail.data) self.ui.imageLabel.setPixmap(QPixmap.fromImage(img)) def enterEvent(self, event): self.setFrameShadow(self.Sunken) QFrame.enterEvent(self, event) def leaveEvent(self, event): self.setFrameShadow(self.Raised) QFrame.leaveEvent(self, event) def mousePressEvent(self, event): QFrame.mousePressEvent(self, event) video = self.backend.fillobj(self.video) if video: video_widget = Video(video, self) video_widget.show() weboob-1.1/weboob/applications/qvideoob/qvideoob.py000066400000000000000000000030771265717027300226060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.video import CapVideo from weboob.tools.application.qt import QtApplication from .main_window import MainWindow class QVideoob(QtApplication): APPNAME = 'qvideoob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-2014 Romain Bignon' DESCRIPTION = "Qt application allowing to search videos on various websites and play them." SHORT_DESCRIPTION = "search and play videos" CAPS = CapVideo CONFIG = {'settings': {'nsfw': 1, 'sfw': 1, 'sortby': 0, 'backend': '' } } def main(self, argv): self.load_backends(CapVideo) self.load_config() self.main_window = MainWindow(self.config, self.weboob, self) self.main_window.show() return self.weboob.loop() weboob-1.1/weboob/applications/qvideoob/ui/000077500000000000000000000000001265717027300210325ustar00rootroot00000000000000weboob-1.1/weboob/applications/qvideoob/ui/Makefile000066400000000000000000000002651265717027300224750ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/applications/qvideoob/ui/__init__.py000066400000000000000000000000001265717027300231310ustar00rootroot00000000000000weboob-1.1/weboob/applications/qvideoob/ui/main_window.ui000066400000000000000000000124101265717027300237020ustar00rootroot00000000000000 MainWindow 0 0 582 463 QVideoob QFrame::StyledPanel QFrame::Raised Search: 0 0 Relevance Rating Duration Date 10 0 0 0 Display: SFW true NSFW true Qt::Horizontal 40 20 true 0 0 560 230 QFrame::StyledPanel QFrame::Raised URL: 0 0 582 25 toolBar TopToolBarArea false Backends weboob-1.1/weboob/applications/qvideoob/ui/minivideo.ui000066400000000000000000000113371265717027300233610ustar00rootroot00000000000000 MiniVideo 0 0 464 132 Form QFrame::StyledPanel QFrame::Raised 9 5 5 0 0 QFormLayout::ExpandingFieldsGrow 75 true Title 0 0 50 true false TextLabel 75 true Duration TextLabel 75 true Author TextLabel 75 true Date TextLabel 75 true Rating TextLabel 75 true Where TextLabel weboob-1.1/weboob/applications/qvideoob/ui/video.ui000066400000000000000000000135151265717027300225040ustar00rootroot00000000000000 Video 0 0 647 404 Video 12 75 true QFrame::Box QFrame::Raised TextLabel Qt::AlignCenter 0 0 QFrame::StyledPanel QFrame::Sunken 0 0 true true QFrame::StyledPanel QFrame::Raised QFormLayout::ExpandingFieldsGrow 75 true URL true ArrowCursor true false true 75 true Duration TextLabel 75 true Author TextLabel 75 true Date TextLabel 75 true Rating TextLabel Phonon::VideoPlayer QWidget

phonon/videoplayer.h
Phonon::SeekSlider QWidget
phonon/seekslider.h
weboob-1.1/weboob/applications/qvideoob/video.py000066400000000000000000000036571265717027300221100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtCore import QUrl from PyQt4.QtGui import QDialog from PyQt4.phonon import Phonon from weboob.applications.qvideoob.ui.video_ui import Ui_Video class Video(QDialog): def __init__(self, video, parent=None): QDialog.__init__(self, parent) self.ui = Ui_Video() self.ui.setupUi(self) self.video = video self.setWindowTitle("Video - %s" % video.title) self.ui.urlEdit.setText(video.url) self.ui.titleLabel.setText(video.title) self.ui.durationLabel.setText(unicode(video.duration)) self.ui.authorLabel.setText(unicode(video.author)) self.ui.dateLabel.setText(unicode(video.date)) if video.rating_max: self.ui.ratingLabel.setText('%s / %s' % (video.rating, video.rating_max)) else: self.ui.ratingLabel.setText('%s' % video.rating) self.ui.seekSlider.setMediaObject(self.ui.videoPlayer.mediaObject()) self.ui.videoPlayer.load(Phonon.MediaSource(QUrl(video.url))) self.ui.videoPlayer.play() def closeEvent(self, event): self.ui.videoPlayer.stop() event.accept() def hideEvent(self, event): self.ui.videoPlayer.stop() event.accept() weboob-1.1/weboob/applications/qwebcontentedit/000077500000000000000000000000001265717027300220045ustar00rootroot00000000000000weboob-1.1/weboob/applications/qwebcontentedit/__init__.py000066400000000000000000000001151265717027300241120ustar00rootroot00000000000000from .qwebcontentedit import QWebContentEdit __all__ = ['QWebContentEdit'] weboob-1.1/weboob/applications/qwebcontentedit/main_window.py000066400000000000000000000250111265717027300246700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import logging from copy import deepcopy from PyQt4.QtCore import SIGNAL from PyQt4.QtGui import QMessageBox, QTableWidgetItem from PyQt4.QtCore import Qt from weboob.tools.application.base import MoreResultsAvailable from weboob.tools.application.qt import QtMainWindow, QtDo from weboob.tools.application.qt.backendcfg import BackendCfg from weboob.capabilities.content import CapContent from weboob.tools.misc import to_unicode from .ui.main_window_ui import Ui_MainWindow class MainWindow(QtMainWindow): def __init__(self, config, weboob, app, parent=None): QtMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.config = config self.weboob = weboob self.backend = None self.app = app self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.loadPage) self.connect(self.ui.loadButton, SIGNAL("clicked()"), self.loadPage) self.connect(self.ui.tabWidget, SIGNAL("currentChanged(int)"), self._currentTabChanged) self.connect(self.ui.saveButton, SIGNAL("clicked()"), self.savePage) self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig) self.connect(self.ui.contentEdit, SIGNAL("textChanged()"), self._textChanged) self.connect(self.ui.loadHistoryButton, SIGNAL("clicked()"), self.loadHistory) if hasattr(self.ui.descriptionEdit, "setPlaceholderText"): self.ui.descriptionEdit.setPlaceholderText("Edit summary") if self.weboob.count_backends() == 0: self.backendsConfig() else: self.loadBackends() def backendsConfig(self): """ Opens backends configuration dialog when 'Backends' is clicked """ bckndcfg = BackendCfg(self.weboob, (CapContent,), self) if bckndcfg.run(): self.loadBackends() def loadBackends(self): """ Fills the backends comboBox with available backends """ self.ui.backendBox.clear() for backend in self.weboob.iter_backends(): self.ui.backendBox.insertItem(0, backend.name) def _currentTabChanged(self): """ Loads history or preview when the corresponding tabs are shown """ if self.ui.tabWidget.currentIndex() == 1: if self.backend is not None: self.loadPreview() elif self.ui.tabWidget.currentIndex() == 2: if self.backend is not None: self.loadHistory() def _textChanged(self): """ The text in the content QPlainTextEdit has changed """ if self.backend: self.ui.saveButton.setEnabled(True) self.ui.saveButton.setText('Save') def loadPage(self): """ Loads a page's source into the 'content' QPlainTextEdit """ _id = unicode(self.ui.idEdit.text()) if not _id: return self.ui.loadButton.setEnabled(False) self.ui.loadButton.setText('Loading...') self.ui.contentEdit.setReadOnly(True) backend = str(self.ui.backendBox.currentText()) def finished(): self.process = None if self.backend: self.ui.contentEdit.setReadOnly(False) self.ui.loadButton.setEnabled(True) self.ui.loadButton.setText('Load') self.process = QtDo(self.weboob, self._loadedPage, self._errorLoadPage, finished) self.process.do('get_content', _id, backends=(backend,)) def _loadedPage(self, data): """ Callback for loadPage """ if not data: self.content = None self.backend = None QMessageBox.critical(self, self.tr('Unable to open page'), 'Unable to open page "%s" on %s: it does not exist.' % (self.ui.idEdit.text(), self.ui.backendBox.currentText()), QMessageBox.Ok) return self.content = data self.ui.contentEdit.setPlainText(self.content.content) self.setWindowTitle("QWebcontentedit - %s@%s" %(self.content.id, self.content.backend)) self.backend = self.weboob[self.content.backend] def _errorLoadPage(self, backend, error, backtrace): """ Error callback for loadPage """ content = unicode(self.tr('Unable to load page:\n%s\n')) % to_unicode(error) if logging.root.level <= logging.DEBUG: content += '\n%s\n' % to_unicode(backtrace) QMessageBox.critical(self, self.tr('Error while loading page'), content, QMessageBox.Ok) self.ui.loadButton.setEnabled(True) self.ui.loadButton.setText("Load") def savePage(self): """ Saves the current page to the remote site """ if self.backend is None: return new_content = unicode(self.ui.contentEdit.toPlainText()) minor = self.ui.minorBox.isChecked() if new_content != self.content.content: self.ui.saveButton.setEnabled(False) self.ui.saveButton.setText('Saving...') self.ui.contentEdit.setReadOnly(True) self.content.content = new_content message = unicode(self.ui.descriptionEdit.text()) def finished(): self.process = None self.ui.saveButton.setText('Saved') self.ui.descriptionEdit.clear() self.ui.contentEdit.setReadOnly(False) self.process = QtDo(self.weboob, None, self._errorSavePage, finished) self.process.do('push_content', self.content, message, minor=minor, backends=self.backend) def _errorSavePage(self, backend, error, backtrace): """ """ content = unicode(self.tr('Unable to save page:\n%s\n')) % to_unicode(error) if logging.root.level <= logging.DEBUG: content += '\n%s\n' % to_unicode(backtrace) QMessageBox.critical(self, self.tr('Error while saving page'), content, QMessageBox.Ok) self.ui.saveButton.setEnabled(True) self.ui.saveButton.setText("Save") def loadPreview(self): """ Loads the current page's preview into the preview QTextEdit """ tmp_content = deepcopy(self.content) tmp_content.content = unicode(self.ui.contentEdit.toPlainText()) self.ui.previewEdit.setHtml(self.backend.get_content_preview(tmp_content)) def loadHistory(self): """ Loads the page's log into the 'History' tab """ if self.backend is None: return self.ui.loadHistoryButton.setEnabled(False) self.ui.loadHistoryButton.setText("Loading...") self.ui.historyTable.clear() self.ui.historyTable.setRowCount(0) self.ui.historyTable.setHorizontalHeaderLabels(["Revision", "Time", "Author", "Summary"]) self.ui.historyTable.setColumnWidth(3, 1000) def finished(): self.process = None self.ui.loadHistoryButton.setEnabled(True) self.ui.loadHistoryButton.setText("Reload") self.process = QtDo(self.weboob, self._gotRevision, self._errorHistory, finished) self.process.do(self.app._do_complete, self.ui.nbRevBox.value(), (), 'iter_revisions', self.content.id, backends=(self.backend,)) def _gotRevision(self, revision): """ Callback for loadHistory's QtDo """ # we set the flags to Qt.ItemIsEnabled so that the items # are not modifiable (they are modifiable by default) item_revision = QTableWidgetItem(revision.id) item_revision.setFlags(Qt.ItemIsEnabled) item_time = QTableWidgetItem(revision.timestamp.strftime('%Y-%m-%d %H:%M:%S')) item_time.setFlags(Qt.ItemIsEnabled) item_author = QTableWidgetItem(revision.author) item_author.setFlags(Qt.ItemIsEnabled) item_summary = QTableWidgetItem(revision.comment) item_summary.setFlags(Qt.ItemIsEnabled) row = self.ui.historyTable.currentRow() + 1 self.ui.historyTable.insertRow(row) self.ui.historyTable.setItem(row, 0, item_revision) self.ui.historyTable.setItem(row, 1, item_time) self.ui.historyTable.setItem(row, 2, item_author) self.ui.historyTable.setItem(row, 3, item_summary) self.ui.historyTable.setCurrentCell(row, 0) def _errorHistory(self, backend, error, backtrace): """ Loading the history has failed """ if isinstance(error, MoreResultsAvailable): return content = unicode(self.tr('Unable to load history:\n%s\n')) % to_unicode(error) if logging.root.level <= logging.DEBUG: content += '\n%s\n' % to_unicode(backtrace) QMessageBox.critical(self, self.tr('Error while loading history'), content, QMessageBox.Ok) self.ui.loadHistoryButton.setEnabled(True) self.ui.loadHistoryButton.setText("Reload") weboob-1.1/weboob/applications/qwebcontentedit/qwebcontentedit.py000066400000000000000000000026131265717027300255570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.application.qt import QtApplication from weboob.capabilities.content import CapContent from .main_window import MainWindow class QWebContentEdit(QtApplication): APPNAME = 'qwebcontentedit' VERSION = '1.1' COPYRIGHT = u'Copyright(C) 2011-2014 Clément Schreiner' DESCRIPTION = "Qt application allowing to manage content of various websites." SHORT_DESCRIPTION = "manage websites content" CAPS = CapContent def main(self, argv): self.load_backends(CapContent, storage=self.create_storage()) self.main_window = MainWindow(self.config, self.weboob, self) self.main_window.show() return self.weboob.loop() weboob-1.1/weboob/applications/qwebcontentedit/ui/000077500000000000000000000000001265717027300224215ustar00rootroot00000000000000weboob-1.1/weboob/applications/qwebcontentedit/ui/Makefile000066400000000000000000000002651265717027300240640ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/applications/qwebcontentedit/ui/__init__.py000066400000000000000000000000001265717027300245200ustar00rootroot00000000000000weboob-1.1/weboob/applications/qwebcontentedit/ui/main_window.ui000066400000000000000000000140551265717027300253000ustar00rootroot00000000000000 MainWindow 0 0 608 609 QWebcontentedit false Load 0 Edit true Preview true History New Column Time Author Summary Qt::Horizontal 40 20 Number of revisions 10 Reload Minor edit false No changes 0 0 608 22 File toolBar TopToolBarArea false Exit Backends actionExit triggered() MainWindow close() -1 -1 343 306 weboob-1.1/weboob/applications/qweboobcfg/000077500000000000000000000000001265717027300207235ustar00rootroot00000000000000weboob-1.1/weboob/applications/qweboobcfg/__init__.py000066400000000000000000000014351265717027300230370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .qweboobcfg import QWeboobCfg __all__ = ['QWeboobCfg'] weboob-1.1/weboob/applications/qweboobcfg/qweboobcfg.py000066400000000000000000000024471265717027300234220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.application.qt import BackendCfg, QtApplication class QWeboobCfg(QtApplication): APPNAME = 'qweboobcfg' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-2014 Romain Bignon' DESCRIPTION = "weboob-config-qt is a graphical application to add/edit/remove backends, " \ "and to register new website accounts." SHORT_DESCRIPTION = "manage backends or register new accounts" def main(self, argv): self.load_backends() self.dlg = BackendCfg(self.weboob) self.dlg.show() return self.weboob.loop() weboob-1.1/weboob/applications/radioob/000077500000000000000000000000001265717027300202245ustar00rootroot00000000000000weboob-1.1/weboob/applications/radioob/__init__.py000066400000000000000000000014241265717027300223360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .radioob import Radioob __all__ = ['Radioob'] weboob-1.1/weboob/applications/radioob/radioob.py000066400000000000000000000371511265717027300222240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import subprocess import os import re import requests from weboob.capabilities.radio import CapRadio, Radio from weboob.capabilities.audio import CapAudio, BaseAudio, Playlist, Album from weboob.capabilities.base import empty from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.media_player import InvalidMediaPlayer, MediaPlayer, MediaPlayerNotFound from weboob.tools.application.formatters.iformatter import PrettyFormatter __all__ = ['Radioob'] class RadioListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title') def get_title(self, obj): return obj.title def get_description(self, obj): result = '' if hasattr(obj, 'description') and not empty(obj.description): result += '%-30s' % obj.description if hasattr(obj, 'current') and not empty(obj.current): if obj.current.who: result += ' (Current: %s - %s)' % (obj.current.who, obj.current.what) else: result += ' (Current: %s)' % obj.current.what return result class SongListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title') def get_title(self, obj): result = obj.title if hasattr(obj, 'author') and not empty(obj.author): result += ' (%s)' % obj.author return result def get_description(self, obj): result = '' if hasattr(obj, 'description') and not empty(obj.description): result += '%-30s' % obj.description return result class AlbumTrackListInfoFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title', 'tracks_list') def get_title(self, obj): result = obj.title if hasattr(obj, 'author') and not empty(obj.author): result += ' (%s)' % obj.author return result def get_description(self, obj): result = '' for song in obj.tracks_list: result += '- %s%-30s%s ' % (self.BOLD, song.title, self.NC) if hasattr(song, 'duration') and not empty(song.duration): result += '%-10s ' % song.duration else: result += '%-10s ' % ' ' result += '(%s)\r\n\t' % (song.id) return result class PlaylistTrackListInfoFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title', 'tracks_list') def get_title(self, obj): return obj.title def get_description(self, obj): result = '' for song in obj.tracks_list: result += '- %s%-30s%s ' % (self.BOLD, song.title, self.NC) if hasattr(song, 'author') and not empty(song.author): result += '(%-15s) ' % song.author if hasattr(song, 'duration') and not empty(song.duration): result += '%-10s ' % song.duration else: result += '%-10s ' % ' ' result += '(%s)\r\n\t' % (song.id) return result class Radioob(ReplApplication): APPNAME = 'radioob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon\nCopyright(C) YEAR Pierre Maziere' DESCRIPTION = "Console application allowing to search for web radio stations, listen to them and get information " \ "like the current song." SHORT_DESCRIPTION = "search, show or listen to radio stations" CAPS = (CapRadio, CapAudio) EXTRA_FORMATTERS = {'radio_list': RadioListFormatter, 'song_list': SongListFormatter, 'album_tracks_list_info': AlbumTrackListInfoFormatter, 'playlist_tracks_list_info': PlaylistTrackListInfoFormatter, } COMMANDS_FORMATTERS = {'ls': 'radio_list', 'playlist': 'radio_list', } COLLECTION_OBJECTS = (Radio, BaseAudio, ) PLAYLIST = [] def __init__(self, *args, **kwargs): ReplApplication.__init__(self, *args, **kwargs) self.player = MediaPlayer(self.logger) def main(self, argv): self.load_config() return ReplApplication.main(self, argv) def complete_download(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() elif len(args) >= 3: return self.path_completer(args[2]) def do_download(self, line): """ download ID [DIRECTORY] Download an audio file """ _id, dest = self.parse_command_args(line, 2, 1) obj = self.retrieve_obj(_id) if obj is None: print('No object matches with this id:', _id, file=self.stderr) return 3 if isinstance(obj, BaseAudio): streams = [obj] else: streams = obj.tracks_list if len(streams) == 0: print('Radio or Audio file not found:', _id, file=self.stderr) return 3 for stream in streams: self.download_file(stream, dest) def download_file(self, audio, dest): _obj = self.get_object(audio.id, 'get_audio', ['url', 'title']) if not _obj: print('Audio file not found: %s' % audio.id, file=self.stderr) return 3 if not _obj.url: print('Error: the direct URL is not available.', file=self.stderr) return 4 audio.url = _obj.url def check_exec(executable): with open(os.devnull, 'w') as devnull: process = subprocess.Popen(['which', executable], stdout=devnull) if process.wait() != 0: print('Please install "%s"' % executable, file=self.stderr) return False return True def audio_to_file(_audio): ext = _audio.ext if not ext: ext = 'audiofile' title = _audio.title if _audio.title else _audio.id return '%s.%s' % (re.sub('[?:/]', '-', title), ext) if dest is not None and os.path.isdir(dest): dest += '/%s' % audio_to_file(audio) if dest is None: dest = audio_to_file(audio) if audio.url.startswith('rtmp'): if not check_exec('rtmpdump'): return 1 args = ('rtmpdump', '-e', '-r', audio.url, '-o', dest) elif audio.url.startswith('mms'): if not check_exec('mimms'): return 1 args = ('mimms', '-r', audio.url, dest) else: if check_exec('wget'): args = ('wget', '-c', audio.url, '-O', dest) elif check_exec('curl'): args = ('curl', '-C', '-', audio.url, '-o', dest) else: return 1 os.spawnlp(os.P_WAIT, args[0], *args) def complete_play(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_play(self, line): """ play ID [stream_id] Play a radio or a audio file with a found player (optionnaly specify the wanted stream). """ _id, stream_id = self.parse_command_args(line, 2, 1) if not _id: print('This command takes an argument: %s' % self.get_command_help('play', short=True), file=self.stderr) return 2 try: stream_id = int(stream_id) except (ValueError, TypeError): stream_id = 0 obj = self.retrieve_obj(_id) if obj is None: print('No object matches with this id:', _id, file=self.stderr) return 3 if isinstance(obj, Radio): try: streams = [obj.streams[stream_id]] except IndexError: print('Stream %d not found' % stream_id, file=self.stderr) return 1 elif isinstance(obj, BaseAudio): streams = [obj] else: streams = obj.tracks_list if len(streams) == 0: print('Radio or Audio file not found:', _id, file=self.stderr) return 3 try: player_name = self.config.get('media_player') media_player_args = self.config.get('media_player_args') if not player_name: self.logger.debug(u'You can set the media_player key to the player you prefer in the radioob ' 'configuration file.') for stream in streams: if isinstance(stream, BaseAudio) and not stream.url: stream = self.get_object(stream.id, 'get_audio') else: r = requests.get(stream.url, stream=True) buf = r.iter_content(512).next() r.close() playlistFormat = None for line in buf.split("\n"): if playlistFormat is None: if line == "[playlist]": playlistFormat = "pls" elif line == "#EXTM3U": playlistFormat = "m3u" else: break elif playlistFormat == "pls": if line.startswith('File'): stream.url = line.split('=', 1).pop(1).strip() break elif playlistFormat == "m3u": if line[0] != "#": stream.url = line.strip() break self.player.play(stream, player_name=player_name, player_args=media_player_args) except (InvalidMediaPlayer, MediaPlayerNotFound) as e: print('%s\nRadio URL: %s' % (e, stream.url)) def retrieve_obj(self, _id): obj = None if self.interactive: try: obj = self.objects[int(_id) - 1] _id = obj.id except (IndexError, ValueError): pass m = CapAudio.get_object_method(_id) if m: obj = self.get_object(_id, m) return obj if obj is not None else self.get_object(_id, 'get_radio') def do_playlist(self, line): """ playlist cmd [args] playlist add ID [ID2 ID3 ...] playlist remove ID [ID2 ID3 ...] playlist export [FILENAME] playlist display """ if not line: print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr) return 2 cmd, args = self.parse_command_args(line, 2, req_n=1) if cmd == "add": _ids = args.strip().split(' ') for _id in _ids: audio = self.get_object(_id, 'get_audio') if not audio: print('Audio file not found: %s' % _id, file=self.stderr) return 3 if not audio.url: print('Error: the direct URL is not available.', file=self.stderr) return 4 self.PLAYLIST.append(audio) elif cmd == "remove": _ids = args.strip().split(' ') for _id in _ids: audio_to_remove = self.get_object(_id, 'get_audio') if not audio_to_remove: print('Audio file not found: %s' % _id, file=self.stderr) return 3 if not audio_to_remove.url: print('Error: the direct URL is not available.', file=self.stderr) return 4 for audio in self.PLAYLIST: if audio.id == audio_to_remove.id: self.PLAYLIST.remove(audio) break elif cmd == "export": filename = "playlist.m3u" if args: filename = args file = open(filename, 'w') for audio in self.PLAYLIST: file.write('%s\r\n' % audio.url) file.close() elif cmd == "display": for audio in self.PLAYLIST: self.cached_format(audio) else: print('Playlist command only support "add", "remove", "display" and "export" arguments.', file=self.stderr) return 2 def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info(self, _id): """ info ID Get information about a radio or an audio file. """ if not _id: print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr) return 2 obj = self.retrieve_obj(_id) if isinstance(obj, Album): self.set_formatter('album_tracks_list_info') elif isinstance(obj, Playlist): self.set_formatter('playlist_tracks_list_info') if obj is None: print('No object matches with this id:', _id, file=self.stderr) return 3 self.format(obj) @defaultcount(10) def do_search(self, pattern=None): """ search (radio|song|file|album|playlist) PATTERN List (radio|song|file|album|playlist) matching a PATTERN. If PATTERN is not given, this command will list all the (radio|song|album|playlist). """ if not pattern: print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr) return 2 cmd, args = self.parse_command_args(pattern, 2, req_n=1) if not args: args = "" self.set_formatter_header(u'Search pattern: %s' % pattern if pattern else u'All radios') self.change_path([u'search']) if cmd == "radio": self.set_formatter('radio_list') for radio in self.do('iter_radios_search', pattern=args): self.add_object(radio) self.format(radio) elif cmd == "song" or cmd == "file": self.set_formatter('song_list') for audio in self.do('search_audio', pattern=args): self.add_object(audio) self.format(audio) elif cmd == "album": self.set_formatter('song_list') for album in self.do('search_album', pattern=args): self.add_object(album) self.format(album) elif cmd == "playlist": self.set_formatter('song_list') for playlist in self.do('search_playlist', pattern=args): self.add_object(playlist) self.format(playlist) else: print('Search command only supports "radio", "song", "file", "album" and "playlist" arguments.', file=self.stderr) return 2 def do_ls(self, line): """ ls List radios """ ret = super(Radioob, self).do_ls(line) return ret weboob-1.1/weboob/applications/shopoob/000077500000000000000000000000001265717027300202565ustar00rootroot00000000000000weboob-1.1/weboob/applications/shopoob/__init__.py000066400000000000000000000014241265717027300223700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .shopoob import Shopoob __all__ = ['Shopoob'] weboob-1.1/weboob/applications/shopoob/shopoob.py000066400000000000000000000150441265717027300223050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Christophe Lampin # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from decimal import Decimal from weboob.capabilities.base import empty from weboob.capabilities.shop import CapShop, Order, Item from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter __all__ = ['Shopoob'] class OrdersFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'date', 'total') def start_format(self, **kwargs): self.output(' Id Date Total ') self.output('-----------------------------+------------+-----------') def format_obj(self, obj, alias): date = obj.date.strftime('%Y-%m-%d') if not empty(obj.date) else '' total = obj.total or Decimal('0') result = u'%s %s %s' % (self.colored('%-28s' % obj.fullid, 'yellow'), self.colored('%-10s' % date, 'blue'), self.colored('%9.2f' % total, 'green')) return result def flush(self): self.output(u'----------------------------+------------+-----------') class ItemsFormatter(IFormatter): MANDATORY_FIELDS = ('label', 'url', 'price') def start_format(self, **kwargs): self.output(' Label Url Price ') self.output('---------------------------------------------------------------------------+---------------------------------------------+----------') def format_obj(self, obj, alias): price = obj.price or Decimal('0') result = u'%s %s %s' % (self.colored('%-75s' % obj.label[:75], 'yellow'), self.colored('%-43s' % obj.url, 'magenta'), self.colored('%9.2f' % price, 'green')) return result def flush(self): self.output(u'---------------------------------------------------------------------------+---------------------------------------------+----------') class PaymentsFormatter(IFormatter): MANDATORY_FIELDS = ('date', 'method', 'amount') def start_format(self, **kwargs): self.output(' Date Method Amount ') self.output('-----------+-----------------+----------') def format_obj(self, obj, alias): date = obj.date.strftime('%Y-%m-%d') if not empty(obj.date) else '' amount = obj.amount or Decimal('0') result = u'%s %s %s' % (self.colored('%-10s' % date, 'blue'), self.colored('%-17s' % obj.method, 'yellow'), self.colored('%9.2f' % amount, 'green')) return result def flush(self): self.output(u'-----------+-----------------+----------') class Shopoob(ReplApplication): APPNAME = 'shopoob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2015 Christophe Lampin' DESCRIPTION = 'Console application to obtain details and status of e-commerce orders.' SHORT_DESCRIPTION = "Obtain details and status of e-commerce orders" CAPS = CapShop COLLECTION_OBJECTS = (Order, ) EXTRA_FORMATTERS = {'orders': OrdersFormatter, 'items': ItemsFormatter, 'payments': PaymentsFormatter } DEFAULT_FORMATTER = 'table' COMMANDS_FORMATTERS = {'orders': 'orders', 'items': 'items', 'payments': 'payments', 'ls': 'orders', } def main(self, argv): self.load_config() return ReplApplication.main(self, argv) @defaultcount(10) def do_orders(self, line): """ orders [BACKEND_NAME] Get orders of a backend. If no BACKEND_NAME given, display all orders of all backends. """ if len(line) > 0: backend_name = line else: backend_name = None self.do_count(str(self.options.count)) # Avoid raise of MoreResultsAvailable l = [] for order in self.do('iter_orders', backends=backend_name): l.append(order) self.start_format() for order in sorted(l, self.comp_object): self.format(order) # Order by date DESC def comp_object(self, obj1, obj2): if obj1.date == obj2.date: return 0 elif obj1.date < obj2.date: return 1 else: return -1 def do_items(self, id): """ items [ID] Get items of orders. """ l = [] id, backend_name = self.parse_id(id, unique_backend=True) if not id: print('Error: please give a order ID (hint: use orders command)', file=self.stderr) return 2 else: l.append((id, backend_name)) for id, backend in l: names = (backend,) if backend is not None else None # TODO: Use specific formatter mysum = Item() mysum.label = u"Sum" mysum.url = u"Generated by shopoob" mysum.price = Decimal("0.") self.start_format() for item in self.do('iter_items', id, backends=names): self.format(item) mysum.price = item.price + mysum.price self.format(mysum) def do_payments(self, id): """ payments [ID] Get payments of orders. If no ID given, display payment of all backends. """ id, backend_name = self.parse_id(id, unique_backend=True) if not id: print('Error: please give a order ID (hint: use orders command)', file=self.stderr) return 2 self.start_format() for payment in self.do('iter_payments', id, backends=backend_name): self.format(payment)weboob-1.1/weboob/applications/suboob/000077500000000000000000000000001265717027300200765ustar00rootroot00000000000000weboob-1.1/weboob/applications/suboob/__init__.py000066400000000000000000000014151265717027300222100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .suboob import Suboob __all__ = ['Suboob'] weboob-1.1/weboob/applications/suboob/suboob.py000066400000000000000000000170501265717027300217440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.subtitle import CapSubtitle from weboob.capabilities.base import empty from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter __all__ = ['Suboob'] LANGUAGE_CONV = { 'ar': 'ara', 'eo': 'epo', 'ga': '', 'ru': 'rus', 'af': '', 'et': 'est', 'it': 'ita', 'sr': 'scc', 'sq': 'alb', 'tl': '', 'ja': 'jpn', 'sk': 'slo', 'hy': 'arm', 'fi': 'fin', 'kn': '', 'sl': 'slv', 'az': '', 'fr': 'fre', 'ko': 'kor', 'es': 'spa', 'eu': 'baq', 'gl': 'glg', 'la': '', 'sw': 'swa', 'be': '', 'ka': 'geo', 'lv': 'lav', 'sv': 'swe', 'bn': 'ben', 'de': 'ger', 'lt': 'lit', 'ta': '', 'bg': 'bul', 'gr': 'ell', 'mk': 'mac', 'te': 'tel', 'ca': 'cat', 'gu': '', 'ms': 'may', 'th': 'tha', 'zh': 'chi', 'ht': '', 'mt': '', 'tr': 'tur', 'hr': 'hrv', 'iw': 'heb', 'no': 'nor', 'uk': 'ukr', 'cz': 'cze', 'hi': 'hin', 'fa': 'per', 'ur': 'urd', 'da': 'dan', 'hu': 'hun', 'pl': 'pol', 'vi': 'vie', 'nl': 'dut', 'is': 'ice', 'pt': 'por', 'cy': '', 'en': 'eng', 'id': 'ind', 'ro': 'rum', 'yi': ''} def sizeof_fmt(num): for x in ['bytes', 'KB', 'MB', 'GB', 'TB']: if num < 1024.0: return "%-4.1f%s" % (num, x) num /= 1024.0 class SubtitleInfoFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'name', 'url', 'description') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC) result += 'ID: %s\n' % obj.fullid result += 'URL: %s\n' % obj.url if not empty(obj.language): result += 'LANG: %s\n' % obj.language if not empty(obj.nb_cd): result += 'NB CD: %s\n' % obj.nb_cd result += '\n%sDescription%s\n' % (self.BOLD, self.NC) result += '%s' % obj.description return result class SubtitleListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'name') def get_title(self, obj): return obj.name def get_description(self, obj): result = u'lang : %s' % obj.language result += ' ; %s CD' % obj.nb_cd if not empty(obj.url): result += ' ; url : %s' % obj.url return result class Suboob(ReplApplication): APPNAME = 'suboob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2013-YEAR Julien Veyssier' DESCRIPTION = "Console application allowing to search for subtitles on various services " \ "and download them." SHORT_DESCRIPTION = "search and download subtitles" CAPS = CapSubtitle EXTRA_FORMATTERS = {'subtitle_list': SubtitleListFormatter, 'subtitle_info': SubtitleInfoFormatter } COMMANDS_FORMATTERS = {'search': 'subtitle_list', 'info': 'subtitle_info' } def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info(self, id): """ info ID Get information about a subtitle. """ subtitle = self.get_object(id, 'get_subtitle') if not subtitle: print('Subtitle not found: %s' % id, file=self.stderr) return 3 self.start_format() self.format(subtitle) def complete_download(self, text, line, *ignored): args = line.split(' ', 2) if len(args) == 2: return self._complete_object() elif len(args) >= 3: return self.path_completer(args[2]) def do_download(self, line): """ download ID [FILENAME] Get the subtitle or archive file. FILENAME is where to write the file. If FILENAME is '-', the file is written to stdout. """ id, dest = self.parse_command_args(line, 2, 1) subtitle = self.get_object(id, 'get_subtitle') if not subtitle: print('Subtitle not found: %s' % id, file=self.stderr) return 3 if dest is None: ext = subtitle.ext if empty(ext): ext = 'zip' dest = '%s.%s' % (subtitle.name, ext) for buf in self.do('get_subtitle_file', subtitle.id, backends=subtitle.backend): if buf: if dest == '-': self.stdout.write(buf) else: try: with open(dest, 'w') as f: f.write(buf) except IOError as e: print('Unable to write file in "%s": %s' % (dest, e), file=self.stderr) return 1 else: print('Saved to %s' % dest) return @defaultcount(10) def do_search(self, line): """ search language [PATTERN] Search subtitles. Language Abbreviation ---------------------- Arabic ar Esperanto eo Irish ga Russian ru Afrikaans af Estonian et Italian it Serbian sr Albanian sq Filipino tl Japanese ja Slovak sk Armenian hy Finnish fi Kannada kn Slovenian sl Azerbaijani az French fr Korean ko Spanish es Basque eu Galician gl Latin la Swahili sw Belarusian be Georgian ka Latvian lv Swedish sv Bengali bn German de Lithuanian lt Tamil ta Bulgarian bg Greek gr Macedonian mk Telugu te Catalan ca Gujarati gu Malay ms Thai th Chinese zh Haitian ht Maltese mt Turkish tr Croatian hr Hebrew iw Norwegian no Ukrainian uk Czech cz Hindi hi Persian fa Urdu ur Danish da Hungaric hu Polish pl Vietnamese vi Dutch nl Icelandic is Portuguese pt Welsh cy English en Indonesian id Romanian ro Yiddish yi ---------------------- """ language, pattern = self.parse_command_args(line, 2, 1) self.change_path([u'search']) if not pattern: pattern = None self.start_format(pattern=pattern) for subtitle in self.do('iter_subtitles', language=language, pattern=pattern): self.cached_format(subtitle) weboob-1.1/weboob/applications/translaboob/000077500000000000000000000000001265717027300211135ustar00rootroot00000000000000weboob-1.1/weboob/applications/translaboob/__init__.py000066400000000000000000000014341265717027300232260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .translaboob import Translaboob __all__ = ['Translaboob'] weboob-1.1/weboob/applications/translaboob/translaboob.py000066400000000000000000000134071265717027300240000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.translate import CapTranslate, TranslationFail, LanguageNotSupported from weboob.tools.application.repl import ReplApplication from weboob.tools.application.formatters.iformatter import IFormatter __all__ = ['Translaboob'] class TranslationFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'text') def format_obj(self, obj, alias): return u'%s* %s%s\n\t%s' % (self.BOLD, obj.backend, self.NC, obj.text.replace('\n', '\n\t')) class XmlTranslationFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'text') def start_format(self, **kwargs): if 'source' in kwargs: self.output('\n%s\n' % kwargs['source']) def format_obj(self, obj, alias): return u'\n%s\n' % (obj.backend, obj.text) class Translaboob(ReplApplication): APPNAME = 'translaboob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2012-YEAR Lucien Loiseau' DESCRIPTION = "Console application to translate text from one language to another" SHORT_DESCRIPTION = "translate text from one language to another" CAPS = CapTranslate EXTRA_FORMATTERS = {'translation': TranslationFormatter, 'xmltrans': XmlTranslationFormatter, } COMMANDS_FORMATTERS = {'translate': 'translation', } LANGUAGE = { 'ar': 'Arabic', 'af': 'Afrikaans', 'sq': 'Albanian', 'hy': 'Armenian', 'az': 'Azerbaijani', 'eu': 'Basque', 'be': 'Belarusian', 'bn': 'Bengali', 'bg': 'Bulgarian', 'ca': 'Catalan', 'zh': 'Chinese', 'hr': 'Croatian', 'cz': 'Czech', 'da': 'Danish', 'nl': 'Dutch', 'en': 'English', 'eo': 'Esperanto', 'et': 'Estonian', 'tl': 'Filipino', 'fi': 'Finnish', 'fr': 'French', 'gl': 'Galician', 'ka': 'Georgian', 'de': 'German', 'gr': 'Greek', 'gu': 'Gujarati', 'ht': 'Haitian', 'iw': 'Hebrew', 'hi': 'Hindi', 'hu': 'Hungaric', 'is': 'Icelandic', 'id': 'Indonesian', 'ga': 'Irish', 'it': 'Italian', 'ja': 'Japanese', 'kn': 'Kannada', 'ko': 'Korean', 'la': 'Latin', 'lv': 'Latvian', 'lt': 'Lithuanian', 'mk': 'Macedonian', 'ms': 'Malay', 'mt': 'Maltese', 'no': 'Norwegian', 'fa': 'Persian', 'pl': 'Polish', 'pt': 'Portuguese', 'ro': 'Romanian', 'ru': 'Russian', 'sr': 'Serbian', 'sk': 'Slovak', 'sl': 'Slovenian', 'es': 'Spanish', 'sw': 'Swahili', 'sv': 'Swedish', 'ta': 'Tamil', 'te': 'Telugu', 'th': 'Thai', 'tr': 'Turkish', 'uk': 'Ukrainian', 'ur': 'Urdu', 'vi': 'Vietnamese', 'cy': 'Welsh', 'yi': 'Yiddish', 'nigger': 'Nigger!', } def do_translate(self, line): """ translate FROM TO [TEXT] Translate from one language to another. * FROM : source language * TO : destination language * TEXT : language to translate, standard input if - is given Language Abbreviation ---------------------- Arabic ar Esperanto eo Irish ga Russian ru Afrikaans af Estonian et Italian it Serbian sr Albanian sq Filipino tl Japanese ja Slovak sk Armenian hy Finnish fi Kannada kn Slovenian sl Azerbaijani az French fr Korean ko Spanish es Basque eu Galician gl Latin la Swahili sw Belarusian be Georgian ka Latvian lv Swedish sv Bengali bn German de Lithuanian lt Tamil ta Bulgarian bg Greek gr Macedonian mk Telugu te Catalan ca Gujarati gu Malay ms Thai th Chinese zh Haitian ht Maltese mt Turkish tr Croatian hr Hebrew iw Norwegian no Ukrainian uk Czech cz Hindi hi Persian fa Urdu ur Danish da Hungaric hu Polish pl Vietnamese vi Dutch nl Icelandic is Portuguese pt Welsh cy English en Indonesian id Romanian ro Yiddish yi ---------------------- """ lan_from, lan_to, text = self.parse_command_args(line, 3, 2) try: if lan_from not in self.LANGUAGE.keys(): raise LanguageNotSupported() if lan_to not in self.LANGUAGE.keys(): raise LanguageNotSupported() if not text or text == '-': text = self.acquire_input() self.start_format(source=text) for translation in self.do('translate', self.LANGUAGE[lan_from], self.LANGUAGE[lan_to], text): self.format(translation) except (TranslationFail, LanguageNotSupported) as error: print(error, file=self.stderr) pass weboob-1.1/weboob/applications/traveloob/000077500000000000000000000000001265717027300206025ustar00rootroot00000000000000weboob-1.1/weboob/applications/traveloob/__init__.py000066400000000000000000000014321265717027300227130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .traveloob import Traveloob __all__ = ['Traveloob'] weboob-1.1/weboob/applications/traveloob/traveloob.py000066400000000000000000000152261265717027300231570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon, Julien Hébert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import datetime from weboob.capabilities.base import Currency, empty from weboob.capabilities.travel import CapTravel, RoadmapFilters from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import PrettyFormatter __all__ = ['Traveloob'] class DeparturesFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'type', 'departure_station', 'arrival_station', 'time') def get_title(self, obj): s = obj.type if hasattr(obj, 'price') and not empty(obj.price): s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored('%6.2f %s' % (obj.price, Currency.currency2txt(obj.currency)), 'green')) if hasattr(obj, 'late') and not empty(obj.late) and obj.late > datetime.time(): s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored('Late: %s' % obj.late, 'red', 'bold')) if hasattr(obj, 'information') and not empty(obj.information) and obj.information.strip() != '': s += u' %s %s' % (self.colored(u'—', 'cyan'), self.colored(obj.information, 'red')) return s def get_description(self, obj): if hasattr(obj, 'arrival_time') and not empty(obj.arrival_time): s = '(%s) %s%s\n\t(%s) %s' % (self.colored(obj.time.strftime('%H:%M') if obj.time else '??:??', 'cyan'), obj.departure_station, self.colored(' [Platform: %s]' % obj.platform, 'yellow') if (hasattr(obj, 'platform') and not empty(obj.platform)) else '', self.colored(obj.arrival_time.strftime('%H:%M'), 'cyan'), obj.arrival_station) else: s = '(%s) %20s -> %s' % (self.colored(obj.time.strftime('%H:%M') if obj.time else '??:??', 'cyan'), obj.departure_station, obj.arrival_station) return s class StationsFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'name') def get_title(self, obj): return obj.name class Traveloob(ReplApplication): APPNAME = 'traveloob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' DESCRIPTION = "Console application allowing to search for train stations and get departure times." SHORT_DESCRIPTION = "search for train stations and departures" CAPS = CapTravel DEFAULT_FORMATTER = 'table' EXTRA_FORMATTERS = {'stations': StationsFormatter, 'departures': DeparturesFormatter, } COMMANDS_FORMATTERS = {'stations': 'stations', 'departures': 'departures', } def add_application_options(self, group): group.add_option('--departure-time') group.add_option('--arrival-time') @defaultcount(10) def do_stations(self, pattern): """ stations PATTERN Search stations. """ for station in self.do('iter_station_search', pattern): self.format(station) @defaultcount(10) def do_departures(self, line): """ departures STATION [ARRIVAL [DATE]]] List all departures for a given station. The format for the date is "yyyy-mm-dd HH:MM" or "HH:MM". """ station, arrival, date = self.parse_command_args(line, 3, 1) station_id, backend_name = self.parse_id(station) if arrival: arrival_id, backend_name2 = self.parse_id(arrival) if backend_name and backend_name2 and backend_name != backend_name2: print('Departure and arrival aren\'t on the same backend', file=self.stderr) return 1 else: arrival_id = backend_name2 = None if backend_name: backends = [backend_name] elif backend_name2: backends = [backend_name2] else: backends = None if date is not None: try: date = self.parse_datetime(date) except ValueError as e: print('Invalid datetime value: %s' % e, file=self.stderr) print('Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".', file=self.stderr) return 1 for departure in self.do('iter_station_departures', station_id, arrival_id, date, backends=backends): self.format(departure) def do_roadmap(self, line): """ roadmap DEPARTURE ARRIVAL Display the roadmap to travel from DEPARTURE to ARRIVAL. Command-line parameters: --departure-time TIME requested departure time --arrival-time TIME requested arrival time TIME might be in form "yyyy-mm-dd HH:MM" or "HH:MM". Example: > roadmap Puteaux Aulnay-sous-Bois --arrival-time 22:00 """ departure, arrival = self.parse_command_args(line, 2, 2) filters = RoadmapFilters() try: filters.departure_time = self.parse_datetime(self.options.departure_time) filters.arrival_time = self.parse_datetime(self.options.arrival_time) except ValueError as e: print('Invalid datetime value: %s' % e, file=self.stderr) print('Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".', file=self.stderr) return 1 for route in self.do('iter_roadmap', departure, arrival, filters): self.format(route) def parse_datetime(self, text): if text is None: return None try: date = datetime.datetime.strptime(text, '%Y-%m-%d %H:%M') except ValueError: try: date = datetime.datetime.strptime(text, '%H:%M') except ValueError: raise ValueError(text) date = datetime.datetime.now().replace(hour=date.hour, minute=date.minute) return date weboob-1.1/weboob/applications/videoob/000077500000000000000000000000001265717027300202345ustar00rootroot00000000000000weboob-1.1/weboob/applications/videoob/__init__.py000066400000000000000000000014261265717027300223500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .videoob import Videoob __all__ = ['Videoob'] weboob-1.1/weboob/applications/videoob/videoob.py000066400000000000000000000271171265717027300222450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz, Romain Bignon, John Obbele, Nicolas Duhamel # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import requests import subprocess import os from weboob.capabilities.video import CapVideo, BaseVideo from weboob.capabilities.base import empty from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.media_player import InvalidMediaPlayer, MediaPlayer, MediaPlayerNotFound from weboob.tools.application.formatters.iformatter import PrettyFormatter __all__ = ['Videoob'] class VideoListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'title', 'duration', 'date') DISPLAYED_FIELDS = ('author', 'rating') def get_title(self, obj): return obj.title def get_description(self, obj): if empty(obj.duration) and empty(obj.date): return None result = '%s' % (obj.duration or obj.date) if hasattr(obj, 'author') and not empty(obj.author): result += u' - %s' % obj.author if hasattr(obj, 'rating') and not empty(obj.rating): result += u' (%s/%s)' % (obj.rating, obj.rating_max) return result class Videoob(ReplApplication): APPNAME = 'videoob' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Christophe Benz, Romain Bignon, John Obbele' DESCRIPTION = "Console application allowing to search for videos on various websites, " \ "play and download them and get information." SHORT_DESCRIPTION = "search and play videos" CAPS = CapVideo EXTRA_FORMATTERS = {'video_list': VideoListFormatter} COMMANDS_FORMATTERS = {'search': 'video_list', 'ls': 'video_list', 'playlist': 'video_list'} COLLECTION_OBJECTS = (BaseVideo, ) PLAYLIST = [] nsfw = True def __init__(self, *args, **kwargs): ReplApplication.__init__(self, *args, **kwargs) self.player = MediaPlayer(self.logger) def main(self, argv): self.load_config() return ReplApplication.main(self, argv) def download(self, video, dest, default=None): if not video.url: print('Error: the direct URL is not available.', file=self.stderr) return 4 def check_exec(executable): with open(os.devnull, 'w') as devnull: process = subprocess.Popen(['which', executable], stdout=devnull) if process.wait() != 0: print('Please install "%s"' % executable, file=self.stderr) return False return True dest = self.obj_to_filename(video, dest, default) if video.url.startswith('rtmp'): if not check_exec('rtmpdump'): return 1 args = ('rtmpdump', '-e', '-r', video.url, '-o', dest) elif video.url.startswith('mms'): if not check_exec('mimms'): return 1 args = ('mimms', '-r', video.url, dest) elif u'm3u8' == video.ext: _dest, _ = os.path.splitext(dest) dest = u'%s.%s' % (_dest, 'mp4') content = tuple() baseurl = video.url.rpartition('/')[0] for line in self.read_url(video.url): if not line.startswith('#'): if not line.startswith('http'): line = u'%s/%s' % (baseurl, line) content += (line,) args = ('wget', '-nv',) + content + ('-O', dest) else: if check_exec('wget'): args = ('wget', '-c', video.url, '-O', dest) elif check_exec('curl'): args = ('curl', '-C', '-', video.url, '-o', dest) else: return 1 self.logger.debug(' '.join(args)) os.spawnlp(os.P_WAIT, args[0], *args) def read_url(self, url): r = requests.get(url, stream=True) return r.iter_lines() def complete_download(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() elif len(args) >= 3: return self.path_completer(args[2]) def do_download(self, line): """ download ID [FILENAME] Download a video Braces-enclosed tags are replaced with data fields. Use the 'info' command to see what fields are available on a given video. Example: download KdRRge4XYIo@youtube '{title}.{ext}' """ _id, dest = self.parse_command_args(line, 2, 1) video = self.get_object(_id, 'get_video', ['url']) if not video: print('Video not found: %s' % _id, file=self.stderr) return 3 return self.download(video, dest) def complete_play(self, text, line, *ignored): args = line.split(' ') if len(args) >= 2: return self._complete_object() def do_play(self, line): """ play ID Play a video with a found player. """ if not line: print('This command takes an argument: %s' % self.get_command_help('play', short=True), file=self.stderr) return 2 ret = 0 for _id in line.split(' '): video = self.get_object(_id, 'get_video', ['url']) error = self.play(video, _id) if error is not None: ret = error return ret def play(self, video, _id): if not video: print('Video not found: %s' % _id, file=self.stderr) return 3 if not video.url: print('Error: the direct URL is not available.', file=self.stderr) return 4 try: player_name = self.config.get('media_player') media_player_args = self.config.get('media_player_args') if not player_name: self.logger.info(u'You can set the media_player key to the player you prefer in the videoob ' 'configuration file.') self.player.play(video, player_name=player_name, player_args=media_player_args) except (InvalidMediaPlayer, MediaPlayerNotFound) as e: print('%s\nVideo URL: %s' % (e, video.url)) def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) >= 2: return self._complete_object() def do_info(self, line): """ info ID [ID2 [...]] Get information about a video. """ if not line: print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr) return 2 self.start_format() for _id in line.split(' '): video = self.get_object(_id, 'get_video') if not video: print('Video not found: %s' % _id, file=self.stderr) return 3 self.format(video) def complete_playlist(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return ['play', 'add', 'remove', 'export', 'display', 'download'] if len(args) >= 3: if args[1] in ('export', 'download'): return self.path_completer(args[2]) if args[1] in ('add', 'remove'): return self._complete_object() def do_playlist(self, line): """ playlist cmd [args] playlist add ID [ID2 ID3 ...] playlist remove ID [ID2 ID3 ...] playlist export [FILENAME] playlist display playlist download [PATH] playlist play """ if not self.interactive: print('This command can be used only in interactive mode.', file=self.stderr) return 1 if not line: print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr) return 2 cmd, args = self.parse_command_args(line, 2, req_n=1) if cmd == "add": _ids = args.strip().split(' ') for _id in _ids: video = self.get_object(_id, 'get_video') if not video: print('Video not found: %s' % _id, file=self.stderr) return 3 if not video.url: print('Error: the direct URL is not available.', file=self.stderr) return 4 self.PLAYLIST.append(video) elif cmd == "remove": _ids = args.strip().split(' ') for _id in _ids: video_to_remove = self.get_object(_id, 'get_video') if not video_to_remove: print('Video not found: %s' % _id, file=self.stderr) return 3 if not video_to_remove.url: print('Error: the direct URL is not available.', file=self.stderr) return 4 for video in self.PLAYLIST: if video.id == video_to_remove.id: self.PLAYLIST.remove(video) break elif cmd == "export": filename = "playlist.m3u" if args: filename = args file = open(filename, 'w') for video in self.PLAYLIST: file.write('%s\r\n' % video.url) file.close() elif cmd == "display": for video in self.PLAYLIST: self.cached_format(video) elif cmd == "download": for i, video in enumerate(self.PLAYLIST): self.download(video, args, '%02d-{id}-{title}.{ext}' % (i+1)) elif cmd == "play": for video in self.PLAYLIST: self.play(video, video.id) else: print('Playlist command only support "add", "remove", "display", "download" and "export" arguments.', file=self.stderr) return 2 def complete_nsfw(self, text, line, begidx, endidx): return ['on', 'off'] def do_nsfw(self, line): """ nsfw [on | off] If argument is given, enable or disable the non-suitable for work behavior. If no argument is given, print the current behavior. """ line = line.strip() if line: if line == 'on': self.nsfw = True elif line == 'off': self.nsfw = False else: print('Invalid argument "%s".' % line) return 2 else: print("on" if self.nsfw else "off") @defaultcount() def do_search(self, pattern): """ search PATTERN Search for videos matching a PATTERN. """ if not pattern: print('This command takes an argument: %s' % self.get_command_help('search', short=True), file=self.stderr) return 2 self.change_path([u'search']) self.start_format(pattern=pattern) for video in self.do('search_videos', pattern=pattern, nsfw=self.nsfw): self.cached_format(video) weboob-1.1/weboob/applications/webcontentedit/000077500000000000000000000000001265717027300216235ustar00rootroot00000000000000weboob-1.1/weboob/applications/webcontentedit/__init__.py000066400000000000000000000014511265717027300237350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .webcontentedit import WebContentEdit __all__ = ['WebContentEdit'] weboob-1.1/weboob/applications/webcontentedit/webcontentedit.py000066400000000000000000000164361265717027300252250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import os import tempfile import codecs from distutils.spawn import find_executable from weboob.core.bcall import CallErrors from weboob.capabilities.content import CapContent, Revision from weboob.tools.application.repl import ReplApplication, defaultcount __all__ = ['WebContentEdit'] class WebContentEdit(ReplApplication): APPNAME = 'webcontentedit' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' DESCRIPTION = "Console application allowing to display and edit contents on various websites." SHORT_DESCRIPTION = "manage websites content" CAPS = CapContent def do_edit(self, line): """ edit ID [ID...] Edit a content with $EDITOR, then push it on the website. """ contents = [] for id in line.split(): _id, backend_name = self.parse_id(id, unique_backend=True) backend_names = (backend_name,) if backend_name is not None else self.enabled_backends contents += [content for content in self.do('get_content', _id, backends=backend_names) if content] if len(contents) == 0: print('No contents found', file=self.stderr) return 3 if self.stdin.isatty(): paths = {} for content in contents: tmpdir = os.path.join(tempfile.gettempdir(), "weboob") if not os.path.isdir(tmpdir): os.makedirs(tmpdir) with tempfile.NamedTemporaryFile(prefix='%s_' % content.id.replace(os.path.sep, '_'), dir=tmpdir, delete=False) as f: data = content.content if isinstance(data, unicode): data = data.encode('utf-8') elif data is None: content.content = u'' data = '' f.write(data) paths[f.name.encode('utf-8')] = content params = '' editor = os.environ.get('EDITOR', 'vim') # check cases where /usr/bin/vi is a symlink to vim if 'vim' in (os.path.basename(editor), os.path.basename(os.path.realpath(find_executable(editor) or '/')).replace('.nox', '')): params = '-p' os.system("%s %s %s" % (editor, params, ' '.join(['"%s"' % path.replace('"', '\\"') for path in paths.iterkeys()]))) for path, content in paths.iteritems(): with open(path, 'r') as f: data = f.read() try: data = data.decode('utf-8') except UnicodeError: pass if content.content != data: content.content = data else: contents.remove(content) if len(contents) == 0: print('No changes. Abort.', file=self.stderr) return 1 print('Contents changed:\n%s' % ('\n'.join(' * %s' % content.id for content in contents))) message = self.ask('Enter a commit message', default='') minor = self.ask('Is this a minor edit?', default=False) if not self.ask('Do you want to push?', default=True): return errors = CallErrors([]) for content in contents: path = [path for path, c in paths.iteritems() if c == content][0] self.stdout.write('Pushing %s...' % content.id.encode('utf-8')) self.stdout.flush() try: self.do('push_content', content, message, minor=minor, backends=[content.backend]).wait() except CallErrors as e: errors.errors += e.errors self.stdout.write(' error (content saved in %s)\n' % path) else: self.stdout.write(' done\n') os.unlink(path) else: # stdin is not a tty if len(contents) != 1: print("Multiple ids not supported with pipe", file=self.stderr) return 2 message, minor = '', False data = self.stdin.read() contents[0].content = data.decode(self.guess_encoding(self.stdin)) errors = CallErrors([]) for content in contents: self.stdout.write('Pushing %s...' % content.id.encode(self.encoding)) self.stdout.flush() try: self.do('push_content', content, message, minor=minor, backends=[content.backend]).wait() except CallErrors as e: errors.errors += e.errors self.stdout.write(' error\n') else: self.stdout.write(' done\n') if len(errors.errors) > 0: raise errors @defaultcount(10) def do_log(self, line): """ log ID Display log of a page """ if not line: print('Error: please give a page ID', file=self.stderr) return 2 _id, backend_name = self.parse_id(line) backend_names = (backend_name,) if backend_name is not None else self.enabled_backends _id = _id.encode('utf-8') self.start_format() for revision in self.do('iter_revisions', _id, backends=backend_names): self.format(revision) def do_get(self, line): """ get ID [-r revision] Get page contents """ if not line: print('Error: please give a page ID', file=self.stderr) return 2 _part_line = line.strip().split(' ') revision = None if '-r' in _part_line: r_index = _part_line.index('-r') if len(_part_line) -1 > r_index: revision = Revision(_part_line[r_index+1]) _part_line.remove(revision.id) _part_line.remove('-r') if not _part_line: print('Error: please give a page ID', file=self.stderr) return 2 _id, backend_name = self.parse_id(" ".join(_part_line)) backend_names = (backend_name,) if backend_name is not None else self.enabled_backends _id = _id.encode('utf-8') output = codecs.getwriter(self.encoding)(self.stdout) for contents in [content for content in self.do('get_content', _id, revision, backends=backend_names) if content]: output.write(contents.content) # add a newline unless we are writing # in a file or in a pipe if output.isatty(): output.write('\n') weboob-1.1/weboob/applications/weboobcfg/000077500000000000000000000000001265717027300205425ustar00rootroot00000000000000weboob-1.1/weboob/applications/weboobcfg/__init__.py000066400000000000000000000014321265717027300226530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .weboobcfg import WeboobCfg __all__ = ['WeboobCfg'] weboob-1.1/weboob/applications/weboobcfg/weboobcfg.py000066400000000000000000000267241265717027300230640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon, Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import os import re from weboob.capabilities.account import CapAccount from weboob.core.modules import ModuleLoadError from weboob.tools.application.repl import ReplApplication from weboob.tools.application.console import ConsoleProgress from weboob.tools.ordereddict import OrderedDict from weboob.tools.application.formatters.iformatter import IFormatter __all__ = ['WeboobCfg'] class CapabilitiesWrapper(list): """ A wrapper class to keep the list nature of capabilities, but provide a comma separated list representation for formaters unable to display a list by themselves. Useful for having an array representation in JSON and comma separated list for simple format. """ def __repr__(self): return ', '.join(self) class ModuleInfoFormatter(IFormatter): def format_dict(self, minfo): result = '.------------------------------------------------------------------------------.\n' result += '| Module %-69s |\n' % minfo['name'] result += "+-----------------.------------------------------------------------------------'\n" result += '| Version | %s\n' % minfo['version'] result += '| Maintainer | %s\n' % minfo['maintainer'] result += '| License | %s\n' % minfo['license'] result += '| Description | %s\n' % minfo['description'] result += '| Capabilities | %s\n' % ', '.join(minfo['capabilities']) result += '| Installed | %s\n' % minfo['installed'] result += '| Location | %s\n' % minfo['location'] if 'config' in minfo: first = True for key, field in minfo['config'].iteritems(): label = field['label'] if field['default'] is not None: label += ' (default: %s)' % field['default'] if first: result += '| | \n' result += '| Configuration | %s: %s\n' % (key, label) first = False else: result += '| | %s: %s\n' % (key, label) result += "'-----------------'\n" return result class WeboobCfg(ReplApplication): APPNAME = 'weboob-config' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Christophe Benz, Romain Bignon' DESCRIPTION = "Weboob-Config is a console application to add/edit/remove backends, " \ "and to register new website accounts." SHORT_DESCRIPTION = "manage backends or register new accounts" EXTRA_FORMATTERS = {'info_formatter': ModuleInfoFormatter} COMMANDS_FORMATTERS = {'modules': 'table', 'list': 'table', 'info': 'info_formatter', } DISABLE_REPL = True def load_default_backends(self): pass def do_add(self, line): """ add MODULE_NAME [BACKEND_NAME] [PARAMETERS ...] Create a backend from a module. By default, if BACKEND_NAME is omitted, that's the module name which is used. You can specify parameters from command line in form "key=value". """ if not line: print('You must specify a module name. Hint: use the "modules" command.', file=self.stderr) return 2 module_name, options = self.parse_command_args(line, 2, 1) if options: options = options.split(' ') else: options = () backend_name = None params = {} # set backend params from command-line arguments for option in options: try: key, value = option.split('=', 1) except ValueError: if backend_name is None: backend_name = option else: print('Parameters have to be formatted "key=value"', file=self.stderr) return 2 else: params[key] = value self.add_backend(module_name, backend_name or module_name, params) def do_register(self, line): """ register MODULE Register a new account on a module. """ self.register_backend(line) def do_confirm(self, backend_name): """ confirm BACKEND For a backend which support CapAccount, parse a confirmation mail after using the 'register' command to automatically confirm the subscribe. It takes mail from stdin. Use it with postfix for example. """ # Do not use the ReplApplication.load_backends() method because we # don't want to prompt user to create backend. self.weboob.load_backends(names=[backend_name]) try: backend = self.weboob.get_backend(backend_name) except KeyError: print('Error: backend "%s" not found.' % backend_name, file=self.stderr) return 1 if not backend.has_caps(CapAccount): print('Error: backend "%s" does not support accounts management' % backend_name, file=self.stderr) return 1 mail = self.acquire_input() if not backend.confirm_account(mail): print('Error: Unable to confirm account creation', file=self.stderr) return 1 return 0 def do_list(self, line): """ list [CAPS ..] Show backends. """ caps = line.split() for backend_name, module_name, params in sorted(self.weboob.backends_config.iter_backends()): try: module = self.weboob.modules_loader.get_or_load_module(module_name) except ModuleLoadError as e: self.logger.warning('Unable to load module %r: %s' % (module_name, e)) continue if caps and not module.has_caps(*caps): continue row = OrderedDict([('Name', backend_name), ('Module', module_name), ('Configuration', ', '.join( '%s=%s' % (key, ('*****' if key in module.config and module.config[key].masked else value)) for key, value in params.iteritems())), ]) self.format(row) def do_remove(self, backend_name): """ remove NAME Remove a backend. """ if not self.weboob.backends_config.remove_backend(backend_name): print('Backend instance "%s" does not exist' % backend_name, file=self.stderr) return 1 def _do_toggle(self, backend_name, state): try: module_name, items = self.weboob.backends_config.get_backend(backend_name) except KeyError: print('Backend instance "%s" does not exist' % backend_name, file=self.stderr) return 1 self.weboob.backends_config.edit_backend(backend_name, module_name, {'_enabled': state}) def do_enable(self, backend_name): """ enable BACKEND Enable a disabled backend """ return self._do_toggle(backend_name, "true") def do_disable(self, backend_name): """ disable BACKEND Disable a backend """ return self._do_toggle(backend_name, "false") def do_edit(self, line): """ edit BACKEND Edit a backend """ try: self.edit_backend(line) except KeyError: print('Error: backend "%s" not found' % line, file=self.stderr) return 1 def do_modules(self, line): """ modules [CAPS ...] Show available modules. """ caps = line.split() for name, info in sorted(self.weboob.repositories.get_all_modules_info(caps).iteritems()): row = OrderedDict([('Name', name), ('Capabilities', CapabilitiesWrapper(info.capabilities)), ('Description', info.description), ('Installed', info.is_installed()), ]) self.format(row) def do_info(self, line): """ info NAME Display information about a module. """ if not line: print('You must specify a module name. Hint: use the "modules" command.', file=self.stderr) return 2 minfo = self.weboob.repositories.get_module_info(line) if not minfo: print('Module "%s" does not exist.' % line, file=self.stderr) return 1 try: module = self.weboob.modules_loader.get_or_load_module(line) except ModuleLoadError: module = None self.start_format() self.format(self.create_minfo_dict(minfo, module)) def create_minfo_dict(self, minfo, module): module_info = {} module_info['name'] = minfo.name module_info['version'] = minfo.version module_info['maintainer'] = minfo.maintainer module_info['license'] = minfo.license module_info['description'] = minfo.description module_info['capabilities'] = minfo.capabilities module_info['installed'] = '%s%s' % (('yes' if module else 'no'), ' (new version available)' if self.weboob.repositories.versions.get(minfo.name) > minfo.version else '') module_info['location'] = '%s' % (minfo.url or os.path.join(minfo.path, minfo.name)) if module: module_info['config'] = {} for key, field in module.config.iteritems(): module_info['config'][key] = {'label': field.label, 'default': field.default, 'description': field.description, 'regexp': field.regexp, 'choices': field.choices, 'masked': field.masked, 'required': field.required} return module_info def do_applications(self, line): """ applications Show applications. """ applications = set() import weboob.applications for path in weboob.applications.__path__: regexp = re.compile('^%s/([\w\d_]+)$' % path) for root, dirs, files in os.walk(path): m = regexp.match(root) if m and '__init__.py' in files: applications.add(m.group(1)) print(' '.join(sorted(applications)).encode('utf-8')) def do_update(self, line): """ update Update weboob. """ self.weboob.update(ConsoleProgress(self)) weboob-1.1/weboob/applications/weboobcli/000077500000000000000000000000001265717027300205525ustar00rootroot00000000000000weboob-1.1/weboob/applications/weboobcli/__init__.py000066400000000000000000000014321265717027300226630ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .weboobcli import WeboobCli __all__ = ['WeboobCli'] weboob-1.1/weboob/applications/weboobcli/weboobcli.py000066400000000000000000000034121265717027300230710ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.tools.application.repl import ReplApplication __all__ = ['WeboobCli'] class WeboobCli(ReplApplication): APPNAME = 'weboob-cli' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' SYNOPSIS = 'Usage: %prog [-dqv] [-b backends] [-cnfs] capability method [arguments..]\n' SYNOPSIS += ' %prog [--help] [--version]' DESCRIPTION = "Weboob-Cli is a console application to call a specific method on backends " \ "which implement the given capability." SHORT_DESCRIPTION = "call a method on backends" DISABLE_REPL = True def load_default_backends(self): pass def main(self, argv): if len(argv) < 3: print("Syntax: %s capability method [args ..]" % argv[0], file=self.stderr) return 2 cap_s = argv[1] cmd = argv[2] args = argv[3:] self.load_backends(cap_s) for obj in self.do(cmd, *args): self.format(obj) self.flush() return 0 weboob-1.1/weboob/applications/weboobdebug/000077500000000000000000000000001265717027300210715ustar00rootroot00000000000000weboob-1.1/weboob/applications/weboobdebug/__init__.py000066400000000000000000000014411265717027300232020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .weboobdebug import WeboobDebug __all__ = ['WeboobDebug'] weboob-1.1/weboob/applications/weboobdebug/weboobdebug.py000066400000000000000000000065441265717027300237400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from optparse import OptionGroup from weboob.tools.application.base import Application class WeboobDebug(Application): APPNAME = 'weboobdebug' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Christophe Benz' DESCRIPTION = "Weboob-Debug is a console application to debug backends." SHORT_DESCRIPTION = "debug backends" def __init__(self, option_parser=None): super(WeboobDebug, self).__init__(option_parser) options = OptionGroup(self._parser, 'Weboob-Debug options') options.add_option('-B', '--bpython', action='store_true', help='Prefer bpython over ipython') self._parser.add_option_group(options) def load_default_backends(self): pass def main(self, argv): """ BACKEND Debug BACKEND. """ try: backend_name = argv[1] except IndexError: print('Usage: %s BACKEND' % argv[0], file=self.stderr) return 1 try: backend = self.weboob.load_backends(names=[backend_name])[backend_name] except KeyError: print(u'Unable to load backend "%s"' % backend_name, file=self.stderr) return 1 locs = dict(backend=backend, browser=backend.browser, application=self, weboob=self.weboob) banner = 'Weboob debug shell\nBackend "%s" loaded.\nAvailable variables:\n' % backend_name \ + '\n'.join([' %s: %s' % (k, v) for k, v in locs.iteritems()]) if self.options.bpython: funcs = [self.bpython, self.ipython, self.python] else: funcs = [self.ipython, self.bpython, self.python] for func in funcs: try: func(locs, banner) except ImportError: continue else: break def ipython(self, locs, banner): try: from IPython import embed embed(user_ns=locs, banner2=banner) except ImportError: from IPython.Shell import IPShellEmbed shell = IPShellEmbed(argv=[]) shell.set_banner(shell.IP.BANNER + '\n\n' + banner) shell(local_ns=locs, global_ns={}) def bpython(self, locs, banner): from bpython import embed embed(locs, banner=banner) def python(self, locs, banner): import code try: import readline import rlcompleter readline.set_completer(rlcompleter.Completer(locs).complete) readline.parse_and_bind("tab:complete") except ImportError: pass code.interact(banner=banner, local=locs) weboob-1.1/weboob/applications/weboobrepos/000077500000000000000000000000001265717027300211335ustar00rootroot00000000000000weboob-1.1/weboob/applications/weboobrepos/__init__.py000066400000000000000000000014401265717027300232430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .weboobrepos import WeboobRepos __all__ = ['WeboobRepos'] weboob-1.1/weboob/applications/weboobrepos/weboobrepos.py000066400000000000000000000207701265717027300240410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from datetime import datetime from time import mktime, strptime import tarfile import os import shutil import subprocess from copy import copy from contextlib import closing from weboob.core.repositories import Repository from weboob.tools.application.repl import ReplApplication from weboob.tools.misc import find_exe __all__ = ['WeboobRepos'] class WeboobRepos(ReplApplication): APPNAME = 'weboob-repos' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2012-YEAR Romain Bignon' DESCRIPTION = "Weboob-repos is a console application to manage a Weboob Repository." SHORT_DESCRIPTION = "manage a weboob repository" COMMANDS_FORMATTERS = {'backends': 'table', 'list': 'table', } DISABLE_REPL = True weboob_commands = copy(ReplApplication.weboob_commands) weboob_commands.remove('backends') def load_default_backends(self): pass def do_create(self, line): """ create NAME [PATH] Create a new repository. If PATH is missing, create repository on the current directory. """ name, path = self.parse_command_args(line, 2, 1) if not path: path = os.getcwd() else: path = os.path.realpath(path) if not os.path.exists(path): os.mkdir(path) elif not os.path.isdir(path): print(u'"%s" is not a directory' % path) return 1 r = Repository('http://') r.name = name r.maintainer = self.ask('Enter maintainer of the repository') r.save(os.path.join(path, r.INDEX)) print(u'Repository "%s" created.' % path) def do_build(self, line): """ build SOURCE REPOSITORY Build backends contained in SOURCE to REPOSITORY. Example: $ weboob-repos build $HOME/src/weboob/modules /var/www/updates.weboob.org/0.a/ """ source_path, repo_path = self.parse_command_args(line, 2, 2) index_file = os.path.join(repo_path, Repository.INDEX) r = Repository('http://') try: with open(index_file, 'r') as fp: r.parse_index(fp) except IOError as e: print('Unable to open repository: %s' % e, file=self.stderr) print('Use the "create" command before.', file=self.stderr) return 1 r.build_index(source_path, index_file) if r.signed: sigfiles = [r.KEYRING, Repository.INDEX] gpg = find_exe('gpg2') or find_exe('gpg') if not gpg: raise Exception('Unable to find the gpg executable.') krname = os.path.join(repo_path, r.KEYRING) if os.path.exists(krname): kr_mtime = int(datetime.fromtimestamp(os.path.getmtime(krname)).strftime('%Y%m%d%H%M')) if not os.path.exists(krname) or kr_mtime < r.key_update: print('Generate keyring') # Remove all existing keys if os.path.exists(krname): os.remove(krname) # Add all valid keys for keyfile in os.listdir(os.path.join(source_path, r.KEYDIR)): print('Adding key %s' % keyfile) keypath = os.path.join(source_path, r.KEYDIR, keyfile) subprocess.check_call([ gpg, '--no-options', '--quiet', '--no-default-keyring', '--keyring', os.path.realpath(krname), '--import', os.path.realpath(keypath)]) # Does not make much sense in our case if os.path.exists(krname + '~'): os.remove(krname + '~') if not os.path.exists(krname): raise Exception('No valid key file found.') kr_mtime = mktime(strptime(str(r.key_update), '%Y%m%d%H%M')) os.chmod(krname, 0o644) os.utime(krname, (kr_mtime, kr_mtime)) else: print('Keyring is up to date') for name, module in r.modules.iteritems(): tarname = os.path.join(repo_path, '%s.tar.gz' % name) if r.signed: sigfiles.append(os.path.basename(tarname)) module_path = os.path.join(source_path, name) if os.path.exists(tarname): tar_mtime = int(datetime.fromtimestamp(os.path.getmtime(tarname)).strftime('%Y%m%d%H%M')) if tar_mtime >= module.version: continue print('Create archive for %s' % name) with closing(tarfile.open(tarname, 'w:gz')) as tar: tar.add(module_path, arcname=name, exclude=self._archive_excludes) tar_mtime = mktime(strptime(str(module.version), '%Y%m%d%H%M')) os.utime(tarname, (tar_mtime, tar_mtime)) # Copy icon. icon_path = os.path.join(module_path, 'favicon.png') if os.path.exists(icon_path): shutil.copy(icon_path, os.path.join(repo_path, '%s.png' % name)) if r.signed: # Find out which keys are allowed to sign fingerprints = [gpgline.strip(':').split(':')[-1] for gpgline in subprocess.Popen([ gpg, '--no-options', '--with-fingerprint', '--with-colons', '--list-public-keys', '--no-default-keyring', '--keyring', os.path.realpath(krname)], stdout=subprocess.PIPE).communicate()[0].splitlines() if gpgline.startswith('fpr:')] # Find out the first secret key we have that is allowed to sign secret_fingerprint = None for fingerprint in fingerprints: proc = subprocess.Popen([ gpg, '--no-options', '--list-secret-keys', fingerprint], stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc.communicate() # if failed if proc.returncode: continue secret_fingerprint = fingerprint if secret_fingerprint is None: raise Exception('No suitable secret key found') # Check if all files have an up to date signature for filename in sigfiles: filepath = os.path.realpath(os.path.join(repo_path, filename)) sigpath = filepath + '.sig' file_mtime = int(os.path.getmtime(filepath)) if os.path.exists(sigpath): sig_mtime = int(os.path.getmtime(sigpath)) if not os.path.exists(sigpath) or sig_mtime < file_mtime: print('Signing %s' % filename) if os.path.exists(sigpath): os.remove(sigpath) subprocess.check_call([ gpg, '--no-options', '--quiet', '--local-user', secret_fingerprint, '--detach-sign', '--output', sigpath, '--sign', filepath]) os.utime(sigpath, (file_mtime, file_mtime)) print('Signatures are up to date') def _archive_excludes(self, filename): # Skip *.pyc files in tarballs. if filename.endswith('.pyc'): return True # Don't include *.png files in tarball if filename.endswith('.png'): return True return False weboob-1.1/weboob/applications/weboorrents/000077500000000000000000000000001265717027300211565ustar00rootroot00000000000000weboob-1.1/weboob/applications/weboorrents/__init__.py000066400000000000000000000014401265717027300232660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .weboorrents import Weboorrents __all__ = ['Weboorrents'] weboob-1.1/weboob/applications/weboorrents/weboorrents.py000066400000000000000000000150111265717027300240770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from weboob.capabilities.torrent import CapTorrent, MagnetOnly from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter from weboob.core import CallErrors from weboob.capabilities.base import NotAvailable, NotLoaded, empty __all__ = ['Weboorrents'] def sizeof_fmt(num): for x in ['bytes', 'KB', 'MB', 'GB', 'TB']: if num < 1024.0: return "%-4.1f%s" % (num, x) num /= 1024.0 class TorrentInfoFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'name', 'size', 'seeders', 'leechers', 'url', 'files', 'description') def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC) result += 'ID: %s\n' % obj.fullid if obj.size != NotAvailable and obj.size != NotLoaded: result += 'Size: %s\n' % sizeof_fmt(obj.size) result += 'Seeders: %s\n' % obj.seeders result += 'Leechers: %s\n' % obj.leechers result += 'URL: %s\n' % obj.url if hasattr(obj, 'magnet') and obj.magnet: result += 'Magnet URL: %s\n' % obj.magnet if obj.files: result += '\n%sFiles%s\n' % (self.BOLD, self.NC) for f in obj.files: result += ' * %s\n' % f result += '\n%sDescription%s\n' % (self.BOLD, self.NC) result += '%s' % obj.description return result class TorrentListFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'name', 'size', 'seeders', 'leechers') def get_title(self, obj): return obj.name NB2COLOR = ((0, 'red', None), (1, 'blue', None), (5, 'green', None), (10, 'green', 'bold'), ) def _get_color(self, nb): if empty(nb): return self.colored('N/A', 'red') for threshold, _color, _attr in self.NB2COLOR: if nb >= threshold: color = _color attr = _attr return self.colored('%3d' % nb, color, attr) def get_description(self, obj): size = self.colored('%10s' % sizeof_fmt(obj.size), 'magenta') return '%s (Seed: %s / Leech: %s)' % (size, self._get_color(obj.seeders), self._get_color(obj.leechers)) class Weboorrents(ReplApplication): APPNAME = 'weboorrents' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' DESCRIPTION = "Console application allowing to search for torrents on various trackers " \ "and download .torrent files." SHORT_DESCRIPTION = "search and download torrents" CAPS = CapTorrent EXTRA_FORMATTERS = {'torrent_list': TorrentListFormatter, 'torrent_info': TorrentInfoFormatter, } COMMANDS_FORMATTERS = {'search': 'torrent_list', 'info': 'torrent_info', } def complete_info(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_info(self, id): """ info ID Get information about a torrent. """ torrent = self.get_object(id, 'get_torrent', ('id', 'name', 'size', 'seeders', 'leechers', 'url', 'files', 'description')) if not torrent: print('Torrent not found: %s' % id, file=self.stderr) return 3 self.start_format() self.format(torrent) def complete_getfile(self, text, line, *ignored): args = line.split(' ', 2) if len(args) == 2: return self._complete_object() elif len(args) >= 3: return self.path_completer(args[2]) def do_getfile(self, line): """ getfile ID [FILENAME] Get the .torrent file. FILENAME is where to write the file. If FILENAME is '-', the file is written to stdout. """ id, dest = self.parse_command_args(line, 2, 1) torrent = self.get_object(id, 'get_torrent', ('description', 'files')) if not torrent: print('Torrent not found: %s' % id, file=self.stderr) return 3 dest = self.obj_to_filename(torrent, dest, '{id}-{name}.torrent') try: for buf in self.do('get_torrent_file', torrent.id, backends=torrent.backend): if buf: if dest == '-': print(buf) else: try: with open(dest, 'w') as f: f.write(buf) except IOError as e: print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr) return 1 return except CallErrors as errors: for backend, error, backtrace in errors: if isinstance(error, MagnetOnly): print(u'Error(%s): No direct URL available, ' u'please provide this magnet URL ' u'to your client:\n%s' % (backend, error.magnet), file=self.stderr) return 4 else: self.bcall_error_handler(backend, error, backtrace) print('Torrent "%s" not found' % id, file=self.stderr) return 3 @defaultcount(10) def do_search(self, pattern): """ search [PATTERN] Search torrents. """ self.change_path([u'search']) if not pattern: pattern = None self.start_format(pattern=pattern) for torrent in self.do('iter_torrents', pattern=pattern): self.cached_format(torrent) weboob-1.1/weboob/applications/wetboobs/000077500000000000000000000000001265717027300204315ustar00rootroot00000000000000weboob-1.1/weboob/applications/wetboobs/__init__.py000066400000000000000000000014271265717027300225460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .wetboobs import WetBoobs __all__ = ['WetBoobs'] weboob-1.1/weboob/applications/wetboobs/wetboobs.py000066400000000000000000000113301265717027300226250ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.weather import CapWeather from weboob.tools.application.repl import ReplApplication, defaultcount from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter __all__ = ['WetBoobs'] class ForecastsFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'date', 'low', 'high') temperature_display = staticmethod(lambda t: u'%s' % t.value) def format_obj(self, obj, alias): result = u'%s* %-15s%s (%s - %s)' % (self.BOLD, '%s:' % obj.date, self.NC, self.temperature_display(obj.low), self.temperature_display(obj.high)) if hasattr(obj, 'text') and obj.text: result += ' %s' % obj.text return result class CurrentFormatter(IFormatter): MANDATORY_FIELDS = ('id', 'date', 'temp') temperature_display = staticmethod(lambda t: u'%s' % t.value) def format_obj(self, obj, alias): result = u'%s%s%s: %s' % (self.BOLD, obj.date, self.NC, self.temperature_display(obj.temp)) if hasattr(obj, 'text') and obj.text: result += u' - %s' % obj.text return result class CitiesFormatter(PrettyFormatter): MANDATORY_FIELDS = ('id', 'name') def get_title(self, obj): return obj.name class WetBoobs(ReplApplication): APPNAME = 'wetboobs' VERSION = '1.1' COPYRIGHT = 'Copyright(C) 2010-YEAR Romain Bignon' DESCRIPTION = "Console application allowing to display weather and forecasts in your city." SHORT_DESCRIPTION = "display weather and forecasts" CAPS = CapWeather DEFAULT_FORMATTER = 'table' EXTRA_FORMATTERS = {'cities': CitiesFormatter, 'current': CurrentFormatter, 'forecasts': ForecastsFormatter, } COMMANDS_FORMATTERS = {'cities': 'cities', 'current': 'current', 'forecasts': 'forecasts', } def main(self, argv): self.load_config() return ReplApplication.main(self, argv) @defaultcount(10) def do_cities(self, pattern): """ cities PATTERN Search cities. """ self.change_path(['cities']) self.start_format() for city in self.do('iter_city_search', pattern, caps=CapWeather): self.cached_format(city) def complete_current(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_current(self, line): """ current CITY_ID Get current weather for specified city. Use the 'cities' command to find them. """ city, = self.parse_command_args(line, 1, 1) _id, backend_name = self.parse_id(city) tr = self.config.get('settings', 'temperature_display', default='C') if tr == 'C': self.formatter.temperature_display = lambda t: t.ascelsius() elif tr == 'F': self.formatter.temperature_display = lambda t: t.asfahrenheit() self.start_format() for current in self.do('get_current', _id, backends=backend_name, caps=CapWeather): if current: self.format(current) def complete_forecasts(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: return self._complete_object() def do_forecasts(self, line): """ forecasts CITY_ID Get forecasts for specified city. Use the 'cities' command to find them. """ city, = self.parse_command_args(line, 1, 1) _id, backend_name = self.parse_id(city) tr = self.config.get('settings', 'temperature_display', default='C') if tr == 'C': self.formatter.temperature_display = lambda t: t.ascelsius() elif tr == 'F': self.formatter.temperature_display = lambda t: t.asfahrenheit() self.start_format() for forecast in self.do('iter_forecast', _id, backends=backend_name, caps=CapWeather): self.format(forecast) weboob-1.1/weboob/browser/000077500000000000000000000000001265717027300156025ustar00rootroot00000000000000weboob-1.1/weboob/browser/__init__.py000066400000000000000000000017261265717027300177210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .browsers import Browser, DomainBrowser, UrlNotAllowed, PagesBrowser, LoginBrowser, need_login from .url import URL __all__ = ['Browser', 'DomainBrowser', 'UrlNotAllowed', 'PagesBrowser', 'URL', 'LoginBrowser', 'need_login'] weboob-1.1/weboob/browser/browsers.py000066400000000000000000000664761265717027300200450ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import absolute_import, print_function import re import pickle import base64 import zlib try: import urllib3 except ImportError: from requests.packages import urllib3 try: from urllib.parse import urlparse, urljoin except ImportError: from urlparse import urlparse, urljoin import os import sys from copy import deepcopy import inspect try: import requests if int(requests.__version__.split('.')[0]) < 2: raise ImportError() except ImportError: raise ImportError('Please install python-requests >= 2.0') from weboob.tools.log import getLogger from weboob.tools.ordereddict import OrderedDict from weboob.tools.json import json from .cookies import WeboobCookieJar from .exceptions import HTTPNotFound, ClientError, ServerError from .sessions import FuturesSession from .profiles import Firefox from .pages import NextPage from .url import URL class Browser(object): """ Simple browser class. Act like a browser, and don't try to do too much. """ PROFILE = Firefox() """ Default profile used by browser to navigate on websites. """ TIMEOUT = 10.0 """ Default timeout during requests. """ REFRESH_MAX = 0.0 """ When handling a Refresh header, the browsers considers it only if the sleep time in lesser than this value. """ VERIFY = True """ Check SSL certificates. """ PROXIES = None MAX_RETRIES = 2 MAX_WORKERS = 10 """ Maximum of threads for asynchronous requests. """ ALLOW_REFERRER = True """ Controls the behavior of get_referrer. """ @classmethod def asset(cls, localfile): """ Absolute file path for a module local file. """ if os.path.isabs(localfile): return localfile return os.path.join(os.path.dirname(inspect.getfile(cls)), localfile) def __init__(self, logger=None, proxy=None, responses_dirname=None): self.logger = getLogger('browser', logger) self.PROXIES = proxy self._setup_session(self.PROFILE) self.url = None self.response = None self.responses_dirname = responses_dirname self.responses_count = 1 if isinstance(self.VERIFY, basestring): self.VERIFY = self.asset(self.VERIFY) def deinit(self): self.session.close() def save_response(self, response, warning=False, **kwargs): if self.responses_dirname is None: import tempfile self.responses_dirname = tempfile.mkdtemp(prefix='weboob_session_') print('Debug data will be saved in this directory: %s' % self.responses_dirname, file=sys.stderr) elif not os.path.isdir(self.responses_dirname): os.makedirs(self.responses_dirname) import mimetypes # get the content-type, remove optionnal charset part mimetype = response.headers.get('Content-Type', '').split(';')[0] # due to http://bugs.python.org/issue1043134 if mimetype == 'text/plain': ext = '.txt' else: # try to get an extension (and avoid adding 'None') ext = mimetypes.guess_extension(mimetype, False) or '' path = re.sub(r'[^A-z0-9\.-_]+', '_', urlparse(response.url).path.rpartition('/')[2])[-10:] if path.endswith(ext): ext = '' filename = '%02d-%d%s%s%s' % \ (self.responses_count, response.status_code, '-' if path else '', path, ext) response_filepath = os.path.join(self.responses_dirname, filename) with open(response_filepath, 'w') as f: f.write(response.content) request = response.request with open(response_filepath + '-request.txt', 'w') as f: f.write('%s %s\n\n\n' % (request.method, request.url)) for key, value in request.headers.iteritems(): f.write('%s: %s\n' % (key, value)) if request.body is not None: # separate '' from None f.write('\n\n\n%s' % request.body) with open(response_filepath + '-response.txt', 'w') as f: if hasattr(response.elapsed, 'total_seconds'): f.write('Time: %3.3fs\n' % response.elapsed.total_seconds()) f.write('%s %s\n\n\n' % (response.status_code, response.reason)) for key, value in response.headers.iteritems(): f.write('%s: %s\n' % (key, value)) match_filepath = os.path.join(self.responses_dirname, 'url_response_match.txt') with open(match_filepath, 'a') as f: f.write('# %d %s %s\n' % (response.status_code, response.reason, response.headers.get('Content-Type', ''))) f.write('%s\t%s\n' % (response.url, filename)) self.responses_count += 1 msg = u'Response saved to %s' % response_filepath if warning: self.logger.warning(msg) else: self.logger.info(msg) def _create_session(self): return FuturesSession(max_workers=self.MAX_WORKERS, max_retries=self.MAX_RETRIES) def _setup_session(self, profile): """ Set up a python-requests session for our usage. """ session = self._create_session() session.proxies = self.PROXIES session.verify = not self.logger.settings['ssl_insecure'] and self.VERIFY if not session.verify: try: urllib3.disable_warnings() except AttributeError: # urllib3 is too old, warnings won't be disable pass # defines a max_retries. It's mandatory in case a server is not # handling keep alive correctly, like the proxy burp adapter_kwargs = dict(max_retries=self.MAX_RETRIES) # set connection pool size equal to MAX_WORKERS if needed if self.MAX_WORKERS > requests.adapters.DEFAULT_POOLSIZE: adapter_kwargs.update(pool_connections=self.MAX_WORKERS, pool_maxsize=self.MAX_WORKERS) session.mount('https://', requests.adapters.HTTPAdapter(**adapter_kwargs)) session.mount('http://', requests.adapters.HTTPAdapter(**adapter_kwargs)) if self.TIMEOUT: session.timeout = self.TIMEOUT ## weboob only can provide proxy and HTTP auth options session.trust_env = False profile.setup_session(session) if self.logger.settings['save_responses']: session.hooks['response'].append(self.save_response) self.session = session session.cookies = WeboobCookieJar() def set_profile(self, profile): profile.setup_session(self.session) def location(self, url, **kwargs): """ Like :meth:`open` but also changes the current URL and response. This is the most common method to request web pages. Other than that, has the exact same behavior of open(). """ assert not kwargs.get('is_async'), "Please use open() instead of location() to make asynchronous requests." response = self.open(url, **kwargs) self.response = response self.url = self.response.url return response def open(self, url, referrer=None, allow_redirects=True, stream=None, timeout=None, verify=None, cert=None, proxies=None, data_encoding=None, is_async=False, callback=lambda response: response, **kwargs): """ Make an HTTP request like a browser does: * follow redirects (unless disabled) * provide referrers (unless disabled) Unless a `method` is explicitly provided, it makes a GET request, or a POST if data is not None, An empty `data` (not None, like '' or {}) *will* make a POST. It is a wrapper around session.request(). All session.request() options are available. You should use location() or open() and not session.request(), since it has some interesting additions, which are easily individually disabled through the arguments. Call this instead of location() if you do not want to "visit" the URL (for instance, you are downloading a file). When `is_async` is True, open() returns a Future object (see concurrent.futures for more details), which can be evaluated with its result() method. If any exception is raised while processing request, it is caught and re-raised when calling result(). For example: >>> Browser().open('http://google.com', is_async=True).result().text # doctest: +SKIP :param url: URL :type url: str :param data: POST data :type url: str or dict or None :param referrer: Force referrer. False to disable sending it, None for guessing :type referrer: str or False or None :param is_async: Process request in a non-blocking way :type is_async: bool :param callback: Callback to be called when request has finished, with response as its first and only argument :type callback: function :rtype: :class:`requests.Response` """ if 'async' in kwargs: import warnings warnings.warn('Please use is_async instead of async.', DeprecationWarning) is_async = kwargs['async'] del kwargs['async'] req = self.build_request(url, referrer, data_encoding=data_encoding, **kwargs) preq = self.prepare_request(req) if hasattr(preq, '_cookies'): # The _cookies attribute is not present in requests < 2.2. As in # previous version it doesn't calls extract_cookies_to_jar(), it is # not a problem as we keep our own cookiejar instance. preq._cookies = WeboobCookieJar.from_cookiejar(preq._cookies) if proxies is None: proxies = self.PROXIES if verify is None: verify = not self.logger.settings['ssl_insecure'] and self.VERIFY if timeout is None: timeout = self.TIMEOUT # We define an inner_callback here in order to execute the same code # regardless of is_async param. def inner_callback(future, response): if allow_redirects: response = self.handle_refresh(response) self.raise_for_status(response) return callback(response) # call python-requests response = self.session.send(preq, allow_redirects=allow_redirects, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies, callback=inner_callback, is_async=is_async) return response def async_open(self, url, **kwargs): """ Shortcut to open(url, is_async=True). """ if 'async' in kwargs: del kwargs['async'] if 'is_async' in kwargs: del kwargs['is_async'] return self.open(url, is_async=True, **kwargs) def raise_for_status(self, response): """ Like Response.raise_for_status but will use other classes if needed. """ http_error_msg = None if 400 <= response.status_code < 500: http_error_msg = '%s Client Error: %s' % (response.status_code, response.reason) cls = ClientError if response.status_code == 404: cls = HTTPNotFound elif 500 <= response.status_code < 600: http_error_msg = '%s Server Error: %s' % (response.status_code, response.reason) cls = ServerError if http_error_msg: raise cls(http_error_msg, response=response) # in case we did not catch something that should be response.raise_for_status() def build_request(self, url, referrer=None, data_encoding=None, **kwargs): """ Does the same job as open(), but returns a Request without submitting it. This allows further customization to the Request. """ if isinstance(url, requests.Request): req = url url = req.url else: req = requests.Request(url=url, **kwargs) # guess method if req.method is None: if req.data: req.method = 'POST' else: req.method = 'GET' # convert unicode strings to proper encoding if isinstance(req.data, unicode) and data_encoding: req.data = req.data.encode(data_encoding) if isinstance(req.data, dict) and data_encoding: req.data = dict([(k, v.encode(data_encoding) if isinstance(v, unicode) else v) for k, v in req.data.iteritems()]) if referrer is None: referrer = self.get_referrer(self.url, url) if referrer: # Yes, it is a misspelling. req.headers.setdefault('Referer', referrer) return req def prepare_request(self, req): """ Get a prepared request from a Request object. This method aims to be overloaded by children classes. """ return self.session.prepare_request(req) REFRESH_RE = re.compile(r"^(?P[\d\.]+)(; url=[\"']?(?P.*?)[\"']?)?$", re.IGNORECASE) def handle_refresh(self, response): """ Called by open, to handle Refresh HTTP header. It only redirect to the refresh URL if the sleep time is inferior to REFRESH_MAX. """ if 'Refresh' not in response.headers: return response m = self.REFRESH_RE.match(response.headers['Refresh']) if m: # XXX perhaps we should not redirect if the refresh url is equal to the current url. url = m.groupdict().get('url', None) or response.request.url sleep = float(m.groupdict()['sleep']) if sleep <= self.REFRESH_MAX: self.logger.debug('Refresh to %s' % url) return self.open(url) else: self.logger.debug('Do not refresh to %s because %s > REFRESH_MAX(%s)' % (url, sleep, self.REFRESH_MAX)) return response self.logger.warning('Unable to handle refresh "%s"' % response.headers['Refresh']) return response def get_referrer(self, oldurl, newurl): """ Get the referrer to send when doing a request. If we should not send a referrer, it will return None. Reference: https://en.wikipedia.org/wiki/HTTP_referer The behavior can be controlled through the ALLOW_REFERRER attribute. True always allows the referers to be sent, False never, and None only if it is within the same domain. :param oldurl: Current absolute URL :type oldurl: str or None :param newurl: Target absolute URL :type newurl: str :rtype: str or None """ if self.ALLOW_REFERRER is False: return if oldurl is None: return old = urlparse(oldurl) new = urlparse(newurl) # Do not leak secure URLs to insecure URLs if old.scheme == 'https' and new.scheme != 'https': return # Reloading the page. Usually no referrer. if oldurl == newurl: return # Domain-based privacy if self.ALLOW_REFERRER is None and old.netloc != new.netloc: return return oldurl class UrlNotAllowed(Exception): """ Raises by :class:`DomainBrowser` when `RESTRICT_URL` is set and trying to go on an url not matching `BASEURL`. """ class DomainBrowser(Browser): """ A browser that handles relative URLs and can have a base URL (usually a domain). For instance self.location('/hello') will get http://weboob.org/hello if BASEURL is 'http://weboob.org/'. """ BASEURL = None """ Base URL, e.g. 'http://weboob.org/' or 'https://weboob.org/' See absurl(). """ RESTRICT_URL = False """ URLs allowed to load. This can be used to force SSL (if the BASEURL is SSL) or any other leakage. Set to True to allow only URLs starting by the BASEURL. Set it to a list of allowed URLs if you have multiple allowed URLs. More complex behavior is possible by overloading url_allowed() """ def __init__(self, baseurl=None, *args, **kwargs): super(DomainBrowser, self).__init__(*args, **kwargs) if baseurl is not None: self.BASEURL = baseurl def url_allowed(self, url): """ Checks if we are allowed to visit an URL. See RESTRICT_URL. :param url: Absolute URL :type url: str :rtype: bool """ if self.BASEURL is None or self.RESTRICT_URL is False: return True if self.RESTRICT_URL is True: return url.startswith(self.BASEURL) for restrict_url in self.RESTRICT_URL: if url.startswith(restrict_url): return True return False def absurl(self, uri, base=None): """ Get the absolute URL, relative to the base URL. If BASEURL is None, it will try to use the current URL. If base is False, it will always try to use the current URL. :param uri: URI to make absolute. It can be already absolute. :type uri: str :param base: Base absolute URL. :type base: str or None or False :rtype: str """ if not base: base = self.url if base is None or base is True: base = self.BASEURL return urljoin(base, uri) def open(self, req, *args, **kwargs): """ Like :meth:`Browser.open` but hanldes urls without domains, using the :attr:`BASEURL` attribute. """ uri = req.url if isinstance(req, requests.Request) else req url = self.absurl(uri) if not self.url_allowed(url): raise UrlNotAllowed(url) if isinstance(req, requests.Request): req.url = url else: req = url return super(DomainBrowser, self).open(req, *args, **kwargs) def go_home(self): """ Go to the "home" page, usually the BASEURL. """ return self.location(self.BASEURL or self.absurl('/')) class _PagesBrowserMeta(type): """ Private meta-class used to keep order of URLs instances of PagesBrowser. """ def __new__(mcs, name, bases, attrs): urls = [(url_name, attrs.pop(url_name)) for url_name, obj in attrs.items() if isinstance(obj, URL)] urls.sort(key=lambda x: x[1]._creation_counter) new_class = super(_PagesBrowserMeta, mcs).__new__(mcs, name, bases, attrs) if new_class._urls is None: new_class._urls = OrderedDict() else: new_class._urls = deepcopy(new_class._urls) new_class._urls.update(urls) return new_class class PagesBrowser(DomainBrowser): r""" A browser which works pages and keep state of navigation. To use it, you have to derive it and to create URL objects as class attributes. When open() or location() are called, if the url matches one of URL objects, it returns a Page object. In case of location(), it stores it in self.page. Example: >>> from .pages import HTMLPage >>> class HomePage(HTMLPage): ... pass ... >>> class ListPage(HTMLPage): ... pass ... >>> class MyBrowser(PagesBrowser): ... BASEURL = 'http://example.org' ... home = URL('/(index\.html)?', HomePage) ... list = URL('/list\.html', ListPage) ... You can then use URL instances to go on pages. """ _urls = None __metaclass__ = _PagesBrowserMeta def __getattr__(self, name): if self._urls is not None and name in self._urls: return self._urls[name] else: raise AttributeError("'%s' object has no attribute '%s'" % ( self.__class__.__name__, name)) def __init__(self, *args, **kwargs): super(PagesBrowser, self).__init__(*args, **kwargs) self.page = None self._urls = deepcopy(self._urls) for url in self._urls.itervalues(): url.browser = self def open(self, *args, **kwargs): """ Same method than :meth:`weboob.browser.browsers.DomainBrowser.open`, but the response contains an attribute `page` if the url matches any :class:`URL` object. """ callback = kwargs.pop('callback', lambda response: response) # Have to define a callback to seamlessly process synchronous and # asynchronous requests, see :meth:`Browser.open` and its `is_async` # and `callback` params. def internal_callback(response): # Try to handle the response page with an URL instance. response.page = None for url in self._urls.itervalues(): page = url.handle(response) if page is not None: self.logger.debug('Handle %s with %s' % (response.url, page.__class__.__name__)) response.page = page break if response.page is None: self.logger.debug('Unable to handle %s' % response.url) return callback(response) return super(PagesBrowser, self).open(callback=internal_callback, *args, **kwargs) def location(self, *args, **kwargs): """ Same method than :meth:`weboob.browser.browsers.Browser.location`, but if the url matches any :class:`URL` object, an attribute `page` is added to response, and the attribute :attr:`PagesBrowser.page` is set. """ if self.page is not None: # Call leave hook. self.page.on_leave() response = self.open(*args, **kwargs) self.response = response self.page = response.page self.url = response.url if self.page is not None: # Call load hook. self.page.on_load() # Returns self.response in case on_load recalls location() return self.response def pagination(self, func, *args, **kwargs): r""" This helper function can be used to handle pagination pages easily. When the called function raises an exception :class:`NextPage`, it goes on the wanted page and recall the function. :class:`NextPage` constructor can take an url or a Request object. >>> from .pages import HTMLPage >>> class Page(HTMLPage): ... def iter_values(self): ... for el in self.doc.xpath('//li'): ... yield el.text ... for next in self.doc.xpath('//a'): ... raise NextPage(next.attrib['href']) ... >>> class Browser(PagesBrowser): ... BASEURL = 'http://people.symlink.me' ... list = URL('/~rom1/projects/weboob/list-(?P\d+).html', Page) ... >>> b = Browser() >>> b.list.go(pagenum=1) # doctest: +ELLIPSIS >>> list(b.pagination(lambda: b.page.iter_values())) ['One', 'Two', 'Three', 'Four'] """ while True: try: for r in func(*args, **kwargs): yield r except NextPage as e: self.location(e.request) else: return def need_login(func): """ Decorator used to require to be logged to access to this function. """ def inner(browser, *args, **kwargs): if browser.page is None or not browser.page.logged: browser.do_login() return func(browser, *args, **kwargs) return inner class LoginBrowser(PagesBrowser): """ A browser which supports login. """ def __init__(self, username, password, *args, **kwargs): super(LoginBrowser, self).__init__(*args, **kwargs) self.username = username self.password = password def do_login(self): """ Abstract method to implement to login on website. It is call when a login is needed. """ raise NotImplementedError() def do_logout(self): """ Logout from website. By default, simply clears the cookies. """ self.session.cookies.clear() class StatesMixin(object): """ Mixin to store states of browser. """ __states__ = [] """ Saved state variables. """ def load_state(self, state): if 'cookies' in state: try: self.session.cookies = pickle.loads(zlib.decompress(base64.b64decode(state['cookies']))) except (TypeError, zlib.error, EOFError, ValueError): self.logger.error('Unable to reload cookies from storage') else: self.logger.info('Reloaded cookies from storage') for attrname in self.__states__: if attrname in state: setattr(self, attrname, state[attrname]) if 'url' in state: try: self.location(state['url']) except requests.exceptions.HTTPError: pass def dump_state(self): state = {} state['url'] = self.page.url state['cookies'] = base64.b64encode(zlib.compress(pickle.dumps(self.session.cookies, -1))) for attrname in self.__states__: state[attrname] = getattr(self, attrname) self.logger.info('Stored cookies into storage') return state class APIBrowser(DomainBrowser): """ A browser for API websites. """ def open(self, *args, **kwargs): """ Do a JSON request. The "Content-Type" header is always set to "application/json". :param data: if specified, format as JSON and send as request body :type data: :class:`dict` :param headers: if specified, add these headers to the request :type headers: :class:`dict` """ if 'data' in kwargs: kwargs['data'] = json.dumps(kwargs['data']) if 'headers' not in kwargs: kwargs['headers'] = {} kwargs['headers']['Content-Type'] = 'application/json' return super(APIBrowser, self).open(*args, **kwargs) def request(self, *args, **kwargs): """ Do a JSON request and parse the response. :returns: a dict containing the parsed JSON server response :rtype: :class:`dict` """ return self.open(*args, **kwargs).json() weboob-1.1/weboob/browser/cookies.py000066400000000000000000000050351265717027300176130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import requests.cookies try: import cookielib except ImportError: import http.cookiejar as cookielib __all__ = ['WeboobCookieJar'] class WeboobCookieJar(requests.cookies.RequestsCookieJar): @classmethod def from_cookiejar(klass, cj): """ Create a WeboobCookieJar from another CookieJar instance. """ return requests.cookies.merge_cookies(klass(), cj) def export(self, filename): """ Export all cookies to a file, regardless of expiration, etc. """ cj = requests.cookies.merge_cookies(cookielib.LWPCookieJar(), self) cj.save(filename, ignore_discard=True, ignore_expires=True) def _cookies_from_attrs_set(self, attrs_set, request): for tup in self._normalized_cookie_tuples(attrs_set): cookie = self._cookie_from_cookie_tuple(tup, request) if cookie: yield cookie def make_cookies(self, response, request): """Return sequence of Cookie objects extracted from response object.""" # get cookie-attributes for RFC 2965 and Netscape protocols headers = response.info() rfc2965_hdrs = headers.getheaders("Set-Cookie2") ns_hdrs = headers.getheaders("Set-Cookie") rfc2965 = self._policy.rfc2965 netscape = self._policy.netscape if netscape: for cookie in self._cookies_from_attrs_set(cookielib.parse_ns_headers(ns_hdrs), request): self._process_rfc2109_cookies([cookie]) yield cookie if rfc2965: for cookie in self._cookies_from_attrs_set(cookielib.split_header_words(rfc2965_hdrs), request): yield cookie def copy(self): """Return an object copy of the cookie jar.""" new_cj = type(self)() new_cj.update(self) return new_cj weboob-1.1/weboob/browser/elements.py000066400000000000000000000224741265717027300200010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import sys from copy import deepcopy from weboob.tools.log import getLogger, DEBUG_FILTERS from weboob.tools.ordereddict import OrderedDict from weboob.browser.pages import NextPage from .filters.standard import _Filter, CleanText from .filters.html import AttributeNotFound, XPathNotFound __all__ = ['DataError', 'AbstractElement', 'ListElement', 'ItemElement', 'TableElement', 'SkipItem'] class DataError(Exception): """ Returned data from pages are incoherent. """ def method(klass): """ Class-decorator to call it as a method. """ def inner(self, *args, **kwargs): return klass(self)(*args, **kwargs) return inner class AbstractElement(object): _creation_counter = 0 def __init__(self, page, parent=None, el=None): self.page = page self.parent = parent if el is not None: self.el = el elif parent is not None: self.el = parent.el else: self.el = page.doc if parent is not None: self.env = deepcopy(parent.env) else: self.env = deepcopy(page.params) # Used by debug self._random_id = AbstractElement._creation_counter AbstractElement._creation_counter += 1 self.loaders = {} def use_selector(self, func, key=None): if isinstance(func, _Filter): func._obj = self func._key = key value = func(self) elif isinstance(func, type) and issubclass(func, ItemElement): value = func(self.page, self, self.el)() elif callable(func): value = func() else: value = deepcopy(func) return value def parse(self, obj): pass def cssselect(self, *args, **kwargs): return self.el.cssselect(*args, **kwargs) def xpath(self, *args, **kwargs): return self.el.xpath(*args, **kwargs) def handle_loaders(self): for attrname in dir(self): m = re.match('load_(.*)', attrname) if not m: continue name = m.group(1) if name in self.loaders: continue loader = getattr(self, attrname) self.loaders[name] = self.use_selector(loader, key=attrname) class ListElement(AbstractElement): item_xpath = None flush_at_end = False ignore_duplicate = False def __init__(self, *args, **kwargs): super(ListElement, self).__init__(*args, **kwargs) self.logger = getLogger(self.__class__.__name__.lower()) self.objects = OrderedDict() def __call__(self, *args, **kwargs): for key, value in kwargs.iteritems(): self.env[key] = value return self.__iter__() def find_elements(self): """ Get the nodes that will have to be processed. This method can be overridden if xpath filters are not sufficient. """ if self.item_xpath is not None: for el in self.el.xpath(self.item_xpath): yield el else: yield self.el def __iter__(self): self.parse(self.el) items = [] for el in self.find_elements(): for attrname in dir(self): attr = getattr(self, attrname) if isinstance(attr, type) and issubclass(attr, AbstractElement) and attr != type(self): item = attr(self.page, self, el) item.handle_loaders() items.append(item) for item in items: for obj in item: obj = self.store(obj) if obj and not self.flush_at_end: yield obj if self.flush_at_end: for obj in self.flush(): yield obj self.check_next_page() def flush(self): for obj in self.objects.itervalues(): yield obj def check_next_page(self): if not hasattr(self, 'next_page'): return next_page = getattr(self, 'next_page') try: value = self.use_selector(next_page) except (AttributeNotFound, XPathNotFound): return if value is None: return raise NextPage(value) def store(self, obj): if obj.id: if obj.id in self.objects: if self.ignore_duplicate: self.logger.warning('There are two objects with the same ID! %s' % obj.id) return else: raise DataError('There are two objects with the same ID! %s' % obj.id) self.objects[obj.id] = obj return obj class SkipItem(Exception): """ Raise this exception in an :class:`ItemElement` subclass to skip an item. """ class _ItemElementMeta(type): """ Private meta-class used to keep order of obj_* attributes in :class:`ItemElement`. """ def __new__(mcs, name, bases, attrs): _attrs = [] for base in bases: if hasattr(base, '_attrs'): _attrs += base._attrs filters = [(re.sub('^obj_', '', attr_name), attrs[attr_name]) for attr_name, obj in attrs.items() if attr_name.startswith('obj_')] # constants first, then filters, then methods filters.sort(key=lambda x: x[1]._creation_counter if hasattr(x[1], '_creation_counter') else (sys.maxsize if callable(x[1]) else 0)) new_class = super(_ItemElementMeta, mcs).__new__(mcs, name, bases, attrs) new_class._attrs = _attrs + [f[0] for f in filters] return new_class class ItemElement(AbstractElement): __metaclass__ = _ItemElementMeta _attrs = None _loaders = None klass = None condition = None validate = None class Index(object): pass def __init__(self, *args, **kwargs): super(ItemElement, self).__init__(*args, **kwargs) self.logger = getLogger(self.__class__.__name__.lower()) self.obj = None def build_object(self): if self.klass is None: return return self.klass() def __call__(self, obj=None): if obj is not None: self.obj = obj for obj in self: return obj def __iter__(self): if self.condition is not None and not self.condition(): return try: if self.obj is None: self.obj = self.build_object() self.parse(self.el) self.handle_loaders() for attr in self._attrs: self.handle_attr(attr, getattr(self, 'obj_%s' % attr)) except SkipItem: return if self.validate is not None and not self.validate(self.obj): return yield self.obj def handle_attr(self, key, func): try: value = self.use_selector(func, key=key) except Exception as e: # Help debugging as tracebacks do not give us the key self.logger.warning('Attribute %s raises %s' % (key, repr(e))) raise logger = getLogger('b2filters') logger.log(DEBUG_FILTERS, "%s.%s = %r" % (self._random_id, key, value)) setattr(self.obj, key, value) class TableElement(ListElement): head_xpath = None cleaner = CleanText def __init__(self, *args, **kwargs): super(TableElement, self).__init__(*args, **kwargs) self._cols = {} columns = {} for attrname in dir(self): m = re.match('col_(.*)', attrname) if m: cols = getattr(self, attrname) if not isinstance(cols, (list,tuple)): cols = [cols] columns[m.group(1)] = [s.lower() for s in cols] colnum = 0 for el in self.el.xpath(self.head_xpath): title = self.cleaner.clean(el).lower() for name, titles in columns.iteritems(): if title in titles and name not in self._cols: self._cols[name] = colnum try: colnum += int(el.attrib.get('colspan', 1)) except (ValueError, AttributeError): colnum += 1 def get_colnum(self, name): return self._cols.get(name, None) class DictElement(ListElement): def find_elements(self): if self.item_xpath is None: selector = [] elif isinstance(self.item_xpath, basestring): selector = self.item_xpath.split('/') else: selector = self.item_xpath for el in selector: if isinstance(self.el, list): el = int(el) self.el = self.el[el] for el in self.el: yield el weboob-1.1/weboob/browser/exceptions.py000066400000000000000000000020011265717027300203260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from requests.exceptions import HTTPError from weboob.exceptions import BrowserHTTPError, BrowserHTTPNotFound class HTTPNotFound(HTTPError, BrowserHTTPNotFound): pass class ClientError(HTTPError, BrowserHTTPError): pass class ServerError(HTTPError, BrowserHTTPError): pass weboob-1.1/weboob/browser/filters/000077500000000000000000000000001265717027300172525ustar00rootroot00000000000000weboob-1.1/weboob/browser/filters/__init__.py000066400000000000000000000013311265717027300213610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . weboob-1.1/weboob/browser/filters/html.py000066400000000000000000000045451265717027300206000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import lxml.html as html from .standard import _Selector, _NO_DEFAULT, Filter, FilterError from weboob.tools.html import html2text __all__ = ['CSS', 'XPath', 'XPathNotFound', 'AttributeNotFound', 'Attr', 'Link', 'CleanHTML'] class XPathNotFound(FilterError): pass class AttributeNotFound(FilterError): pass class CSS(_Selector): @classmethod def select(cls, selector, item, obj=None, key=None): return item.cssselect(selector) class XPath(_Selector): pass class Attr(Filter): def __init__(self, selector, attr, default=_NO_DEFAULT): super(Attr, self).__init__(selector, default=default) self.attr = attr def filter(self, el): try: return u'%s' % el[0].attrib[self.attr] except IndexError: return self.default_or_raise(XPathNotFound('Unable to find tag %s' % self.selector)) except KeyError: return self.default_or_raise(AttributeNotFound('Element %s does not have attribute %s' % (el[0], self.attr))) class Link(Attr): """ Get the link uri of an element. If the tag is not found, an exception IndexError is raised. """ def __init__(self, selector=None, default=_NO_DEFAULT): super(Link, self).__init__(selector, 'href', default=default) class CleanHTML(Filter): def filter(self, txt): if isinstance(txt, (tuple, list)): return u' '.join([self.clean(item) for item in txt]) return self.clean(txt) @classmethod def clean(cls, txt): if not isinstance(txt, basestring): txt = html.tostring(txt, encoding=unicode) return html2text(txt) weboob-1.1/weboob/browser/filters/javascript.py000066400000000000000000000136361265717027300220030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Simon Murail # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from ast import literal_eval from weboob.browser.filters.standard import Filter, Regexp, RegexpError from weboob.exceptions import ParseError __all__ = ['JSPayload', 'JSValue', 'JSVar'] def _quoted(q): return r'(?: >>> JSPayload.filter('''someString = "An example comment: /* example */"; ... ... // The comment around this code has been commented out. ... // /* ... some_code(); ... // */''') 'someString = "An example comment: /* example */";\n\nsome_code();\n' """ _single_line_comment = '[ \t\v\f]*//.*\r?(?:\n|$)' _multi_line_comment = '/\*(?:.|[\r\n])*?\*/' _splitter = re.compile('(?:(%s|%s)|%s|%s)' % (_quoted('"'), _quoted("'"), _single_line_comment, _multi_line_comment)) @classmethod def filter(cls, value): return ''.join(filter(bool, cls._splitter.split(value))) class JSValue(Regexp): r""" Get one or many JavaScript literals. It only understands literal values, but should parse them well. Values are converted in python values, quotes and slashes in strings are stripped. >>> JSValue().filter('boringVar = "boring string"') u'boring string' >>> JSValue().filter('somecode(); doConfuse(0xdead, cat);') 57005 >>> JSValue(need_type=int, nth=2).filter('fazboo("3", "5", 7, "9");') 7 >>> JSValue(nth='*').filter('foo([1, 2, 3], "blah", 5.0, true, null]);') [1, 2, 3, u'blah', 5.0, True, None] """ pattern = r"""(?x) (?:(?P(?:[-+]\s*)? # float ? (?:(?:\d+\.\d*|\d*\.\d+)(?:[eE]\d+)? |\d+[eE]\d+)) |(?P(?:[-+]\s*)?(?:0[bB][01]+ # int ? |0[oO][0-7]+ |0[xX][0-9a-fA-F]+ |\d+)) |(?:(?:(?:new\s+)?String\()?(?P(?:%s|%s))) # str ? |(?Ptrue|false) # bool ? |(?Pnull)) # None ? """ % (_quoted('"'), _quoted("'")) def to_python(self, m): "Convert MatchObject to python value" values = m.groupdict() for t, v in values.iteritems(): if v is not None: break if self.need_type and t != self.need_type: raise ParseError('Value with type %s not found' % self.need_type) if t in ('int', 'float'): return literal_eval(v) if t == 'str': return literal_eval(v).decode('utf-8') if t == 'bool': return v == 'true' if t == 'None': return if self.default: return self.default raise ParseError('Unable to parse %r value' % m.group(0)) def __init__(self, selector=None, need_type=None, **kwargs): assert 'pattern' not in kwargs and 'flags' not in kwargs, \ "It would be meaningless to define a pattern and/or flags, use Regexp" assert 'template' not in kwargs, "Can't use a template, use Regexp if you have to" self.need_type = need_type.__name__ if type(need_type) == type else need_type super(JSValue, self).__init__(selector, pattern=self.pattern, template=self.to_python, **kwargs) class JSVar(JSValue): r""" Get assigned value of a variable, either as an initialisation value, either as an assignement. One can use Regexp's nth parameter to be more specific. See JSValue for more details about parsed values. >>> JSVar(var='test').filter("var test = .1;\nsomecode()") 0.1 >>> JSVar(var='test').filter("test = 666;\nsomecode()") 666 >>> JSVar(var='test').filter("test = 'Some \\'string\\' value, isn\\'t it ?';\nsomecode()") u"Some 'string' value, isn't it ?" >>> JSVar(var='test').filter('test = "Some \\"string\\" value";\nsomecode()') u'Some "string" value' >>> JSVar(var='test').filter("var test = false;\nsomecode()") False >>> JSVar(var='test', nth=1).filter("var test = false; test = true;\nsomecode()") True """ pattern_template = r"""(?x) (?:var\s+)? # optional var keyword \b%s # var name \s*=\s* # equal sign """ + JSValue.pattern def __init__(self, selector=None, var=None, need_type=None, **kwargs): assert var is not None, 'Please give a var parameter' self.var = var self.pattern = self.pattern_template % re.escape(var) super(JSVar, self).__init__(selector, need_type=need_type, **kwargs) def filter(self, txt): try: return super(JSVar, self).filter(txt) except RegexpError: raise ParseError('Variable %r not found' % self.var) weboob-1.1/weboob/browser/filters/json.py000066400000000000000000000045611265717027300206030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014-2015 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .standard import _Filter, _NO_DEFAULT, Filter, ParseError __all__ = ['Dict'] class NotFound(object): def __repr__(self): return 'NOT_FOUND' _NOT_FOUND = NotFound() class _DictMeta(type): def __getitem__(cls, name): return cls(name) class Dict(Filter): __metaclass__ = _DictMeta def __init__(self, selector=None, default=_NO_DEFAULT): super(Dict, self).__init__(self, default=default) if selector is None: self.selector = [] elif isinstance(selector, basestring): self.selector = selector.split('/') elif callable(selector): self.selector = [selector] else: self.selector = selector def __getitem__(self, name): self.selector.append(name) return self def filter(self, elements): if elements is not _NOT_FOUND: return elements else: return self.default_or_raise(ParseError('Element %r not found' % self.selector)) @classmethod def select(cls, selector, item, obj=None, key=None): if isinstance(item, (dict, list)): content = item else: content = item.el for el in selector: if isinstance(content, list): el = int(el) elif isinstance(el, _Filter): el._key = key el._obj = obj el = el(item) elif callable(el): el = el(item) try: content = content[el] except (KeyError, IndexError, TypeError): return _NOT_FOUND return content weboob-1.1/weboob/browser/filters/standard.py000066400000000000000000000606071265717027300214350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import absolute_import import datetime import re import unicodedata from decimal import Decimal, InvalidOperation from itertools import islice from collections import Iterator from dateutil.parser import parse as parse_date from weboob.capabilities.base import empty from weboob.tools.compat import basestring from weboob.exceptions import ParseError from weboob.browser.url import URL from weboob.tools.log import getLogger, DEBUG_FILTERS class NoDefault(object): def __repr__(self): return 'NO_DEFAULT' _NO_DEFAULT = NoDefault() __all__ = ['FilterError', 'ColumnNotFound', 'RegexpError', 'ItemNotFound', 'Filter', 'Base', 'Env', 'TableCell', 'RawText', 'CleanText', 'Lower', 'CleanDecimal', 'Field', 'Regexp', 'Map', 'DateTime', 'Date', 'Time', 'DateGuesser', 'Duration', 'MultiFilter', 'CombineDate', 'Format', 'Join', 'Type', 'Eval', 'BrowserURL', 'Async', 'AsyncLoad'] class FilterError(ParseError): pass class ColumnNotFound(FilterError): pass class RegexpError(FilterError): pass class ItemNotFound(FilterError): pass class _Filter(object): _creation_counter = 0 def __init__(self, default=_NO_DEFAULT): self._key = None self._obj = None self.default = default self._creation_counter = _Filter._creation_counter _Filter._creation_counter += 1 def __or__(self, o): self.default = o return self def __and__(self, o): if isinstance(o, type) and issubclass(o, _Filter): o = o() o.selector = self return o def default_or_raise(self, exception): if self.default is not _NO_DEFAULT: return self.default else: raise exception def __str__(self): return self.__class__.__name__ def debug(*args): """ A decorator function to provide some debug information in Filters. It prints by default the name of the Filter and the input value. """ def wraper(function): def print_debug(self, value): logger = getLogger('b2filters') result = '' outputvalue = value if isinstance(value, list): from lxml import etree outputvalue = '' first = True for element in value: if first: first = False else: outputvalue += ', ' if isinstance(element, etree.ElementBase): outputvalue += "%s" % etree.tostring(element, encoding=unicode) else: outputvalue += "%r" % element if self._obj is not None: result += "%s" % self._obj._random_id if self._key is not None: result += ".%s" % self._key name = str(self) result += " %s(%r" % (name, outputvalue) for arg in self.__dict__: if arg.startswith('_') or arg == u"selector": continue if arg == u'default' and getattr(self, arg) == _NO_DEFAULT: continue result += ", %s=%r" % (arg, getattr(self, arg)) result += u')' logger.log(DEBUG_FILTERS, result) res = function(self, value) return res return print_debug return wraper class Filter(_Filter): """ Class used to filter on a HTML element given as call parameter to return matching elements. Filters can be chained, so the parameter supplied to constructor can be either a xpath selector string, or an other filter called before. >>> from lxml.html import etree >>> f = CleanDecimal(CleanText('//p'), replace_dots=True) >>> f(etree.fromstring('

blah: 229,90

')) Decimal('229.90') """ def __init__(self, selector=None, default=_NO_DEFAULT): super(Filter, self).__init__(default=default) self.selector = selector @classmethod def select(cls, selector, item, obj=None, key=None): if isinstance(selector, basestring): return item.xpath(selector) elif isinstance(selector, _Filter): selector._key = key selector._obj = obj return selector(item) elif callable(selector): return selector(item) else: return selector def __call__(self, item): return self.filter(self.select(self.selector, item, key=self._key, obj=self._obj)) @debug() def filter(self, value): """ This method have to be overrided by children classes. """ raise NotImplementedError() class _Selector(Filter): def filter(self, elements): if elements is not None: return elements else: return self.default_or_raise(ParseError('Element %r not found' % self.selector)) class AsyncLoad(Filter): def __call__(self, item): link = self.select(self.selector, item, key=self._key, obj=self._obj) return item.page.browser.async_open(link) if link else None class Async(_Filter): def __init__(self, name, selector=None): super(Async, self).__init__() self.selector = selector self.name = name def __and__(self, o): if isinstance(o, type) and issubclass(o, _Filter): o = o() self.selector = o return self def __call__(self, item): if item.loaders[self.name] is None: return None result = item.loaders[self.name].result() assert result.page is not None, 'The loaded url %s hasn\'t been matched by an URL object' % result.url return self.selector(result.page.doc) class Base(Filter): """ Change the base element used in filters. >>> Base(Env('header'), CleanText('./h1')) # doctest: +SKIP """ def __call__(self, item): base = self.select(self.base, item, obj=self._obj, key=self._key) return self.selector(base) def __init__(self, base, selector=None, default=_NO_DEFAULT): super(Base, self).__init__(selector, default) self.base = base class Decode(Filter): """ Filter that aims to decode urlencoded strings >>> Decode(Env(_id)) >>> Decode(Link(./a)) """ def __call__(self, item): self.encoding = item.page.ENCODING if item.page.ENCODING else 'utf-8' return self.filter(self.select(self.selector, item, key=self._key, obj=self._obj)) @debug() def filter(self, txt): from urllib import unquote try: txt = unquote(txt.encode('ascii')).decode(self.encoding) except (UnicodeDecodeError, UnicodeEncodeError): pass return txt class Env(_Filter): """ Filter to get environment value of the item. It is used for example to get page parameters, or when there is a parse() method on ItemElement. """ def __init__(self, name, default=_NO_DEFAULT): super(Env, self).__init__(default) self.name = name def __call__(self, item): try: return item.env[self.name] except KeyError: return self.default_or_raise(ParseError('Environment variable %s not found' % self.name)) class TableCell(_Filter): """ Used with TableElement, it get the cell value from its name. For example: >>> from weboob.capabilities.bank import Transaction >>> from weboob.browser.elements import TableElement, ItemElement >>> class table(TableElement): ... head_xpath = '//table/thead/th' ... item_xpath = '//table/tbody/tr' ... col_date = u'Date' ... col_label = [u'Name', u'Label'] ... class item(ItemElement): ... klass = Transaction ... obj_date = Date(TableCell('date')) ... obj_label = CleanText(TableCell('label')) ... """ def __init__(self, *names, **kwargs): super(TableCell, self).__init__(**kwargs) self.names = names def __call__(self, item): for name in self.names: idx = item.parent.get_colnum(name) if idx is not None: return item.xpath('./td[%s]' % (idx + 1)) return self.default_or_raise(ColumnNotFound('Unable to find column %s' % ' or '.join(self.names))) class RawText(Filter): @debug() def filter(self, el): if isinstance(el, (tuple, list)): return u' '.join([self.filter(e) for e in el]) if el.text is None: return self.default else: return unicode(el.text) class CleanText(Filter): """ Get a cleaned text from an element. It first replaces all tabs and multiple spaces (including newlines if ``newlines`` is True) to one space and strips the result string. The result is coerced into unicode, and optionally normalized according to the ``normalize`` argument. Then it replaces all symbols given in the ``symbols`` argument. >>> CleanText().filter('coucou ') u'coucou' >>> CleanText().filter(u'coucou\xa0coucou') u'coucou coucou' >>> CleanText(newlines=True).filter(u'coucou\\r\\n coucou ') u'coucou coucou' >>> CleanText(newlines=False).filter(u'coucou\\r\\n coucou ') u'coucou\\ncoucou' """ def __init__(self, selector=None, symbols='', replace=[], children=True, newlines=True, normalize='NFC', **kwargs): super(CleanText, self).__init__(selector, **kwargs) self.symbols = symbols self.toreplace = replace self.children = children self.newlines = newlines self.normalize = normalize @debug() def filter(self, txt): if isinstance(txt, (tuple, list)): txt = u' '.join([self.clean(item, children=self.children) for item in txt]) txt = self.clean(txt, self.children, self.newlines, self.normalize) txt = self.remove(txt, self.symbols) txt = self.replace(txt, self.toreplace) # ensure it didn't become str by mistake return unicode(txt) @classmethod def clean(cls, txt, children=True, newlines=True, normalize='NFC'): if not isinstance(txt, basestring): if children: txt = [t.strip() for t in txt.itertext()] else: txt = [txt.text.strip()] txt = u' '.join(txt) # 'foo bar' if newlines: txt = re.compile(u'\s+', flags=re.UNICODE).sub(u' ', txt) # 'foo bar' else: # normalize newlines and clean what is inside txt = '\n'.join([cls.clean(l) for l in txt.splitlines()]) txt = txt.strip() # lxml under Python 2 returns str instead of unicode if it is pure ASCII txt = unicode(txt) # normalize to a standard Unicode form if normalize: txt = unicodedata.normalize(normalize, txt) return txt @classmethod def remove(cls, txt, symbols): for symbol in symbols: txt = txt.replace(symbol, '') return txt.strip() @classmethod def replace(cls, txt, replace): for before, after in replace: txt = txt.replace(before, after) return txt class Lower(CleanText): @debug() def filter(self, txt): txt = super(Lower, self).filter(txt) return txt.lower() class CleanDecimal(CleanText): """ Get a cleaned Decimal value from an element. replace_dots is False by default. A dot is interpreted as a decimal separator. If replace_dots is set to True, we remove all the dots. The ',' is used as decimal separator (often useful for French values) If replace_dots is a tuple, the first element will be used as the thousands separator, and the second as the decimal separator. See http://en.wikipedia.org/wiki/Thousands_separator#Examples_of_use For example, for the UK style (as in 1,234,567.89): >>> CleanDecimal('./td[1]', replace_dots=(',', '.')) # doctest: +SKIP """ def __init__(self, selector=None, replace_dots=False, sign=None, default=_NO_DEFAULT): super(CleanDecimal, self).__init__(selector, default=default) self.replace_dots = replace_dots self.sign = sign @debug() def filter(self, text): if type(text) in (float, int, long): text = str(text) if empty(text): return self.default_or_raise(ParseError('Unable to parse %r' % text)) original_text = text = super(CleanDecimal, self).filter(text) if self.replace_dots: if type(self.replace_dots) is tuple: thousands_sep, decimal_sep = self.replace_dots else: thousands_sep, decimal_sep = '.', ',' text = text.replace(thousands_sep, '').replace(decimal_sep, '.') try: v = Decimal(re.sub(r'[^\d\-\.]', '', text)) if self.sign: v *= self.sign(original_text) return v except InvalidOperation as e: return self.default_or_raise(e) class Slugify(Filter): @debug() def filter(self, label): label = re.sub(r'[^A-Za-z0-9]', ' ', label.lower()).strip() label = re.sub(r'\s+', '-', label) return label class Type(Filter): """ Get a cleaned value of any type from an element text. The type_func can be any callable (class, function, etc.). By default an empty string will not be parsed but it can be changed by specifying minlen=False. Otherwise, a minimal length can be specified. >>> Type(CleanText('./td[1]'), type=int) # doctest: +SKIP >>> Type(type=int).filter('42') 42 >>> Type(type=int, default='NaN').filter('') 'NaN' >>> Type(type=str, minlen=False, default='a').filter('') '' >>> Type(type=str, minlen=0, default='a').filter('') 'a' """ def __init__(self, selector=None, type=None, minlen=0, default=_NO_DEFAULT): super(Type, self).__init__(selector, default=default) self.type_func = type self.minlen = minlen @debug() def filter(self, txt): if empty(txt): return self.default_or_raise(ParseError('Unable to parse %r' % txt)) if self.minlen is not False and len(txt) <= self.minlen: return self.default_or_raise(ParseError('Unable to parse %r' % txt)) try: return self.type_func(txt) except ValueError as e: return self.default_or_raise(ParseError('Unable to parse %r: %s' % (txt, e))) class Field(_Filter): """ Get the attribute of object. """ def __init__(self, name): super(Field, self).__init__() self.name = name def __call__(self, item): return item.use_selector(getattr(item, 'obj_%s' % self.name), key=self._key) # Based on nth from https://docs.python.org/2/library/itertools.html def nth(iterable, n, default=None): "Returns the nth item or a default value, n can be negative, or '*' for all" if n == '*': return iterable if n < 0: iterable = reversed(list(iterable)) n = abs(n) - 1 return next(islice(iterable, n, None), default) def ordinal(n): "To have some readable debug information: '*' => all, 0 => 1st, 1 => 2nd..." if n == '*': return 'all' i = abs(n) n = n - 1 if n < 0 else n + 1 return str(n) + ('th' if i > 2 else ['st', 'nd', 'rd'][i]) class Regexp(Filter): r""" Apply a regex. >>> from lxml.html import etree >>> doc = etree.fromstring('

Date: 13/08/1988

') >>> Regexp(CleanText('//p'), r'Date: (\d+)/(\d+)/(\d+)', '\\3-\\2-\\1')(doc) u'1988-08-13' >>> (Regexp(CleanText('//body'), r'(\d+)', nth=1))(doc) u'08' >>> (Regexp(CleanText('//body'), r'(\d+)', nth=-1))(doc) u'1988' >>> (Regexp(CleanText('//body'), r'(\d+)', template='[\\1]', nth='*'))(doc) [u'[13]', u'[08]', u'[1988]'] """ def __init__(self, selector=None, pattern=None, template=None, nth=0, flags=0, default=_NO_DEFAULT): super(Regexp, self).__init__(selector, default=default) assert pattern is not None self.pattern = pattern self._regex = re.compile(pattern, flags) self.template = template self.nth = nth def expand(self, m): if self.template is None: return next(g for g in m.groups() if g is not None) return self.template(m) if callable(self.template) else m.expand(self.template) @debug() def filter(self, txt): if isinstance(txt, (tuple, list)): txt = u' '.join([t.strip() for t in txt.itertext()]) m = self._regex.search(txt) if self.nth == 0 else \ nth(self._regex.finditer(txt), self.nth) if not m: msg = 'Unable to find %s %s in %r' % (ordinal(self.nth), self.pattern, txt) return self.default_or_raise(RegexpError(msg)) if isinstance(m, Iterator): return map(self.expand, m) return self.expand(m) class Map(Filter): def __init__(self, selector, map_dict, default=_NO_DEFAULT): super(Map, self).__init__(selector, default=default) self.map_dict = map_dict @debug() def filter(self, txt): try: return self.map_dict[txt] except KeyError: return self.default_or_raise(ItemNotFound('Unable to handle %r on %r' % (txt, self.map_dict))) class DateTime(Filter): def __init__(self, selector=None, default=_NO_DEFAULT, dayfirst=False, translations=None, parse_func=parse_date): super(DateTime, self).__init__(selector, default=default) self.dayfirst = dayfirst self.translations = translations self.parse_func = parse_func @debug() def filter(self, txt): if empty(txt) or txt == '': return self.default_or_raise(ParseError('Unable to parse %r' % txt)) try: if self.translations: for search, repl in self.translations: txt = search.sub(repl, txt) return self.parse_func(txt, dayfirst=self.dayfirst) except (ValueError, TypeError) as e: return self.default_or_raise(ParseError('Unable to parse %r: %s' % (txt, e))) class Date(DateTime): def __init__(self, selector=None, default=_NO_DEFAULT, dayfirst=False, translations=None, parse_func=parse_date): super(Date, self).__init__(selector, default=default, dayfirst=dayfirst, translations=translations, parse_func=parse_func) @debug() def filter(self, txt): datetime = super(Date, self).filter(txt) if hasattr(datetime, 'date'): return datetime.date() else: return datetime class DateGuesser(Filter): def __init__(self, selector, date_guesser, **kwargs): super(DateGuesser, self).__init__(selector) self.date_guesser = date_guesser self.kwargs = kwargs def __call__(self, item): values = self.select(self.selector, item, obj=self._obj, key=self._key) date_guesser = self.date_guesser # In case Env() is used to kive date_guesser. if isinstance(date_guesser, _Filter): date_guesser = self.select(date_guesser, item, obj=self._obj, key=self._key) if isinstance(values, basestring): values = re.split('[/-]', values) if len(values) == 2: day, month = map(int, values) else: raise ParseError('Unable to take (day, month) tuple from %r' % values) return date_guesser.guess_date(day, month, **self.kwargs) class Time(Filter): klass = datetime.time _regexp = re.compile(r'(?P\d+)[:h]?(?P\d+)([:m](?P\d+))?') kwargs = {'hour': 'hh', 'minute': 'mm', 'second': 'ss'} def __init__(self, selector=None, default=_NO_DEFAULT): super(Time, self).__init__(selector, default=default) @debug() def filter(self, txt): m = self._regexp.search(txt) if m: kwargs = {} for key, index in self.kwargs.iteritems(): kwargs[key] = int(m.groupdict()[index] or 0) return self.klass(**kwargs) return self.default_or_raise(ParseError('Unable to find time in %r' % txt)) class Duration(Time): klass = datetime.timedelta _regexp = re.compile(r'((?P\d+)[:;])?(?P\d+)[;:](?P\d+)') kwargs = {'hours': 'hh', 'minutes': 'mm', 'seconds': 'ss'} class MultiFilter(Filter): def __init__(self, *args, **kwargs): default = kwargs.pop('default', _NO_DEFAULT) super(MultiFilter, self).__init__(args, default) def __call__(self, item): values = [self.select(selector, item, obj=self._obj, key=self._key) for selector in self.selector] return self.filter(tuple(values)) def filter(self, values): raise NotImplementedError() class CombineDate(MultiFilter): def __init__(self, date, time): super(CombineDate, self).__init__(date, time) @debug() def filter(self, values): return datetime.datetime.combine(values[0], values[1]) class Format(MultiFilter): def __init__(self, fmt, *args): super(Format, self).__init__(*args) self.fmt = fmt @debug() def filter(self, values): return self.fmt % values class BrowserURL(MultiFilter): def __init__(self, url_name, **kwargs): super(BrowserURL, self).__init__(*kwargs.values()) self.url_name = url_name self.keys = kwargs.keys() def __call__(self, item): values = super(BrowserURL, self).__call__(item) url = getattr(item.page.browser, self.url_name) assert isinstance(url, URL), "%s.%s must be an URL object" % (type(item.page.browser).__name__, self.url_name) return url.build(**dict(zip(self.keys, values))) @debug() def filter(self, values): return values class Join(Filter): def __init__(self, pattern, selector=None, textCleaner=CleanText, newline=False, addBefore='', addAfter=''): super(Join, self).__init__(selector) self.pattern = pattern self.textCleaner = textCleaner self.newline = newline self.addBefore = addBefore self.addAfter = addAfter @debug() def filter(self, el): items = [self.textCleaner.clean(e) for e in el] items = [item for item in items if item] if self.newline: items = ['%s\r\n' % item for item in items] result = self.pattern.join(items) if self.addBefore: result = '%s%s' % (self.addBefore, result) if self.addAfter: result = '%s%s' % (result, self.addAfter) return result class Eval(MultiFilter): """ Evaluate a function with given 'deferred' arguments. >>> F = Field; Eval(lambda a, b, c: a * b + c, F('foo'), F('bar'), F('baz')) # doctest: +SKIP >>> Eval(lambda x, y: x * y + 1).filter([3, 7]) 22 """ def __init__(self, func, *args): super(Eval, self).__init__(*args) self.func = func @debug() def filter(self, values): return self.func(*values) def test_CleanText(): # This test works poorly under a doctest, or would be hard to read assert CleanText().filter(u' coucou  \n\théhé') == u'coucou héhé' assert CleanText().filter('coucou\xa0coucou') == CleanText().filter(u'coucou\xa0coucou') == u'coucou coucou' # Unicode normalization assert CleanText().filter(u'Éçã') == u'Éçã' assert CleanText(normalize='NFKC').filter(u'…') == u'...' assert CleanText().filter(u'…') == u'…' # Diacritical mark (dakuten) assert CleanText().filter(u'\u3053\u3099') == u'\u3054' assert CleanText(normalize='NFD').filter(u'\u3053\u3099') == u'\u3053\u3099' assert CleanText(normalize='NFD').filter(u'\u3054') == u'\u3053\u3099' assert CleanText(normalize=False).filter(u'\u3053\u3099') == u'\u3053\u3099' weboob-1.1/weboob/browser/pages.py000066400000000000000000000511001265717027300172500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import absolute_import import warnings from io import BytesIO import codecs from cgi import parse_header import urlparse import requests from weboob.tools.ordereddict import OrderedDict from weboob.tools.compat import basestring from weboob.tools.log import getLogger def pagination(func): r""" This helper decorator can be used to handle pagination pages easily. When the called function raises an exception :class:`NextPage`, it goes on the wanted page and recall the function. :class:`NextPage` constructor can take an url or a Request object. >>> class Page(HTMLPage): ... @pagination ... def iter_values(self): ... for el in self.doc.xpath('//li'): ... yield el.text ... for next in self.doc.xpath('//a'): ... raise NextPage(next.attrib['href']) ... >>> from .browsers import PagesBrowser >>> from .url import URL >>> class Browser(PagesBrowser): ... BASEURL = 'http://people.symlink.me' ... list = URL('/~rom1/projects/weboob/list-(?P\d+).html', Page) ... >>> b = Browser() >>> b.list.go(pagenum=1) # doctest: +ELLIPSIS >>> list(b.page.iter_values()) ['One', 'Two', 'Three', 'Four'] """ def inner(page, *args, **kwargs): while True: try: for r in func(page, *args, **kwargs): yield r except NextPage as e: result = page.browser.location(e.request) page = result.page else: return return inner class NextPage(Exception): """ Exception used for example in a Page to tell PagesBrowser.pagination to go on the next page. See :meth:`PagesBrowser.pagination` or decorator :func:`pagination`. """ def __init__(self, request): super(NextPage, self).__init__() self.request = request class Page(object): """ Represents a page. Encoding can be forced by setting the :attr:`ENCODING` class-wide attribute, or by passing an `encoding` keyword argument, which overrides :attr:`ENCODING`. Finally, it can be manually changed by assigning a new value to :attr:`encoding` instance attribute. A unicode version of the response content is accessible in :attr:`text`, decoded with specified :attr:`encoding`. :param browser: browser used to go on the page :type browser: :class:`weboob.browser.browsers.Browser` :param response: response object :type response: :class:`Response` :param params: optional dictionary containing parameters given to the page (see :class:`weboob.browser.url.URL`) :type params: :class:`dict` :param encoding: optional parameter to force the encoding of the page, overrides :attr:`ENCODING` :type encoding: :class:`basestring` """ ENCODING = None """ Force a page encoding. It is recommended to use None for autodetection. """ logged = False """ If True, the page is in a restrected area of the wesite. Useful with :class:`LoginBrowser` and the :func:`need_login` decorator. """ def __init__(self, browser, response, params=None, encoding=None): self.browser = browser self.logger = getLogger(self.__class__.__name__.lower(), browser.logger) self.response = response self.url = self.response.url self.params = params # Setup encoding and build document self.forced_encoding = encoding or self.ENCODING if self.forced_encoding: self.response.encoding = self.forced_encoding self.doc = self.build_doc(self.data) # Last chance to change encoding, according to :meth:`detect_encoding`, # which can be used to detect a document-level encoding declaration if not self.forced_encoding: encoding = self.detect_encoding() if encoding and encoding != self.encoding: self.response.encoding = encoding self.doc = self.build_doc(self.data) # Encoding issues are delegated to Response instance, implemented by # requests module. @property def encoding(self): return self.response.encoding @encoding.setter def encoding(self, value): self.forced_encoding = True self.response.encoding = value @property def content(self): """ Raw content from response. """ return self.response.content @property def text(self): """ Content of the response, in unicode, decoded with :attr:`encoding`. """ return self.response.text @property def data(self): """ Data passed to :meth:`build_doc`. """ return self.content def on_load(self): """ Event called when browser loads this page. """ def on_leave(self): """ Event called when browser leaves this page. """ def build_doc(self, content): """ Abstract method to be implemented by subclasses to build structured data (HTML, Json, CSV...) from :attr:`data` property. It also can be overriden in modules pages to preprocess or postprocess data. It must return an object -- that will be assigned to :attr:`doc`. """ raise NotImplementedError() def detect_encoding(self): """ Override this method to implement detection of document-level encoding declaration, if any (eg. html5's ). """ return None def absurl(self, url): """ Get an absolute URL from an a partial URL, relative to the Page URL """ return urlparse.urljoin(self.url, url) class FormNotFound(Exception): """ Raised when :meth:`HTMLPage.get_form` can't find a form. """ class FormSubmitWarning(UserWarning): """ A form has more than one submit element selected, and will likely generate an invalid request. """ class Form(OrderedDict): """ Represents a form of an HTML page. It is used as a dict with pre-filled values from HTML. You can set new values as strings by setting an item value. It is recommended to not use this class by yourself, but call :meth:`HTMLPage.get_form`. :param page: the page where the form is located :type page: :class:`Page` :param el: the form element on the page :param submit_el: allows you to only consider one submit button (which is what browsers do). If set to None, it takes all of them, and if set to False, it takes none. """ def __init__(self, page, el, submit_el=None): super(Form, self).__init__() self.page = page self.el = el self.submit_el = submit_el self.method = el.attrib.get('method', 'GET') self.url = el.attrib.get('action', page.url) self.name = el.attrib.get('name', '') submits = 0 # Find all elements of the form that will be useful to create the request for inp in el.xpath('.//input | .//select | .//textarea'): # Step 1: Ignore some elements try: name = inp.attrib['name'] except KeyError: continue # Ignore checkboxes and radios that are not selected # as they are just not present in the request instead of being empty # values. try: if inp.attrib['type'] in ('checkbox', 'radio') and 'checked' not in inp.attrib: continue except KeyError: pass # Either filter the submit buttons, or count how many we have found try: if inp.attrib['type'] == 'submit': # If we chose a submit button, ignore all others if self.submit_el is not None and inp is not self.submit_el: continue else: # Register that we have found a submit button, and that it will # be used submits += 1 except KeyError: pass # Step 2: Extract the key-value pair from the remaining elements if inp.tag == 'select': options = inp.xpath('.//option[@selected]') if len(options) == 0: options = inp.xpath('.//option') if len(options) == 0: value = u'' else: value = options[0].attrib.get('value', options[0].text or u'') else: value = inp.attrib.get('value', inp.text or u'') # TODO check if value already exists, emit warning self[name] = value # Sanity checks if submits > 1: warnings.warn('Form has more than one submit input, you should chose the correct one', FormSubmitWarning, stacklevel=3) if self.submit_el is not None and self.submit_el is not False and submits == 0: warnings.warn('Form had a submit element provided, but it was not found', FormSubmitWarning, stacklevel=3) @property def request(self): """ Get the Request object from the form. """ if self.method.lower() == 'get': req = requests.Request(self.method, self.url, params=self) else: req = requests.Request(self.method, self.url, data=self) req.headers.setdefault('Referer', self.page.url) return req def submit(self, **kwargs): """ Submit the form and tell browser to be located to the new page. """ kwargs.setdefault('data_encoding', self.page.encoding) return self.page.browser.location(self.request, **kwargs) class CsvPage(Page): """ Page which parses CSV files. """ DIALECT = 'excel' """ Dialect given to the :mod:`csv` module. """ FMTPARAMS = {} """ Parameters given to the :mod:`csv` module. """ ENCODING = 'utf-8' """ Encoding of the file. """ NEWLINES_HACK = True """ Convert all strange newlines to unix ones. """ HEADER = None """ If not None, will consider the line represented by this index as a header. This means the rows will be also available as dictionaries. """ def build_doc(self, content): # We may need to temporarily convert content to utf-8 because csv # does not support Unicode. encoding = self.encoding if encoding == 'utf-16le': # If there is a BOM, decode('utf-16') will get rid of it content = content.decode('utf-16').encode('utf-8') encoding = 'utf-8' if self.NEWLINES_HACK: content = content.replace('\r\n', '\n').replace('\r', '\n') return self.parse(BytesIO(content), encoding) def parse(self, data, encoding=None): """ Method called by the constructor of :class:`CsvPage` to parse the document. :param data: file stream :type data: :class:`BytesIO` :param encoding: if given, use it to decode cell strings :type encoding: :class:`str` """ import csv reader = csv.reader(data, dialect=self.DIALECT, **self.FMTPARAMS) header = None drows = [] rows = [] for i, row in enumerate(reader): if self.HEADER and i+1 < self.HEADER: continue row = map(unicode.strip, self.decode_row(row, encoding)) if header is None and self.HEADER: header = row else: rows.append(row) if header: drow = {} for i, cell in enumerate(row): drow[header[i]] = cell drows.append(drow) return drows if header is not None else rows def decode_row(self, row, encoding): """ Method called by :meth:`CsvPage.parse` to decode a row using the given encoding. """ if encoding: return [unicode(cell, encoding) for cell in row] else: return row class JsonPage(Page): """ Json Page. """ @property def data(self): return self.response.text def get(self, path): node = self.doc for name in filter(None, path.strip('.').split('.')): node = node.get(name) if node is None: break return node def path(self, path, context=None): from weboob.tools.json import mini_jsonpath return mini_jsonpath(context or self.doc, path) def build_doc(self, text): from weboob.tools.json import json return json.loads(text) class XMLPage(Page): """ XML Page. """ def detect_encoding(self): import re m = re.search('<\?xml version="1.0" encoding="(.*)"\?>', self.data) if m: return m.group(1) def build_doc(self, content): import lxml.etree as etree parser = etree.XMLParser(encoding=self.encoding) return etree.parse(BytesIO(content), parser) class RawPage(Page): """ Raw page where the "doc" attribute is the content string. """ def build_doc(self, content): return content class HTMLPage(Page): """ HTML page. :param browser: browser used to go on the page :type browser: :class:`weboob.browser.browsers.Browser` :param response: response object :type response: :class:`Response` :param params: optional dictionary containing parameters given to the page (see :class:`weboob.browser.url.URL`) :type params: :class:`dict` :param encoding: optional parameter to force the encoding of the page :type encoding: :class:`basestring` """ FORM_CLASS = Form """ The class to instanciate when using :meth:`HTMLPage.get_form`. Default to :class:`Form`. """ REFRESH_MAX = None """ When handling a "Refresh" meta header, the page considers it only if the sleep time in lesser than this value. Default value is None, means refreshes aren't handled. """ def __init__(self, *args, **kwargs): import lxml.html as html ns = html.etree.FunctionNamespace(None) self.define_xpath_functions(ns) super(HTMLPage, self).__init__(*args, **kwargs) def on_load(self): # Default on_load handle "Refresh" meta tag. self.handle_refresh() def handle_refresh(self): if self.REFRESH_MAX is None: return for refresh in self.doc.xpath('//head/meta[@http-equiv="Refresh"]'): m = self.browser.REFRESH_RE.match(refresh.get('content', '')) if not m: continue url = urlparse.urljoin(self.url, m.groupdict().get('url', None)) sleep = float(m.groupdict()['sleep']) if sleep <= self.REFRESH_MAX: self.logger.info('Redirecting to %s', url) self.browser.location(url) break else: self.logger.debug('Do not refresh to %s because %s > REFRESH_MAX(%s)' % (url, sleep, self.REFRESH_MAX)) def define_xpath_functions(self, ns): """ Define XPath functions on the given lxml function namespace. This method is called in constructor of :class:`HTMLPage` and can be overloaded by children classes to add extra functions. """ ns['lower-case'] = lambda context, args: ' '.join([s.lower() for s in args]) ns['replace'] = lambda context, args, old, new: ' '.join([s.replace(old, new) for s in args]) def has_class(context, *classes): """ This lxml extension allows to select by CSS class more easily >>> ns = html.etree.FunctionNamespace(None) >>> ns['has-class'] = has_class >>> root = html.etree.fromstring(''' ...
... I ... LOVE ... CSS ... ... ''') >>> len(root.xpath('//b[has-class("text")]')) 3 >>> len(root.xpath('//b[has-class("one")]')) 1 >>> len(root.xpath('//b[has-class("text", "first")]')) 1 >>> len(root.xpath('//b[not(has-class("first"))]')) 2 >>> len(root.xpath('//b[has-class("not-exists")]')) 0 """ expressions = ' and '.join(["contains(concat(' ', normalize-space(@class), ' '), ' {0} ')".format(c) for c in classes]) xpath = 'self::*[@class and {0}]'.format(expressions) return bool(context.context_node.xpath(xpath)) ns['has-class'] = has_class def build_doc(self, content): """ Method to build the lxml document from response and given encoding. """ import lxml.html as html parser = html.HTMLParser(encoding=self.encoding) return html.parse(BytesIO(content), parser) def detect_encoding(self): """ Look for encoding in the document "http-equiv" and "charset" meta nodes. """ encoding = self.encoding for content in self.doc.xpath('//head/meta[lower-case(@http-equiv)="content-type"]/@content'): # meta http-equiv=content-type content=... _, params = parse_header(content) if 'charset' in params: encoding = params['charset'].strip("'\"") for charset in self.doc.xpath('//head/meta[@charset]/@charset'): # meta charset=... encoding = charset.lower() if encoding == 'iso-8859-1' or not encoding: encoding = 'windows-1252' try: codecs.lookup(encoding) except LookupError: encoding = 'windows-1252' return encoding def get_form(self, xpath='//form', name=None, id=None, nr=None, submit=None): """ Get a :class:`Form` object from a selector. The form will be analyzed and its parameters extracted. In the case there is more than one "submit" input, only one of them should be chosen to generate the request. :param xpath: xpath string to select forms :type xpath: :class:`str` :param name: if supplied, select a form with the given name :type name: :class:`str` :param nr: if supplied, take the n+1 th selected form :type nr: :class:`int` :param submit: if supplied, xpath string to select the submit \ element from the form :type submit: :class:`str` :rtype: :class:`Form` :raises: :class:`FormNotFound` if no form is found """ i = 0 for el in self.doc.xpath(xpath): if name is not None and el.attrib.get('name', '') != name: continue if id is not None and el.attrib.get('id', '') != id: continue if nr is not None and i != nr: i += 1 continue if isinstance(submit, basestring): submit_el = el.xpath(submit)[0] else: submit_el = submit return self.FORM_CLASS(self, el, submit_el) raise FormNotFound() class LoggedPage(object): """ A page that only logged users can reach. If we did not get a redirection for this page, we are sure that the login is still active. Do not use this class for page we mixed content (logged/anonymous) or for pages with a login form. """ logged = True class ChecksumPage(object): """ Compute a checksum of raw content before parsing it. """ import hashlib hashfunc = hashlib.md5 checksum = None def build_doc(self, content): self.checksum = self.hashfunc(content).hexdigest() return super(ChecksumPage, self).build_doc(content) weboob-1.1/weboob/browser/profiles.py000066400000000000000000000117261265717027300200060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012-2014 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . class Profile(object): """ A profile represents the way Browser should act. Usually it is to mimic a real browser. """ def setup_session(self, session): """ Change default headers, set up hooks, etc. Warning: Do not enable lzma, bzip or bzip2, sdch encodings as python-requests does not support it yet. Supported as of 2.2: gzip, deflate, compress. In doubt, do not change the default Accept-Encoding header of python-requests. """ raise NotImplementedError() class Weboob(Profile): """ It's us! Recommended for Weboob-friendly websites only. """ def __init__(self, version): self.version = version def setup_session(self, session): session.headers['User-Agent'] = 'weboob/%s' % self.version class Firefox(Profile): """ Try to mimic a specific version of Firefox. Ideally, it should follow the current ESR Firefox: https://www.mozilla.org/en-US/firefox/organizations/all.html Do not change the Firefox version without checking the Gecko one! """ def setup_session(self, session): """ Set up headers for a standard Firefox request (except for DNT which isn't on by default but is a good idea). The goal is to be unidentifiable. """ # Replace all base requests headers # https://developer.mozilla.org/en/Gecko_user_agent_string_reference # https://bugzilla.mozilla.org/show_bug.cgi?id=572650 session.headers = { 'Accept-Language': 'en-us,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0', 'DNT': '1'} class GoogleBot(Profile): """ Try to mimic Googlebot. Keep in mind there are ways to authenticate real Googlebot IPs. You will most likely want to set ALLOW_REFERRER to False. """ def setup_session(self, session): """ Set up headers for a standard Firefox request (except for DNT which isn't on by default but is a good idea). The goal is to be unidentifiable. """ # Replace all base requests headers # http://googlewebmastercentral.blogspot.com/2008/03/first-date-with-googlebot-headers-and.html # Cached versions of: # http://request.urih.com/ # http://xhaus.com/headers session.headers = { 'Accept-Encoding': 'gzip,deflate', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'From': 'googlebot(at)googlebot.com', 'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'} class Wget(Profile): """ Common alternative user agent. Some websites will give you a version with less JavaScript. Some others could ban you (after all, wget is not a real browser). """ def __init__(self, version='1.11.4'): self.version = version def setup_session(self, session): # Don't remove base headers, if websites want to block fake browsers, # they will probably block any wget user agent anyway. session.headers.update({ 'Accept': '*/*', 'User-Agent': 'Wget/%s' % self.version}) class Android(Profile): """ An android profile for mobile websites """ def setup_session(self, session): """ Set up user agent. """ session.headers.update({ 'User-Agent': 'Mozilla/5.0 (Linux; U; Android 4.0.3; fr-fr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'}) class IPhone(Profile): """ An iphone profile for mobile websites and some API websites """ def __init__(self, application): self.application = application def setup_session(self, session): session.headers["Accept-Language"] = "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5" session.headers["Accept"] = "*/*" session.headers["User-Agent"] = "%s (iPhone; iOS 7.1; Scale/2.00)" % self.application session.headers["Accept-Encoding"] = "gzip, deflate" weboob-1.1/weboob/browser/sessions.py000066400000000000000000000135531265717027300200310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Copyright(C) 2014 Simon Murail # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . # Inspired by: https://github.com/ross/requests-futures/blob/master/requests_futures/sessions.py # XXX Licence issues? try: from concurrent.futures import ThreadPoolExecutor except ImportError: ThreadPoolExecutor = None from requests import Session from requests.adapters import DEFAULT_POOLSIZE, HTTPAdapter from requests.compat import cookielib, OrderedDict from requests.cookies import cookiejar_from_dict, RequestsCookieJar from requests.models import PreparedRequest from requests.sessions import merge_setting from requests.structures import CaseInsensitiveDict from requests.utils import get_netrc_auth def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict): """ Properly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely. Backport from request so we can use it in wheezy """ if session_hooks is None or session_hooks.get('response') == []: return request_hooks if request_hooks is None or request_hooks.get('response') == []: return session_hooks ret = {} for (k, v) in request_hooks.items(): if v is not None: ret[k] = set(v).union(session_hooks.get(k, [])) return ret class WeboobSession(Session): def prepare_request(self, request): """Constructs a :class:`PreparedRequest ` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request ` instance and those of the :class:`Session`. :param request: :class:`Request` instance to prepare with this session's settings. """ cookies = request.cookies or {} # Bootstrap CookieJar. if not isinstance(cookies, cookielib.CookieJar): cookies = cookiejar_from_dict(cookies) # Merge with session cookies merged_cookies = RequestsCookieJar() merged_cookies.update(self.cookies) merged_cookies.update(cookies) # Set environment's basic authentication if not explicitly set. auth = request.auth if self.trust_env and not auth and not self.auth: auth = get_netrc_auth(request.url) p = PreparedRequest() p.prepare( method=request.method.upper(), url=request.url, files=request.files, data=request.data, headers=merge_setting(request.headers, self.headers, dict_class=CaseInsensitiveDict), params=merge_setting(request.params, self.params), auth=merge_setting(auth, self.auth), cookies=merged_cookies, hooks=merge_hooks(request.hooks, self.hooks), ) return p class FuturesSession(WeboobSession): def __init__(self, executor=None, max_workers=2, max_retries=2, *args, **kwargs): """Creates a FuturesSession Notes ~~~~~ * ProcessPoolExecutor is not supported b/c Response objects are not picklable. * If you provide both `executor` and `max_workers`, the latter is ignored and provided executor is used as is. """ super(FuturesSession, self).__init__(*args, **kwargs) if executor is None and ThreadPoolExecutor is not None: executor = ThreadPoolExecutor(max_workers=max_workers) # set connection pool size equal to max_workers if needed if max_workers > DEFAULT_POOLSIZE: adapter_kwargs = dict(pool_connections=max_workers, pool_maxsize=max_workers, max_retries=max_retries) self.mount('https://', HTTPAdapter(**adapter_kwargs)) self.mount('http://', HTTPAdapter(**adapter_kwargs)) self.executor = executor def send(self, *args, **kwargs): """Maintains the existing api for :meth:`Session.send` Used by :meth:`request` and thus all of the higher level methods If the `is_async` param is True, the request is processed in a thread. Otherwise, the request is processed as usual, in a blocking way. In all cases, it will call the `callback` parameter and return its result when the request has been processed. """ if 'async' in kwargs: import warnings warnings.warn('Please use is_async instead of async.', DeprecationWarning) kwargs['is_async'] = kwargs['async'] del kwargs['async'] sup = super(FuturesSession, self).send callback = kwargs.pop('callback', lambda future, response: response) is_async = kwargs.pop('is_async', False) def func(*args, **kwargs): resp = sup(*args, **kwargs) return callback(self, resp) if is_async: if not self.executor: raise ImportError('Please install python-concurrent.futures') return self.executor.submit(func, *args, **kwargs) return func(*args, **kwargs) def close(self): super(FuturesSession, self).close() if self.executor: self.executor.shutdown() weboob-1.1/weboob/browser/tests/000077500000000000000000000000001265717027300167445ustar00rootroot00000000000000weboob-1.1/weboob/browser/tests/__init__.py000066400000000000000000000000001265717027300210430ustar00rootroot00000000000000weboob-1.1/weboob/browser/tests/form.py000066400000000000000000000107661265717027300202730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Julia Leven # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import collections import warnings from unittest import TestCase import lxml.html from weboob.browser import URL from weboob.browser.pages import Form, FormSubmitWarning # Mock that allows to represent a Page class MyMockPage(): url = URL("http://httpbin.org") # Class that tests different methods from the class URL class FormTest(TestCase): # Initialization of the objects needed by the tests def setUp(self): self.page = MyMockPage() self.el = lxml.html.fromstring( """
""") self.elMoreSubmit = lxml.html.fromstring( """
""") # Checks that the dictionary is correctly initialised def test_init_nominal_case(self): form = Form(self.page, self.el, None) self.assertDictEqual(form, collections.OrderedDict([ ('nom', 'Dupont'), ('prenom', ''), ('mySelect', 'item2'), ('mySelectNotSelected', 'item1'), ('submitForm', u'')])) # Checks that submit fields are not added to the dictionary when the # attribute submit_el is set to False def test_no_submit(self): formNoSubmit = Form(self.page, self.el, False) self.assertDictEqual(formNoSubmit, collections.OrderedDict([ ('nom', 'Dupont'), ('prenom', ''), ('mySelect', 'item2'), ('mySelectNotSelected', 'item1')])) # Checks that the right warning is issued when there are several submit # fields def test_warning_more_submit(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') Form(self.page, self.elMoreSubmit) warningMsg = "Form has more than one submit input, you" + \ " should chose the correct one" assert len(w) == 1 assert issubclass(w[-1].category, FormSubmitWarning) assert warningMsg in str(w[-1].message) # Checks that a warning is raised when the submit passed as a parameter # does not exist in the form def test_warning_submit_not_find(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') Form(self.page, self.el, lxml.html.fromstring( "")) warningMsg = "Form had a submit element provided, but" + \ " it was not found" assert len(w) == 1 assert issubclass(w[-1].category, FormSubmitWarning) assert warningMsg in str(w[-1].message) weboob-1.1/weboob/browser/tests/url.py000066400000000000000000000117741265717027300201320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Julia Leven # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from unittest import TestCase from weboob.browser import PagesBrowser, URL from weboob.browser.pages import Page from weboob.browser.url import UrlNotResolvable class MyMockBrowserWithoutBrowser(): BASEURL = "http://weboob.org" url = URL("http://test.org") # Mock that allows to represent a Page class MyMockPage(Page): pass # Mock that allows to represent a Browser class MyMockBrowser(PagesBrowser): BASEURL = "http://weboob.org" # URL used by method match urlNotRegex = URL("http://test.org", "http://test2.org") urlRegex = URL("http://test.org", "http://weboob2.org") urlRegWithoutHttp = URL("news") urlNotRegWithoutHttp = URL("youtube") # URL used by method build urlValue = URL("http://test.com/(?P\d+)") urlParams = URL("http://test.com\?id=(?P\d+)&name=(?P.+)") # URL used by method is_here urlIsHere = URL('http://weboob.org/(?P)', MyMockPage) urlIsHereDifKlass = URL('http://free.fr', MyMockPage) # Class that tests different methods from the class URL class URLTest(TestCase): # Initialization of the objects needed by the tests def setUp(self): self.myBrowser = MyMockBrowser() self.myBrowserWithoutBrowser = MyMockBrowserWithoutBrowser() # Check that an assert is sent if both base and browser are none def test_match_base_none_browser_none(self): self.assertRaises(AssertionError, self.myBrowserWithoutBrowser.url.match, "http://weboob.org") # Check that no assert is raised when browser is none and a base is indeed # instanciated when given as a parameter def test_match_base_not_none_browser_none(self): try: self.myBrowserWithoutBrowser.url.match("http://weboob.org/news", "http://weboob.org") except AssertionError: self.fail("Method match returns an AssertionError while" + " base parameter is not none!") # Check that none is returned when none of the defined urls is a regex for # the given url def test_match_url_pasregex_baseurl(self): res = self.myBrowser.urlNotRegex.match("http://weboob.org/news") self.assertIsNone(res) # Check that true is returned when one of the defined urls is a regex # for the given url def test_match_url_regex_baseurl(self): res = self.myBrowser.urlRegex.match("http://weboob2.org/news") self.assertTrue(res) # Successful test with relatives url def test_match_url_without_http(self): res = self.myBrowser.urlRegWithoutHttp.match("http://weboob.org/news") self.assertTrue(res) # Unsuccessful test with relatives url def test_match_url_without_http_fail(self): browser = self.myBrowser res = browser.urlNotRegWithoutHttp.match("http://weboob.org/news") self.assertIsNone(res) # Checks that build returns the right url when it needs to add # the value of a parameter def test_build_nominal_case(self): res = self.myBrowser.urlValue.build(id=2) self.assertEquals(res, "http://test.com/2") # Checks that build returns the right url when it needs to add # identifiers and values of some parameters def test_build_urlParams_OK(self): res = self.myBrowser.urlParams.build(id=2, name="weboob") self.assertEquals(res, "http://test.com?id=2&name=weboob") # Checks that an exception is raised when a parameter is missing # (here, the parameter name) def test_build_urlParams_KO_missedparams(self): self.assertRaises(UrlNotResolvable, self.myBrowser.urlParams.build, id=2) # Checks that an exception is raised when there is an extra parameter # added to the build function (here, the parameter title) def test_build_urlParams_KO_moreparams(self): self.assertRaises(UrlNotResolvable, self.myBrowser.urlParams.build, id=2, name="weboob", title="test") # Check that an assert is sent if both klass is none def test_ishere_klass_none(self): self.assertRaisesRegexp(AssertionError, "You can use this method" + " only if there is a Page class handler.", self.myBrowser.urlRegex.is_here, id=2) weboob-1.1/weboob/browser/url.py000066400000000000000000000155231265717027300167640ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . try: from urllib.parse import unquote except ImportError: from urllib import unquote import re import requests from weboob.tools.regex_helper import normalize class UrlNotResolvable(Exception): """ Raised when trying to locate on an URL instance which url pattern is not resolvable as a real url. """ class URL(object): """ A description of an URL on the PagesBrowser website. It takes one or several regexps to match urls, and an optional Page class which is instancied by PagesBrowser.open if the page matches a regex. """ _creation_counter = 0 def __init__(self, *args): self.urls = [] self.klass = None self.browser = None for arg in args: if isinstance(arg, basestring): self.urls.append(arg) if isinstance(arg, type): self.klass = arg self._creation_counter = URL._creation_counter URL._creation_counter += 1 def is_here(self, **kwargs): """ Returns True if the current page of browser matches this URL. If arguments are provided, and only then, they are checked against the arguments that were used to build the current page URL. """ assert self.klass is not None, "You can use this method only if there is a Page class handler." if len(kwargs): params = self.match(self.build(**kwargs)).groupdict() else: params = None # XXX use unquote on current params values because if there are spaces # or special characters in them, it is encoded only in but not in kwargs. return self.browser.page and isinstance(self.browser.page, self.klass) \ and (params is None or params == dict([(k,unquote(v)) for k,v in self.browser.page.params.iteritems()])) def stay_or_go(self, **kwargs): """ Request to go on this url only if we aren't already here. Arguments are optional parameters for url. >>> url = URL('http://exawple.org/(?P).html') >>> url.stay_or_go(pagename='index') """ if self.is_here(**kwargs): return self.browser.page return self.go(**kwargs) def go(self, params=None, data=None, method=None, **kwargs): """ Request to go on this url. Arguments are optional parameters for url. >>> url = URL('http://exawple.org/(?P).html') >>> url.stay_or_go(pagename='index') """ r = self.browser.location(self.build(**kwargs), params=params, data=data, method=method) return r.page or r def open(self, params=None, data=None, **kwargs): """ Request to open on this url. Arguments are optional parameters for url. :param data: POST data :type url: str or dict or None >>> url = URL('http://exawple.org/(?P).html') >>> url.open(pagename='index') """ r = self.browser.open(self.build(**kwargs), params=params, data=data) return r.page or r def build(self, **kwargs): """ Build an url with the given arguments from URL's regexps. :param param: Query string parameters :rtype: :class:`str` :raises: :class:`UrlNotResolvable` if unable to resolve a correct url with the given arguments. """ browser = kwargs.pop('browser', self.browser) params = kwargs.pop('params', None) patterns = [] for url in self.urls: patterns += normalize(url) for pattern, _ in patterns: url = pattern # only use full-name substitutions, to allow % in URLs for kwkey in kwargs.keys(): # need to use keys() because of pop() search = '%%(%s)s' % kwkey if search in pattern: url = url.replace(search, unicode(kwargs.pop(kwkey))) # if there are named substitutions left, ignore pattern if re.search('%\([A-z_]+\)s', url): continue # if not all kwargs were used if len(kwargs): continue url = browser.absurl(url, base=True) if params: p = requests.models.PreparedRequest() p.prepare_url(url, params) url = p.url return url raise UrlNotResolvable('Unable to resolve URL with %r. Available are %s' % (kwargs, ', '.join([pattern for pattern, _ in patterns]))) def match(self, url, base=None): """ Check if the given url match this object. """ if base is None: assert self.browser is not None base = self.browser.BASEURL for regex in self.urls: if not re.match(r'^\w+://.*', regex): regex = re.escape(base).rstrip('/') + '/' + regex.lstrip('/') m = re.match(regex, url) if m: return m def handle(self, response): """ Handle a HTTP response to get an instance of the klass if it matches. """ if self.klass is None: return if response.request.method == 'HEAD': return m = self.match(response.url) if m: page = self.klass(self.browser, response, m.groupdict()) if hasattr(page, 'is_here'): if callable(page.is_here): if page.is_here(): return page else: assert isinstance(page.is_here, basestring) if page.doc.xpath(page.is_here): return page else: return page def id2url(self, func): r""" Helper decorator to get an URL if the given first parameter is an ID. """ def inner(browser, id_or_url, *args, **kwargs): if re.match('^https?://.*', id_or_url): if not self.match(id_or_url, browser.BASEURL): return else: id_or_url = self.build(id=id_or_url, browser=browser) return func(browser, id_or_url, *args, **kwargs) return inner weboob-1.1/weboob/capabilities/000077500000000000000000000000001265717027300165505ustar00rootroot00000000000000weboob-1.1/weboob/capabilities/__init__.py000066400000000000000000000002701265717027300206600ustar00rootroot00000000000000# -*- coding: utf-8 -*- from .base import UserError, NotLoaded, NotAvailable, BaseObject, Capability __all__ = ['UserError', 'NotLoaded', 'NotAvailable', 'BaseObject', 'Capability'] weboob-1.1/weboob/capabilities/account.py000066400000000000000000000064031265717027300205610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField, IntField, Field, UserError __all__ = ['AccountRegisterError', 'Account', 'StatusField', 'CapAccount'] class AccountRegisterError(UserError): """ Raised when there is an error during registration. """ class Account(BaseObject): """ Describe an account and its properties. """ login = StringField('Login') password = StringField('Password') properties = Field('List of key/value properties', dict) def __init__(self, id=None): BaseObject.__init__(self, id) class StatusField(BaseObject): """ Field of an account staeobjectus. """ FIELD_TEXT = 0x001 # the value is a long text FIELD_HTML = 0x002 # the value is HTML formated key = StringField('Key') label = StringField('Label') value = StringField('Value') flags = IntField('Flags') def __init__(self, key, label, value, flags=0): super(StatusField, self).__init__(key) self.key = key self.label = label self.value = value self.flags = flags class CapAccount(Capability): """ Capability for websites when you can create and manage accounts. :var ACCOUNT_REGISTER_PROPERTIES: This class constant may be a list of :class:`weboob.tools.value.Value` objects. If the value remains None, weboob considers that :func:`register_account` isn't supported. """ ACCOUNT_REGISTER_PROPERTIES = None @staticmethod def register_account(account): """ Register an account on website This is a static method, it would be called even if the backend is instancied. :param account: describe the account to create :type account: :class:`Account` :raises: :class:`AccountRegisterError` """ raise NotImplementedError() def confirm_account(self, mail): """ From an email go to the confirm link. """ raise NotImplementedError() def get_account(self): """ Get the current account. """ raise NotImplementedError() def update_account(self, account): """ Update the current account. """ raise NotImplementedError() def get_account_status(self): """ Get status of the current account. :returns: a list of fields """ raise NotImplementedError() weboob-1.1/weboob/capabilities/audio.py000066400000000000000000000110471265717027300202260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from datetime import timedelta from .image import BaseImage from .base import Field, StringField, IntField, BaseObject from .file import CapFile, BaseFile __all__ = ['BaseAudio', 'CapAudio'] def decode_id(decode_id): def wrapper(func): def inner(self, *args, **kwargs): arg = unicode(args[0]) _id = decode_id(arg) if _id is None: return None new_args = [_id] new_args.extend(args[1:]) return func(self, *new_args, **kwargs) return inner return wrapper class Album(BaseObject): """ Represent an album """ title = StringField('album name') author = StringField('artist name') year = IntField('release year') thumbnail = Field('Image associated to the album', BaseImage) tracks_list = Field('list of tracks', list) @classmethod def decode_id(cls, _id): if _id: m = re.match('^(album)\.(.*)', _id) if m: return m.group(2) return _id class Playlist(BaseObject): """ Represent a playlist """ title = StringField('playlist name') tracks_list = Field('list of tracks', list) @classmethod def decode_id(cls, _id): if _id: m = re.match('^(playlist)\.(.*)', _id) if m: return m.group(2) return _id class BaseAudio(BaseFile): """ Represent an audio file """ duration = Field('file duration', int, long, timedelta) bitrate = Field('file bit rate in Kbps', int) format = StringField('file format') thumbnail = Field('Image associated to the file', BaseImage) @classmethod def decode_id(cls, _id): if _id: m = re.match('^(audio)\.(.*)', _id) if m: return m.group(2) return _id class CapAudio(CapFile): """ Audio file provider """ @classmethod def get_object_method(cls, _id): m = re.match('^(\w+)\.(.*)', _id) if m: if m.group(1) == 'album': return 'get_album' elif m.group(1) == 'playlist': return 'get_playlist' else: return 'get_audio' def search_audio(self, pattern, sortby=CapFile.SEARCH_RELEVANCE): """ search for a audio file :param pattern: pattern to search on :type pattern: str :param sortby: sort by ...(use SEARCH_* constants) :rtype: iter[:class:`BaseAudio`] """ return self.search_file(pattern, sortby) def search_album(self, pattern, sortby=CapFile.SEARCH_RELEVANCE): """ search for an album :param pattern: pattern to search on :type pattern: str :rtype: iter[:class:`Album`] """ raise NotImplementedError() def search_playlist(self, pattern, sortby=CapFile.SEARCH_RELEVANCE): """ search for an album :param pattern: pattern to search on :type pattern: str :rtype: iter[:class:`Playlist`] """ raise NotImplementedError() @decode_id(BaseAudio.decode_id) def get_audio(self, _id): """ Get an audio file from an ID. :param id: audio file ID :type id: str :rtype: :class:`BaseAudio`] """ return self.get_file(_id) @decode_id(Playlist.decode_id) def get_playlist(self, _id): """ Get a playlist from an ID. :param id: playlist ID :type id: str :rtype: :class:`Playlist`] """ raise NotImplementedError() @decode_id(Album.decode_id) def get_album(self, _id): """ Get an album from an ID. :param id: album ID :type id: str :rtype: :class:`Album`] """ raise NotImplementedError() weboob-1.1/weboob/capabilities/audiostream.py000066400000000000000000000035321265717027300214420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.capabilities.streaminfo import StreamInfo from .base import Field from .file import CapFile from .audio import CapAudio, BaseAudio __all__ = ['BaseAudioStream', 'CapAudioStream'] class BaseAudioStream(BaseAudio): """ Audio stream object """ current = Field('Information related to current broadcast', StreamInfo) def __unicode__(self): return u'%s (%s)' % (self.title, self.url) def __repr__(self): return self.__unicode__() class CapAudioStream(CapAudio): """ Audio streams provider """ def search_audiostreams(self, pattern, sortby=CapFile.SEARCH_RELEVANCE): """ Search an audio stream :param pattern: pattern to search :type pattern: str :param sortby: sort by ... (use SEARCH_* constants) :rtype: iter[:class:`BaseAudioStream`] """ return self.search_audio(pattern, sortby) def get_audiostream(self, _id): """ Get an audio stream :param _id: Audiostream ID :type id: str :rtype: :class:`BaseAudioStream` """ return self.get_audio(_id) weboob-1.1/weboob/capabilities/bank.py000066400000000000000000000240551265717027300200430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2015 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import date, datetime from binascii import crc32 import re from weboob.tools.compat import basestring, long from .base import BaseObject, Field, StringField, DecimalField, IntField, UserError, Currency, NotAvailable from .date import DateField from .collection import CapCollection __all__ = ['AccountNotFound', 'TransferError', 'Recipient', 'Account', 'Transaction', 'Investment', 'Transfer', 'CapBank'] class AccountNotFound(UserError): """ Raised when an account is not found. """ def __init__(self, msg='Account not found'): UserError.__init__(self, msg) class TransferError(UserError): """ A transfer has failed. """ class Recipient(BaseObject, Currency): """ Recipient of a transfer. """ label = StringField('Name') currency = StringField('Currency', default=None) def __init__(self): BaseObject.__init__(self, 0) @property def currency_text(self): return Currency.currency2txt(self.currency) class Account(Recipient): """ Bank account. It is a child class of :class:`Recipient`, because an account can be a recipient of a transfer. """ TYPE_UNKNOWN = 0 TYPE_CHECKING = 1 "Transaction, everyday transactions" TYPE_SAVINGS = 2 "Savings/Deposit, can be used for every banking" TYPE_DEPOSIT = 3 "Term of Fixed Deposit, has time/amount constraints" TYPE_LOAN = 4 "Loan account" TYPE_MARKET = 5 "Stock market or other variable investments" TYPE_JOINT = 6 "Joint account" TYPE_CARD = 7 "Card account" TYPE_LIFE_INSURANCE = 8 "Life insurances" type = IntField('Type of account', default=TYPE_UNKNOWN) balance = DecimalField('Balance on this bank account') coming = DecimalField('Coming balance') # card attributes paydate = DateField('For credit cards. When next payment is due.') paymin = DecimalField('For credit cards. Minimal payment due.') cardlimit = DecimalField('For credit cards. Credit limit.') iban = StringField('International Bank Account Number') number = StringField('Shown by the bank to identify your account ie ****7489') # market and lifeinssurance accounts valuation_diff = DecimalField('+/- values total') @property def ban(self): """ Bank Account Number part of IBAN""" if not self.iban: return NotAvailable return self.iban[4:] def __repr__(self): return u"" % (self.id, self.label) class Transaction(BaseObject): """ Bank transaction. """ TYPE_UNKNOWN = 0 TYPE_TRANSFER = 1 TYPE_ORDER = 2 TYPE_CHECK = 3 TYPE_DEPOSIT = 4 TYPE_PAYBACK = 5 TYPE_WITHDRAWAL = 6 TYPE_CARD = 7 TYPE_LOAN_PAYMENT = 8 TYPE_BANK = 9 TYPE_CASH_DEPOSIT = 10 date = DateField('Debit date on the bank statement') rdate = DateField('Real date, when the payment has been made; usually extracted from the label or from credit card info') vdate = DateField('Value date, or accounting date; usually for professional accounts') type = IntField('Type of transaction, use TYPE_* constants', default=TYPE_UNKNOWN) raw = StringField('Raw label of the transaction') category = StringField('Category of the transaction') label = StringField('Pretty label') amount = DecimalField('Amount of the transaction') card = StringField('Card number (if any)') commission = DecimalField('Commission part on the transaction (in account currency)') # International original_amount = DecimalField('Original amount (in another currency)') original_currency = StringField('Currency of the original amount') country = StringField('Country of transaction') # Financial arbitrations investments = Field('List of investments related to the transaction', list, default=[]) def __repr__(self): return "" % (self.date, self.label, self.amount) def unique_id(self, seen=None, account_id=None): """ Get an unique ID for the transaction based on date, amount and raw. :param seen: if given, the method uses this dictionary as a cache to prevent several transactions with the same values to have the same unique ID. :type seen: :class:`dict` :param account_id: if given, add the account ID in data used to create the unique ID. Can be useful if you want your ID to be unique across several accounts. :type account_id: :class:`str` :returns: an unique ID encoded in 8 length hexadecimal string (for example ``'a64e1bc9'``) :rtype: :class:`str` """ crc = crc32(str(self.date)) crc = crc32(str(self.amount), crc) crc = crc32(re.sub('[ ]+', ' ', self.raw.encode("utf-8")), crc) if account_id is not None: crc = crc32(str(account_id), crc) if seen is not None: while crc in seen: crc = crc32("*", crc) seen.add(crc) return "%08x" % (crc & 0xffffffff) class Investment(BaseObject): """ Investment in a financial market. """ label = StringField('Label of stocks') code = StringField('Identifier of the stock (ISIN code)') description = StringField('Short description of the stock') quantity = DecimalField('Quantity of stocks') unitprice = DecimalField('Buy price of one stock') unitvalue = DecimalField('Current value of one stock') valuation = DecimalField('Total current valuation of the Investment') vdate = DateField('Value date of the valuation amount') diff = DecimalField('Difference between the buy cost and the current valuation') class Transfer(BaseObject): """ Transfer from an account to a recipient. """ amount = DecimalField('Amount to transfer') date = Field('Date of transfer', basestring, date, datetime) origin = Field('Origin of transfer', int, long, basestring) recipient = Field('Recipient', int, long, basestring) reason = StringField('Reason') class CapBank(CapCollection): """ Capability of bank websites to see accounts and transactions. """ def iter_resources(self, objs, split_path): """ Iter resources. Default implementation of this method is to return on top-level all accounts (by calling :func:`iter_accounts`). :param objs: type of objects to get :type objs: tuple[:class:`BaseObject`] :param split_path: path to discover :type split_path: :class:`list` :rtype: iter[:class:`BaseObject`] """ if Account in objs: self._restrict_level(split_path) return self.iter_accounts() def iter_accounts(self): """ Iter accounts. :rtype: iter[:class:`Account`] """ raise NotImplementedError() def get_account(self, id): """ Get an account from its ID. :param id: ID of the account :type id: :class:`str` :rtype: :class:`Account` :raises: :class:`AccountNotFound` """ raise NotImplementedError() def iter_history(self, account): """ Iter history of transactions on a specific account. :param account: account to get history :type account: :class:`Account` :rtype: iter[:class:`Transaction`] :raises: :class:`AccountNotFound` """ raise NotImplementedError() def iter_coming(self, account): """ Iter coming transactions on a specific account. :param account: account to get coming transactions :type account: :class:`Account` :rtype: iter[:class:`Transaction`] :raises: :class:`AccountNotFound` """ raise NotImplementedError() def iter_transfer_recipients(self, account): """ Iter recipients availables for a transfer from a specific account. :param account: account which initiate the transfer :type account: :class:`Account` :rtype: iter[:class:`Recipient`] :raises: :class:`AccountNotFound` """ raise NotImplementedError() def transfer(self, account, recipient, amount, reason=None): """ Make a transfer from an account to a recipient. :param account: account to take money :type account: :class:`Account` :param recipient: account to send money :type recipient: :class:`Recipient` :param amount: amount :type amount: :class:`decimal.Decimal` :param reason: reason of transfer :type reason: :class:`unicode` :rtype: :class:`Transfer` :raises: :class:`AccountNotFound`, :class:`TransferError` """ raise NotImplementedError() def iter_investment(self, account): """ Iter investment of a market account :param account: account to get investments :type account: :class:`Account` :rtype: iter[:class:`Investment`] :raises: :class:`AccountNotFound` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/base.py000066400000000000000000000362311265717027300200410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Christophe Benz, Romain Bignon, Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import warnings import re from decimal import Decimal from copy import deepcopy, copy from weboob.tools.compat import unicode, long from weboob.tools.misc import to_unicode from weboob.tools.ordereddict import OrderedDict __all__ = ['UserError', 'FieldNotFound', 'NotAvailable', 'NotLoaded', 'Capability', 'Field', 'IntField', 'DecimalField', 'FloatField', 'StringField', 'BytesField', 'empty', 'BaseObject'] def enum(**enums): _values = enums.values() _keys = enums.keys() _items = enums.items() _types = list((type(value) for value in enums.values())) _index = dict((value if not isinstance(value, dict) else value.itervalues().next(), i) for i, value in enumerate(enums.values())) enums['keys'] = _keys enums['values'] = _values enums['items'] = _items enums['index'] = _index enums['types'] = _types return type('Enum', (), enums) def empty(value): """ Checks if a value is empty (None, NotLoaded or NotAvailable). :rtype: :class:`bool` """ for cls in (None, NotLoaded, NotAvailable): if value is cls: return True return False def find_object(mylist, error=None, **kwargs): """ Very simple tools to return an object with the matching parameters in kwargs. """ for a in mylist: found = True for key, value in kwargs.iteritems(): if getattr(a, key) != value: found = False break if found: return a if error is not None: raise error() return None class UserError(Exception): """ Exception containing an error message for user. """ class FieldNotFound(Exception): """ A field isn't found. :param obj: object :type obj: :class:`BaseObject` :param field: field not found :type field: :class:`Field` """ def __init__(self, obj, field): Exception.__init__(self, u'Field "%s" not found for object %s' % (field, obj)) class ConversionWarning(UserWarning): """ A field's type was changed when setting it. Ideally, the module should use the right type before setting it. """ pass class AttributeCreationWarning(UserWarning): """ A non-field attribute has been created with a name not prefixed with a _. """ class NotAvailableType(object): """ NotAvailable is a constant to use on non available fields. """ def __str__(self): return unicode(self).decode('utf-8') def __copy__(self): return self def __deepcopy__(self, memo): return self def __repr__(self): return 'NotAvailable' def __unicode__(self): return u'Not available' def __nonzero__(self): return False NotAvailable = NotAvailableType() class NotLoadedType(object): """ NotLoaded is a constant to use on not loaded fields. When you use :func:`weboob.tools.backend.Module.fillobj` on a object based on :class:`BaseObject`, it will request all fields with this value. """ def __str__(self): return unicode(self).decode('utf-8') def __copy__(self): return self def __deepcopy__(self, memo): return self def __repr__(self): return u'NotLoaded' def __unicode__(self): return u'Not loaded' def __nonzero__(self): return False NotLoaded = NotLoadedType() class Capability(object): """ This is the base class for all capabilities. A capability may define abstract methods (which raise :class:`NotImplementedError`) with an explicit docstring to tell backends how to implement them. Also, it may define some *objects*, using :class:`BaseObject`. """ class Field(object): """ Field of a :class:`BaseObject` class. :param doc: docstring of the field :type doc: :class:`str` :param args: list of types accepted :param default: default value of this field. If not specified, :class:`NotLoaded` is used. """ _creation_counter = 0 def __init__(self, doc, *args, **kwargs): self.types = () self.value = kwargs.get('default', NotLoaded) self.doc = doc for arg in args: if isinstance(arg, type) or isinstance(arg,str): self.types += (arg,) else: raise TypeError('Arguments must be types or strings of type name') self._creation_counter = Field._creation_counter Field._creation_counter += 1 def convert(self, value): """ Convert value to the wanted one. """ return value class IntField(Field): """ A field which accepts only :class:`int` and :class:`long` types. """ def __init__(self, doc, **kwargs): Field.__init__(self, doc, int, long, **kwargs) def convert(self, value): return int(value) class DecimalField(Field): """ A field which accepts only :class:`decimal` type. """ def __init__(self, doc, **kwargs): Field.__init__(self, doc, Decimal, **kwargs) def convert(self, value): if isinstance(value, Decimal): return value return Decimal(value) class FloatField(Field): """ A field which accepts only :class:`float` type. """ def __init__(self, doc, **kwargs): Field.__init__(self, doc, float, **kwargs) def convert(self, value): return float(value) class StringField(Field): """ A field which accepts only :class:`unicode` strings. """ def __init__(self, doc, **kwargs): Field.__init__(self, doc, unicode, **kwargs) def convert(self, value): return to_unicode(value) class BytesField(Field): """ A field which accepts only :class:`str` strings. """ def __init__(self, doc, **kwargs): Field.__init__(self, doc, str, **kwargs) def convert(self, value): if isinstance(value, unicode): value = value.encode('utf-8') return str(value) class _BaseObjectMeta(type): def __new__(cls, name, bases, attrs): fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)] fields.sort(key=lambda x: x[1]._creation_counter) new_class = super(_BaseObjectMeta, cls).__new__(cls, name, bases, attrs) if new_class._fields is None: new_class._fields = OrderedDict() else: new_class._fields = deepcopy(new_class._fields) new_class._fields.update(fields) if new_class.__doc__ is None: new_class.__doc__ = '' for name, field in fields: doc = '(%s) %s' % (', '.join([':class:`%s`' % v.__name__ if isinstance(v,type) else v for v in field.types]), field.doc) if field.value is not NotLoaded: doc += ' (default: %s)' % field.value new_class.__doc__ += '\n:var %s: %s' % (name, doc) return new_class class BaseObject(object): """ This is the base class for a capability object. A capability interface may specify to return several kind of objects, to formalise retrieved information from websites. As python is a flexible language where variables are not typed, we use a system to force backends to set wanted values on all fields. To do that, we use the :class:`Field` class and all derived ones. For example:: class Transfer(BaseObject): " Transfer from an account to a recipient. " amount = DecimalField('Amount to transfer') date = Field('Date of transfer', basestring, date, datetime) origin = Field('Origin of transfer', int, long, basestring) recipient = Field('Recipient', int, long, basestring) The docstring is mandatory. """ __metaclass__ = _BaseObjectMeta id = None backend = None _fields = None def __init__(self, id=u'', backend=None): self.id = to_unicode(id) self.backend = backend self._fields = deepcopy(self._fields) @property def fullid(self): """ Full ID of the object, in form '**ID@backend**'. """ return '%s@%s' % (self.id, self.backend) def __iscomplete__(self): """ Return True if the object is completed. It is usefull when the object is a field of an other object which is going to be filled. The default behavior is to iter on fields (with iter_fields) and if a field is NotLoaded, return False. """ for key, value in self.iter_fields(): if value is NotLoaded: return False return True def copy(self): obj = copy(self) obj._fields = copy(self._fields) return obj def __deepcopy__(self, memo): return self.copy() def set_empty_fields(self, value, excepts=()): """ Set the same value on all empty fields. :param value: value to set on all empty fields :param excepts: if specified, do not change fields listed """ for key, old_value in self.iter_fields(): if empty(old_value) and key not in excepts: setattr(self, key, value) def iter_fields(self): """ Iterate on the fields keys and values. Can be overloaded to iterate on other things. :rtype: iter[(key, value)] """ if hasattr(self, 'id') and self.id is not None: yield 'id', self.id for name, field in self._fields.iteritems(): yield name, field.value def __eq__(self, obj): if isinstance(obj, BaseObject): return self.backend == obj.backend and self.id == obj.id else: return False def __getattr__(self, name): if self._fields is not None and name in self._fields: return self._fields[name].value else: raise AttributeError("'%s' object has no attribute '%s'" % ( self.__class__.__name__, name)) def __setattr__(self, name, value): try: attr = (self._fields or {})[name] except KeyError: if name not in dir(self) and not name.startswith('_'): warnings.warn('Creating a non-field attribute %s. Please prefix it with _' % name, AttributeCreationWarning, stacklevel=2) object.__setattr__(self, name, value) else: if not empty(value): try: # Try to convert value to the wanted one. nvalue = attr.convert(value) # If the value was converted if nvalue is not value: warnings.warn('Value %s was converted from %s to %s' % (name, type(value), type(nvalue)), ConversionWarning, stacklevel=2) value = nvalue except Exception: # error during conversion, it will probably not # match the wanted following types, so we'll # raise ValueError. pass from collections import deque actual_types=() for v in attr.types: if isinstance(v,str): # the following is a (almost) copy/paste from # https://stackoverflow.com/questions/11775460/lexical-cast-from-string-to-type q=deque([object]) while q: t=q.popleft() if t.__name__ == v: actual_types+=(t,) else: try: # keep looking! q.extend(t.__subclasses__()) except TypeError: # type.__subclasses__ needs an argument for # whatever reason. if t is type: continue else: raise else: actual_types+=(v,) if not isinstance(value, actual_types) and not empty(value): raise ValueError( 'Value for "%s" needs to be of type %r, not %r' % ( name, actual_types, type(value))) attr.value = value def __delattr__(self, name): try: self._fields.pop(name) except KeyError: object.__delattr__(self, name) def to_dict(self): def iter_decorate(d): for key, value in d: if key == 'id' and self.backend is not None: value = self.fullid yield key, value fields_iterator = self.iter_fields() return OrderedDict(iter_decorate(fields_iterator)) @classmethod def from_dict(cls, values, backend=None): self = cls() for attr in values: setattr(self, attr, values[attr]) return self class Currency(object): CURRENCIES = {u'EUR': u'€', u'CHF': u'CHF', u'USD': u'$', u'GBP': u'£', u'LBP': u'ل.ل', u'AED': u'AED', u'XOF': u'XOF', u'RUB': u'руб', u'SGD': u'SGD', u'BRL': u'R$', u'MXN': u'$', u'JPY': u'¥', } EXTRACTOR = re.compile(r'[\d\s,\.\-]', re.UNICODE) @classmethod def get_currency(klass, text): u""" >>> Currency.get_currency(u'42') None >>> Currency.get_currency(u'42 €') u'EUR' >>> Currency.get_currency(u'$42') u'USD' >>> Currency.get_currency(u'42.000,00€') u'EUR' >>> Currency.get_currency(u'$42 USD') u'USD' >>> Currency.get_currency(u'%42 USD') u'USD' >>> Currency.get_currency(u'US1D') None """ curtexts = klass.EXTRACTOR.sub(' ', text.upper()).split() for curtext in curtexts: for currency, symbol in klass.CURRENCIES.iteritems(): if curtext in (currency, symbol) or symbol in curtext: return currency return None @classmethod def currency2txt(klass, currency): return klass.CURRENCIES.get(currency, u'') weboob-1.1/weboob/capabilities/bill.py000066400000000000000000000116631265717027300200530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import BaseObject, StringField, DecimalField, UserError, Currency from .date import DateField from .collection import CapCollection __all__ = ['SubscriptionNotFound', 'BillNotFound', 'Detail', 'Bill', 'Subscription', 'CapBill'] class SubscriptionNotFound(UserError): """ Raised when a subscription is not found. """ def __init__(self, msg='Subscription not found'): UserError.__init__(self, msg) class BillNotFound(UserError): """ Raised when a bill is not found. """ def __init__(self, msg='Bill not found'): UserError.__init__(self, msg) class Detail(BaseObject, Currency): """ Detail of a subscription """ label = StringField('label of the detail line') infos = StringField('information') datetime = DateField('date information') price = DecimalField('Total price, taxes included') vat = DecimalField('Value added Tax') currency = StringField('Currency', default=None) quantity = DecimalField('Number of units consumed') unit = StringField('Unit of the consumption') class Bill(BaseObject, Currency): """ Bill. """ date = DateField('The day the bill has been sent to the subscriber') format = StringField('file format of the bill') label = StringField('label of bill') price = DecimalField('Price to pay') currency = StringField('Currency', default=None) vat = DecimalField('VAT included in the price') deadline = DateField('The latest day to pay') startdate = DateField('The first day the bill applies to') finishdate = DateField('The last day the bill applies to') class Subscription(BaseObject): """ Subscription to a service. """ label = StringField('label of subscription') subscriber = StringField('whe has subscribed') validity = DateField('End validity date of the subscription') renewdate = DateField('Reset date of consumption') class CapBill(CapCollection): def iter_resources(self, objs, split_path): """ Iter resources. Will return :func:`iter_subscriptions`. """ if Subscription in objs: self._restrict_level(split_path) return self.iter_subscription() def iter_subscription(self): """ Iter subscriptions. :rtype: iter[:class:`Subscription`] """ raise NotImplementedError() def get_subscription(self, _id): """ Get a subscription. :param _id: ID of subscription :rtype: :class:`Subscription` :raises: :class:`SubscriptionNotFound` """ raise NotImplementedError() def iter_bills_history(self, subscription): """ Iter history of a subscription. :param subscription: subscription to get history :type subscription: :class:`Subscription` :rtype: iter[:class:`Detail`] """ raise NotImplementedError() def get_bill(self, id): """ Get a bill. :param id: ID of bill :rtype: :class:`Bill` :raises: :class:`BillNotFound` """ raise NotImplementedError() def download_bill(self, id): """ Download a bill. :param id: ID of bill :rtype: str :raises: :class:`BillNotFound` """ raise NotImplementedError() def iter_bills(self, subscription): """ Iter bills. :param subscription: subscription to get bills :type subscription: :class:`Subscription` :rtype: iter[:class:`Bill`] """ raise NotImplementedError() def get_details(self, subscription): """ Get details of a subscription. :param subscription: subscription to get details :type subscription: :class:`Subscription` :rtype: iter[:class:`Detail`] """ raise NotImplementedError() def get_balance(self, subscription): """ Get the balance of a subscription. :param subscription: subscription to get balance :type subscription: :class:`Subscription` :rtype: class:`Detail` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/bugtracker.py000066400000000000000000000206611265717027300212600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, Field, StringField,\ IntField, UserError from .date import DateField, DeltaField __all__ = ['IssueError', 'Project', 'User', 'Version', 'Status', 'Attachment', 'Change', 'Update', 'Issue', 'Query', 'CapBugTracker'] class IssueError(UserError): """ Raised when there is an error with an issue. """ class Project(BaseObject): """ Represents a project. """ name = StringField('Name of the project') members = Field('Members of projects', list) versions = Field('List of versions available for this project', list) trackers = Field('All trackers', list) categories = Field('All categories', list) statuses = Field('Available statuses for issues', list) priorities = Field('Available priorities for issues', list) def __init__(self, id, name): BaseObject.__init__(self, id) self.name = unicode(name) def __repr__(self): return '' % self.name def find_user(self, id, name): """ Find a user from its ID. If not found, create a :class:`User` with the specified name. :param id: ID of user :type id: str :param name: Name of user :type name: str :rtype: :class:`User` """ for user in self.members: if user.id == id: return user if name is None: return None return User(id, name) def find_version(self, id, name): """ Find a version from an ID. If not found, create a :class:`Version` with the specified name. :param id: ID of version :type id: str :param name: Name of version :type name: str :rtype: :class:`Version` """ for version in self.versions: if version.id == id: return version if name is None: return None return Version(id, name) def find_status(self, name): """ Find a status from a name. :param name: Name of status :type name: str :rtype: :class:`Status` """ for status in self.statuses: if status.name == name: return status if name is None: return None return None class User(BaseObject): """ User. """ name = StringField('Name of user') def __init__(self, id, name): BaseObject.__init__(self, id) self.name = unicode(name) def __repr__(self): return '' % self.name class Version(BaseObject): """ Version of a project. """ name = StringField('Name of version') def __init__(self, id, name): BaseObject.__init__(self, id) self.name = unicode(name) def __repr__(self): return '' % self.name class Status(BaseObject): """ Status of an issue. **VALUE_** constants are the primary status types. """ (VALUE_NEW, VALUE_PROGRESS, VALUE_RESOLVED, VALUE_REJECTED) = range(4) name = StringField('Name of status') value = IntField('Value of status (constants VALUE_*)') def __init__(self, id, name, value): BaseObject.__init__(self, id) self.name = unicode(name) self.value = value def __repr__(self): return '' % self.name class Attachment(BaseObject): """ Attachment of an issue. """ filename = StringField('Filename') url = StringField('Direct URL to attachment') def __repr__(self): return '' % self.filename class Change(BaseObject): """ A change of an update. """ field = StringField('What field has been changed') last = StringField('Last value of field') new = StringField('New value of field') class Update(BaseObject): """ Represents an update of an issue. """ author = Field('Author of update', User) date = DateField('Date of update') hours = DeltaField('Time activity') message = StringField('Log message') attachments = Field('Files attached to update', list, tuple) changes = Field('List of changes', list, tuple) def __repr__(self): return '' % self.id class Issue(BaseObject): """ Represents an issue. """ project = Field('Project of this issue', Project) title = StringField('Title of issue') body = StringField('Text of issue') creation = DateField('Date when this issue has been created') updated = DateField('Date when this issue has been updated for the last time') start = DateField('Date when this issue starts') due = DateField('Date when this issue is due for') attachments = Field('List of attached files', list, tuple) history = Field('History of updates', list, tuple) author = Field('Author of this issue', User) assignee = Field('User assigned to this issue', User) tracker = StringField('Name of the tracker') category = StringField('Name of the category') version = Field('Target version of this issue', Version) status = Field('Status of this issue', Status) fields = Field('Custom fields (key,value)', dict) priority = StringField('Priority of the issue') #XXX class Query(BaseObject): """ Query to find an issue. """ project = StringField('Filter on projects') title = StringField('Filter on titles') author = StringField('Filter on authors') assignee = StringField('Filter on assignees') version = StringField('Filter on versions') category = StringField('Filter on categories') status = StringField('Filter on statuses') def __init__(self): BaseObject.__init__(self, '') class CapBugTracker(Capability): """ Bug trackers websites. """ def iter_issues(self, query): """ Iter issues with optionnal patterns. :param query: query :type query: :class:`Query` :rtype: iter[:class:`Issue`] """ raise NotImplementedError() def get_issue(self, id): """ Get an issue from its ID. :param id: ID of issue :rtype: :class:`Issue` """ raise NotImplementedError() def create_issue(self, project): """ Create an empty issue on the given project. :param project: project :type project: :class:`Project` :returns: the created issue :rtype: :class:`Issue` """ raise NotImplementedError() def post_issue(self, issue): """ Post an issue to create or update it. :param issue: issue to create or update :type issue: :class:`Issue` """ raise NotImplementedError() def update_issue(self, issue, update): """ Add an update to an issue. :param issue: issue or id of issue :type issue: :class:`Issue` :param update: an Update object :type update: :class:`Update` """ raise NotImplementedError() def remove_issue(self, issue): """ Remove an issue. :param issue: issue :type issue: :class:`Issue` """ raise NotImplementedError() def iter_projects(self): """ Iter projects. :rtype: iter[:class:`Project`] """ raise NotImplementedError() def get_project(self, id): """ Get a project from its ID. :rtype: :class:`Project` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/calendar.py000066400000000000000000000143071265717027300207000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import BaseObject, StringField, IntField, FloatField, Field, enum from .collection import CapCollection, CollectionNotFound, Collection from .date import DateField from datetime import time, datetime from weboob.tools.date import parse_date __all__ = ['BaseCalendarEvent', 'CapCalendarEvent'] CATEGORIES = enum(CONCERT=u'Concert', CINE=u'Cinema', THEATRE=u'Theatre', TELE=u'Television', CONF=u'Conference', AUTRE=u'Autre', EXPO=u'Exposition', SPECTACLE=u'Spectacle', FEST=u'Festival', SPORT=u'Sport') #the following elements deal with ICalendar stantdards #see http://fr.wikipedia.org/wiki/ICalendar#Ev.C3.A9nements_.28VEVENT.29 TRANSP = enum(OPAQUE=u'OPAQUE', TRANSPARENT=u'TRANSPARENT') STATUS = enum(TENTATIVE=u'TENTATIVE', CONFIRMED=u'CONFIRMED', CANCELLED=u'CANCELLED') TICKET = enum(AVAILABLE=u'Available', NOTAVAILABLE=u'Not available', CLOSED='Closed') class BaseCalendarEvent(BaseObject): """ Represents a calendar event """ url = StringField('URL of the event') start_date = DateField('Start date of the event') end_date = DateField('End date of the event') timezone = StringField('Timezone of the event in order to convert to utc time', default='Etc/UCT') summary = StringField('Title of the event') city = StringField('Name of the city in witch event will take place') location = StringField('Location of the event') category = Field('Category of the event', *CATEGORIES.types) description = StringField('Description of the event') price = FloatField('Price of the event') booked_entries = IntField('Entry number') max_entries = IntField('Max entry number') event_planner = StringField('Name of the event planner') #the following elements deal with ICalendar stantdards #see http://fr.wikipedia.org/wiki/ICalendar#Ev.C3.A9nements_.28VEVENT.29 sequence = IntField('Number of updates, the first is number 1') # (TENTATIVE, CONFIRMED, CANCELLED) status = Field('Status of theevent', *STATUS.types) # (OPAQUE, TRANSPARENT) transp = Field('Describes if event is available', *TRANSP.types) # (AVAILABLE, NOTAVAILABLE, CLOSED) ticket = Field('Describes if tickets are available', *TICKET.types) @classmethod def id2url(cls, _id): """Overloaded in child classes provided by backends.""" raise NotImplementedError() @property def page_url(self): """ Get page URL of the announce. """ return self.id2url(self.id) class Query(BaseObject): """ Query to find events """ start_date = DateField('Start date of the event') end_date = DateField('End date of the event') city = StringField('Name of the city in witch event will take place') categories = Field('List of categories of the event', list, tuple, default=CATEGORIES.values) ticket = Field('List of status of the tickets sale', list, tuple, default=TICKET.values) summary = StringField('Title of the event') class CapCalendarEvent(CapCollection): """ Capability of calendar event type sites """ ASSOCIATED_CATEGORIES = 'ALL' def has_matching_categories(self, query): if self.ASSOCIATED_CATEGORIES == 'ALL': return True for category in query.categories: if category in self.ASSOCIATED_CATEGORIES: return True return False def search_events(self, query): """ Search event :param query: search query :type query: :class:`Query` :rtype: iter[:class:`BaseCalendarEvent`] """ raise NotImplementedError() def list_events(self, date_from, date_to=None): """ list coming event. :param date_from: date of beguinning of the events list :type date_from: date :param date_to: date of ending of the events list :type date_to: date :rtype: iter[:class:`BaseCalendarEvent`] """ raise NotImplementedError() def get_event(self, _id): """ Get an event from an ID. :param _id: id of the event :type _id: str :rtype: :class:`BaseCalendarEvent` or None is fot found. """ raise NotImplementedError() def attends_event(self, event, is_attending=True): """ Attends or not to an event :param event : the event :type event : BaseCalendarEvent :param is_attending : is attending to the event or not :type is_attending : bool """ raise NotImplementedError() def iter_resources(self, objs, split_path): """ Iter events by category """ if len(split_path) == 0 and self.ASSOCIATED_CATEGORIES != 'ALL': for category in self.ASSOCIATED_CATEGORIES: collection = Collection([category], category) yield collection elif len(split_path) == 1 and split_path[0] in self.ASSOCIATED_CATEGORIES: query = Query() query.categories = split_path query.start_date = datetime.combine(parse_date('today'), time.min) query.end_date = parse_date('') query.city = u'' for event in self.search_events(query): yield event def validate_collection(self, objs, collection): """ Validate Collection """ if collection.path_level == 0: return if collection.path_level == 1 and collection.split_path[0] in CATEGORIES.values: return raise CollectionNotFound(collection.split_path) weboob-1.1/weboob/capabilities/chat.py000066400000000000000000000044141265717027300200440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from .base import Capability, BaseObject, StringField, UserError from .date import DateField __all__ = ['ChatException', 'ChatMessage', 'CapChat'] class ChatException(UserError): """ Exception raised when there is a problem with the chat. """ class ChatMessage(BaseObject): """ Message on the chat. """ id_from = StringField('ID of sender') id_to = StringField('ID of recipient') message = StringField('Content of message') date = DateField('Date when the message has been sent') def __init__(self, id_from, id_to, message, date=None): BaseObject.__init__(self, '%s.%s' % (id_from, id_to)) self.id_from = id_from self.id_to = id_to self.message = message self.date = date if self.date is None: self.date = datetime.datetime.utcnow() class CapChat(Capability): """ Websites with a chat system. """ def iter_chat_messages(self, _id=None): """ Iter messages. :param _id: optional parameter to only get messages from a given contact. :type _id: str :rtype: iter[:class:`ChatMessage`] """ raise NotImplementedError() def send_chat_message(self, _id, message): """ Send a message to a contact. :param _id: ID of recipient :type _id: str :param message: message to send :type message: str :raises: :class:`ChatException` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/cinema.py000066400000000000000000000142021265717027300203550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField, IntField, Field from .date import DateField __all__ = ['Movie', 'Person', 'CapCinema'] class Movie(BaseObject): """ Movie object. """ original_title = StringField('Original title of the movie') other_titles = Field('Titles in other countries', list) release_date = DateField('Release date of the movie') all_release_dates= StringField('Release dates list of the movie') duration = IntField('Duration of the movie in minutes') short_description= StringField('Short description of the movie') genres = Field('Genres of the movie', list) pitch = StringField('Short story description of the movie') country = StringField('Origin country of the movie') note = StringField('Notation of the movie') roles = Field('Lists of Persons related to the movie indexed by roles', dict) thumbnail_url = StringField('Url of movie thumbnail') def __init__(self, id, original_title): BaseObject.__init__(self, id) self.original_title = original_title def get_roles_by_person_name(self,name): for role in self.roles.keys(): if name.lower() in [person[1].lower() for person in self.roles[role]]: return role return None def get_roles_by_person_id(self,id): result = [] for role in self.roles.keys(): if id in [person[0] for person in self.roles[role]]: result.append(role) return result class Person(BaseObject): """ Person object. """ name = StringField('Star name of a person') real_name = StringField('Real name of a person') birth_date = DateField('Birth date of a person') death_date = DateField('Death date of a person') birth_place = StringField('City and country of birth of a person') gender = StringField('Gender of a person') nationality = StringField('Nationality of a person') short_biography = StringField('Short biography of a person') biography = StringField('Full biography of a person') short_description= StringField('Short description of a person') roles = Field('Lists of movies related to the person indexed by roles',dict) thumbnail_url = StringField('Url of person thumbnail') def __init__(self, id, name): BaseObject.__init__(self, id) self.name = name def get_roles_by_movie_title(self,title): for role in self.roles.keys(): for mt in [movie[1] for movie in self.roles[role]]: # title we have is included ? if title.lower() in mt.lower(): return role return None def get_roles_by_movie_id(self,id): result = [] for role in self.roles.keys(): if id in [movie[0] for movie in self.roles[role]]: result.append(role) return result class CapCinema(Capability): """ Cinema databases. """ def iter_movies(self, pattern): """ Search movies and iterate on results. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`Movies`] """ raise NotImplementedError() def get_movie(self, _id): """ Get a movie object from an ID. :param _id: ID of movie :type _id: str :rtype: :class:`Movie` """ raise NotImplementedError() def get_movie_releases(self, _id, country=None): """ Get a list of a movie releases from an ID. :param _id: ID of movie :type _id: str :rtype: :class:`String` """ raise NotImplementedError() def iter_movie_persons(self, _id, role=None): """ Get the list of persons who are related to a movie. :param _id: ID of movie :type _id: str :rtype: iter[:class:`Person`] """ raise NotImplementedError() def iter_persons(self, pattern): """ Search persons and iterate on results. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`persons`] """ raise NotImplementedError() def get_person(self, _id): """ Get a person object from an ID. :param _id: ID of person :type _id: str :rtype: :class:`Person` """ raise NotImplementedError() def iter_person_movies(self, _id, role=None): """ Get the list of movies related to a person. :param _id: ID of person :type _id: str :rtype: iter[:class:`Movie`] """ raise NotImplementedError() def iter_person_movies_ids(self, _id): """ Get the list of movie ids related to a person. :param _id: ID of person :type _id: str :rtype: iter[str] """ raise NotImplementedError() def iter_movie_persons_ids(self, _id): """ Get the list of person ids related to a movie. :param _id: ID of movie :type _id: str :rtype: iter[str] """ raise NotImplementedError() def get_person_biography(self, id): """ Get the person full biography. :param _id: ID of person :type _id: str :rtype: str """ raise NotImplementedError() weboob-1.1/weboob/capabilities/collection.py000066400000000000000000000131211265717027300212530ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Nicolas Duhamel, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.ordereddict import OrderedDict from .base import Capability, BaseObject, UserError, StringField, Field __all__ = ['CapCollection', 'BaseCollection', 'Collection', 'CollectionNotFound'] class CollectionNotFound(UserError): def __init__(self, split_path=None): if split_path is not None: msg = 'Collection not found: %s' % '/'.join(split_path) else: msg = 'Collection not found' UserError.__init__(self, msg) class BaseCollection(BaseObject): """ Inherit from this if you want to create an object that is *also* a Collection. However, this probably will not work properly for now. """ def __init__(self, split_path): BaseObject.__init__(self, None) self.split_path = split_path @property def basename(self): return self.split_path[-1] if self.path_level else None @property def parent_path(self): return self.split_path[0:-1] if self.path_level else None @property def path_level(self): return len(self.split_path) def to_dict(self): def iter_decorate(d): for key, value in d: if key == 'id' and self.backend is not None: value = u'%s@%s' % (self.basename, self.backend) yield key, value if key == 'split_path': yield key, '/'.join(value) fields_iterator = self.iter_fields() return OrderedDict(iter_decorate(fields_iterator)) class Collection(BaseCollection): """ A Collection is a "fake" object returned in results, which shows you can get more results if you go into its path. It is a dumb object, it must not contain callbacks to a backend. Do not inherit from this class if you want to make a regular BaseObject a Collection, use BaseCollection instead. """ title = StringField('Collection title') split_path = Field('Full collection path', list) def __init__(self, split_path=None, title=None): self.title = title BaseCollection.__init__(self, split_path) def __unicode__(self): if self.title and self.basename: return u'%s (%s)' % (self.basename, self.title) elif self.basename: return u'%s' % self.basename else: return u'Unknown collection' class CapCollection(Capability): def iter_resources_flat(self, objs, split_path, clean_only=False): """ Call iter_resources() to fetch all resources in the tree. If clean_only is True, do not explore paths, only remove them. split_path is used to set the starting path. """ for resource in self.iter_resources(objs, split_path): if isinstance(resource, Collection): if not clean_only: for res in self.iter_resources_flat(objs, resource.split_path): yield res else: yield resource def iter_resources(self, objs, split_path): """ split_path is a list, either empty (root path) or with one or many components. """ raise NotImplementedError() def get_collection(self, objs, split_path): """ Get a collection for a given split path. If the path is invalid (i.e. can't be handled by this module), it should return None. """ collection = Collection(split_path, None) return self.validate_collection(objs, collection) or collection def validate_collection(self, objs, collection): """ Tests if a collection is valid. For compatibility reasons, and to provide a default way, it checks if the collection has at least one object in it. However, it is not very efficient or exact, and you are encouraged to override this method. You can replace the collection object entirely by returning a new one. """ # Root if collection.path_level == 0: return try: i = self.iter_resources(objs, collection.split_path) i.next() except StopIteration: raise CollectionNotFound(collection.split_path) def _restrict_level(self, split_path, lmax=0): if len(split_path) > lmax: raise CollectionNotFound(split_path) def test(): c = Collection([]) assert c.basename is None assert c.parent_path is None assert c.path_level == 0 c = Collection([u'lol']) assert c.basename == u'lol' assert c.parent_path == [] assert c.path_level == 1 c = Collection([u'lol', u'cat']) assert c.basename == u'cat' assert c.parent_path == [u'lol'] assert c.path_level == 2 c = Collection([u'w', u'e', u'e', u'b', u'o', u'o', u'b']) assert c.basename == u'b' assert c.parent_path == [u'w', u'e', u'e', u'b', u'o', u'o'] assert c.path_level == 7 weboob-1.1/weboob/capabilities/contact.py000066400000000000000000000156531265717027300205670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, Field, StringField, BytesField, IntField, \ UserError from weboob.tools.ordereddict import OrderedDict __all__ = ['ProfileNode', 'ContactPhoto', 'Contact', 'QueryError', 'Query', 'CapContact'] class ProfileNode(object): """ Node of a :class:`Contact` profile. """ HEAD = 0x01 SECTION = 0x02 def __init__(self, name, label, value, sufix=None, flags=0): self.name = name self.label = label self.value = value self.sufix = sufix self.flags = flags def __getitem__(self, key): return self.value[key] class ContactPhoto(BaseObject): """ Photo of a contact. """ name = StringField('Name of the photo') url = StringField('Direct URL to photo') data = BytesField('Data of photo') thumbnail_url = StringField('Direct URL to thumbnail') thumbnail_data = BytesField('Data of thumbnail') hidden = Field('True if the photo is hidden on website', bool) def __init__(self, name): BaseObject.__init__(self, name) self.name = name def __iscomplete__(self): return (self.data and (not self.thumbnail_url or self.thumbnail_data)) def __str__(self): return self.url def __repr__(self): return u'' % (self.id, len(self.data) if self.data else 0, len(self.thumbnail_data) if self.thumbnail_data else 0) class Contact(BaseObject): """ A contact. """ STATUS_ONLINE = 0x001 STATUS_AWAY = 0x002 STATUS_OFFLINE = 0x004 STATUS_ALL = 0xfff name = StringField('Name of contact') status = IntField('Status of contact (STATUS_* constants)') url = StringField('URL to the profile of contact') status_msg = StringField('Message of status') summary = StringField('Description of contact') photos = Field('List of photos', dict, default=OrderedDict()) profile = Field('Contact profile', dict, default=OrderedDict()) def __init__(self, id, name, status): BaseObject.__init__(self, id) self.name = name self.status = status def set_photo(self, name, **kwargs): """ Set photo of contact. :param name: name of photo :type name: str :param kwargs: See :class:`ContactPhoto` to know what other parameters you can use """ if name not in self.photos: self.photos[name] = ContactPhoto(name) photo = self.photos[name] for key, value in kwargs.iteritems(): setattr(photo, key, value) def get_text(self): def print_node(node, level=1): result = u'' if node.flags & node.SECTION: result += u'\t' * level + node.label + '\n' for sub in node.value.itervalues(): result += print_node(sub, level + 1) else: if isinstance(node.value, (tuple, list)): value = ', '.join(unicode(v) for v in node.value) elif isinstance(node.value, float): value = '%.2f' % node.value else: value = node.value result += u'\t' * level + u'%-20s %s\n' % (node.label + ':', value) return result result = u'Nickname: %s\n' % self.name if self.status & Contact.STATUS_ONLINE: s = 'online' elif self.status & Contact.STATUS_OFFLINE: s = 'offline' elif self.status & Contact.STATUS_AWAY: s = 'away' else: s = 'unknown' result += u'Status: %s (%s)\n' % (s, self.status_msg) result += u'URL: %s\n' % self.url result += u'Photos:\n' for name, photo in self.photos.iteritems(): result += u'\t%s%s\n' % (photo, ' (hidden)' if photo.hidden else '') result += u'\nProfile:\n' for head in self.profile.itervalues(): result += print_node(head) result += u'Description:\n' for s in self.summary.split('\n'): result += u'\t%s\n' % s return result class QueryError(UserError): """ Raised when unable to send a query to a contact. """ class Query(BaseObject): """ Query to send to a contact. """ message = StringField('Message received') def __init__(self, id, message): BaseObject.__init__(self, id) self.message = message class CapContact(Capability): def iter_contacts(self, status=Contact.STATUS_ALL, ids=None): """ Iter contacts :param status: get only contacts with the specified status :type status: Contact.STATUS_* :param ids: if set, get the specified contacts :type ids: list[str] :rtype: iter[:class:`Contact`] """ raise NotImplementedError() def get_contact(self, id): """ Get a contact from his id. The default implementation only calls iter_contacts() with the proper values, but it might be overloaded by backends. :param id: the ID requested :type id: str :rtype: :class:`Contact` or None if not found """ l = self.iter_contacts(ids=[id]) try: return l[0] except IndexError: return None def send_query(self, id): """ Send a query to a contact :param id: the ID of contact :type id: str :rtype: :class:`Query` :raises: :class:`QueryError` """ raise NotImplementedError() def get_notes(self, id): """ Get personal notes about a contact :param id: the ID of the contact :type id: str :rtype: unicode """ raise NotImplementedError() def save_notes(self, id, notes): """ Set personal notes about a contact :param id: the ID of the contact :type id: str :returns: the unicode object to save as notes """ raise NotImplementedError() weboob-1.1/weboob/capabilities/content.py000066400000000000000000000052251265717027300206000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField, Field from .date import DateField __all__ = ['Content', 'Revision', 'CapContent'] class Content(BaseObject): """ Content object. """ title = StringField('Title of content') author = StringField('Original author of content') content = StringField('Body') revision = StringField('ID of revision') class Revision(BaseObject): """ Revision of a change on a content. """ author = StringField('Author of revision') comment = StringField('Comment log about revision') timestamp = DateField('Date of revision') minor = Field('Is this change minor?', bool) class CapContent(Capability): def get_content(self, id, revision=None): """ Get a content from an ID. :param id: ID of content :type id: str :param revision: if given, get the content at this revision :type revision: :class:`Revision` :rtype: :class:`Content` """ raise NotImplementedError() def iter_revisions(self, id): """ Iter revisions of a content. :param id: id of content :type id: str :rtype: iter[:class:`Revision`] """ raise NotImplementedError() def push_content(self, content, message=None, minor=False): """ Push a new revision of a content. :param content: object to push :type content: :class:`Content` :param message: log message to associate to new revision :type message: str :param minor: this is a minor revision :type minor: bool """ raise NotImplementedError() def get_content_preview(self, content): """ Get a HTML preview of a content. :param content: content object :type content: :class:`Content` :rtype: str """ raise NotImplementedError() weboob-1.1/weboob/capabilities/date.py000066400000000000000000000040211265717027300200340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Christophe Benz, Romain Bignon, Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from weboob.tools.date import new_date, new_datetime from weboob.capabilities.base import Field __all__ = ['DateField', 'TimeField', 'DeltaField'] class DateField(Field): """ A field which accepts only :class:`datetime.date` and :class:`datetime.datetime` types. """ def __init__(self, doc, **kwargs): Field.__init__(self, doc, datetime.date, datetime.datetime, **kwargs) def __setattr__(self, name, value): if name == 'value': # Force use of our date and datetime types, to fix bugs in python2 # with strftime on year<1900. if type(value) is datetime.datetime: value = new_datetime(value) if type(value) is datetime.date: value = new_date(value) return object.__setattr__(self, name, value) class TimeField(Field): """ A field which accepts only :class:`datetime.time` and :class:`datetime.time` types. """ def __init__(self, doc, **kwargs): Field.__init__(self, doc, datetime.time, datetime.datetime, **kwargs) class DeltaField(Field): """ A field which accepts only :class:`datetime.timedelta` type. """ def __init__(self, doc, **kwargs): Field.__init__(self, doc, datetime.timedelta, **kwargs) weboob-1.1/weboob/capabilities/dating.py000066400000000000000000000074641265717027300204030ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, Field, StringField, UserError from .date import DateField from .contact import Contact __all__ = ['OptimizationNotFound', 'Optimization', 'Event', 'CapDating'] class OptimizationNotFound(UserError): """ Raised when an optimization is not found. """ class Optimization(BaseObject): """ Optimization. :var CONFIG: Configuration of optim can be made by :class:`weboob.tools.value.Value` objects in this dict. """ CONFIG = {} def start(self): """ Start optimization. """ raise NotImplementedError() def stop(self): """ Stop optimization. """ raise NotImplementedError() def is_running(self): """ Know if the optimization is currently running. :rtype: bool """ raise NotImplementedError() def get_config(self): """ Get config of this optimization. :rtype: dict """ return None def set_config(self, params): """ Set config of this optimization. :param params: parameters :type params: dict """ raise NotImplementedError() class Event(BaseObject): """ A dating event (for example a visite, a query received, etc.) """ date = DateField('Date of event') contact = Field('Contact related to this event', Contact) type = StringField('Type of event') message = StringField('Message of the event') class CapDating(Capability): """ Capability for dating websites. """ def init_optimizations(self): """ Initialization of optimizations. """ raise NotImplementedError() def add_optimization(self, name, optim): """ Add an optimization. :param name: name of optimization :type name: str :param optim: optimization :type optim: :class:`Optimization` """ optim.id = name setattr(self, 'OPTIM_%s' % name, optim) def iter_optimizations(self): """ Iter optimizations. :rtype: iter[:class:`Optimization`] """ for attr_name in dir(self): if not attr_name.startswith('OPTIM_'): continue attr = getattr(self, attr_name) if attr is None: continue yield attr def get_optimization(self, optim): """ Get an optimization from a name. :param optim: name of optimization :type optim: str :rtype: :class:`Optimization` """ optim = optim.upper() if not hasattr(self, 'OPTIM_%s' % optim): raise OptimizationNotFound() return getattr(self, 'OPTIM_%s' % optim) def iter_events(self): """ Iter events. :rtype: iter[:class:`Event`] """ raise NotImplementedError() def iter_new_contacts(self): """ Iter new contacts. :rtype: iter[:class:`Contact`] """ raise NotImplementedError() weboob-1.1/weboob/capabilities/file.py000066400000000000000000000051321265717027300200420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, NotAvailable, Field, StringField from .date import DateField __all__ = ['BaseFile', 'CapFile'] class BaseFile(BaseObject): """ Represent a file. """ title = StringField('File title') url = StringField('File URL') ext = StringField('File extension') author = StringField('File author') description = StringField('File description') date = DateField('File publication date') size = Field('File size in bytes',int,long, default=NotAvailable) rating = Field('Rating', int, long, float, default=NotAvailable) rating_max = Field('Maximum rating', int, long, float, default=NotAvailable) def __str__(self): return self.url or '' def __repr__(self): return '<%s title=%r url=%r>' % (type(self).__name__, self.title, self.url) @classmethod def id2url(cls, _id): """ Overloaded in child classes provided by backends. """ raise NotImplementedError() @property def page_url(self): """ Get file page URL """ return self.id2url(self.id) class CapFile(Capability): """ Provide file download """ (SEARCH_RELEVANCE, SEARCH_RATING, SEARCH_VIEWS, SEARCH_DATE) = range(4) def search_file(self, pattern, sortby=SEARCH_RELEVANCE): """ :param pattern: pattern to search on :type pattern: str :param sortby: sort by ... (user SEARCH_* constants) :rtype: iter[:class:`BaseFile`] """ raise NotImplementedError() def get_file(self, _id): """ Get a file from an ID :param _id: the file id. I can be a numeric ID, or a page url :type _id: str :rtype: :class:`BaseFile` or None if not found. """ raise NotImplementedError() weboob-1.1/weboob/capabilities/gallery.py000066400000000000000000000105011265717027300205560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Christophe Benz, Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.capabilities.thumbnail import Thumbnail from .base import Capability, BaseObject, NotLoaded, Field, StringField, \ BytesField, IntField, FloatField from .date import DateField __all__ = ['BaseGallery', 'BaseImage', 'CapGallery'] class BaseGallery(BaseObject): """ Represents a gallery. This object has to be inherited to specify how to calculate the URL of the gallery from its ID. """ title = StringField('Title of gallery') url = StringField('Direct URL to gallery') description = StringField('Description of gallery') cardinality = IntField('Cardinality of gallery') date = DateField('Date of gallery') rating = FloatField('Rating of this gallery') rating_max = FloatField('Max rating available') thumbnail = Field('Thumbnail', Thumbnail) def __init__(self, _id, title=NotLoaded, url=NotLoaded, cardinality=NotLoaded, date=NotLoaded, rating=NotLoaded, rating_max=NotLoaded, thumbnail=NotLoaded, thumbnail_url=None, nsfw=False): BaseObject.__init__(self, unicode(_id)) self.title = title self.url = url self.date = date self.rating = rating self.rating_max = rating_max self.thumbnail = thumbnail @classmethod def id2url(cls, _id): """Overloaded in child classes provided by backends.""" raise NotImplementedError() @property def page_url(self): """ Get URL to page of this gallery. """ return self.id2url(self.id) def iter_image(self): """ Iter images. """ raise NotImplementedError() class BaseImage(BaseObject): """ Base class for images. """ index = IntField('Usually page number') thumbnail = Field('Thumbnail of the image', Thumbnail) url = StringField('Direct URL to image') ext = StringField('Extension of image') data = BytesField('Data of image') gallery = Field('Reference to the Gallery object', BaseGallery) def __init__(self, _id, index=None, thumbnail=NotLoaded, url=NotLoaded, ext=NotLoaded, gallery=None): BaseObject.__init__(self, unicode(_id)) self.index = index self.thumbnail = thumbnail self.url = url self.ext = ext self.gallery = gallery def __str__(self): return self.url def __repr__(self): return '' % self.url def __iscomplete__(self): return self.data is not NotLoaded class CapGallery(Capability): """ This capability represents the ability for a website backend to provide videos. """ (SEARCH_RELEVANCE, SEARCH_RATING, SEARCH_VIEWS, SEARCH_DATE) = range(4) def search_galleries(self, pattern, sortby=SEARCH_RELEVANCE): """ Iter results of a search on a pattern. :param pattern: pattern to search on :type pattern: str :param sortby: sort by... :type sortby: SEARCH_* :rtype: :class:`BaseGallery` """ raise NotImplementedError() def get_gallery(self, _id): """ Get gallery from an ID. :param _id: the gallery id. It can be a numeric ID, or a page url, or so. :type _id: str :rtype: :class:`Gallery` """ raise NotImplementedError() def iter_gallery_images(self, gallery): """ Iterate images from a Gallery. :type gallery: BaseGallery :rtype: iter(BaseImage) """ raise NotImplementedError() weboob-1.1/weboob/capabilities/gauge.py000066400000000000000000000065101265717027300202140ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon, Florent Fourcot # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField, FloatField, Field, UserError, empty from .date import DateField __all__ = ['Gauge', 'GaugeSensor', 'GaugeMeasure', 'CapGauge', 'SensorNotFound'] class SensorNotFound(UserError): """ Not found a sensor """ class Gauge(BaseObject): """ Gauge class. """ name = StringField('Name of gauge') city = StringField('City of the gauge') object = StringField('What is evaluate') # For example, name of a river sensors = Field('List of sensors on the gauge', list) class GaugeMeasure(BaseObject): """ Measure of a gauge sensor. """ level = FloatField('Level of measure') date = DateField('Date of measure') alarm = StringField('Alarm level') def __init__(self): BaseObject.__init__(self) def __repr__(self): if empty(self.level): return "" % self.level else: return "" % (self.level, self.alarm, self.date) class GaugeSensor(BaseObject): """ GaugeSensor class. """ name = StringField('Name of the sensor') unit = StringField('Unit of values') forecast = StringField('Forecast') address = StringField('Address') lastvalue = Field('Last value', GaugeMeasure) history = Field('Value history', list) # lastvalue not included gaugeid = StringField('Id of the gauge') def __repr__(self): return "" % (self.id, self.name) class CapGauge(Capability): def iter_gauges(self, pattern=None): """ Iter gauges. :param pattern: if specified, used to search gauges. :type pattern: str :rtype: iter[:class:`Gauge`] """ raise NotImplementedError() def iter_sensors(self, id, pattern=None): """ Iter instrument of a gauge. :param: ID of the gauge :param pattern: if specified, used to search sensors. :type pattern: str :rtype: iter[:class:`GaugeSensor`] """ raise NotImplementedError() def iter_gauge_history(self, id): """ Get history of a gauge sensor. :param id: ID of the gauge sensor :type id: str :rtype: iter[:class:`GaugeMeasure`] """ raise NotImplementedError() def get_last_measure(self, id): """ Get last measures of a censor. :param id: ID of the censor. :type id: str :rtype: :class:`GaugeMeasure` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/geolocip.py000066400000000000000000000033771265717027300207350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField, FloatField __all__ = ['IpLocation', 'CapGeolocIp'] class IpLocation(BaseObject): """ Represents the location of an IP address. """ city = StringField('City') region = StringField('Region') zipcode = StringField('Zip code') country = StringField('Country') lt = FloatField('Latitude') lg = FloatField('Longitude') osmlink = StringField('Link to OpenStreetMap location page') host = StringField('Hostname') tld = StringField('Top Level Domain') isp = StringField('Internet Service Provider') def __init__(self, ipaddr): BaseObject.__init__(self, ipaddr) class CapGeolocIp(Capability): """ Access information about IP addresses database. """ def get_location(self, ipaddr): """ Get location of an IP address. :param ipaddr: IP address :type ipaddr: str :rtype: :class:`IpLocation` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/housing.py000066400000000000000000000101471265717027300206010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, Field, IntField, DecimalField, \ StringField, BytesField, enum, UserError from .date import DateField __all__ = ['HousingPhoto', 'Housing', 'Query', 'City', 'CapHousing'] class TypeNotSupported(UserError): """ Raised when query type is not supported """ def __init__(self, msg='This type of house is not supported by this module'): UserError.__init__(self, msg) class HousingPhoto(BaseObject): """ Photo of a housing. """ url = StringField('Direct URL to photo') data = BytesField('Data of photo') def __init__(self, url): BaseObject.__init__(self, url.split('/')[-1]) self.url = url def __iscomplete__(self): return self.data def __str__(self): return self.url def __repr__(self): return u'' % (self.id, len(self.data) if self.data else 0) class Housing(BaseObject): """ Content of a housing. """ title = StringField('Title of housing') area = DecimalField('Area of housing, in m2') cost = DecimalField('Cost of housing') currency = StringField('Currency of cost') date = DateField('Date when the housing has been published') location = StringField('Location of housing') station = StringField('What metro/bus station next to housing') text = StringField('Text of the housing') phone = StringField('Phone number to contact') photos = Field('List of photos', list) details = Field('Key/values of details', dict) url = StringField('Url of the the advert') class Query(BaseObject): """ Query to find housings. """ TYPE_RENT = 0 TYPE_SALE = 1 TYPE_SHARING = 2 HOUSE_TYPES = enum(APART=u'Apartment', HOUSE=u'House', PARKING=u'Parking', LAND=u'Land', OTHER=u'Other', UNKNOWN=u'Unknown') type = IntField('Type of housing to find (TYPE_* constants)') cities = Field('List of cities to search in', list, tuple) area_min = IntField('Minimal area (in m2)') area_max = IntField('Maximal area (in m2)') cost_min = IntField('Minimal cost') cost_max = IntField('Maximal cost') nb_rooms = IntField('Number of rooms') house_types = Field('List of house types', list, tuple, default=HOUSE_TYPES.values) class City(BaseObject): """ City. """ name = StringField('Name of city') class CapHousing(Capability): """ Capability of websites to search housings. """ def search_housings(self, query): """ Search housings. :param query: search query :type query: :class:`Query` :rtype: iter[:class:`Housing`] """ raise NotImplementedError() def get_housing(self, housing): """ Get an housing from an ID. :param housing: ID of the housing :type housing: str :rtype: :class:`Housing` or None if not found. """ raise NotImplementedError() def search_city(self, pattern): """ Search a city from a pattern. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`City`] """ raise NotImplementedError() weboob-1.1/weboob/capabilities/image.py000066400000000000000000000050271265717027300202100ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Christophe Benz, Noé Rubinstein # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.ordereddict import OrderedDict from .base import NotLoaded, Field, BytesField from .file import CapFile, BaseFile __all__ = ['BaseImage', 'CapImage'] class _BaseImage(BaseFile): """ Fake class to allow the inclusion of a BaseImage property within the real BaseImage class """ pass class BaseImage(_BaseImage): """ Represents an image file. """ nsfw = Field('Is this Not Safe For Work', bool, default=False) thumbnail = Field('Thumbnail of the image', _BaseImage) data = BytesField('Data of image') def __iscomplete__(self): return self.data is not NotLoaded def to_dict(self): def iter_decorate(d): for key, value in d: if key == 'data': continue if key == 'id' and self.backend is not None: value = self.fullid yield key, value fields_iterator = self.iter_fields() return OrderedDict(iter_decorate(fields_iterator)) class CapImage(CapFile): """ Image file provider """ def search_image(self, pattern, sortby=CapFile.SEARCH_RELEVANCE, nsfw=False): """ search for an image file :param pattern: pattern to search on :type pattern: str :param sortby: sort by ...(use SEARCH_* constants) :param nsfw: include non-suitable for work images if True :type nsfw: bool :rtype: iter[:class:`BaseImage`] """ return self.search_file(pattern, sortby) def get_image(self, _id): """ Get an image file from an ID. :param id: image file ID :type id: str :rtype: :class:`BaseImage`] """ return self.get_file(_id) weboob-1.1/weboob/capabilities/job.py000066400000000000000000000067101265717027300177000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import BaseObject, Capability, StringField from .date import DateField __all__ = ['BaseJobAdvert', 'CapJob'] class BaseJobAdvert(BaseObject): """ Represents a job announce. """ url = StringField('URL of the announce') publication_date = DateField('Date when the announce has been published') society_name = StringField('Name of the society taht published the announce') place = StringField('Place where the job take place') job_name = StringField('Name of the job') title = StringField('Title of the announce') contract_type = StringField('Type of the contrat : CDI, CDD') pay = StringField('Amount of the salary') description = StringField('Description of the job') formation = StringField('Required formation') experience = StringField('Required experience') def __unicode__(self): message = u'\r\n-- Advert --\r\n' message += u'id : %s\r\n' % self.id message += u'url : %s\r\n' % self.url message += u'publication_date : %s\r\n' % self.publication_date message += u'society_name : %s\r\n' % self.society_name message += u'place : %s\r\n' % self.place message += u'job_name : %s\r\n' % self.job_name message += u'title : %s\r\n' % self.title message += u'contract_type : %s\r\n' % self.contract_type message += u'pay : %s\r\n' % self.pay message += u'description : %s\r\n' % self.description message += u'formation : %s\r\n' % self.formation message += u'experience : %s\r\n' % self.experience return message @classmethod def id2url(cls, _id): """Overloaded in child classes provided by backends.""" raise NotImplementedError() @property def page_url(self): """ Get page URL of the announce. """ return self.id2url(self.id) class CapJob(Capability): """ Capability of job annouce websites. """ def search_job(self, pattern=None): """ Iter results of a search on a pattern. :param pattern: pattern to search on :type pattern: str :rtype: iter[:class:`BaseJobAdvert`] """ raise NotImplementedError() def advanced_search_job(self): """ Iter results of an advanced search :rtype: iter[:class:`BaseJobAdvert`] """ def get_job_advert(self, _id, advert=None): """ Get an announce from an ID. :param _id: id of the advert :type _id: str :param advert: the advert :type advert: BaseJobAdvert :rtype: :class:`BaseJobAdvert` or None if not found. """ raise NotImplementedError() weboob-1.1/weboob/capabilities/library.py000066400000000000000000000042511265717027300205700ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Jeremy Monnet # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .collection import CapCollection from .base import BaseObject, Field, StringField from .date import DateField __all__ = ['Book', 'Renew', 'CapBook'] class Book(BaseObject): """ Describes a book. """ name = StringField('Name of the book') author = StringField('Author of the book') location = StringField('Location') date = DateField('The due date') late = Field('Are you late?', bool) class Renew(BaseObject): """ A renew message. """ message = StringField('Message') class CapBook(CapCollection): """ Library websites. """ def iter_resources(self, objs, split_path): """ Iter resources. It retuns :func:`iter_books`. """ if Book in objs: self._restrict_level(split_path) return self.iter_books() def iter_books(self): """ Iter books. :rtype: iter[:class:`Book`] """ raise NotImplementedError() def get_book(self, _id): """ Get a book from an ID. :param _id: ID of the book :type _id: str :rtype: :class:`Book` """ raise NotImplementedError() def get_booked(self, _id): raise NotImplementedError() def renew_book(self, _id): raise NotImplementedError() def get_rented(self, _id): raise NotImplementedError() def search_books(self, _string): raise NotImplementedError() weboob-1.1/weboob/capabilities/lyrics.py000066400000000000000000000034051265717027300204310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField __all__ = ['SongLyrics', 'CapLyrics'] class SongLyrics(BaseObject): """ Song lyrics object. """ title = StringField('Title of the song') artist = StringField('Artist of the song') content = StringField('Lyrics of the song') def __init__(self, id, title): BaseObject.__init__(self, id) self.title = title class CapLyrics(Capability): """ Lyrics websites. """ def iter_lyrics(self, criteria, pattern): """ Search lyrics by artist or by song and iterate on results. :param criteria: 'artist' or 'song' :type criteria: str :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`SongLyrics`] """ raise NotImplementedError() def get_lyrics(self, _id): """ Get a lyrics object from an ID. :param _id: ID of lyrics :type _id: str :rtype: :class:`SongLyrics` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/messages.py000066400000000000000000000141671265717027300207420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2015 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime import time from .base import Capability, BaseObject, NotLoaded, Field, StringField, \ IntField, UserError from .date import DateField __all__ = ['Thread', 'Message', 'CapMessages', 'CantSendMessage', 'CapMessagesPost'] class Message(BaseObject): """ Represents a message read or to send. """ IS_HTML = 0x001 "The content is HTML formatted" IS_UNREAD = 0x002 "The message is unread" IS_RECEIVED = 0x004 "The receiver has read this message" IS_NOT_RECEIVED = 0x008 "The receiver hass not read this message" thread = Field('Reference to the thread', 'Thread') title = StringField('Title of message') sender = StringField('Author of this message') receivers = Field('Receivers of the message', list) date = DateField('Date when the message has been sent') content = StringField('Body of message') signature = StringField('Optional signature') parent = Field('Parent message', 'Message') children = Field('Children fields', list) flags = IntField('Flags (IS_* constants)', default=0) def __init__(self, thread=NotLoaded, id=NotLoaded, title=NotLoaded, sender=NotLoaded, receivers=NotLoaded, date=None, parent=NotLoaded, content=NotLoaded, signature=NotLoaded, children=NotLoaded, flags=0): super(Message, self).__init__(id) self.thread = thread self.title = title self.sender = sender self.receivers = receivers self.content = content self.signature = signature self.children = children self.flags = flags if date is None: date = datetime.datetime.utcnow() self.date = date if isinstance(parent, Message): self.parent = parent else: self.parent = NotLoaded self._parent_id = parent @property def date_int(self): """ Date of message as an integer. """ return int(time.strftime('%Y%m%d%H%M%S', self.date.timetuple())) @property def full_id(self): """ Full ID of message (in form '**THREAD_ID.MESSAGE_ID**') """ return '%s.%s' % (self.thread.id, self.id) @property def full_parent_id(self): """ Get the full ID of the parent message (in form '**THREAD_ID.MESSAGE_ID**'). """ if self.parent: return self.parent.full_id elif self._parent_id is None: return '' elif self._parent_id is NotLoaded: return NotLoaded else: return '%s.%s' % (self.thread.id, self._parent_id) def __eq__(self, msg): if not isinstance(msg, Message): return False if self.thread: return unicode(self.thread.id) == unicode(msg.thread.id) and \ unicode(self.id) == unicode(msg.id) else: return unicode(self.id) == unicode(msg.id) def __repr__(self): return '' % ( self.full_id, self.title, self.date, self.sender) class Thread(BaseObject): """ Thread containing messages. """ IS_THREADS = 0x001 IS_DISCUSSION = 0x002 root = Field('Root message', Message) title = StringField('Title of thread') date = DateField('Date of thread') flags = IntField('Flags (IS_* constants)', default=IS_THREADS) def iter_all_messages(self): """ Iter all messages of the thread. :rtype: iter[:class:`Message`] """ if self.root: yield self.root for m in self._iter_all_messages(self.root): yield m def _iter_all_messages(self, message): if message.children: for child in message.children: yield child for m in self._iter_all_messages(child): yield m class CapMessages(Capability): """ Capability to read messages. """ def iter_threads(self): """ Iterates on threads, from newers to olders. :rtype: iter[:class:`Thread`] """ raise NotImplementedError() def get_thread(self, id): """ Get a specific thread. :rtype: :class:`Thread` """ raise NotImplementedError() def iter_unread_messages(self): """ Iterates on messages which hasn't been marked as read. :rtype: iter[:class:`Message`] """ raise NotImplementedError() def set_message_read(self, message): """ Set a message as read. :param message: message read (or ID) :type message: :class:`Message` or str """ raise NotImplementedError() class CantSendMessage(UserError): """ Raised when a message can't be send. """ class CapMessagesPost(Capability): """ This capability allow user to send a message. """ def post_message(self, message): """ Post a message. :param message: message to send :type message: :class:`Message` :raises: :class:`CantSendMessage` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/parcel.py000066400000000000000000000036631265717027300204000ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, Field, StringField, UserError from .date import DateField class Event(BaseObject): date = DateField('Date') activity = StringField('Activity') location = StringField('Location') def __repr__(self): return u'' % (self.date, self.activity, self.location) class Parcel(BaseObject): STATUS_UNKNOWN = 0 STATUS_PLANNED = 1 STATUS_IN_TRANSIT = 2 STATUS_ARRIVED = 3 arrival = DateField('Scheduled arrival date') status = Field('Status of parcel', int, default=STATUS_UNKNOWN) info = StringField('Information about parcel status') history = Field('History', list) class CapParcel(Capability): def get_parcel_tracking(self, id): """ Get information abouut a parcel. :param id: ID of the parcel :type id: :class:`str` :rtype: :class:`Parcel` :raises: :class:`ParcelNotFound` """ raise NotImplementedError() class ParcelNotFound(UserError): """ Raised when a parcell is not found. It can be an user error, or an expired parcel """ def __init__(self, msg='Account not found'): UserError.__init__(self, msg) weboob-1.1/weboob/capabilities/paste.py000066400000000000000000000071161265717027300202430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, NotLoaded, Field, StringField, UserError __all__ = ['PasteNotFound', 'BasePaste', 'CapPaste'] class PasteNotFound(UserError): """ Raised when a paste is not found. """ def __init__(self): return super(PasteNotFound, self).__init__("Paste not found") class BasePaste(BaseObject): """ Represents a pasted text. """ title = StringField('Title of paste') language = StringField('Language of the paste') contents = StringField('Content of the paste') public = Field('Is this paste public?', bool) def __init__(self, _id, title=NotLoaded, language=NotLoaded, contents=NotLoaded, public=NotLoaded): BaseObject.__init__(self, unicode(_id)) self.title = title self.language = language self.contents = contents self.public = public @classmethod def id2url(cls, _id): """Overloaded in child classes provided by backends.""" raise NotImplementedError() @property def page_url(self): """ Get URL to page of this paste. """ return self.id2url(self.id) class CapPaste(Capability): """ This capability represents the ability for a website backend to store plain text. """ def new_paste(self, *args, **kwargs): """ Get a new paste object for posting it with the backend. The parameters should be passed to the object init. :rtype: :class:`BasePaste` """ raise NotImplementedError() def can_post(self, contents, title=None, public=None, max_age=None): """ Checks if the paste can be pasted by this backend. Some properties are considered required (public/private, max_age) while others are just bonuses (language). contents: Can be used to check encodability, maximum length, etc. title: Can be used to check length, allowed characters. Should not be required. public: True must be public, False must be private, None do not care. max_age: Maximum time to live in seconds. A score of 0 means the backend is not suitable. A score of 1 means the backend is suitable. Higher scores means it is more suitable than others with a lower score. :rtype: int :returns: score """ raise NotImplementedError() def get_paste(self, url): """ Get a Paste from an ID or URL. :param _id: the paste id. It can be an ID or a page URL. :type _id: str :rtype: :class:`BasePaste` :raises: :class:`PasteNotFound` """ raise NotImplementedError() def post_paste(self, paste, max_age=None): """ Post a paste. :param paste: a Paste object :type paste: :class:`BasePaste` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/pricecomparison.py000066400000000000000000000046311265717027300223230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, Field, DecimalField, \ StringField from .date import DateField __all__ = ['Shop', 'Price', 'Product', 'CapPriceComparison'] class Product(BaseObject): """ A product. """ name = StringField('Name of product') class Shop(BaseObject): """ A shop where the price is. """ name = StringField('Name of shop') location = StringField('Location of the shop') info = StringField('Information about the shop') class Price(BaseObject): """ Price. """ date = DateField('Date when this price has been published') cost = DecimalField('Cost of the product in this shop') currency = StringField('Currency of the price') message = StringField('Message related to this price') shop = Field('Shop information', Shop) product = Field('Product', Product) class CapPriceComparison(Capability): """ Capability for price comparison websites. """ def search_products(self, pattern=None): """ Search products from a pattern. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`Product`] """ raise NotImplementedError() def iter_prices(self, product): """ Iter prices for a product. :param product: product to search :type product: :class:`Product` :rtype: iter[:class:`Price`] """ raise NotImplementedError() def get_price(self, id): """ Get a price from an ID :param id: ID of price :type id: str :rtype: :class:`Price` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/radio.py000066400000000000000000000032751265717027300202270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, Field, StringField from weboob.tools.capabilities.streaminfo import StreamInfo __all__ = ['Radio', 'CapRadio'] class Radio(BaseObject): """ Radio object. """ title = StringField('Title of radio') description = StringField('Description of radio') current = Field('Current emission', StreamInfo) streams = Field('List of streams', list) class CapRadio(Capability): """ Capability of radio websites. """ def iter_radios_search(self, pattern): """ Search a radio. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`Radio`] """ raise NotImplementedError() def get_radio(self, id): """ Get a radio from an ID. :param id: ID of radio :type id: str :rtype: :class:`Radio` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/recipe.py000066400000000000000000000150501265717027300203720ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField, IntField, Field, empty import lxml.etree as ET import base64 import re import urllib __all__ = ['Recipe', 'CapRecipe'] class Comment(): def __init__(self, author=None, rate=None, text=None): self.author = author self.rate = rate self.text = text def __str__(self): result = u'' if self.author: result += 'author: %s, ' % self.author if self.rate: result += 'note: %s, ' % self.rate if self.text: result += 'comment: %s' % self.text return result class Recipe(BaseObject): """ Recipe object. """ title = StringField('Title of the recipe') author = StringField('Author name of the recipe') thumbnail_url = StringField('Direct url to recipe thumbnail') picture_url = StringField('Direct url to recipe picture') short_description = StringField('Short description of a recipe') nb_person = Field('The recipe was made for this amount of persons', list) preparation_time = IntField('Preparation time of the recipe in minutes') cooking_time = IntField('Cooking time of the recipe in minutes') ingredients = Field('Ingredient list necessary for the recipe', list) instructions = StringField('Instruction step list of the recipe') comments = Field('User comments about the recipe', list) def __init__(self, id='', title=u''): BaseObject.__init__(self, id) self.title = title def toKrecipesXml(self, author=None): """ Export recipe to KRecipes XML string """ sauthor = u'' if not empty(self.author): sauthor += '%s@' % self.author if author is None: sauthor += 'Cookboob' else: sauthor += author header = u'\n' initial_xml = '''\ ''' doc = ET.fromstring(initial_xml) recipe = doc.find('krecipes-recipe') desc = ET.SubElement(recipe, 'krecipes-description') title = ET.SubElement(desc, 'title') title.text = self.title authors = ET.SubElement(desc, 'author') authors.text = sauthor eyield = ET.SubElement(desc, 'yield') if not empty(self.nb_person): amount = ET.SubElement(eyield, 'amount') if len(self.nb_person) == 1: amount.text = '%s' % self.nb_person[0] else: mini = ET.SubElement(amount, 'min') mini.text = u'%s' % self.nb_person[0] maxi = ET.SubElement(amount, 'max') maxi.text = u'%s' % self.nb_person[1] etype = ET.SubElement(eyield, 'type') etype.text = 'persons' if not empty(self.preparation_time): preptime = ET.SubElement(desc, 'preparation-time') preptime.text = '%02d:%02d' % (self.preparation_time / 60, self.preparation_time % 60) if not empty(self.picture_url): data = urllib.urlopen(self.picture_url).read() datab64 = base64.encodestring(data)[:-1] pictures = ET.SubElement(desc, 'pictures') pic = ET.SubElement(pictures, 'pic', {'format': 'JPEG', 'id': '1'}) pic.text = ET.CDATA(datab64) if not empty(self.ingredients): ings = ET.SubElement(recipe, 'krecipes-ingredients') pat = re.compile('^[0-9]*') for i in self.ingredients: sname = u'%s' % i samount = '' sunit = '' first_nums = pat.match(i).group() if first_nums != '': samount = first_nums sname = i.lstrip('0123456789 ') ing = ET.SubElement(ings, 'ingredient') am = ET.SubElement(ing, 'amount') am.text = samount unit = ET.SubElement(ing, 'unit') unit.text = sunit name = ET.SubElement(ing, 'name') name.text = sname if not empty(self.instructions): instructions = ET.SubElement(recipe, 'krecipes-instructions') instructions.text = self.instructions if not empty(self.comments): ratings = ET.SubElement(recipe, 'krecipes-ratings') for c in self.comments: rating = ET.SubElement(ratings, 'rating') if c.author: rater = ET.SubElement(rating, 'rater') rater.text = c.author if c.text: com = ET.SubElement(rating, 'comment') com.text = c.text crits = ET.SubElement(rating, 'criterion') if c.rate: crit = ET.SubElement(crits, 'criteria') critname = ET.SubElement(crit, 'name') critname.text = 'Overall' critstars = ET.SubElement(crit, 'stars') critstars.text = c.rate.split('/')[0] return header + ET.tostring(doc, encoding='UTF-8', pretty_print=True).decode('utf-8') class CapRecipe(Capability): """ Recipe providers. """ def iter_recipes(self, pattern): """ Search recipes and iterate on results. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`Recipe`] """ raise NotImplementedError() def get_recipe(self, _id): """ Get a recipe object from an ID. :param _id: ID of recipe :type _id: str :rtype: :class:`Recipe` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/shop.py000066400000000000000000000076101265717027300200770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import BaseObject, StringField, DecimalField, UserError from .date import DateField from .collection import CapCollection __all__ = ['OrderNotFound', 'Order', 'Payment', 'Item', 'CapShop'] class OrderNotFound(UserError): """ Raised when an order is not found. """ def __init__(self, msg='Order not found'): UserError.__init__(self, msg) class Order(BaseObject): """ Purchase order. """ date = DateField('Date when the order was placed') shipping = DecimalField('Shipping price') discount = DecimalField('Discounts') tax = DecimalField('Tax') total = DecimalField('Total') def __repr__(self): return u"" % (self.id, self.date) class Payment(BaseObject): """ Payment for an order. """ date = DateField('The date when payment was applied') method = StringField('Payment method; e.g. "VISA 1234"') amount = DecimalField('Payment amount') def __repr__(self): return u"" % \ (self.date, self.method, self.amount) class Item(BaseObject): """ Purchased item within an order. """ label = StringField('Item label') url = StringField('URL with item description') price = DecimalField('Item price') def __repr__(self): return u"" % (self.label, self.price) class CapShop(CapCollection): """ Capability of online shops to see orders history. """ def iter_resources(self, objs, split_path): """ Iter resources. Default implementation of this method is to return on top-level all orders (by calling :func:`iter_accounts`). :param objs: type of objects to get :type objs: tuple[:class:`BaseObject`] :param split_path: path to discover :type split_path: :class:`list` :rtype: iter[:class:`BaseObject`] """ if Order in objs: self._restrict_level(split_path) return self.iter_orders() def get_currency(self): """ Get the currency this shop uses. :rtype: :class:`str` """ raise NotImplementedError() def iter_orders(self): """ Iter history of orders. :rtype: iter[:class:`Order`] """ raise NotImplementedError() def get_order(self, id): """ Get an order from its ID. :param id: ID of the order :type id: :class:`str` :rtype: :class:`Order` :raises: :class:`OrderNotFound` """ raise NotImplementedError() def iter_payments(self, order): """ Iter payments of a specific order. :param order: order to get payments :type order: :class:`Order` :rtype: iter[:class:`Payment`] :raises: :class:`OrderNotFound` """ raise NotImplementedError() def iter_items(self, order): """ Iter items of a specific order. :param order: order to get items :type order: :class:`Order` :rtype: iter[:class:`Item`] :raises: :class:`OrderNotFound` """ raise NotImplementedError() weboob-1.1/weboob/capabilities/subtitle.py000066400000000000000000000044251265717027300207620ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField, IntField, UserError __all__ = ['Subtitle', 'CapSubtitle'] class LanguageNotSupported(UserError): """ Raised when the language is not supported """ def __init__(self, msg='language is not supported'): UserError.__init__(self, msg) class Subtitle(BaseObject): """ Subtitle object. """ name = StringField('Name of subtitle') ext = StringField('Extension of file') url = StringField('Direct url to subtitle file') nb_cd = IntField('Number of cd or files') language = StringField('Language of the subtitle') description=StringField('Description of corresponding video') def __init__(self, id, name): BaseObject.__init__(self, id) self.name = name class CapSubtitle(Capability): """ Subtitle providers. """ def iter_subtitles(self, pattern): """ Search subtitles and iterate on results. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`Subtitle`] """ raise NotImplementedError() def get_subtitle(self, _id): """ Get a subtitle object from an ID. :param _id: ID of subtitle :type _id: str :rtype: :class:`Subtitle` """ raise NotImplementedError() def get_subtitle_file(self, _id): """ Get the content of the subtitle file. :param _id: ID of subtitle :type _id: str :rtype: str """ raise NotImplementedError() weboob-1.1/weboob/capabilities/torrent.py000066400000000000000000000047721265717027300206310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, Field, StringField, FloatField, \ IntField, UserError from .date import DateField __all__ = ['MagnetOnly', 'Torrent', 'CapTorrent'] class MagnetOnly(UserError): """ Raised when trying to get URL to torrent but only magnet is available. """ def __init__(self, magnet): self.magnet = magnet UserError.__init__(self, 'Only magnet URL is available') class Torrent(BaseObject): """ Torrent object. """ name = StringField('Name of torrent') size = FloatField('Size of torrent') date = DateField('Date when torrent has been published') url = StringField('Direct url to .torrent file') magnet = StringField('URI of magnet') seeders = IntField('Number of seeders') leechers = IntField('Number of leechers') files = Field('Files in torrent', list) description = StringField('Description of torrent') filename = StringField('Name of .torrent file') class CapTorrent(Capability): """ Torrent trackers. """ def iter_torrents(self, pattern): """ Search torrents and iterate on results. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`Torrent`] """ raise NotImplementedError() def get_torrent(self, _id): """ Get a torrent object from an ID. :param _id: ID of torrent :type _id: str :rtype: :class:`Torrent` """ raise NotImplementedError() def get_torrent_file(self, _id): """ Get the content of the .torrent file. :param _id: ID of torrent :type _id: str :rtype: str """ raise NotImplementedError() weboob-1.1/weboob/capabilities/translate.py000066400000000000000000000037351265717027300211270ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Lucien Loiseau # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .base import Capability, BaseObject, StringField, UserError __all__ = ['TranslationFail', 'LanguageNotSupported', 'CapTranslate'] class LanguageNotSupported(UserError): """ Raised when the language is not supported """ def __init__(self, msg='language is not supported'): UserError.__init__(self, msg) class TranslationFail(UserError): """ Raised when no translation matches the given request """ def __init__(self, msg='No Translation Available'): UserError.__init__(self, msg) class Translation(BaseObject): """ Translation. """ lang_src = StringField('Source language') lang_dst = StringField('Destination language') text = StringField('Translation') class CapTranslate(Capability): """ Capability of online translation website to translate word or sentence """ def translate(self, source_language, destination_language, request): """ Perfom a translation. :param source_language: language in which the request is written :param destination_language: language to translate the request into :param request: the sentence to be translated :rtype: Translation """ raise NotImplementedError() weboob-1.1/weboob/capabilities/travel.py000066400000000000000000000102461265717027300204220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime from .base import Capability, BaseObject, StringField, DecimalField, UserError from .date import TimeField, DeltaField, DateField __all__ = ['Station', 'Departure', 'RoadStep', 'RoadmapError', 'RoadmapFilters', 'CapTravel'] class Station(BaseObject): """ Describes a station. """ name = StringField('Name of station') def __init__(self, id=None, name=None): BaseObject.__init__(self, id) self.name = name def __repr__(self): return "" % (self.id, self.name) class Departure(BaseObject): """ Describes a departure. """ type = StringField('Type of train') time = TimeField('Departure time') departure_station = StringField('Departure station') arrival_station = StringField('Destination of the train') arrival_time = TimeField('Arrival time') late = TimeField('Optional late', default=datetime.time()) information = StringField('Informations') plateform = StringField('Where the train will leave') price = DecimalField('Price of ticket') currency = StringField('Currency', default=None) def __init__(self, id=None, _type=None, _time=None): BaseObject.__init__(self, id) self.type = _type self.time = _time def __repr__(self): return u"" % ( self.id, self.type, self.time.strftime('%H:%M'), self.departure_station, self.arrival_station) class RoadStep(BaseObject): """ A step on a roadmap. """ line = StringField('When line') start_time = TimeField('Start of step') end_time = TimeField('End of step') departure = StringField('Departure station') arrival = StringField('Arrival station') duration = DeltaField('Duration of this step') class RoadmapError(UserError): """ Raised when the roadmap is unable to be calculated. """ class RoadmapFilters(BaseObject): """ Filters to get a roadmap. """ departure_time = DateField('Wanted departure time') arrival_time = DateField('Wanted arrival time') def __init__(self): BaseObject.__init__(self, '') class CapTravel(Capability): """ Travel websites. """ def iter_station_search(self, pattern): """ Iterates on search results of stations. :param pattern: the search pattern :type pattern: str :rtype: iter[:class:`Station`] """ raise NotImplementedError() def iter_station_departures(self, station_id, arrival_id=None, date=None): """ Iterate on departures. :param station_id: the station ID :type station_id: str :param arrival_id: optionnal arrival station ID :type arrival_id: str :param date: optional date :type date: datetime.datetime :rtype: iter[:class:`Departure`] """ raise NotImplementedError() def iter_roadmap(self, departure, arrival, filters): """ Get a roadmap. :param departure: name of departure station :type departure: str :param arrival: name of arrival station :type arrival: str :param filters: filters on search :type filters: :class:`RoadmapFilters` :rtype: iter[:class:`RoadStep`] """ raise NotImplementedError() weboob-1.1/weboob/capabilities/video.py000066400000000000000000000036031265717027300202320ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon, Christophe Benz # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import timedelta from .base import Field from .image import CapImage, BaseImage __all__ = ['BaseVideo', 'CapVideo'] class BaseVideo(BaseImage): """ Represents a video. This object has to be inherited to specify how to calculate the URL of the video from its ID. """ duration = Field('file duration', int, long, timedelta) class CapVideo(CapImage): """ Video file provider. """ def search_videos(self, pattern, sortby=CapImage.SEARCH_RELEVANCE, nsfw=False): """ search for a video file :param pattern: pattern to search on :type pattern: str :param sortby: sort by... (use SEARCH_* constants) :param nsfw: include non-suitable for work videos if True :type nsfw: bool :rtype: iter[:class:`BaseVideo`] """ return self.search_image(pattern, sortby, nsfw) def get_video(self, _id): """ Get a video file from an ID. :param _id: video file ID :type _id: str :rtype: :class:`BaseVideo` or None is fot found. """ return self.get_image(_id) weboob-1.1/weboob/capabilities/weather.py000066400000000000000000000077661265717027300206010ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from datetime import datetime, date from .base import Capability, BaseObject, Field, FloatField, \ StringField, UserError, NotLoaded from .date import DateField __all__ = ['Forecast', 'Current', 'City', 'CityNotFound', 'Temperature', 'CapWeather'] class Temperature(BaseObject): value = FloatField('Temperature value') unit = StringField('Input unit') def __init__(self, value=NotLoaded, unit = u''): BaseObject.__init__(self, unicode(value)) self.value = value if unit not in [u'C', u'F']: unit = u'' self.unit = unit def asfahrenheit(self): if not self.unit: return u'%s' % int(round(self.value)) elif self.unit == 'F': return u'%s °F' % int(round(self.value)) else: return u'%s °F' % int(round((self.value * 9.0 / 5.0) + 32)) def ascelsius(self): if not self.unit: return u'%s' % int(round(self.value)) elif self.unit == 'C': return u'%s °C' % int(round(self.value)) else: return u'%s °C' % int(round((self.value - 32.0) * 5.0 / 9.0)) def __repr__(self): if self.value is not None and self.unit: return u'%s %s' % (self.value, self.unit) class Forecast(BaseObject): """ Weather forecast. """ date = Field('Date for the forecast', datetime, date, basestring) low = Field('Low temperature', Temperature) high = Field('High temperature', Temperature) text = StringField('Comment on forecast') def __init__(self, date=NotLoaded, low=None, high=None, text=None, unit=None): BaseObject.__init__(self, unicode(date)) self.date = date self.low = Temperature(low, unit) self.high = Temperature(high, unit) self.text = text class Current(BaseObject): """ Current weather. """ date = DateField('Date of measure') text = StringField('Comment about current weather') temp = Field('Current temperature', Temperature) def __init__(self, date=NotLoaded, temp=None, text=None, unit=None): BaseObject.__init__(self, unicode(date)) self.date = date self.text = text self.temp = Temperature(temp, unit) class City(BaseObject): """ City where to find weather. """ name = StringField('Name of city') def __init__(self, id='', name=None): BaseObject.__init__(self, id) self.name = name class CityNotFound(UserError): """ Raised when a city is not found. """ class CapWeather(Capability): """ Capability for weather websites. """ def iter_city_search(self, pattern): """ Look for a city. :param pattern: pattern to search :type pattern: str :rtype: iter[:class:`City`] """ raise NotImplementedError() def get_current(self, city_id): """ Get current weather. :param city_id: ID of the city :rtype: :class:`Current` """ raise NotImplementedError() def iter_forecast(self, city_id): """ Iter forecasts of a city. :param city_id: ID of the city :rtype: iter[:class:`Forecast`] """ raise NotImplementedError() weboob-1.1/weboob/core/000077500000000000000000000000001265717027300150475ustar00rootroot00000000000000weboob-1.1/weboob/core/__init__.py000066400000000000000000000015231265717027300171610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .bcall import CallErrors from .ouiboube import Weboob, WebNip __all__ = ['CallErrors', 'Weboob', 'WebNip'] weboob-1.1/weboob/core/backendscfg.py000066400000000000000000000135431265717027300176610ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import stat import os import sys try: from ConfigParser import RawConfigParser, DuplicateSectionError except ImportError: from configparser import RawConfigParser, DuplicateSectionError from logging import warning __all__ = ['BackendsConfig', 'BackendAlreadyExists'] class BackendAlreadyExists(Exception): pass class BackendsConfig(object): """ Config of backends. A backend is an instance of a module with a config. A module can thus have multiple instances. """ class WrongPermissions(Exception): pass def __init__(self, confpath): self.confpath = confpath try: mode = os.stat(confpath).st_mode except OSError: if not os.path.isdir(os.path.dirname(confpath)): os.makedirs(os.path.dirname(confpath)) if sys.platform == 'win32': fptr = open(confpath, 'w') fptr.close() else: try: fd = os.open(confpath, os.O_WRONLY | os.O_CREAT, 0o600) os.close(fd) except OSError: fptr = open(confpath, 'w') fptr.close() os.chmod(confpath, 0o600) else: if sys.platform != 'win32': if mode & stat.S_IRGRP or mode & stat.S_IROTH: raise self.WrongPermissions( u'Weboob will not start as long as config file %s is readable by group or other users.' % confpath) def iter_backends(self): """ Iterate on backends. :returns: each tuple contains the backend name, module name and module options :rtype: :class:`tuple` """ config = RawConfigParser() config.read(self.confpath) changed = False for backend_name in config.sections(): params = dict(config.items(backend_name)) try: module_name = params.pop('_module') except KeyError: try: module_name = params.pop('_backend') config.set(backend_name, '_module', module_name) config.remove_option(backend_name, '_backend') changed = True except KeyError: warning('Missing field "_module" for configured backend "%s"', backend_name) continue yield backend_name, module_name, params if changed: with open(self.confpath, 'wb') as f: config.write(f) def backend_exists(self, name): """ Return True if the backend exists in config. """ config = RawConfigParser() config.read(self.confpath) return name in config.sections() def add_backend(self, backend_name, module_name, params, edit=False): """ Add a backend to config. :param backend_name: name of the backend in config :param module_name: name of the Python submodule to run :param params: params to pass to the module :type params: :class:`dict` """ if not backend_name: raise ValueError(u'Please give a name to the configured backend.') config = RawConfigParser() config.read(self.confpath) if not edit: try: config.add_section(backend_name) except DuplicateSectionError: raise BackendAlreadyExists(backend_name) config.set(backend_name, '_module', module_name) for key, value in params.iteritems(): if isinstance(value, unicode): value = value.encode('utf-8') config.set(backend_name, key, value) with open(self.confpath, 'wb') as f: config.write(f) def edit_backend(self, backend_name, module_name, params): """Edit a backend from config.""" return self.add_backend(backend_name, module_name, params, True) def get_backend(self, backend_name): """ Get options of backend. :returns: a tuple with the module name and the module options dict :rtype: tuple """ config = RawConfigParser() config.read(self.confpath) if not config.has_section(backend_name): raise KeyError(u'Configured backend "%s" not found' % backend_name) items = dict(config.items(backend_name)) try: module_name = items.pop('_module') except KeyError: try: module_name = items.pop('_backend') self.edit_backend(backend_name, module_name, items) except KeyError: warning('Missing field "_module" for configured backend "%s"', backend_name) raise KeyError(u'Configured backend "%s" not found' % backend_name) return module_name, items def remove_backend(self, backend_name): """Remove a backend from config.""" config = RawConfigParser() config.read(self.confpath) if not config.remove_section(backend_name): return False with open(self.confpath, 'w') as f: config.write(f) return True weboob-1.1/weboob/core/bcall.py000066400000000000000000000125671265717027300165110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon, Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from copy import copy from threading import Thread try: import Queue except ImportError: import queue as Queue from weboob.capabilities.base import BaseObject from weboob.tools.misc import get_backtrace from weboob.tools.log import getLogger __all__ = ['BackendsCall', 'CallErrors'] class CallErrors(Exception): def __init__(self, errors): msg = 'Errors during backend calls:\n' + \ '\n'.join(['Module(%r): %r\n%r\n' % (backend, error, backtrace) for backend, error, backtrace in errors]) Exception.__init__(self, msg) self.errors = copy(errors) def __iter__(self): return self.errors.__iter__() class BackendsCall(object): def __init__(self, backends, function, *args, **kwargs): """ :param backends: List of backends to call :type backends: list[:class:`Module`] :param function: backends' method name, or callable object. :type function: :class:`str` or :class:`callable` """ self.logger = getLogger('bcall') self.responses = Queue.Queue() self.errors = [] self.tasks = Queue.Queue() for backend in backends: Thread(target=self.backend_process, args=(function, args, kwargs)).start() self.tasks.put(backend) def store_result(self, backend, result): """Store the result when a backend task finished.""" if result is None: return if isinstance(result, BaseObject): result.backend = backend.name self.responses.put(result) def backend_process(self, function, args, kwargs): """ Internal method to run a method of a backend. As this method may be blocking, it should be run on its own thread. """ backend = self.tasks.get() with backend: try: # Call method on backend try: self.logger.debug('%s: Calling function %s', backend, function) if callable(function): result = function(backend, *args, **kwargs) else: result = getattr(backend, function)(*args, **kwargs) except Exception as error: self.logger.debug('%s: Called function %s raised an error: %r', backend, function, error) self.errors.append((backend, error, get_backtrace(error))) else: self.logger.debug('%s: Called function %s returned: %r', backend, function, result) if hasattr(result, '__iter__') and not isinstance(result, basestring): # Loop on iterator try: for subresult in result: self.store_result(backend, subresult) except Exception as error: self.errors.append((backend, error, get_backtrace(error))) else: self.store_result(backend, result) finally: self.tasks.task_done() def _callback_thread_run(self, callback, errback, finishback): while self.tasks.unfinished_tasks or not self.responses.empty(): try: response = self.responses.get(timeout=0.1) if callback: callback(response) except Queue.Empty: continue # Raise errors while errback and self.errors: errback(*self.errors.pop(0)) if finishback: finishback() def callback_thread(self, callback, errback=None, finishback=None): """ Call this method to create a thread which will callback a specified function everytimes a new result comes. When the process is over, the function will be called with both arguments set to None. The functions prototypes: def callback(result) def errback(backend, error, backtrace) def finishback() """ thread = Thread(target=self._callback_thread_run, args=(callback, errback, finishback)) thread.start() return thread def wait(self): """Wait until all tasks are finished.""" self.tasks.join() if self.errors: raise CallErrors(self.errors) def __iter__(self): while self.tasks.unfinished_tasks or not self.responses.empty(): try: yield self.responses.get(timeout=0.1) except Queue.Empty: continue if self.errors: raise CallErrors(self.errors) weboob-1.1/weboob/core/modules.py000066400000000000000000000141711265717027300170750ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import os import imp import logging from weboob.tools.backend import Module from weboob.tools.log import getLogger __all__ = ['LoadedModule', 'ModulesLoader', 'RepositoryModulesLoader', 'ModuleLoadError'] class ModuleLoadError(Exception): def __init__(self, module_name, msg): Exception.__init__(self, msg) self.module = module_name class LoadedModule(object): def __init__(self, package): self.logger = getLogger('backend') self.package = package self.klass = None for attrname in dir(self.package): attr = getattr(self.package, attrname) if isinstance(attr, type) and issubclass(attr, Module) and attr != Module: self.klass = attr if not self.klass: raise ImportError('%s is not a backend (no Module class found)' % package) @property def name(self): return self.klass.NAME @property def maintainer(self): return u'%s <%s>' % (self.klass.MAINTAINER, self.klass.EMAIL) @property def version(self): return self.klass.VERSION @property def description(self): return self.klass.DESCRIPTION @property def license(self): return self.klass.LICENSE @property def config(self): return self.klass.CONFIG @property def website(self): if self.klass.BROWSER and hasattr(self.klass.BROWSER, 'BASEURL') and self.klass.BROWSER.BASEURL: return self.klass.BROWSER.BASEURL if self.klass.BROWSER and hasattr(self.klass.BROWSER, 'DOMAIN') and self.klass.BROWSER.DOMAIN: return '%s://%s' % (self.klass.BROWSER.PROTOCOL, self.klass.BROWSER.DOMAIN) else: return None @property def icon(self): return self.klass.ICON def iter_caps(self): return self.klass.iter_caps() def has_caps(self, *caps): """Return True if module implements at least one of the caps.""" for c in caps: if (isinstance(c, basestring) and c in [cap.__name__ for cap in self.iter_caps()]) or \ (type(c) == type and issubclass(self.klass, c)): return True return False def create_instance(self, weboob, backend_name, config, storage): backend_instance = self.klass(weboob, backend_name, config, storage, self.logger) self.logger.debug(u'Created backend "%s" for module "%s"' % (backend_name, self.name)) return backend_instance class ModulesLoader(object): """ Load modules. """ def __init__(self, path, version=None): self.version = version self.path = path self.loaded = {} self.logger = getLogger('modules') def get_or_load_module(self, module_name): """ Can raise a ModuleLoadError exception. """ if module_name not in self.loaded: self.load_module(module_name) return self.loaded[module_name] def iter_existing_module_names(self): for name in os.listdir(self.path): try: if '__init__.py' in os.listdir(os.path.join(self.path, name)): yield name except OSError: # if path/name is not a directory continue def load_all(self): for existing_module_name in self.iter_existing_module_names(): try: self.load_module(existing_module_name) except ModuleLoadError as e: self.logger.warning(e) def load_module(self, module_name): if module_name in self.loaded: self.logger.debug('Module "%s" is already loaded from %s' % (module_name, self.loaded[module_name].package.__path__[0])) return path = self.get_module_path(module_name) try: fp, pathname, description = imp.find_module(module_name, [path]) try: module = LoadedModule(imp.load_module(module_name, fp, pathname, description)) finally: if fp: fp.close() except Exception as e: if logging.root.level <= logging.DEBUG: self.logger.exception(e) raise ModuleLoadError(module_name, e) if module.version != self.version: raise ModuleLoadError(module_name, "Module requires Weboob %s, but you use Weboob %s. Hint: use 'weboob-config update'" % (module.version, self.version)) self.loaded[module_name] = module self.logger.debug('Loaded module "%s" from %s' % (module_name, module.package.__path__[0])) def get_module_path(self, module_name): return self.path class RepositoryModulesLoader(ModulesLoader): """ Load modules from repositories. """ def __init__(self, repositories): super(RepositoryModulesLoader, self).__init__(repositories.modules_dir, repositories.version) self.repositories = repositories def iter_existing_module_names(self): for name in self.repositories.get_all_modules_info().iterkeys(): yield name def get_module_path(self, module_name): minfo = self.repositories.get_module_info(module_name) if minfo is None: raise ModuleLoadError(module_name, 'No such module %s' % module_name) if minfo.path is None: raise ModuleLoadError(module_name, 'Module %s is not installed' % module_name) return minfo.path weboob-1.1/weboob/core/ouiboube.py000066400000000000000000000425621265717027300172430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import os from weboob.core.bcall import BackendsCall from weboob.core.modules import ModulesLoader, RepositoryModulesLoader, ModuleLoadError from weboob.core.backendscfg import BackendsConfig from weboob.core.repositories import Repositories, PrintProgress from weboob.core.scheduler import Scheduler from weboob.tools.backend import Module from weboob.tools.config.iconfig import ConfigError from weboob.tools.log import getLogger __all__ = ['WebNip', 'Weboob'] class VersionsMismatchError(ConfigError): pass class WebNip(object): """ Weboob in Non Integrated Programs It provides methods to build backends or call methods on all loaded backends. :param modules_path: path to directory containing modules. :type modules_path: :class:`basestring` :param storage: provide a storage where backends can save data :type storage: :class:`weboob.tools.storage.IStorage` :param scheduler: what scheduler to use; default is :class:`weboob.core.scheduler.Scheduler` :type scheduler: :class:`weboob.core.scheduler.IScheduler` """ VERSION = '1.1' def __init__(self, modules_path=None, storage=None, scheduler=None): self.logger = getLogger('weboob') self.backend_instances = {} self.callbacks = {'login': lambda backend_name, value: None, 'captcha': lambda backend_name, image: None, } if modules_path is None: import pkg_resources modules_path = pkg_resources.resource_filename('weboob_modules', '') if modules_path: self.modules_loader = ModulesLoader(modules_path, self.VERSION) if scheduler is None: scheduler = Scheduler() self.scheduler = scheduler self.storage = storage def __deinit__(self): self.deinit() def deinit(self): """ Call this method when you stop using Weboob, to properly unload all correctly. """ self.unload_backends() def build_backend(self, module_name, params=None, storage=None, name=None): """ Create a backend. It does not load it into the Weboob object, so you are responsible for deinitialization and calls. :param module_name: name of module :param params: parameters to give to backend :type params: :class:`dict` :param storage: storage to use :type storage: :class:`weboob.tools.storage.IStorage` :param name: name of backend :type name: :class:`basestring` :rtype: :class:`weboob.tools.backend.Module` """ module = self.modules_loader.get_or_load_module(module_name) backend_instance = module.create_instance(self, name or module_name, params or {}, storage) return backend_instance class LoadError(Exception): """ Raised when a backend is unabled to load. :param backend_name: name of backend we can't load :param exception: exception object """ def __init__(self, backend_name, exception): Exception.__init__(self, unicode(exception)) self.backend_name = backend_name def load_backend(self, module_name, name, params=None, storage=None): """ Load a backend. :param module_name: name of module to load :type module_name: :class:`basestring`: :param name: name of instance :type name: :class:`basestring` :param params: parameters to give to backend :type params: :class:`dict` :param storage: storage to use :type storage: :class:`weboob.tools.storage.IStorage` :rtype: :class:`weboob.tools.backend.Module` """ if name is None: name = module_name if name in self.backend_instances: raise self.LoadError(name, 'A loaded backend already named "%s"' % name) backend = self.build_backend(module_name, params, storage, name) self.backend_instances[name] = backend return backend def unload_backends(self, names=None): """ Unload backends. :param names: if specified, only unload that backends :type names: :class:`list` """ unloaded = {} if isinstance(names, basestring): names = [names] elif names is None: names = self.backend_instances.keys() for name in names: backend = self.backend_instances.pop(name) with backend: backend.deinit() unloaded[backend.name] = backend return unloaded def __getitem__(self, name): """ Alias for :func:`WebNip.get_backend`. """ return self.get_backend(name) def get_backend(self, name, **kwargs): """ Get a backend from its name. :param name: name of backend to get :type name: str :param default: if specified, get this value when the backend is not found :type default: whatever you want :raises: :class:`KeyError` if not found. """ try: return self.backend_instances[name] except KeyError: if 'default' in kwargs: return kwargs['default'] else: raise def count_backends(self): """ Get number of loaded backends. """ return len(self.backend_instances) def iter_backends(self, caps=None, module=None): """ Iter on each backends. Note: each backend is locked when it is returned. :param caps: optional list of capabilities to select backends :type caps: tuple[:class:`weboob.capabilities.base.Capability`] :param module: optional name of module :type module: :class:`basestring` :rtype: iter[:class:`weboob.tools.backend.Module`] """ for _, backend in sorted(self.backend_instances.iteritems()): if (caps is None or backend.has_caps(caps)) and \ (module is None or backend.NAME == module): with backend: yield backend def __getattr__(self, name): def caller(*args, **kwargs): return self.do(name, *args, **kwargs) return caller def do(self, function, *args, **kwargs): r""" Do calls on loaded backends with specified arguments, in separated threads. This function has two modes: - If *function* is a string, it calls the method with this name on each backends with the specified arguments; - If *function* is a callable, it calls it in a separated thread with the locked backend instance at first arguments, and \*args and \*\*kwargs. :param function: backend's method name, or a callable object :type function: :class:`str` :param backends: list of backends to iterate on :type backends: list[:class:`str`] :param caps: iterate on backends which implement this caps :type caps: list[:class:`weboob.capabilities.base.Capability`] :rtype: A :class:`weboob.core.bcall.BackendsCall` object (iterable) """ backends = self.backend_instances.values() _backends = kwargs.pop('backends', None) if _backends is not None: if isinstance(_backends, Module): backends = [_backends] elif isinstance(_backends, basestring): if len(_backends) > 0: try: backends = [self.backend_instances[_backends]] except (ValueError, KeyError): backends = [] elif isinstance(_backends, (list, tuple, set)): backends = [] for backend in _backends: if isinstance(backend, basestring): try: backends.append(self.backend_instances[backend]) except (ValueError, KeyError): pass else: backends.append(backend) else: self.logger.warning(u'The "backends" value isn\'t supported: %r', _backends) if 'caps' in kwargs: caps = kwargs.pop('caps') backends = [backend for backend in backends if backend.has_caps(caps)] # The return value MUST BE the BackendsCall instance. Please never iterate # here on this object, because caller might want to use other methods, like # wait() on callback_thread(). # Thanks a lot. return BackendsCall(backends, function, *args, **kwargs) def schedule(self, interval, function, *args): """ Schedule an event. :param interval: delay before calling the function :type interval: int :param function: function to call :type function: callabale :param args: arguments to give to function :returns: an event identificator """ return self.scheduler.schedule(interval, function, *args) def repeat(self, interval, function, *args): """ Repeat a call to a function :param interval: interval between two calls :type interval: int :param function: function to call :type function: callable :param args: arguments to give to function :returns: an event identificator """ return self.scheduler.repeat(interval, function, *args) def cancel(self, ev): """ Cancel an event :param ev: the event identificator """ return self.scheduler.cancel(ev) def want_stop(self): """ Plan to stop the scheduler. """ return self.scheduler.want_stop() def loop(self): """ Run the scheduler loop """ return self.scheduler.run() class Weboob(WebNip): """ The main class of Weboob, used to manage backends, modules repositories and call methods on all loaded backends. :param workdir: optional parameter to set path of the working directory :type workdir: str :param datadir: optional parameter to set path of the data directory :type datadir: str :param backends_filename: name of the *backends* file, where configuration of backends is stored :type backends_filename: str :param storage: provide a storage where backends can save data :type storage: :class:`weboob.tools.storage.IStorage` """ BACKENDS_FILENAME = 'backends' def __init__(self, workdir=None, datadir=None, backends_filename=None, scheduler=None, storage=None): super(Weboob, self).__init__(modules_path=False, scheduler=scheduler, storage=storage) # Create WORKDIR if workdir is None: if 'WEBOOB_WORKDIR' in os.environ: workdir = os.environ['WEBOOB_WORKDIR'] else: workdir = os.path.join(os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), '.config')), 'weboob') self.workdir = os.path.realpath(workdir) self._create_dir(workdir) # Create DATADIR if datadir is None: if 'WEBOOB_DATADIR' in os.environ: datadir = os.environ['WEBOOB_DATADIR'] elif 'WEBOOB_WORKDIR' in os.environ: datadir = os.environ['WEBOOB_WORKDIR'] else: datadir = os.path.join(os.environ.get('XDG_DATA_HOME', os.path.join(os.path.expanduser('~'), '.local', 'share')), 'weboob') _datadir = os.path.realpath(datadir) self._create_dir(_datadir) # Modules management self.repositories = Repositories(workdir, _datadir, self.VERSION) self.modules_loader = RepositoryModulesLoader(self.repositories) # Backend instances config if not backends_filename: backends_filename = os.environ.get('WEBOOB_BACKENDS', os.path.join(self.workdir, self.BACKENDS_FILENAME)) elif not backends_filename.startswith('/'): backends_filename = os.path.join(self.workdir, backends_filename) self.backends_config = BackendsConfig(backends_filename) def _create_dir(self, name): if not os.path.exists(name): os.makedirs(name) elif not os.path.isdir(name): self.logger.error(u'"%s" is not a directory', name) def update(self, progress=PrintProgress()): """ Update modules from repositories. """ self.repositories.update(progress) modules_to_check = set([module_name for _, module_name, _ in self.backends_config.iter_backends()]) for module_name in modules_to_check: minfo = self.repositories.get_module_info(module_name) if minfo and not minfo.is_installed(): self.repositories.install(minfo, progress) def build_backend(self, module_name, params=None, storage=None, name=None): """ Create a single backend which is not listed in configuration. :param module_name: name of module :param params: parameters to give to backend :type params: :class:`dict` :param storage: storage to use :type storage: :class:`weboob.tools.storage.IStorage` :param name: name of backend :type name: :class:`basestring` :rtype: :class:`weboob.tools.backend.Module` """ minfo = self.repositories.get_module_info(module_name) if minfo is None: raise ModuleLoadError(module_name, 'Module does not exist.') if not minfo.is_installed(): self.repositories.install(minfo) return super(Weboob, self).build_backend(module_name, params, storage, name) def load_backends(self, caps=None, names=None, modules=None, exclude=None, storage=None, errors=None): """ Load backends listed in config file. :param caps: load backends which implement all of specified caps :type caps: tuple[:class:`weboob.capabilities.base.Capability`] :param names: load backends in list :type names: tuple[:class:`str`] :param modules: load backends which module is in list :type modules: tuple[:class:`str`] :param exclude: do not load backends in list :type exclude: tuple[:class:`str`] :param storage: use this storage if specified :type storage: :class:`weboob.tools.storage.IStorage` :param errors: if specified, store every errors in this list :type errors: list[:class:`LoadError`] :returns: loaded backends :rtype: dict[:class:`str`, :class:`weboob.tools.backend.Module`] """ loaded = {} if storage is None: storage = self.storage if not self.repositories.check_repositories(): self.logger.error(u'Repositories are not consistent with the sources.list') raise VersionsMismatchError(u'Versions mismatch, please run "weboob-config update"') for backend_name, module_name, params in self.backends_config.iter_backends(): if '_enabled' in params and not params['_enabled'].lower() in ('1', 'y', 'true', 'on', 'yes') or \ names is not None and backend_name not in names or \ modules is not None and module_name not in modules or \ exclude is not None and backend_name in exclude: continue minfo = self.repositories.get_module_info(module_name) if minfo is None: self.logger.warning(u'Backend "%s" is referenced in %s but was not found. ' u'Perhaps a missing repository or a removed module?', module_name, self.backends_config.confpath) continue if caps is not None and not minfo.has_caps(caps): continue if not minfo.is_installed(): self.repositories.install(minfo) module = None try: module = self.modules_loader.get_or_load_module(module_name) except ModuleLoadError as e: self.logger.error(u'Unable to load module "%s": %s', module_name, e) continue if backend_name in self.backend_instances: self.logger.warning(u'Oops, the backend "%s" is already loaded. Unload it before reloading...', backend_name) self.unload_backends(backend_name) try: backend_instance = module.create_instance(self, backend_name, params, storage) except Module.ConfigError as e: if errors is not None: errors.append(self.LoadError(backend_name, e)) else: self.backend_instances[backend_name] = loaded[backend_name] = backend_instance return loaded weboob-1.1/weboob/core/repositories.py000066400000000000000000000704501265717027300201560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import imp import posixpath import shutil import re import sys import os import subprocess import hashlib from datetime import datetime from contextlib import closing from compileall import compile_dir from io import BytesIO from weboob.exceptions import BrowserHTTPError, BrowserHTTPNotFound from .modules import LoadedModule from weboob.tools.log import getLogger from weboob.tools.misc import get_backtrace, to_unicode, find_exe try: from ConfigParser import RawConfigParser, DEFAULTSECT except ImportError: from configparser import RawConfigParser, DEFAULTSECT class ModuleInfo(object): """ Information about a module available on a repository. """ def __init__(self, name): self.name = name # path to the local directory containing this module. self.path = None self.url = None self.repo_url = None self.version = 0 self.capabilities = () self.description = u'' self.maintainer = u'' self.license = u'' self.icon = u'' self.urls = u'' def load(self, items): self.version = int(items['version']) self.capabilities = items['capabilities'].split() self.description = to_unicode(items['description']) self.maintainer = to_unicode(items['maintainer']) self.license = to_unicode(items['license']) self.icon = items['icon'].strip() or None self.urls = items['urls'] def has_caps(self, caps): """Return True if module implements at least one of the caps.""" if not isinstance(caps, (list, tuple)): caps = [caps] for c in caps: if type(c) == type: c = c.__name__ if c in self.capabilities: return True return False def is_installed(self): return self.path is not None def is_local(self): return self.url is None def dump(self): return (('version', self.version), ('capabilities', ' '.join(self.capabilities)), ('description', self.description), ('maintainer', self.maintainer), ('license', self.license), ('icon', self.icon or ''), ('urls', self.urls), ) class RepositoryUnavailable(Exception): """ Repository in not available. """ class Repository(object): """ Represents a repository. """ INDEX = 'modules.list' KEYDIR = '.keys' KEYRING = 'trusted.gpg' def __init__(self, url): self.url = url self.name = u'' self.update = 0 self.maintainer = u'' self.local = None self.signed = False self.key_update = 0 self.logger = getLogger('repository') self.modules = {} if self.url.startswith('file://'): self.local = True elif re.match('https?://.*', self.url): self.local = False else: # This is probably a file in ~/.weboob/repositories/, we # don't know if this is a local or a remote repository. with open(self.url, 'r') as fp: self.parse_index(fp) def __repr__(self): return '' % self.name def localurl2path(self): """ Get a local path of a file:// URL. """ assert self.local is True if self.url.startswith('file://'): return self.url[len('file://'):] return self.url def retrieve_index(self, browser, repo_path): """ Retrieve the index file of this repository. It can use network if this is a remote repository. :param repo_path: path to save the downloaded index file. :type repo_path: str """ if self.local: # Repository is local, open the file. filename = os.path.join(self.localurl2path(), self.INDEX) try: fp = open(filename, 'r') except IOError as e: # This local repository doesn't contain a built modules.list index. self.name = Repositories.url2filename(self.url) self.build_index(self.localurl2path(), filename) fp = open(filename, 'r') else: # This is a remote repository, download file try: fp = BytesIO(browser.open(posixpath.join(self.url, self.INDEX)).content) except BrowserHTTPError as e: raise RepositoryUnavailable(unicode(e)) self.parse_index(fp) if self.local: # Always rebuild index of a local repository. self.build_index(self.localurl2path(), filename) # Save the repository index in ~/.weboob/repositories/ self.save(repo_path, private=True) def retrieve_keyring(self, browser, keyring_path, progress): # ignore local if self.local: return keyring = Keyring(keyring_path) # prevent previously signed repos from going unsigned if not self.signed and keyring.exists(): raise RepositoryUnavailable('Previously signed repository can not go unsigned') if not self.signed: return if not keyring.exists() or self.key_update > keyring.version: # This is a remote repository, download file try: keyring_data = browser.open(posixpath.join(self.url, self.KEYRING)).content sig_data = browser.open(posixpath.join(self.url, self.KEYRING + '.sig')).content except BrowserHTTPError as e: raise RepositoryUnavailable(unicode(e)) if keyring.exists(): if not keyring.is_valid(keyring_data, sig_data): raise InvalidSignature('the keyring itself') progress.progress(0.0, 'The keyring was updated (and validated by the previous one).') elif not progress.prompt('The repository %s isn\'t trusted yet.\nFingerprint of keyring is %s\nAre you sure you want to continue?' % (self.url, hashlib.sha1(keyring_data).hexdigest())): raise RepositoryUnavailable('Repository not trusted') keyring.save(keyring_data, self.key_update) progress.progress(0.0, str(keyring)) def parse_index(self, fp): """ Parse index of a repository :param fp: file descriptor to read :type fp: buffer """ config = RawConfigParser() config.readfp(fp) # Read default parameters items = dict(config.items(DEFAULTSECT)) try: self.name = items['name'] self.update = int(items['update']) self.maintainer = items['maintainer'] self.signed = bool(int(items.get('signed', '0'))) self.key_update = int(items.get('key_update', '0')) except KeyError as e: raise RepositoryUnavailable('Missing global parameters in repository: %s' % e) except ValueError as e: raise RepositoryUnavailable('Incorrect value in repository parameters: %s' % e) if len(self.name) == 0: raise RepositoryUnavailable('Name is empty') if 'url' in items: self.url = items['url'] self.local = self.url.startswith('file://') elif self.local is None: raise RepositoryUnavailable('Missing "url" key in settings') # Load modules self.modules.clear() for section in config.sections(): module = ModuleInfo(section) module.load(dict(config.items(section))) if not self.local: module.url = posixpath.join(self.url, '%s.tar.gz' % module.name) module.repo_url = self.url module.signed = self.signed self.modules[section] = module def build_index(self, path, filename): """ Rebuild index of modules of repository. :param path: path of the repository :type path: str :param filename: file to save index :type filename: str """ print('Rebuild index') self.modules.clear() if os.path.isdir(os.path.join(path, self.KEYDIR)): self.signed = True self.key_update = self.get_tree_mtime(os.path.join(path, self.KEYDIR), True) else: self.signed = False self.key_update = 0 for name in sorted(os.listdir(path)): module_path = os.path.join(path, name) if not os.path.isdir(module_path) or '.' in name or name == self.KEYDIR: continue try: fp, pathname, description = imp.find_module(name, [path]) try: module = LoadedModule(imp.load_module(name, fp, pathname, description)) finally: if fp: fp.close() except Exception as e: print('Unable to build module %s: [%s] %s' % (name, type(e).__name__, e), file=sys.stderr) self.logger.debug(get_backtrace(e)) else: m = ModuleInfo(module.name) m.version = self.get_tree_mtime(module_path) m.capabilities = list(set([c.__name__ for c in module.iter_caps()])) m.description = module.description m.maintainer = module.maintainer m.license = module.license m.icon = module.icon or '' self.modules[module.name] = m self.update = int(datetime.now().strftime('%Y%m%d%H%M')) self.save(filename) @staticmethod def get_tree_mtime(path, include_root=False): mtime = 0 if include_root: mtime = int(datetime.fromtimestamp(os.path.getmtime(path)).strftime('%Y%m%d%H%M')) for root, dirs, files in os.walk(path): for f in files: if f.endswith('.pyc'): continue m = int(datetime.fromtimestamp(os.path.getmtime(os.path.join(root, f))).strftime('%Y%m%d%H%M')) mtime = max(mtime, m) return mtime def save(self, filename, private=False): """ Save repository into a file (modules.list for example). :param filename: path to file to save repository. :type filename: str :param private: if enabled, save URL of repository. :type private: bool """ config = RawConfigParser() config.set(DEFAULTSECT, 'name', self.name) config.set(DEFAULTSECT, 'update', self.update) config.set(DEFAULTSECT, 'maintainer', self.maintainer) config.set(DEFAULTSECT, 'signed', int(self.signed)) config.set(DEFAULTSECT, 'key_update', self.key_update) if private: config.set(DEFAULTSECT, 'url', self.url) for module in self.modules.itervalues(): config.add_section(module.name) for key, value in module.dump(): config.set(module.name, key, to_unicode(value).encode('utf-8')) with open(filename, 'wb') as f: config.write(f) class Versions(object): VERSIONS_LIST = 'versions.list' def __init__(self, path): self.path = path self.versions = {} try: with open(os.path.join(self.path, self.VERSIONS_LIST), 'r') as fp: config = RawConfigParser() config.readfp(fp) # Read default parameters for key, value in config.items(DEFAULTSECT): self.versions[key] = int(value) except IOError: pass def get(self, name): return self.versions.get(name, None) def set(self, name, version): self.versions[name] = int(version) self.save() def save(self): config = RawConfigParser() for name, version in self.versions.iteritems(): config.set(DEFAULTSECT, name, version) with open(os.path.join(self.path, self.VERSIONS_LIST), 'wb') as fp: config.write(fp) class IProgress(object): def progress(self, percent, message): raise NotImplementedError() def error(self, message): raise NotImplementedError() def prompt(self, message): raise NotImplementedError() def __repr__(self): return '<%s>' % self.__class__.__name__ class PrintProgress(IProgress): def progress(self, percent, message): print('=== [%3.0f%%] %s' % (percent*100, message)) def error(self, message): print('ERROR: %s' % message, file=sys.stderr) def prompt(self, message): print('%s (Y/n): *** ASSUMING YES ***' % message) return True class ModuleInstallError(Exception): pass DEFAULT_SOURCES_LIST = \ """# List of Weboob repositories # # The entries below override the entries above (with # backends of the same name). http://updates.weboob.org/%(version)s/main/ # DEVELOPMENT # If you want to hack on Weboob modules, you may add a # reference to sources, for example: #file:///home/rom1/src/weboob/modules/ """ class Repositories(object): SOURCES_LIST = 'sources.list' MODULES_DIR = 'modules' REPOS_DIR = 'repositories' KEYRINGS_DIR = 'keyrings' ICONS_DIR = 'icons' SHARE_DIRS = [MODULES_DIR, REPOS_DIR, KEYRINGS_DIR, ICONS_DIR] def __init__(self, workdir, datadir, version): self.logger = getLogger('repositories') self.version = version self.browser = None self.workdir = workdir self.datadir = datadir self.sources_list = os.path.join(self.workdir, self.SOURCES_LIST) self.modules_dir = os.path.join(self.datadir, self.MODULES_DIR, self.version) self.repos_dir = os.path.join(self.datadir, self.REPOS_DIR) self.keyrings_dir = os.path.join(self.datadir, self.KEYRINGS_DIR) self.icons_dir = os.path.join(self.datadir, self.ICONS_DIR) self.create_dir(self.datadir) self.create_dir(self.modules_dir) self.create_dir(self.repos_dir) self.create_dir(self.keyrings_dir) self.create_dir(self.icons_dir) self.versions = Versions(self.modules_dir) self.repositories = [] if not os.path.exists(self.sources_list): with open(self.sources_list, 'w') as f: f.write(DEFAULT_SOURCES_LIST) self.update() else: self.load() def load_browser(self): from weboob.browser.browsers import Browser from weboob.browser.profiles import Weboob as WeboobProfile class WeboobBrowser(Browser): PROFILE = WeboobProfile(self.version) if self.browser is None: self.browser = WeboobBrowser() def create_dir(self, name): if not os.path.exists(name): os.makedirs(name) elif not os.path.isdir(name): self.logger.error(u'"%s" is not a directory' % name) def _extend_module_info(self, repo, info): if repo.local: info.path = repo.localurl2path() elif self.versions.get(info.name) is not None: info.path = self.modules_dir return info def get_all_modules_info(self, caps=None): """ Get all ModuleInfo instances available. :param caps: filter on capabilities: :type caps: list[str] :rtype: dict[:class:`ModuleInfo`] """ modules = {} for repos in reversed(self.repositories): for name, info in repos.modules.iteritems(): if name not in modules and (not caps or info.has_caps(caps)): modules[name] = self._extend_module_info(repos, info) return modules def get_module_info(self, name): """ Get ModuleInfo object of a module. It tries all repositories from last to first, and set the 'path' attribute of ModuleInfo if it is installed. """ for repos in reversed(self.repositories): if name in repos.modules: m = repos.modules[name] self._extend_module_info(repos, m) return m return None def load(self): """ Load repositories from ~/.local/share/weboob/repositories/. """ self.repositories = [] for name in sorted(os.listdir(self.repos_dir)): path = os.path.join(self.repos_dir, name) try: repository = Repository(path) self.repositories.append(repository) except RepositoryUnavailable as e: print('Unable to load repository %s (%s), try to update repositories.' % (name, e), file=sys.stderr) def get_module_icon_path(self, module): return os.path.join(self.icons_dir, '%s.png' % module.name) def retrieve_icon(self, module): """ Retrieve the icon of a module and save it in ~/.local/share/weboob/icons/. """ self.load_browser() if not isinstance(module, ModuleInfo): module = self.get_module_info(module) dest_path = self.get_module_icon_path(module) icon_url = module.icon if not icon_url: if module.is_local(): icon_path = os.path.join(module.path, module.name, 'favicon.png') if module.path and os.path.exists(icon_path): shutil.copy(icon_path, dest_path) return else: icon_url = module.url.replace('.tar.gz', '.png') try: icon = self.browser.open(icon_url) except BrowserHTTPNotFound: pass # no icon, no problem else: with open(dest_path, 'wb') as fp: fp.write(icon.content) def _parse_source_list(self): l = [] with open(self.sources_list, 'r') as f: for line in f: line = line.strip() % {'version': self.version} m = re.match('(file|https?)://.*', line) if m: l.append(line) return l def update_repositories(self, progress=PrintProgress()): self.load_browser() """ Update list of repositories by downloading them and put them in ~/.local/share/weboob/repositories/. :param progress: observer object. :type progress: :class:`IProgress` """ self.repositories = [] for name in os.listdir(self.repos_dir): os.remove(os.path.join(self.repos_dir, name)) gpg_found = Keyring.find_gpg() or Keyring.find_gpgv() for line in self._parse_source_list(): progress.progress(0.0, 'Getting %s' % line) repository = Repository(line) filename = self.url2filename(repository.url) prio_filename = '%02d-%s' % (len(self.repositories), filename) repo_path = os.path.join(self.repos_dir, prio_filename) keyring_path = os.path.join(self.keyrings_dir, filename) try: repository.retrieve_index(self.browser, repo_path) if gpg_found: repository.retrieve_keyring(self.browser, keyring_path, progress) else: progress.error('Cannot find gpg or gpgv to check for repository authenticity.\n' 'You should install GPG for better security.') except RepositoryUnavailable as e: progress.error('Unable to load repository: %s' % e) else: self.repositories.append(repository) def check_repositories(self): """ Check if sources.list is consistent with repositories """ l = [] for line in self._parse_source_list(): repository = Repository(line) filename = self.url2filename(repository.url) prio_filename = '%02d-%s' % (len(l), filename) repo_path = os.path.join(self.repos_dir, prio_filename) if not os.path.isfile(repo_path): return False l.append(repository) return True def update(self, progress=PrintProgress()): """ Update repositories and install new packages versions. :param progress: observer object. :type progress: :class:`IProgress` """ self.update_repositories(progress) to_update = [] for name, info in self.get_all_modules_info().iteritems(): if not info.is_local() and info.is_installed(): to_update.append(info) if len(to_update) == 0: progress.progress(1.0, 'All modules are up-to-date.') return class InstallProgress(PrintProgress): def __init__(self, n): self.n = n def progress(self, percent, message): progress.progress(float(self.n)/len(to_update) + 1.0/len(to_update)*percent, message) for n, info in enumerate(to_update): inst_progress = InstallProgress(n) try: self.install(info, inst_progress) except ModuleInstallError as e: inst_progress.progress(1.0, unicode(e)) def install(self, module, progress=PrintProgress()): """ Install a module. :param module: module to install :type module: :class:`str` or :class:`ModuleInfo` :param progress: observer object :type progress: :class:`IProgress` """ import tarfile self.load_browser() if isinstance(module, ModuleInfo): info = module elif isinstance(module, basestring): progress.progress(0.0, 'Looking for module %s' % module) info = self.get_module_info(module) if not info: raise ModuleInstallError('Module "%s" does not exist' % module) else: raise ValueError('"module" parameter might be a ModuleInfo object or a string, not %r' % module) module = info if module.is_local(): raise ModuleInstallError('%s is available on local.' % module.name) module_dir = os.path.join(self.modules_dir, module.name) installed = self.versions.get(module.name) if installed is None or not os.path.exists(module_dir): progress.progress(0.3, 'Module %s is not installed yet' % module.name) elif module.version > installed: progress.progress(0.3, 'A new version of %s is available' % module.name) else: raise ModuleInstallError('The latest version of %s is already installed' % module.name) progress.progress(0.2, 'Downloading module...') try: tardata = self.browser.open(module.url).content except BrowserHTTPError as e: raise ModuleInstallError('Unable to fetch module: %s' % e) # Check signature if module.signed and (Keyring.find_gpg() or Keyring.find_gpgv()): progress.progress(0.5, 'Checking module authenticity...') sig_data = self.browser.open(posixpath.join(module.url + '.sig')).content keyring_path = os.path.join(self.keyrings_dir, self.url2filename(module.repo_url)) keyring = Keyring(keyring_path) if not keyring.exists(): raise ModuleInstallError('No keyring found, please update repos.') if not keyring.is_valid(tardata, sig_data): raise ModuleInstallError('Invalid signature for %s.' % module.name) # Extract module from tarball. if os.path.isdir(module_dir): shutil.rmtree(module_dir) progress.progress(0.7, 'Setting up module...') with closing(tarfile.open('', 'r:gz', BytesIO(tardata))) as tar: tar.extractall(self.modules_dir) if not os.path.isdir(module_dir): raise ModuleInstallError('The archive for %s looks invalid.' % module.name) # Precompile compile_dir(module_dir, quiet=True) self.versions.set(module.name, module.version) progress.progress(0.9, 'Downloading icon...') self.retrieve_icon(module) progress.progress(1.0, 'Module %s has been installed!' % module.name) @staticmethod def url2filename(url): """ Get a safe file name for an URL. All non-alphanumeric characters are replaced by _. """ return ''.join([l if l.isalnum() else '_' for l in url]) class InvalidSignature(Exception): def __init__(self, filename): self.filename = filename Exception.__init__(self, 'Invalid signature for %s' % filename) class Keyring(object): EXTENSION = '.gpg' def __init__(self, path): self.path = path + self.EXTENSION self.vpath = path + '.version' self.version = 0 if self.exists(): with open(self.vpath, 'r') as f: self.version = int(f.read().strip()) else: if os.path.exists(self.path): os.remove(self.path) if os.path.exists(self.vpath): os.remove(self.vpath) def exists(self): if not os.path.exists(self.vpath): return False if os.path.exists(self.path): # Check the file is not empty. # This is because there was a bug creating empty keyring files. with open(self.path, 'r') as fp: if len(fp.read().strip()): return True return False def save(self, keyring_data, version): with open(self.path, 'wb') as fp: fp.write(keyring_data) self.version = version with open(self.vpath, 'wb') as fp: fp.write(str(version)) @staticmethod def find_gpgv(): return find_exe('gpgv2') or find_exe('gpgv') @staticmethod def find_gpg(): return find_exe('gpg2') or find_exe('gpg') def is_valid(self, data, sigdata): """ Check if the data is signed by an accepted key. data and sigdata should be strings. """ gpg = self.find_gpg() gpgv = self.find_gpgv() if gpg: from tempfile import mkdtemp gpg_homedir = mkdtemp(prefix='weboob_gpg_') verify_command = [gpg, '--verify', '--no-options', '--no-default-keyring', '--quiet', '--homedir', gpg_homedir] elif gpgv: verify_command = [gpgv] from tempfile import NamedTemporaryFile with NamedTemporaryFile(suffix='.sig', delete=False) as sigfile: temp_filename = sigfile.name return_code = None out = '' err = '' try: sigfile.write(sigdata) sigfile.flush() # very important assert isinstance(data, basestring) # Yes, all of it is necessary proc = subprocess.Popen(verify_command + [ '--status-fd', '1', '--keyring', os.path.realpath(self.path), os.path.realpath(sigfile.name), '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = proc.communicate(data) return_code = proc.returncode finally: os.unlink(temp_filename) if gpg: shutil.rmtree(gpg_homedir) if return_code or 'GOODSIG' not in out or 'VALIDSIG' not in out: print(out, err, file=sys.stderr) return False return True def __str__(self): if self.exists(): with open(self.path, 'r') as f: h = hashlib.sha1(f.read()).hexdigest() return 'Keyring version %s, checksum %s' % (self.version, h) return 'NO KEYRING' weboob-1.1/weboob/core/scheduler.py000066400000000000000000000122041265717027300173760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from threading import Event, RLock try: from threading import _Timer as Timer except ImportError: from threading import Timer from weboob.tools.log import getLogger from weboob.tools.misc import get_backtrace __all__ = ['Scheduler'] class IScheduler(object): """Interface of a scheduler.""" def schedule(self, interval, function, *args): """ Schedule an event. :param interval: delay before calling the function :type interval: int :param function: function to call :type function: callabale :param args: arguments to give to function :returns: an event identificator """ raise NotImplementedError() def repeat(self, interval, function, *args): """ Repeat a call to a function :param interval: interval between two calls :type interval: int :param function: function to call :type function: callable :param args: arguments to give to function :returns: an event identificator """ raise NotImplementedError() def cancel(self, ev): """ Cancel an event :param ev: the event identificator """ raise NotImplementedError() def run(self): """ Run the scheduler loop """ raise NotImplementedError() def want_stop(self): """ Plan to stop the scheduler. """ raise NotImplementedError() class RepeatedTimer(Timer): def run(self): while not self.finished.isSet(): try: self.function(*self.args, **self.kwargs) except Exception: # do not stop timer because of an exception print(get_backtrace()) self.finished.wait(self.interval) self.finished.set() class Scheduler(IScheduler): """Scheduler using Python's :mod:`threading`.""" def __init__(self): self.logger = getLogger('scheduler') self.mutex = RLock() self.stop_event = Event() self.count = 0 self.queue = {} def schedule(self, interval, function, *args): return self._schedule(Timer, interval, self._schedule_callback, function, *args) def repeat(self, interval, function, *args): return self._schedule(RepeatedTimer, interval, self._repeat_callback, function, *args) def _schedule(self, klass, interval, meta_func, function, *args): if self.stop_event.isSet(): return with self.mutex: self.count += 1 self.logger.debug('function "%s" will be called in %s seconds' % (function.__name__, interval)) timer = klass(interval, meta_func, (self.count, interval, function, args)) self.queue[self.count] = timer timer.start() return self.count def _schedule_callback(self, count, interval, function, args): with self.mutex: self.queue.pop(count) return function(*args) def _repeat_callback(self, count, interval, function, args): function(*args) with self.mutex: try: e = self.queue[count] except KeyError: return else: self.logger.debug('function "%s" will be called in %s seconds' % (function.__name__, e.interval)) def cancel(self, ev): with self.mutex: try: e = self.queue.pop(ev) except KeyError: return False e.cancel() self.logger.debug('scheduled function "%s" is canceled' % e.function.__name__) return True def _wait_to_stop(self): self.want_stop() with self.mutex: for e in self.queue.itervalues(): e.cancel() e.join() self.queue = {} def run(self): try: while True: self.stop_event.wait(0.1) except KeyboardInterrupt: self._wait_to_stop() raise else: self._wait_to_stop() return True def want_stop(self): self.stop_event.set() with self.mutex: for t in self.queue.itervalues(): t.cancel() # Contrary to _wait_to_stop(), don't call t.join # because want_stop() have to be non-blocking. self.queue = {} weboob-1.1/weboob/deprecated/000077500000000000000000000000001265717027300162175ustar00rootroot00000000000000weboob-1.1/weboob/deprecated/__init__.py000066400000000000000000000000001265717027300203160ustar00rootroot00000000000000weboob-1.1/weboob/deprecated/browser/000077500000000000000000000000001265717027300177025ustar00rootroot00000000000000weboob-1.1/weboob/deprecated/browser/__init__.py000066400000000000000000000027441265717027300220220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser.browser import BrowserIncorrectPassword, BrowserBanned, \ BrowserUnavailable, BrowserRetry, \ BrowserHTTPNotFound, BrowserHTTPError, \ Page, Browser, BrokenPageError, \ StandardBrowser, BrowserPasswordExpired, \ BrowserForbidden, StateBrowser __all__ = ['BrowserIncorrectPassword', 'BrowserPasswordExpired', 'BrowserBanned', 'BrowserUnavailable', 'BrowserRetry', 'BrowserHTTPNotFound', 'BrowserHTTPError', 'Page', 'Browser', 'BrokenPageError', 'StandardBrowser', 'BrowserForbidden', 'StateBrowser'] weboob-1.1/weboob/deprecated/browser/browser.py000066400000000000000000000656631265717027300217570ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import sys if sys.version_info >= (3,0): raise ImportError("This module isn't compatible with python3") from copy import copy from httplib import BadStatusLine try: import mechanize except ImportError: raise ImportError('Please install python-mechanize') import pickle import base64 import zlib import os import re from threading import RLock import ssl import httplib import socket import hashlib import time import urllib import urllib2 import mimetypes import logging from contextlib import closing from gzip import GzipFile import warnings from weboob.exceptions import BrowserUnavailable, BrowserIncorrectPassword, BrowserPasswordExpired, BrowserForbidden, BrowserBanned, BrowserHTTPNotFound, BrowserHTTPError, FormFieldConversionWarning, BrowserSSLError from weboob.tools.decorators import retry from weboob.tools.log import getLogger from weboob.deprecated.mech import ClientForm ControlNotFoundError = ClientForm.ControlNotFoundError from weboob.deprecated.browser.parsers import get_parser __all__ = ['BrowserIncorrectPassword', 'BrowserForbidden', 'BrowserBanned', 'BrowserUnavailable', 'BrowserRetry', 'BrowserPasswordExpired', 'BrowserHTTPNotFound', 'BrowserHTTPError', 'BrokenPageError', 'Page', 'StandardBrowser', 'Browser', 'StateBrowser'] class BrowserRetry(Exception): pass class NoHistory(object): """ We don't want to fill memory with history """ def __init__(self): pass def add(self, request, response): pass def back(self, n, _response): pass def clear(self): pass def close(self): pass class BrokenPageError(Exception): pass class Page(object): """ Base page """ ENCODING = None def __init__(self, browser, document, url='', groups=None, group_dict=None, logger=None): self.browser = browser self.parser = browser.parser self.document = document self.url = url self.groups = groups self.group_dict = group_dict self.logger = getLogger('page', logger) def on_loaded(self): """ Called when the page is loaded. """ pass def check_location(func): def inner(self, *args, **kwargs): if args and isinstance(args[0], basestring): url = args[0] if url.startswith('/') and hasattr(self, 'DOMAIN') and (not self.request or self.request.host != self.DOMAIN): url = '%s://%s%s' % (self.PROTOCOL, self.DOMAIN, url) url = re.sub('(.*)#.*', r'\1', url) if isinstance(url, unicode): url = url.encode('utf-8') args = (url,) + args[1:] return func(self, *args, **kwargs) return inner class StandardBrowser(mechanize.Browser): """ Standard Browser. :param firefox_cookies: path to cookies sqlite file :type firefox_cookies: str :param parser: parser to use on HTML files :type parser: :class:`weboob.deprecated.browser.parsers.iparser.IParser` :param history: history manager; default value is an object which does not keep history :type history: object :param proxy: proxy URL to use :type proxy: str :param factory: mechanize factory. None to use Mechanize's default :type factory: object """ # ------ Class attributes -------------------------------------- ENCODING = 'utf-8' USER_AGENTS = { 'desktop_firefox': 'Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0', 'android': 'Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17', 'microb': 'Mozilla/5.0 (X11; U; Linux armv7l; fr-FR; rv:1.9.2.3pre) Gecko/20100723 Firefox/3.5 Maemo Browser 1.7.4.8 RX-51 N900', 'wget': 'Wget/1.11.4', } USER_AGENT = USER_AGENTS['desktop_firefox'] DEBUG_HTTP = False DEBUG_MECHANIZE = False DEFAULT_TIMEOUT = 15 INSECURE = False # if True, do not validate SSL logger = None # ------ Browser methods --------------------------------------- # I'm not a robot, so disable the check of permissions in robots.txt. default_features = copy(mechanize.Browser.default_features) default_features.remove('_robots') default_features.remove('_refresh') def __init__(self, firefox_cookies=None, parser=None, history=NoHistory(), proxy=None, logger=None, factory=None, responses_dirname=None): mechanize.Browser.__init__(self, history=history, factory=factory) self.logger = getLogger('browser', logger) self.addheaders = [ ['User-agent', self.USER_AGENT] ] # Use a proxy self.proxy = proxy if proxy is not None: self.set_proxies(proxy) # Share cookies with firefox if firefox_cookies: # Try to load cookies try: from .firefox_cookies import FirefoxCookieJar self._cookie = FirefoxCookieJar(self.DOMAIN, firefox_cookies) self._cookie.load() self.set_cookiejar(self._cookie) except ImportError as e: logging.warning("Unable to store Firefox cookies: %s", e) self._cookie = None else: self._cookie = None if parser is None: parser = get_parser()() elif isinstance(parser, (tuple,list,basestring)): parser = get_parser(parser)() self.parser = parser self.lock = RLock() if self.DEBUG_HTTP: # display messages from httplib self.set_debug_http(True) if logging.root.level <= logging.DEBUG: # Enable log messages from mechanize.Browser self.set_debug_redirects(True) mech_logger = logging.getLogger("mechanize") mech_logger.setLevel(logging.INFO) self.responses_dirname = responses_dirname self.responses_count = 0 def __enter__(self): self.lock.acquire() def __exit__(self, t, v, tb): self.lock.release() def _openurl(self, *args, **kwargs): return mechanize.Browser.open(self, *args, **kwargs) @check_location @retry(BrowserHTTPError, tries=3) def openurl(self, *args, **kwargs): """ Open an URL but do not create a Page object. """ if_fail = kwargs.pop('if_fail', 'raise') self.logger.debug('Opening URL "%s", %s' % (args, kwargs)) kwargs['timeout'] = kwargs.get('timeout', self.DEFAULT_TIMEOUT) try: return self._openurl(*args, **kwargs) except (mechanize.BrowserStateError, mechanize.response_seek_wrapper, urllib2.HTTPError, urllib2.URLError, BadStatusLine, ssl.SSLError) as e: if isinstance(e, mechanize.BrowserStateError) and hasattr(self, 'home'): self.home() return self._openurl(*args, **kwargs) elif if_fail == 'raise': raise self.get_exception(e)('%s (url="%s")' % (e, args and args[0] or 'None')) else: return None except BrowserRetry as e: return self._openurl(*args, **kwargs) def get_exception(self, e): if isinstance(e, urllib2.HTTPError) and hasattr(e, 'getcode'): if e.getcode() in (404, 403): return BrowserHTTPNotFound if e.getcode() == 401: return BrowserIncorrectPassword elif isinstance(e, mechanize.BrowserStateError): return BrowserHTTPNotFound return BrowserHTTPError def readurl(self, url, *args, **kwargs): """ Download URL data specifying what to do on failure (nothing by default). """ if 'if_fail' not in kwargs: kwargs['if_fail'] = None result = self.openurl(url, *args, **kwargs) if result: if self.logger.settings['save_responses']: self.save_response(result) return result.read() else: return None def save_response(self, result, warning=False): """ Save a stream to a temporary file, and log its name. The stream is rewinded after saving. """ if self.responses_dirname is None: import tempfile self.responses_dirname = tempfile.mkdtemp(prefix='weboob_session_') print('Debug data will be saved in this directory: %s' % self.responses_dirname, file=sys.stderr) elif not os.path.isdir(self.responses_dirname): os.makedirs(self.responses_dirname) # get the content-type, remove optionnal charset part mimetype = result.info().get('Content-Type', '').split(';')[0] # due to http://bugs.python.org/issue1043134 if mimetype == 'text/plain': ext = '.txt' else: # try to get an extension (and avoid adding 'None') ext = mimetypes.guess_extension(mimetype, False) or '' response_filepath = os.path.join(self.responses_dirname, unicode(self.responses_count)+ext) with open(response_filepath, 'w') as f: f.write(result.read()) result.seek(0) match_filepath = os.path.join(self.responses_dirname, 'url_response_match.txt') with open(match_filepath, 'a') as f: f.write('%s\t%s\n' % (result.geturl(), os.path.basename(response_filepath))) self.responses_count += 1 msg = u'Response saved to %s' % response_filepath if warning: self.logger.warning(msg) else: self.logger.info(msg) def get_document(self, result, parser=None, encoding=None): """ Get a parsed document from a stream. :param result: HTML page stream :type result: stream """ if parser is None: parser = self.parser elif isinstance(parser, (basestring, list, tuple)): parser = get_parser(parser)() if encoding is None: encoding = self.ENCODING return parser.parse(result, encoding) def location(self, *args, **kwargs): """ Go on an URL and get the related document. """ return self.get_document(self.openurl(*args, **kwargs)) @staticmethod def buildurl(base, *args, **kwargs): """ Build an URL and escape arguments. You can give a serie of tuples in args (and the order is keept), or a dict in kwargs (but the order is lost). Example: >>> StandardBrowser.buildurl('/blah.php', ('a', '&'), ('b', '=')) '/blah.php?a=%26&b=%3D' >>> StandardBrowser.buildurl('/blah.php', a='&', b='=') '/blah.php?b=%3D&a=%26' """ if not args: args = kwargs if not args: return base else: return '%s?%s' % (base, urllib.urlencode(args)) def str(self, s): if isinstance(s, unicode): s = s.encode('iso-8859-15', 'replace') return s def set_field(self, args, label, field=None, value=None, is_list=False): """ Set a value to a form field. :param args: arguments where to look for value :type args: dict :param label: label in args :type label: str :param field: field name. If None, use label instead :type field: str :param value: value to give on field :type value: str :param is_list: the field is a list :type is_list: bool """ try: if not field: field = label if args.get(label, None) is not None: if not value: if is_list: if isinstance(is_list, (list, tuple)): try: value = [self.str(is_list.index(args[label]))] except ValueError as e: if args[label]: print('[%s] %s: %s' % (label, args[label], e), file=sys.stderr) return else: value = [self.str(args[label])] else: value = self.str(args[label]) self[field] = value except ControlNotFoundError: return def lowsslcheck(self, domain, hsh): if self.INSECURE or (self.logger is not None and self.logger.settings['ssl_insecure']) or self.proxy is not None: return certhash = self._certhash(domain) if self.logger: self.logger.debug('Found %s as certificate hash' % certhash) if isinstance(hsh, basestring): hsh = [hsh] if certhash not in hsh: raise BrowserSSLError() def _certhash(self, domain, port=443): for proto in HTTPSConnection2._PROTOCOLS: try: certs = ssl.get_server_certificate((domain, port), ssl_version=proto) except ssl.SSLError as e: continue else: return hashlib.sha256(certs).hexdigest() raise e def __setitem__(self, key, value): if isinstance(value, unicode): value = value.encode(self.ENCODING or 'utf-8') warnings.warn('Implicit conversion of form field %r from unicode to str' % key, FormFieldConversionWarning, stacklevel=2) if self.form is None: raise AttributeError('Please select a form before setting values to fields') return self.form.__setitem__(key, value) class Browser(StandardBrowser): """ Base browser class to navigate on a website. :param username: username on website :type username: str :param password: password on website. If it is None, Browser will not try to login :type password: str :param firefox_cookies: path to cookies sqlite file :type firefox_cookies: str :param parser: parser to use on HTML files :type parser: :class:`weboob.deprecated.browser.parsers.iparser.IParser` :param history: history manager; default value is an object which does not keep history :type history: object :param proxy: proxy URL to use :type proxy: dictionnary :param logger: logger to use for logging :type logger: :class:`logging.Logger` :param factory: mechanize factory. None to use Mechanize's default :type factory: object :param get_home: try to get the homepage. :type get_homme: bool :param responses_dirname: directory to store responses :type responses_dirname: str """ # ------ Class attributes -------------------------------------- DOMAIN = None PROTOCOL = 'http' PAGES = {} # SHA-256 hash of server certificate. If set, it will automatically check it, # and raise a SSLError exception if it doesn't match. CERTHASH = None # ------ Abstract methods -------------------------------------- def home(self): """ Go to the home page. """ if self.DOMAIN is not None: self.location('%s://%s/' % (self.PROTOCOL, self.DOMAIN)) def login(self): """ Login to the website. This function is called when is_logged() returns False and the password attribute is not None. """ raise NotImplementedError() def is_logged(self): """ Return True if we are logged on website. When Browser tries to access to a page, if this method returns False, it calls login(). It is never called if the password attribute is None. """ raise NotImplementedError() # ------ Browser methods --------------------------------------- def __init__(self, username=None, password=None, firefox_cookies=None, parser=None, history=NoHistory(), proxy=None, logger=None, factory=None, get_home=True, responses_dirname=None): StandardBrowser.__init__(self, firefox_cookies, parser, history, proxy, logger, factory, responses_dirname) self.page = None self.last_update = 0.0 self.username = username self.password = password if self.CERTHASH is not None and self.DOMAIN is not None: self.lowsslcheck(self.DOMAIN, self.CERTHASH) if self.password and get_home: try: self.home() # Do not abort the build of browser when the website is down. except BrowserUnavailable: pass def submit(self, *args, **kwargs): """ Submit the selected form. """ no_login = kwargs.pop('nologin', kwargs.pop('no_login', False)) try: self._change_location(mechanize.Browser.submit(self, *args, **kwargs), no_login=no_login) except (mechanize.response_seek_wrapper, urllib2.HTTPError, urllib2.URLError, BadStatusLine, ssl.SSLError) as e: self.page = None raise self.get_exception(e)(e) except (mechanize.BrowserStateError, BrowserRetry) as e: raise BrowserUnavailable(e) def is_on_page(self, pageCls): """ Check the current page. :param pageCls: class of the page to check :type pageCls: :class:`Page` :rtype: bool """ return isinstance(self.page, pageCls) def absurl(self, rel): """ Get an absolute URL from a relative one. """ if rel is None: return None if not rel.startswith('/'): rel = '/' + rel return '%s://%s%s' % (self.PROTOCOL, self.DOMAIN, rel) def follow_link(self, *args, **kwargs): """ Follow a link on the page. """ try: self._change_location(mechanize.Browser.follow_link(self, *args, **kwargs)) except (mechanize.response_seek_wrapper, urllib2.HTTPError, urllib2.URLError, BadStatusLine, ssl.SSLError) as e: self.page = None raise self.get_exception(e)('%s (url="%s")' % (e, args and args[0] or 'None')) except (mechanize.BrowserStateError, BrowserRetry) as e: self.home() raise BrowserUnavailable(e) def _openurl(self, *args, **kwargs): return mechanize.Browser.open_novisit(self, *args, **kwargs) @check_location @retry(BrowserHTTPError, tries=3) def location(self, *args, **kwargs): """ Change location of browser on an URL. When the page is loaded, it looks up PAGES to find a regexp which matches, and create the object. Then, the 'on_loaded' method of this object is called. If a password is set, and is_logged() returns False, it tries to login with login() and reload the page. """ keep_args = copy(args) keep_kwargs = kwargs.copy() no_login = kwargs.pop('no_login', kwargs.pop('nologin', False)) kwargs['timeout'] = kwargs.get('timeout', self.DEFAULT_TIMEOUT) try: self._change_location(mechanize.Browser.open(self, *args, **kwargs), no_login=no_login) except BrowserRetry: if not self.page or not args or self.page.url != args[0]: keep_kwargs['no_login'] = True self.location(*keep_args, **keep_kwargs) except (mechanize.response_seek_wrapper, urllib2.HTTPError, urllib2.URLError, BadStatusLine, ssl.SSLError) as e: self.page = None raise self.get_exception(e)('%s (url="%s")' % (e, args and args[0] or 'None')) except mechanize.BrowserStateError: self.home() self.location(*keep_args, **keep_kwargs) # DO NOT ENABLE THIS FUCKING PEACE OF CODE EVEN IF IT WOULD BE BETTER # TO SANITARIZE FUCKING HTML. #def _set_response(self, response, *args, **kwargs): # import time # if response and hasattr(response, 'set_data'): # print time.time() # r = response.read() # start = 0 # end = 0 # new = '' # lowr = r.lower() # start = lowr[end:].find('= end: # start_stop = start + lowr[start:].find('>') + 1 # new += r[end:start_stop] # end = start + lowr[start:].find('') # new += r[start_stop:end].replace('<', '<').replace('>', '>') # start = end + lowr[end:].find(' 3600: raise DNSTimeoutException() return res except (KeyError, DNSTimeoutException): res = socket.getaddrinfoold(*args) cacheDNS[args] = res, time.time() return res socket.getaddrinfoold = socket.getaddrinfo socket.getaddrinfo = my_getaddrinfo class HTTPSConnection2(httplib.HTTPSConnection): _HOSTS = {} _PROTOCOLS = [ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv23] def _my_create_connection(self): sock = socket.create_connection((self.host, self.port), self.timeout) if self._tunnel_host: self._tunnel() return sock def _get_protocols(self): return self._HOSTS.get('%s:%s' % (self.host, self.port), self._PROTOCOLS) def connect(self): for proto in self._get_protocols(): sock = self._my_create_connection() try: self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=proto) self._HOSTS['%s:%s' % (self.host, self.port)] = [proto] return except ssl.SSLError as e: sock.close() raise e httplib.HTTPSConnection = HTTPSConnection2 weboob-1.1/weboob/deprecated/browser/decorators.py000066400000000000000000000047731265717027300224340ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . __all__ = ['check_url', 'id2url'] from urlparse import urlsplit import re class check_url(object): """ Checks if the first argument matches the given regular expression (given as str, without the ^$ delimiters which are automatically added). If not, this decorator will return None instead of calling the function. """ def __init__(self, regexp): self.regexp = re.compile('^%s$' % regexp) def __call__(self, func): def wrapper(funcself, *args, **kwargs): if self.regexp.match(args[0]): return func(funcself, *args, **kwargs) return None return wrapper def id2url(id2url): """ If the first argument is not an URL, this decorator will try to convert it to one, by calling the id2url function. If id2url returns None (because the id is invalid), the decorated function will not be called and None will be returned. If the DOMAIN attribute of the method's class is not empty, it will also check it. If it does not match, the decorated function will not be called and None will be returned. """ def wrapper(func): def inner(self, *args, **kwargs): arg = unicode(args[0]) if arg.startswith('http://') or arg.startswith('https://'): domain = urlsplit(arg).netloc if not self.DOMAIN or self.DOMAIN == domain or domain.endswith('.'+self.DOMAIN): url = arg else: return None else: url = id2url(arg) if url is None: return None new_args = [url] new_args.extend(args[1:]) return func(self, *new_args, **kwargs) return inner return wrapper weboob-1.1/weboob/deprecated/browser/firefox_cookies.py000066400000000000000000000074171265717027300234430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function try: import sqlite3 as sqlite except ImportError as e: from pysqlite2 import dbapi2 as sqlite from mechanize import CookieJar, Cookie __all__ = ['FirefoxCookieJar'] class FirefoxCookieJar(CookieJar): def __init__(self, domain, sqlite_file=None, policy=None): CookieJar.__init__(self, policy) self.domain = domain self.sqlite_file = sqlite_file def __connect(self): try: db = sqlite.connect(database=self.sqlite_file, timeout=10.0) except sqlite.OperationalError as err: print('Unable to open %s database: %s' % (self.sqlite_file, err)) return None return db def load(self): db = self.__connect() if not db: return cookies = db.execute("""SELECT host, path, name, value, expiry, lastAccessed, isSecure FROM moz_cookies WHERE host LIKE '%%%s%%'""" % self.domain) for entry in cookies: domain = entry[0] initial_dot = domain.startswith(".") domain_specified = initial_dot path = entry[1] name = entry[2] value = entry[3] expires = entry[4] secure = entry[6] discard = False c = Cookie(0, name, value, None, False, domain, domain_specified, initial_dot, path, False, secure, expires, discard, None, None, {}) #if not ignore_discard and c.discard: # continue #if not ignore_expires and c.is_expired(now): # continue self.set_cookie(c) def save(self): db = self.__connect() if not db: return db.execute("DELETE FROM moz_cookies WHERE host LIKE '%%%s%%'" % self.domain) for cookie in self: if cookie.secure: secure = 1 else: secure = 0 if cookie.expires is not None: expires = cookie.expires else: expires = 0 if cookie.value is None: # cookies.txt regards 'Set-Cookie: foo' as a cookie # with no name, whereas cookielib regards it as a # cookie with no value. name = "" value = cookie.name else: name = cookie.name value = cookie.value # XXX ugly hack to keep this cookie if name == 'PHPSESSID': expires = 1854242393 db.execute("""INSERT INTO moz_cookies (host, path, name, value, expiry, isSecure) VALUES (?, ?, ?, ?, ?, ?)""", (cookie.domain, cookie.path, name, value, int(expires), int(secure))) db.commit() weboob-1.1/weboob/deprecated/browser/parsers/000077500000000000000000000000001265717027300213615ustar00rootroot00000000000000weboob-1.1/weboob/deprecated/browser/parsers/__init__.py000066400000000000000000000043251265717027300234760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz, Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import logging __all__ = ['get_parser', 'NoParserFound'] class NoParserFound(Exception): pass def load_lxml(): from .lxmlparser import LxmlHtmlParser return LxmlHtmlParser def load_lxmlsoup(): from .lxmlsoupparser import LxmlSoupParser return LxmlSoupParser def load_xml(): from .lxmlparser import LxmlXmlParser return LxmlXmlParser def load_json(): # This parser doesn't read HTML, don't include it in the # preference_order default value below. from .jsonparser import JsonParser return JsonParser def load_csv(): # This parser doesn't read HTML, don't include it in the # preference_order default value below. from .csvparser import CsvParser return CsvParser def load_raw(): # This parser doesn't read HTML, don't include it in the # preference_order default value below. from .iparser import RawParser return RawParser def get_parser(preference_order=('lxml', 'lxmlsoup')): """ Get a parser from a preference order list. Return a parser implementing IParser. """ if not isinstance(preference_order, (tuple, list)): preference_order = [preference_order] for kind in preference_order: if not 'load_%s' % kind in globals(): continue try: return globals()['load_%s' % kind]() except ImportError: logging.debug('%s is not installed.' % kind) raise NoParserFound("No parser found (%s)" % ','.join(preference_order)) weboob-1.1/weboob/deprecated/browser/parsers/csvparser.py000066400000000000000000000051441265717027300237470ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import csv from weboob.tools.log import getLogger from .iparser import IParser class Csv(object): """ CSV parser result. header contains the first row if it is a header rows contains the raw rows drows contains the rows with cells indexed by header title """ def __init__(self): self.header = None self.rows = [] self.drows = [] class CsvParser(IParser): """ CSV Parser. Since CSV files are not normalized, this parser is intended to be derived. """ DIALECT = 'excel' FMTPARAMS = {} """ If True, will consider the first line as a header. This means the rows will be also available as dictionnaries. """ HEADER = False def parse(self, data, encoding=None): reader = csv.reader(data, dialect=self.DIALECT, **self.FMTPARAMS) c = Csv() try: for row in reader: row = self.decode_row(row, encoding) if c.header is None and self.HEADER: c.header = row else: c.rows.append(row) if c.header: drow = {} for i, cell in enumerate(row): drow[c.header[i]] = cell c.drows.append(drow) except csv.Error as error: # If there are errors in CSV, for example the file is truncated, do # not crash as there already are lines parsed. logger = getLogger('csv') logger.warning('Error during parse of CSV: %s', error) return c def decode_row(self, row, encoding): if encoding: return [unicode(cell, encoding) for cell in row] else: return row def tostring(self, element): if not isinstance(element, basestring): return unicode(element) return element weboob-1.1/weboob/deprecated/browser/parsers/iparser.py000066400000000000000000000032561265717027300234060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re __all__ = ['IParser', 'RawParser'] class IParser(object): def parse(self, data, encoding=None): """ Parse a HTML document with a specific encoding to get a tree. @param data [str] HTML document @param encoding [str] encoding to use @return an object with the structured document """ raise NotImplementedError() def tostring(self, elem): """ Get HTML string from an element. """ raise NotImplementedError() def tocleanstring(self, elem): """ Get a clean string from an element. """ return self.strip(self.tostring(elem)) def strip(self, data): """ Strip a HTML string. """ p = re.compile(r'<.*?>') return p.sub(' ', data).strip() class RawParser(IParser): def parse(self, data, encoding=None): return data.read() def tostring(self, elem): return elem weboob-1.1/weboob/deprecated/browser/parsers/jsonparser.py000066400000000000000000000020261265717027300241210ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.json import json from .iparser import IParser __all__ = ['JsonParser'] class JsonParser(IParser): """ Json parser. """ def parse(self, data, encoding=None): return json.load(data, encoding=encoding) def tostring(self, element): return json.dumps(element) weboob-1.1/weboob/deprecated/browser/parsers/lxmlparser.py000066400000000000000000000103041265717027300241220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import lxml.html as html import lxml.etree as etree from .iparser import IParser from ..browser import BrokenPageError __all__ = ['LxmlHtmlParser', 'LxmlXmlParser'] class LxmlParser(IParser): """ Parser using lxml. Note that it is not available on every systems. """ def get_parser(encoding=None): pass def parse(self, data, encoding=None): if encoding is None: parser = None else: parser = self.get_parser(encoding=encoding) return self.module.parse(data, parser) def tostring(self, element): return self.module.tostring(element, encoding=unicode) def tocleanstring(self, element): txt = [txt.strip() for txt in element.itertext()] txt = u' '.join(txt) # 'foo bar' txt = re.sub('\s+', ' ', txt) # 'foo bar' return txt.strip() def strip(self, s): doc = self.module.fromstring(s) # parse html/xml string return self.tocleanstring(doc) @classmethod def select(cls, element, selector, nb=None, method='cssselect', **kwargs): """ Select one or many elements from an element, using lxml cssselect by default. Raises :class:`weboob.deprecated.browser.browser.BrokenPageError` if not found. :param element: element on which to apply selector :type element: object :param selector: CSS or XPath expression :type selector: str :param method: (cssselect|xpath) :type method: str :param nb: number of elements expected to be found. Use None for undefined number, and 'many' for 1 to infinite :type nb: :class:`int` or :class:`str` :rtype: Element """ if method == 'cssselect': results = element.cssselect(selector, **kwargs) elif method == 'xpath': results = element.xpath(selector, **kwargs) else: raise NotImplementedError('Only the cssselect and xpath methods are supported') if nb is None: return results elif isinstance(nb, basestring) and nb == 'many': if results is None or len(results) == 0: raise BrokenPageError('Element not found with selector "%s"' % selector) elif len(results) == 1: raise BrokenPageError('Only one element found with selector "%s"' % selector) else: return results elif isinstance(nb, int) and nb > 0: if results is None: raise BrokenPageError('Element not found with selector "%s"' % selector) elif len(results) < nb: raise BrokenPageError('Not enough elements found (%d expected) with selector "%s"' % (nb, selector)) else: return results[0] if nb == 1 else results else: raise Exception('Unhandled value for kwarg "nb": %s' % nb) class LxmlHtmlParser(LxmlParser): """ Parser using lxml. Note that it is not available on every systems. """ def __init__(self, *args, **kwargs): self.module = html def get_parser(self, encoding=None): return html.HTMLParser(encoding=encoding) class LxmlXmlParser(LxmlParser): """ Parser using lxml. Note that it is not available on every systems. """ def __init__(self, *args, **kwargs): self.module = etree def get_parser(self, encoding=None): return etree.XMLParser(encoding=encoding, strip_cdata=False) weboob-1.1/weboob/deprecated/browser/parsers/lxmlsoupparser.py000066400000000000000000000022171265717027300250350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import lxml.html import lxml.html.soupparser from .iparser import IParser __all__ = ['LxmlSoupParser'] class LxmlSoupParser(IParser): """ Parser using lxml elementsoup. Note that it is not available on every systems. """ def parse(self, data, encoding=None): return lxml.html.soupparser.parse(data) def tostring(self, element): return lxml.html.tostring(element, encoding=unicode) weboob-1.1/weboob/deprecated/mech.py000066400000000000000000000015711265717027300175110ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . __all__ = ['ClientForm', 'mechanize'] import mechanize if hasattr(mechanize, "FormParser"): ClientForm = mechanize else: import ClientForm weboob-1.1/weboob/exceptions.py000066400000000000000000000027501265717027300166560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . class BrowserIncorrectPassword(Exception): pass class BrowserForbidden(Exception): pass class BrowserBanned(BrowserIncorrectPassword): pass class BrowserPasswordExpired(BrowserIncorrectPassword): pass class BrowserUnavailable(Exception): pass class BrowserQuestion(BrowserIncorrectPassword): """ When raised by a browser, """ def __init__(self, *fields): self.fields = fields class BrowserHTTPNotFound(BrowserUnavailable): pass class BrowserHTTPError(BrowserUnavailable): pass class BrowserSSLError(BrowserUnavailable): pass class ParseError(Exception): pass class FormFieldConversionWarning(UserWarning): """ A value has been set to a form's field and has been implicitly converted. """ weboob-1.1/weboob/tools/000077500000000000000000000000001265717027300152575ustar00rootroot00000000000000weboob-1.1/weboob/tools/__init__.py000066400000000000000000000000001265717027300173560ustar00rootroot00000000000000weboob-1.1/weboob/tools/application/000077500000000000000000000000001265717027300175625ustar00rootroot00000000000000weboob-1.1/weboob/tools/application/__init__.py000066400000000000000000000000001265717027300216610ustar00rootroot00000000000000weboob-1.1/weboob/tools/application/base.py000066400000000000000000000410321265717027300210460ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon, Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import logging import optparse from optparse import OptionGroup, OptionParser from datetime import datetime import os import sys import warnings from weboob.capabilities.base import ConversionWarning, BaseObject from weboob.core import Weboob, CallErrors from weboob.core.backendscfg import BackendsConfig from weboob.tools.config.iconfig import ConfigError from weboob.exceptions import FormFieldConversionWarning from weboob.tools.log import createColoredFormatter, getLogger, DEBUG_FILTERS, settings as log_settings from weboob.tools.misc import to_unicode, guess_encoding from .results import ResultsConditionError __all__ = ['Application'] class MoreResultsAvailable(Exception): pass class ApplicationStorage(object): def __init__(self, name, storage): self.name = name self.storage = storage def set(self, *args): if self.storage: return self.storage.set('applications', self.name, *args) def delete(self, *args): if self.storage: return self.storage.delete('applications', self.name, *args) def get(self, *args, **kwargs): if self.storage: return self.storage.get('applications', self.name, *args, **kwargs) else: return kwargs.get('default', None) def load(self, default): if self.storage: return self.storage.load('applications', self.name, default) def save(self): if self.storage: return self.storage.save('applications', self.name) class Application(object): """ Base application. This class can be herited to have some common code within weboob applications. """ # ------ Class attributes -------------------------------------- # Application name APPNAME = '' # Configuration and work directory (if None, use the Weboob instance one) CONFDIR = None # Default configuration dict (can only contain key/values) CONFIG = {} # Default storage tree STORAGE = {} # Synopsis SYNOPSIS = 'Usage: %prog [-h] [-dqv] [-b backends] ...\n' SYNOPSIS += ' %prog [--help] [--version]' # Description DESCRIPTION = None # Version VERSION = None # Copyright COPYRIGHT = None # Verbosity of DEBUG DEBUG_FILTER = 2 stdin = sys.stdin stdout = sys.stdout stderr = sys.stderr # ------ Abstract methods -------------------------------------- def create_weboob(self): return Weboob() def _get_completions(self): """ Overload this method in subclasses if you want to enrich shell completion. @return a set object """ return set() def _handle_options(self): """ Overload this method in application type subclass if you want to handle options defined in subclass constructor. """ pass def add_application_options(self, group): """ Overload this method if your application needs extra options. These options will be displayed in an option group. """ pass def handle_application_options(self): """ Overload this method in your application if you want to handle options defined in add_application_options. """ pass # ------ Application methods ------------------------------- def __init__(self, option_parser=None): self.encoding = self.guess_encoding() self.logger = getLogger(self.APPNAME) self.weboob = self.create_weboob() if self.CONFDIR is None: self.CONFDIR = self.weboob.workdir self.config = None self.options = None self.condition = None self.storage = None if option_parser is None: self._parser = OptionParser(self.SYNOPSIS, version=self._get_optparse_version()) else: self._parser = option_parser if self.DESCRIPTION: self._parser.description = self.DESCRIPTION app_options = OptionGroup(self._parser, '%s Options' % self.APPNAME.capitalize()) self.add_application_options(app_options) if len(app_options.option_list) > 0: self._parser.add_option_group(app_options) self._parser.add_option('-b', '--backends', help='what backend(s) to enable (comma separated)') self._parser.add_option('-e', '--exclude-backends', help='what backend(s) to exclude (comma separated)') self._parser.add_option('-I', '--insecure', action='store_true', help='do not validate SSL') logging_options = OptionGroup(self._parser, 'Logging Options') logging_options.add_option('-d', '--debug', action='count', help='display debug messages. Set up it twice to more verbosity') logging_options.add_option('-q', '--quiet', action='store_true', help='display only error messages') logging_options.add_option('-v', '--verbose', action='store_true', help='display info messages') logging_options.add_option('--logging-file', action='store', type='string', dest='logging_file', help='file to save logs') logging_options.add_option('-a', '--save-responses', action='store_true', help='save every response') self._parser.add_option_group(logging_options) self._parser.add_option('--shell-completion', action='store_true', help=optparse.SUPPRESS_HELP) self._is_default_count = True def guess_encoding(self, stdio=None): return guess_encoding(stdio or self.stdout) def deinit(self): self.weboob.want_stop() self.weboob.deinit() def create_storage(self, path=None, klass=None, localonly=False): """ Create a storage object. :param path: An optional specific path :type path: :class:`str` :param klass: What class to instance :type klass: :class:`weboob.tools.storage.IStorage` :param localonly: If True, do not set it on the :class:`Weboob` object. :type localonly: :class:`bool` :rtype: :class:`weboob.tools.storage.IStorage` """ if klass is None: from weboob.tools.storage import StandardStorage klass = StandardStorage if path is None: path = os.path.join(self.CONFDIR, self.APPNAME + '.storage') elif os.path.sep not in path: path = os.path.join(self.CONFDIR, path) storage = klass(path) self.storage = ApplicationStorage(self.APPNAME, storage) self.storage.load(self.STORAGE) if not localonly: self.weboob.storage = storage return storage def load_config(self, path=None, klass=None): """ Load a configuration file and get his object. :param path: An optional specific path :type path: :class:`str` :param klass: What class to instance :type klass: :class:`weboob.tools.config.iconfig.IConfig` :rtype: :class:`weboob.tools.config.iconfig.IConfig` """ if klass is None: from weboob.tools.config.iniconfig import INIConfig klass = INIConfig if path is None: path = os.path.join(self.CONFDIR, self.APPNAME) elif os.path.sep not in path: path = os.path.join(self.CONFDIR, path) self.config = klass(path) self.config.load(self.CONFIG) def main(self, argv): """ Main method Called by run """ raise NotImplementedError() def load_backends(self, caps=None, names=None, exclude=None, *args, **kwargs): if names is None and self.options.backends: names = self.options.backends.split(',') if exclude is None and self.options.exclude_backends: exclude = self.options.exclude_backends.split(',') loaded = self.weboob.load_backends(caps, names, exclude=exclude, *args, **kwargs) if not loaded: logging.info(u'No backend loaded') return loaded def _get_optparse_version(self): version = None if self.VERSION: if self.COPYRIGHT: copyright = self.COPYRIGHT.replace('YEAR', '%d' % datetime.today().year) version = '%s v%s %s' % (self.APPNAME, self.VERSION, copyright) else: version = '%s v%s' % (self.APPNAME, self.VERSION) return version def _do_complete_obj(self, backend, fields, obj): if not obj: return obj if not isinstance(obj, BaseObject): return obj obj.backend = backend.name if fields is None or len(fields) > 0: backend.fillobj(obj, fields) return obj def _do_complete_iter(self, backend, count, fields, res): modif = 0 for i, sub in enumerate(res): sub = self._do_complete_obj(backend, fields, sub) if self.condition and self.condition.limit and \ self.condition.limit == i: return if self.condition and not self.condition.is_valid(sub): modif += 1 else: if count and i - modif == count: if self._is_default_count: raise MoreResultsAvailable() else: return yield sub def _do_complete(self, backend, count, selected_fields, function, *args, **kwargs): assert count is None or count > 0 if callable(function): res = function(backend, *args, **kwargs) else: res = getattr(backend, function)(*args, **kwargs) if hasattr(res, '__iter__'): return self._do_complete_iter(backend, count, selected_fields, res) else: return self._do_complete_obj(backend, selected_fields, res) def bcall_error_handler(self, backend, error, backtrace): """ Handler for an exception inside the CallErrors exception. This method can be overrided to support more exceptions types. """ # Ignore this error. if isinstance(error, MoreResultsAvailable): return False print(u'Error(%s): %s' % (backend.name, error), file=self.stderr) if logging.root.level <= logging.DEBUG: print(backtrace, file=self.stderr) else: return True def bcall_errors_handler(self, errors, debugmsg='Use --debug option to print backtraces', ignore=()): """ Handler for the CallErrors exception. It calls `bcall_error_handler` for each error. :param errors: Object containing errors from backends :type errors: :class:`weboob.core.bcall.CallErrors` :param debugmsg: Default message asking to enable the debug mode :type debugmsg: :class:`basestring` :param ignore: Exceptions to ignore :type ignore: tuple[:class:`Exception`] """ ask_debug_mode = False for backend, error, backtrace in errors.errors: if isinstance(error, ignore): continue elif self.bcall_error_handler(backend, error, backtrace): ask_debug_mode = True if ask_debug_mode: print(debugmsg, file=self.stderr) def parse_args(self, args): self.options, args = self._parser.parse_args(args) if self.options.shell_completion: items = set() for option in self._parser.option_list: if option.help is not optparse.SUPPRESS_HELP: items.update(str(option).split('/')) items.update(self._get_completions()) print(' '.join(items)) sys.exit(0) if self.options.debug >= self.DEBUG_FILTER: level = DEBUG_FILTERS elif self.options.debug or self.options.save_responses: level = logging.DEBUG elif self.options.verbose: level = logging.INFO elif self.options.quiet: level = logging.ERROR else: level = logging.WARNING if self.options.insecure: log_settings['ssl_insecure'] = True # this only matters to developers if not self.options.debug and not self.options.save_responses: warnings.simplefilter('ignore', category=ConversionWarning) warnings.simplefilter('ignore', category=FormFieldConversionWarning) handlers = [] if self.options.save_responses: import tempfile responses_dirname = tempfile.mkdtemp(prefix='weboob_session_') print('Debug data will be saved in this directory: %s' % responses_dirname, file=self.stderr) log_settings['save_responses'] = True log_settings['responses_dirname'] = responses_dirname handlers.append(self.create_logging_file_handler(os.path.join(responses_dirname, 'debug.log'))) # file logger if self.options.logging_file: handlers.append(self.create_logging_file_handler(self.options.logging_file)) else: handlers.append(self.create_default_logger()) self.setup_logging(level, handlers) self._handle_options() self.handle_application_options() return args @classmethod def create_default_logger(cls): # stderr logger format = '%(asctime)s:%(levelname)s:%(name)s:' + cls.VERSION +\ ':%(filename)s:%(lineno)d:%(funcName)s %(message)s' handler = logging.StreamHandler(cls.stderr) handler.setFormatter(createColoredFormatter(cls.stderr, format)) return handler @classmethod def setup_logging(cls, level, handlers): logging.root.handlers = [] logging.root.setLevel(level) for handler in handlers: logging.root.addHandler(handler) def create_logging_file_handler(self, filename): try: stream = open(filename, 'w') except IOError as e: self.logger.error('Unable to create the logging file: %s' % e) sys.exit(1) else: format = '%(asctime)s:%(levelname)s:%(name)s:' + self.VERSION +\ ':%(filename)s:%(lineno)d:%(funcName)s %(message)s' handler = logging.StreamHandler(stream) handler.setFormatter(logging.Formatter(format)) return handler @classmethod def run(cls, args=None): """ This static method can be called to run the application. It creates the application object, handles options, setups logging, calls the main() method, and catches common exceptions. You can't do anything after this call, as it *always* finishes with a call to sys.exit(). For example: >>> from weboob.application.myapplication import MyApplication >>> MyApplication.run() """ cls.setup_logging(logging.INFO, [cls.create_default_logger()]) if args is None: args = [(cls.stdin.encoding and isinstance(arg, bytes) and arg.decode(cls.stdin.encoding) or to_unicode(arg)) for arg in sys.argv] try: app = cls() except BackendsConfig.WrongPermissions as e: print(e, file=cls.stderr) sys.exit(1) try: try: args = app.parse_args(args) sys.exit(app.main(args)) except KeyboardInterrupt: print('Program killed by SIGINT', file=cls.stderr) sys.exit(0) except EOFError: sys.exit(0) except ConfigError as e: print('Configuration error: %s' % e, file=cls.stderr) sys.exit(1) except CallErrors as e: try: app.bcall_errors_handler(e) except KeyboardInterrupt: pass sys.exit(1) except ResultsConditionError as e: print('%s' % e, file=cls.stderr) sys.exit(1) finally: app.deinit() weboob-1.1/weboob/tools/application/console.py000066400000000000000000000613761265717027300216130ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Christophe Benz, Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function from copy import copy import getpass import logging import subprocess import sys import os from weboob.capabilities import UserError from weboob.capabilities.account import CapAccount, Account, AccountRegisterError from weboob.core.backendscfg import BackendAlreadyExists from weboob.core.modules import ModuleLoadError from weboob.core.repositories import ModuleInstallError, IProgress from weboob.exceptions import BrowserUnavailable, BrowserIncorrectPassword, BrowserForbidden, BrowserSSLError, BrowserQuestion from weboob.tools.value import Value, ValueBool, ValueFloat, ValueInt, ValueBackendPassword from weboob.tools.misc import to_unicode from weboob.tools.compat import check_output from weboob.tools.ordereddict import OrderedDict from .base import Application, MoreResultsAvailable __all__ = ['ConsoleApplication', 'BackendNotGiven'] class BackendNotGiven(Exception): def __init__(self, id, backends): self.id = id self.backends = sorted(backends) Exception.__init__(self, 'Please specify a backend to use for this argument (%s@backend_name). ' 'Availables: %s.' % (id, ', '.join(name for name, backend in backends))) class BackendNotFound(Exception): pass class ConsoleProgress(IProgress): def __init__(self, app): self.app = app def progress(self, percent, message): self.app.stdout.write('=== [%3.0f%%] %s\n' % (percent*100, message)) def error(self, message): self.app.stderr.write('ERROR: %s\n' % message) def prompt(self, message): return self.app.ask(message, default=True) class ConsoleApplication(Application): """ Base application class for CLI applications. """ CAPS = None # shell escape strings if sys.platform == 'win32' \ or not sys.stdout.isatty() \ or os.getenv('ANSI_COLORS_DISABLED') is not None: #workaround to disable bold BOLD = '' NC = '' # no color else: BOLD = '' NC = '' # no color def __init__(self, option_parser=None): Application.__init__(self, option_parser) self.weboob.callbacks['login'] = self.login_cb self.enabled_backends = set() def login_cb(self, backend_name, value): return self.ask('[%s] %s' % (backend_name, value.label), masked=True, default='', regexp=value.regexp) def unload_backends(self, *args, **kwargs): unloaded = self.weboob.unload_backends(*args, **kwargs) for backend in unloaded.itervalues(): try: self.enabled_backends.remove(backend) except KeyError: pass return unloaded def is_module_loadable(self, info): return self.CAPS is None or info.has_caps(self.CAPS) def load_backends(self, *args, **kwargs): if 'errors' in kwargs: errors = kwargs['errors'] else: kwargs['errors'] = errors = [] ret = super(ConsoleApplication, self).load_backends(*args, **kwargs) for err in errors: print(u'Error(%s): %s' % (err.backend_name, err), file=self.stderr) if self.ask('Do you want to reconfigure this backend?', default=True): self.edit_backend(err.backend_name) self.load_backends(names=[err.backend_name]) for name, backend in ret.iteritems(): self.enabled_backends.add(backend) self.check_loaded_backends() return ret def check_loaded_backends(self, default_config=None): while len(self.enabled_backends) == 0: print('Warning: there is currently no configured backend for %s' % self.APPNAME) if not self.stdout.isatty() or not self.ask('Do you want to configure backends?', default=True): return False self.prompt_create_backends(default_config) return True def prompt_create_backends(self, default_config=None): r = '' while r != 'q': modules = [] print('\nAvailable modules:') for name, info in sorted(self.weboob.repositories.get_all_modules_info().iteritems()): if not self.is_module_loadable(info): continue modules.append(name) loaded = ' ' for bi in self.weboob.iter_backends(): if bi.NAME == name: if loaded == ' ': loaded = 'X' elif loaded == 'X': loaded = 2 else: loaded += 1 print('%s%d)%s [%s] %s%-15s%s %s' % (self.BOLD, len(modules), self.NC, loaded, self.BOLD, name, self.NC, info.description.encode(self.encoding))) print('%sa) --all--%s install all backends' % (self.BOLD, self.NC)) print('%sq)%s --stop--\n' % (self.BOLD, self.NC)) r = self.ask('Select a backend to create (q to stop)', regexp='^(\d+|q|a)$') if str(r).isdigit(): i = int(r) - 1 if i < 0 or i >= len(modules): print('Error: %s is not a valid choice' % r, file=self.stderr) continue name = modules[i] try: inst = self.add_backend(name, name, default_config) if inst: self.load_backends(names=[inst]) except (KeyboardInterrupt, EOFError): print('\nAborted.') elif r == 'a': try: for name in modules: if name in [b.NAME for b in self.weboob.iter_backends()]: continue inst = self.add_backend(name, name, default_config) if inst: self.load_backends(names=[inst]) except (KeyboardInterrupt, EOFError): print('\nAborted.') else: break print('Right right!') def _handle_options(self): self.load_default_backends() def load_default_backends(self): """ By default loads all backends. Applications can overload this method to restrict backends loaded. """ if len(self.STORAGE) > 0: self.load_backends(self.CAPS, storage=self.create_storage()) else: self.load_backends(self.CAPS) @classmethod def run(klass, args=None): try: super(ConsoleApplication, klass).run(args) except BackendNotFound as e: print('Error: Backend "%s" not found.' % e) sys.exit(1) def do(self, function, *args, **kwargs): if 'backends' not in kwargs: kwargs['backends'] = self.enabled_backends return self.weboob.do(function, *args, **kwargs) def parse_id(self, _id, unique_backend=False): try: _id, backend_name = _id.rsplit('@', 1) except ValueError: backend_name = None backends = [(b.name, b) for b in self.enabled_backends] if unique_backend and not backend_name: if len(backends) == 1: backend_name = backends[0][0] else: raise BackendNotGiven(_id, backends) if backend_name is not None and backend_name not in dict(backends): # Is the backend a short version of a real one? found = False for key in dict(backends): if backend_name in key: # two choices, ambiguous command if found: raise BackendNotFound(backend_name) else: found = True _back = key if found: return _id, _back raise BackendNotFound(backend_name) return _id, backend_name # user interaction related methods def register_backend(self, name, ask_add=True): try: backend = self.weboob.modules_loader.get_or_load_module(name) except ModuleLoadError as e: backend = None if not backend: print('Backend "%s" does not exist.' % name, file=self.stderr) return 1 if not backend.has_caps(CapAccount) or backend.klass.ACCOUNT_REGISTER_PROPERTIES is None: print('You can\'t register a new account with %s' % name, file=self.stderr) return 1 account = Account() account.properties = {} if backend.website: website = 'on website %s' % backend.website else: website = 'with backend %s' % backend.name while True: asked_config = False for key, prop in backend.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems(): if not asked_config: asked_config = True print('Configuration of new account %s' % website) print('-----------------------------%s' % ('-' * len(website))) p = copy(prop) p.set(self.ask(prop, default=account.properties[key].get() if (key in account.properties) else prop.default)) account.properties[key] = p if asked_config: print('-----------------------------%s' % ('-' * len(website))) try: backend.klass.register_account(account) except AccountRegisterError as e: print(u'%s' % e) if self.ask('Do you want to try again?', default=True): continue else: return None else: break backend_config = {} for key, value in account.properties.iteritems(): if key in backend.config: backend_config[key] = value.get() if ask_add and self.ask('Do you want to add the new register account?', default=True): return self.add_backend(name, name, backend_config, ask_register=False) return backend_config def install_module(self, name): try: self.weboob.repositories.install(name, ConsoleProgress(self)) except ModuleInstallError as e: print('Unable to install module "%s": %s' % (name, e), file=self.stderr) return False print('') return True def edit_backend(self, name, params=None): return self.add_backend(name, name, params, True) def add_backend(self, module_name, backend_name, params=None, edit=False, ask_register=True): if params is None: params = {} module = None config = None try: if not edit: minfo = self.weboob.repositories.get_module_info(module_name) if minfo is None: raise ModuleLoadError(module_name, 'Module does not exist') if not minfo.is_installed(): print('Module "%s" is available but not installed.' % minfo.name) self.install_module(minfo) module = self.weboob.modules_loader.get_or_load_module(module_name) config = module.config else: module_name, items = self.weboob.backends_config.get_backend(backend_name) module = self.weboob.modules_loader.get_or_load_module(module_name) items.update(params) params = items config = module.config.load(self.weboob, module_name, backend_name, params, nofail=True) except ModuleLoadError as e: print('Unable to load module "%s": %s' % (module_name, e), file=self.stderr) return 1 # ask for params non-specified on command-line arguments asked_config = False for key, value in config.iteritems(): if not asked_config: asked_config = True print('') print('Configuration of backend %s' % module.name) print('-------------------------%s' % ('-' * len(module.name))) if key not in params or edit: params[key] = self.ask(value, default=params[key] if (key in params) else value.default) else: print(u'[%s] %s: %s' % (key, value.description, '(masked)' if value.masked else to_unicode(params[key]))) if asked_config: print('-------------------------%s' % ('-' * len(module.name))) i = 2 while not edit and self.weboob.backends_config.backend_exists(backend_name): if not self.ask('Backend "%s" already exists. Add a new one for module %s?' % (backend_name, module.name), default=False): return 1 backend_name = backend_name.rstrip('0123456789') while self.weboob.backends_config.backend_exists('%s%s' % (backend_name, i)): i += 1 backend_name = self.ask('Please give new instance name', default='%s%s' % (backend_name, i), regexp=r'^[\w\-_]+$') try: config = config.load(self.weboob, module.name, backend_name, params, nofail=True) for key, value in params.iteritems(): if key not in config: continue config[key].set(value) config.save(edit=edit) print('Backend "%s" successfully %s.' % (backend_name, 'edited' if edit else 'added')) return backend_name except BackendAlreadyExists: print('Backend "%s" already exists.' % backend_name, file=self.stderr) return 1 def ask(self, question, default=None, masked=None, regexp=None, choices=None, tiny=None): """ Ask a question to user. @param question text displayed (str) @param default optional default value (str) @param masked if True, do not show typed text (bool) @param regexp text must match this regexp (str) @param choices choices to do (list) @param tiny ask for the (small) value of the choice (bool) @return entered text by user (str) """ if isinstance(question, Value): v = copy(question) if default is not None: v.default = to_unicode(default) if isinstance(default, str) else default if masked is not None: v.masked = masked if regexp is not None: v.regexp = regexp if choices is not None: v.choices = choices if tiny is not None: v.tiny = tiny else: if isinstance(default, bool): klass = ValueBool elif isinstance(default, float): klass = ValueFloat elif isinstance(default, (int,long)): klass = ValueInt else: klass = Value v = klass(label=question, default=default, masked=masked, regexp=regexp, choices=choices, tiny=tiny) question = v.label if v.id: question = u'[%s] %s' % (v.id, question) if isinstance(v, ValueBackendPassword): print(question.encode(self.encoding) + ':') question = v.label choices = OrderedDict() choices['c'] = 'Run an external tool during backend load' if not v.noprompt: choices['p'] = 'Prompt value when needed (do not store it)' choices['s'] = 'Store value in config' if v.is_command(v.default): d = 'c' elif v.default == '' and not v.noprompt: d = 'p' else: d = 's' r = self.ask('*** How do you want to store it?', choices=choices, tiny=True, default=d) if r == 'p': return '' if r == 'c': print('Enter the shell command that will print the required value on the standard output') if v.is_command(v.default): print(': %s' % v.default[1:-1]) else: d = None while True: cmd = self.ask('') try: check_output(cmd, shell=True) except subprocess.CalledProcessError as e: print('%s' % e) else: return '`%s`' % cmd aliases = {} if isinstance(v, ValueBool): question = u'%s (%s/%s)' % (question, 'Y' if v.default else 'y', 'n' if v.default else 'N') elif v.choices: if v.tiny is None: v.tiny = True for key in v.choices.iterkeys(): if len(key) > 5 or ' ' in key: v.tiny = False break if v.tiny: question = u'%s (%s)' % (question, '/'.join((s.upper() if s == v.default else s) for s in v.choices.iterkeys())) for s in v.choices.iterkeys(): if s == v.default: aliases[s.upper()] = s for key, value in v.choices.iteritems(): print(' %s%s%s: %s' % (self.BOLD, key, self.NC, value)) else: for n, (key, value) in enumerate(v.choices.iteritems()): print(' %s%2d)%s %s' % (self.BOLD, n + 1, self.NC, value.encode(self.encoding))) aliases[str(n + 1)] = key question = u'%s (choose in list)' % question if v.masked: question = u'%s (hidden input)' % question if not isinstance(v, ValueBool) and not v.tiny and v.default not in (None, ''): question = u'%s [%s]' % (question, '*******' if v.masked else v.default) question += ': ' while True: if v.masked: if sys.platform == 'win32': line = getpass.getpass(str(question)) else: line = getpass.getpass(question.encode(self.encoding)) else: self.stdout.write(question.encode(self.encoding)) self.stdout.flush() line = self.stdin.readline() if len(line) == 0: raise EOFError() else: line = line.rstrip('\r\n') if not line and v.default is not None: line = v.default if isinstance(line, str): line = line.decode('utf-8') if line in aliases: line = aliases[line] try: v.set(line) except ValueError as e: print(u'Error: %s' % e, file=self.stderr) else: break v.noprompt = True return v.get() def acquire_input(self, content=None, editor_params=None): editor = os.getenv('EDITOR', 'vi') if self.stdin.isatty() and editor: from tempfile import NamedTemporaryFile with NamedTemporaryFile() as f: filename = f.name if content is not None: if isinstance(content, unicode): content = content.encode(self.encoding) f.write(content) f.flush() try: params = editor_params[os.path.basename(editor)] except (KeyError,TypeError): params = '' os.system("%s %s %s" % (editor, params, filename)) f.seek(0) text = f.read() else: if self.stdin.isatty(): print('Reading content from stdin... Type ctrl-D ' 'from an empty line to stop.') text = self.stdin.read() return text.decode(self.encoding) def bcall_error_handler(self, backend, error, backtrace): """ Handler for an exception inside the CallErrors exception. This method can be overrided to support more exceptions types. """ if isinstance(error, BrowserQuestion): for field in error.fields: v = self.ask(field) if v: backend.config[field.id].set(v) elif isinstance(error, BrowserIncorrectPassword): msg = unicode(error) if not msg: msg = 'invalid login/password.' print('Error(%s): %s' % (backend.name, msg), file=self.stderr) if self.ask('Do you want to reconfigure this backend?', default=True): self.unload_backends(names=[backend.name]) self.edit_backend(backend.name) self.load_backends(names=[backend.name]) elif isinstance(error, BrowserSSLError): print(u'FATAL(%s): ' % backend.name + self.BOLD + '/!\ SERVER CERTIFICATE IS INVALID /!\\' + self.NC, file=self.stderr) elif isinstance(error, BrowserForbidden): msg = unicode(error) print(u'Error(%s): %s' % (backend.name, msg or 'Forbidden'), file=self.stderr) elif isinstance(error, BrowserUnavailable): msg = unicode(error) if not msg: msg = 'website is unavailable.' print(u'Error(%s): %s' % (backend.name, msg), file=self.stderr) elif isinstance(error, NotImplementedError): print(u'Error(%s): this feature is not supported yet by this backend.' % backend.name, file=self.stderr) print(u' %s To help the maintainer of this backend implement this feature,' % (' ' * len(backend.name)), file=self.stderr) print(u' %s please contact: %s <%s@issues.weboob.org>' % (' ' * len(backend.name), backend.MAINTAINER, backend.NAME), file=self.stderr) elif isinstance(error, UserError): print(u'Error(%s): %s' % (backend.name, to_unicode(error)), file=self.stderr) elif isinstance(error, MoreResultsAvailable): print(u'Hint: There are more results for backend %s' % (backend.name), file=self.stderr) else: print(u'Bug(%s): %s' % (backend.name, to_unicode(error)), file=self.stderr) minfo = self.weboob.repositories.get_module_info(backend.NAME) if minfo and not minfo.is_local(): self.weboob.repositories.update_repositories(ConsoleProgress(self)) # minfo of the new available module minfo = self.weboob.repositories.get_module_info(backend.NAME) if minfo and minfo.version > self.weboob.repositories.versions.get(minfo.name) and \ self.ask('A new version of %s is available. Do you want to install it?' % minfo.name, default=True) and \ self.install_module(minfo): print('New version of module %s has been installed. Retry to call the command.' % minfo.name) return if logging.root.level <= logging.DEBUG: print(backtrace, file=self.stderr) else: return True def bcall_errors_handler(self, errors, debugmsg='Use --debug option to print backtraces', ignore=()): """ Handler for the CallErrors exception. """ ask_debug_mode = False more_results = set() for backend, error, backtrace in errors.errors: if isinstance(error, MoreResultsAvailable): more_results.add(backend.name) elif isinstance(error, ignore): continue elif self.bcall_error_handler(backend, error, backtrace): ask_debug_mode = True if ask_debug_mode: print(debugmsg, file=self.stderr) elif len(more_results) > 0: print('Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results)), file=self.stderr) weboob-1.1/weboob/tools/application/formatters/000077500000000000000000000000001265717027300217505ustar00rootroot00000000000000weboob-1.1/weboob/tools/application/formatters/__init__.py000066400000000000000000000000001265717027300240470ustar00rootroot00000000000000weboob-1.1/weboob/tools/application/formatters/csv.py000066400000000000000000000024671265717027300231260ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .iformatter import IFormatter __all__ = ['CSVFormatter'] class CSVFormatter(IFormatter): def __init__(self, field_separator=u';'): IFormatter.__init__(self) self.field_separator = field_separator self.started = False def flush(self): self.started = False def format_dict(self, item): result = u'' if not self.started: result += self.field_separator.join(item.iterkeys()) + '\n' self.started = True result += self.field_separator.join(unicode(v) for v in item.itervalues()) return result weboob-1.1/weboob/tools/application/formatters/iformatter.py000066400000000000000000000232001265717027300244730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Christophe Benz, Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import os import sys import subprocess try: from termcolor import colored except ImportError: def colored(s, color=None, on_color=None, attrs=None): if os.getenv('ANSI_COLORS_DISABLED') is None \ and attrs is not None and 'bold' in attrs: return '%s%s%s' % (IFormatter.BOLD, s, IFormatter.NC) else: return s try: import tty import termios except ImportError: PROMPT = '--Press return to continue--' def readch(): return sys.stdin.readline() else: PROMPT = '--Press a key to continue--' def readch(): fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) tty.setcbreak(fd) try: c = sys.stdin.read(1) # XXX do not read magic number if c == '\x03': raise KeyboardInterrupt() return c finally: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) from weboob.capabilities.base import BaseObject from weboob.tools.application.console import ConsoleApplication from weboob.tools.ordereddict import OrderedDict from weboob.tools.misc import guess_encoding __all__ = ['IFormatter', 'MandatoryFieldsNotFound'] class MandatoryFieldsNotFound(Exception): def __init__(self, missing_fields): Exception.__init__(self, u'Mandatory fields not found: %s.' % ', '.join(missing_fields)) class IFormatter(object): # Tuple of fields mandatory to not crash MANDATORY_FIELDS = None # Tuple of displayed field. Set to None if all available fields are # displayed DISPLAYED_FIELDS = None BOLD = ConsoleApplication.BOLD NC = ConsoleApplication.NC def colored(self, string, color, attrs=None, on_color=None): if self.outfile != sys.stdout or not self.outfile.isatty(): return string if isinstance(attrs, basestring): attrs = [attrs] return colored(string, color, on_color=on_color, attrs=attrs) def __init__(self, display_keys=True, display_header=True, outfile=sys.stdout): self.display_keys = display_keys self.display_header = display_header self.interactive = False self.print_lines = 0 self.termrows = 0 self.termcols = None self.outfile = outfile # XXX if stdin is not a tty, it seems that the command fails. if sys.stdout.isatty() and sys.stdin.isatty(): if sys.platform == 'win32': from ctypes import windll, create_string_buffer h = windll.kernel32.GetStdHandle(-12) csbi = create_string_buffer(22) res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi) if res: import struct (bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw) self.termrows = right - left + 1 self.termcols = bottom - top + 1 else: self.termrows = 80 # can't determine actual size - return default values self.termcols = 80 else: self.termrows = int( subprocess.Popen('stty size', shell=True, stdout=subprocess.PIPE).communicate()[0].split()[0] ) self.termcols = int( subprocess.Popen('stty size', shell=True, stdout=subprocess.PIPE).communicate()[0].split()[1] ) def output(self, formatted): if self.outfile != sys.stdout: with open(self.outfile, "a+") as outfile: outfile.write(formatted.encode(guess_encoding(outfile), 'replace') + os.linesep) else: for line in formatted.split('\n'): if self.termrows and (self.print_lines + 1) >= self.termrows: self.outfile.write(PROMPT) self.outfile.flush() readch() self.outfile.write('\b \b' * len(PROMPT)) self.print_lines = 0 plen = len('%s'.replace(self.BOLD, '').replace(self.NC, '') % line) if isinstance(line, unicode): line = line.encode(guess_encoding(self.outfile), 'replace') print(line) if self.termcols: self.print_lines += int(plen/self.termcols) + 1 else: self.print_lines += 1 def start_format(self, **kwargs): pass def flush(self): pass def format(self, obj, selected_fields=None, alias=None): """ Format an object to be human-readable. An object has fields which can be selected. :param obj: object to format :type obj: BaseObject or dict :param selected_fields: fields to display. If None, all fields are selected :type selected_fields: tuple :param alias: an alias to use instead of the object's ID :type alias: unicode """ if isinstance(obj, BaseObject): if selected_fields: # can be an empty list (nothing to do), or None (return all fields) obj = obj.copy() for name, value in obj.iter_fields(): if name not in selected_fields: delattr(obj, name) if self.MANDATORY_FIELDS: missing_fields = set(self.MANDATORY_FIELDS) - set([name for name, value in obj.iter_fields()]) if missing_fields: raise MandatoryFieldsNotFound(missing_fields) formatted = self.format_obj(obj, alias) else: try: obj = OrderedDict(obj) except ValueError: raise TypeError('Please give a BaseObject or a dict') if selected_fields: obj = obj.copy() for name, value in obj.iteritems(): if name not in selected_fields: obj.pop(name) if self.MANDATORY_FIELDS: missing_fields = set(self.MANDATORY_FIELDS) - set(obj.iterkeys()) if missing_fields: raise MandatoryFieldsNotFound(missing_fields) formatted = self.format_dict(obj) if formatted: self.output(formatted) return formatted def format_obj(self, obj, alias=None): """ Format an object to be human-readable. Called by format(). This method has to be overridden in child classes. :param obj: object to format :type obj: BaseObject :rtype: str """ return self.format_dict(obj.to_dict()) def format_dict(self, obj): """ Format a dict to be human-readable. :param obj: dict to format :type obj: dict :rtype: str """ return NotImplementedError() def format_collection(self, collection, only): """ Format a collection to be human-readable. :param collection: collection to format :type collection: BaseCollection :rtype: str """ if only is False or collection.basename in only: if collection.basename and collection.title: self.output(u'%s~ (%s) %s (%s)%s' % (self.BOLD, collection.basename, collection.title, collection.backend, self.NC)) else: self.output(u'%s~ (%s) (%s)%s' % (self.BOLD, collection.basename, collection.backend, self.NC)) class PrettyFormatter(IFormatter): def format_obj(self, obj, alias): title = self.get_title(obj) desc = self.get_description(obj) if alias is not None: result = u'%s %s %s (%s)' % (self.colored('%2s' % alias, 'red', 'bold'), self.colored(u'—', 'cyan', 'bold'), self.colored(title, 'yellow', 'bold'), self.colored(obj.backend, 'blue', 'bold')) else: result = u'%s %s %s' % (self.colored(obj.fullid, 'red', 'bold'), self.colored(u'—', 'cyan', 'bold'), self.colored(title, 'yellow', 'bold')) if desc is not None: result += u'%s\t%s' % (os.linesep, self.colored(desc, 'white')) return result def get_title(self, obj): raise NotImplementedError() def get_description(self, obj): return None def formatter_test_output(Formatter, obj): """ Formats an object and returns output as a string. For test purposes only. """ from tempfile import mkstemp from os import remove _, name = mkstemp() fmt = Formatter() fmt.outfile = name fmt.format(obj) fmt.flush() with open(name) as f: res = f.read() remove(name) return res weboob-1.1/weboob/tools/application/formatters/json.py000066400000000000000000000043211265717027300232730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013-2014 Julien Hebert, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.tools.json import json from .iformatter import IFormatter __all__ = ['JsonFormatter', 'JsonLineFormatter'] class Encoder(json.JSONEncoder): "generic weboob object encoder" def default(self, obj): try: return json.JSONEncoder.default(self, obj) except TypeError: if obj is NotAvailable or obj is NotLoaded: return None try: dct = obj.to_dict() except AttributeError: return str(obj) return dct class JsonFormatter(IFormatter): """ Formats the whole list as a single JSON list object. """ def __init__(self): IFormatter.__init__(self) self.queue = [] def flush(self): self.output(json.dumps(self.queue, cls=Encoder)) def format_dict(self, item): self.queue.append(item) def format_collection(self, collection, only): self.queue.append(collection.to_dict()) class JsonLineFormatter(IFormatter): """ Formats the list as received, with a JSON object per line. The advantage is that it can be streamed. """ def format_dict(self, item): self.output(json.dumps(item, cls=Encoder)) def test(): from .iformatter import formatter_test_output as fmt assert fmt(JsonFormatter, {'foo': 'bar'}) == '[{"foo": "bar"}]\n' assert fmt(JsonLineFormatter, {'foo': 'bar'}) == '{"foo": "bar"}\n' weboob-1.1/weboob/tools/application/formatters/load.py000066400000000000000000000053021265717027300232410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz, Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . __all__ = ['FormattersLoader', 'FormatterLoadError'] class FormatterLoadError(Exception): pass class FormattersLoader(object): BUILTINS = ['htmltable', 'multiline', 'simple', 'table', 'csv', 'webkit', 'json', 'json_line'] def __init__(self): self.formatters = {} def register_formatter(self, name, klass): self.formatters[name] = klass def get_available_formatters(self): l = set(self.formatters.iterkeys()) l = l.union(self.BUILTINS) l = sorted(l) return l def build_formatter(self, name): if name not in self.formatters: try: self.formatters[name] = self.load_builtin_formatter(name) except ImportError as e: FormattersLoader.BUILTINS.remove(name) raise FormatterLoadError('Unable to load formatter "%s": %s' % (name, e)) return self.formatters[name]() def load_builtin_formatter(self, name): if name not in self.BUILTINS: raise FormatterLoadError('Formatter "%s" does not exist' % name) if name == 'htmltable': from .table import HTMLTableFormatter return HTMLTableFormatter elif name == 'table': from .table import TableFormatter return TableFormatter elif name == 'simple': from .simple import SimpleFormatter return SimpleFormatter elif name == 'multiline': from .multiline import MultilineFormatter return MultilineFormatter elif name == 'webkit': from .webkit import WebkitGtkFormatter return WebkitGtkFormatter elif name == 'csv': from .csv import CSVFormatter return CSVFormatter elif name == 'json': from .json import JsonFormatter return JsonFormatter elif name == 'json_line': from .json import JsonLineFormatter return JsonLineFormatter weboob-1.1/weboob/tools/application/formatters/multiline.py000066400000000000000000000027061265717027300243310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.base import NotLoaded, NotAvailable from .iformatter import IFormatter __all__ = ['MultilineFormatter'] class MultilineFormatter(IFormatter): def __init__(self, key_value_separator=u': ', after_item=u'\n'): IFormatter.__init__(self) self.key_value_separator = key_value_separator self.after_item = after_item def flush(self): pass def format_dict(self, item): result = u'\n'.join(u'%s%s' % ( (u'%s%s' % (k, self.key_value_separator) if self.display_keys else ''), v) for k, v in item.iteritems() if (v is not NotLoaded and v is not NotAvailable)) if len(item) > 1: result += self.after_item return result weboob-1.1/weboob/tools/application/formatters/simple.py000066400000000000000000000023631265717027300236170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .iformatter import IFormatter __all__ = ['SimpleFormatter'] class SimpleFormatter(IFormatter): def __init__(self, field_separator=u'\t', key_value_separator=u'='): IFormatter.__init__(self) self.field_separator = field_separator self.key_value_separator = key_value_separator def format_dict(self, item): return self.field_separator.join(u'%s%s' % ( (u'%s%s' % (k, self.key_value_separator) if self.display_keys else ''), v) for k, v in item.iteritems()) weboob-1.1/weboob/tools/application/formatters/table.py000066400000000000000000000064631265717027300234220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from prettytable import PrettyTable from weboob.capabilities.base import empty from weboob.tools.misc import guess_encoding from .iformatter import IFormatter __all__ = ['TableFormatter', 'HTMLTableFormatter'] class TableFormatter(IFormatter): HTML = False def __init__(self): IFormatter.__init__(self) self.queue = [] self.keys = None self.header = None def flush(self): s = self.get_formatted_table() if s is not None: self.output(s.encode(guess_encoding(self.outfile), 'replace')) def get_formatted_table(self): if len(self.queue) == 0: return queue = [() for i in xrange(len(self.queue))] column_headers = [] # Do not display columns when all values are NotLoaded or NotAvailable for i in xrange(len(self.keys)): available = False for line in self.queue: if not empty(line[i]): available = True break if available: column_headers.append(self.keys[i].capitalize().replace('_', ' ')) for j in xrange(len(self.queue)): queue[j] += (self.queue[j][i],) s = '' if self.display_header and self.header: if self.HTML: s += '

%s

' % self.header else: s += self.header s += "\n" table = PrettyTable(list(column_headers)) for column_header in column_headers: # API changed in python-prettytable. The try/except is a bad hack to support both versions # Note: two versions are not exactly the same... # (first one: header in center. Second one: left align for header too) try: table.set_field_align(column_header, 'l') except: table.align[column_header] = 'l' for line in queue: table.add_row(line) if self.HTML: s += table.get_html_string() else: s += table.get_string() self.queue = [] return s def format_dict(self, item): if self.keys is None: self.keys = item.keys() self.queue.append(item.values()) def set_header(self, string): self.header = string class HTMLTableFormatter(TableFormatter): HTML = True def test(): from .iformatter import formatter_test_output as fmt assert fmt(TableFormatter, {'foo': 'bar'}) == \ '+-----+\n' \ '| Foo |\n' \ '+-----+\n' \ '| bar |\n' \ '+-----+\n' weboob-1.1/weboob/tools/application/formatters/webkit/000077500000000000000000000000001265717027300232355ustar00rootroot00000000000000weboob-1.1/weboob/tools/application/formatters/webkit/__init__.py000066400000000000000000000014561265717027300253540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from .webkitgtk import WebkitGtkFormatter __all__ = ['WebkitGtkFormatter'] weboob-1.1/weboob/tools/application/formatters/webkit/webkitgtk.py000066400000000000000000000051331265717027300256040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import os import gtk import webkit from weboob.tools.application.javascript import get_javascript from ..table import HTMLTableFormatter __all__ = ['WebkitGtkFormatter'] class WebBrowser(gtk.Window): def __init__(self): gtk.Window.__init__(self) self.connect('destroy', gtk.main_quit) self.set_default_size(800, 600) self.web_view = webkit.WebView() sw = gtk.ScrolledWindow() sw.add(self.web_view) self.add(sw) self.show_all() class WebkitGtkFormatter(HTMLTableFormatter): def flush(self): table_string = self.get_formatted_table() js_filepaths = [] js_filepaths.append(get_javascript('jquery')) js_filepaths.append(get_javascript('tablesorter')) scripts = ['' % js_filepath for js_filepath in js_filepaths] html_string_params = dict(table=table_string) if scripts: html_string_params['scripts'] = ''.join(scripts) html_string = """ %(scripts)s %(table)s """ % html_string_params web_browser = WebBrowser() web_browser.web_view.load_html_string(html_string, 'file://%s' % os.path.abspath(os.getcwd())) gtk.main() weboob-1.1/weboob/tools/application/javascript.py000066400000000000000000000034441265717027300223070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import os __all__ = ['get_javascript'] def get_javascript(name, load_order=('local', 'web'), minified=True): if name == 'jquery': for src in load_order: if src == 'local': # try Debian paths if minified: filepath = '/usr/share/javascript/jquery/jquery.min.js' else: filepath = '/usr/share/javascript/jquery/jquery.js' if os.path.exists(filepath): return filepath elif src == 'web': # return Google-hosted URLs if minified: return 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' else: return 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js' elif name == 'tablesorter': if 'web' in load_order: if minified: return 'http://tablesorter.com/jquery.tablesorter.min.js' else: return 'http://tablesorter.com/jquery.tablesorter.js' return None weboob-1.1/weboob/tools/application/media_player.py000066400000000000000000000156031265717027300225740ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz, Romain Bignon, John Obbele # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import os from subprocess import PIPE, Popen import cookielib import urllib2 from weboob.tools.log import getLogger __all__ = ['InvalidMediaPlayer', 'MediaPlayer', 'MediaPlayerNotFound'] PLAYERS = ( ('mpv', '-'), ('mplayer2', '-'), ('mplayer', '-'), ('vlc', '-'), ('parole', 'fd://0'), ('totem', 'fd://0'), ('xine', 'stdin:/'), ) class MediaPlayerNotFound(Exception): def __init__(self): Exception.__init__(self, u'No media player found on this system. Please install one of them: %s.' % ', '.join(player[0] for player in PLAYERS)) class InvalidMediaPlayer(Exception): def __init__(self, player_name): Exception.__init__(self, u'Invalid media player: %s. Valid media players: %s.' % ( player_name, ', '.join(player[0] for player in PLAYERS))) class MediaPlayer(object): """ Black magic invoking a media player to this world. Presently, due to strong disturbances in the holidays of the ether world, the media player used is chosen from a static list of programs. See PLAYERS for more information. """ def __init__(self, logger=None): self.logger = getLogger('mediaplayer', logger) def guess_player_name(self): for player_name in [player[0] for player in PLAYERS]: if self._find_in_path(os.environ['PATH'], player_name): return player_name return None def play(self, media, player_name=None, player_args=None): """ Play a media object, using programs from the PLAYERS list. This function dispatch calls to either _play_default or _play_rtmp for special rtmp streams using SWF verification. """ player_names = [player[0] for player in PLAYERS] if not player_name: self.logger.debug(u'No media player given. Using the first available from: %s.' % ', '.join(player_names)) player_name = self.guess_player_name() if player_name is None: raise MediaPlayerNotFound() if media.url.startswith('rtmp'): self._play_rtmp(media, player_name, args=player_args) else: self._play_default(media, player_name, args=player_args) def _play_default(self, media, player_name, args=None): """ Play media.url with the media player. """ # if flag play_proxy... if hasattr(media, '_play_proxy') and media._play_proxy is True: # use urllib2 to handle redirect and cookies self._play_proxy(media, player_name, args) return None args = player_name.split(' ') player_name = args[0] args.append(media.url) print('Invoking "%s".' % (' '.join(args))) os.spawnlp(os.P_WAIT, player_name, *args) def _play_proxy(self, media, player_name, args): """ Load data with python urllib2 and pipe data to a media player. We need this function for url that use redirection and cookies. This function is used if the non-standard, non-API compliant '_play_proxy' attribute of the 'media' object is defined and is True. """ if args is None: for (binary, stdin_args) in PLAYERS: if binary == player_name: args = stdin_args assert args is not None print(':: Play_proxy streaming from %s' % media.url) print(':: to %s %s' % (player_name, args)) print(player_name + ' ' + args) proc = Popen(player_name + ' ' + args, stdin=PIPE, shell=True) # Handle cookies (and redirection 302...) cj = cookielib.CookieJar() url_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) url_handler = url_opener.open(media.url) file_size = int(url_handler.info().getheaders("Content-Length")[0]) file_size_dl = 0 block_sz = 8192 while file_size_dl < file_size: _buffer = url_handler.read(block_sz) if not buffer: break file_size_dl += len(_buffer) try: proc.stdin.write(_buffer) except: print("play_proxy broken pipe. Can't write anymore.") break def _play_rtmp(self, media, player_name, args): """ Download data with rtmpdump and pipe them to a media player. You need a working version of rtmpdump installed and the SWF object url in order to comply with SWF verification requests from the server. The last one is retrieved from the non-standard non-API compliant 'swf_player' attribute of the 'media' object. """ if not self._find_in_path(os.environ['PATH'], 'rtmpdump'): self.logger.warning('"rtmpdump" binary not found') return self._play_default(media, player_name) media_url = media.url try: player_url = media.swf_player if media.swf_player: rtmp = 'rtmpdump -r %s --swfVfy %s' % (media_url, player_url) else: rtmp = 'rtmpdump -r %s' % media_url except AttributeError: self.logger.warning('Your media object does not have a "swf_player" attribute. SWF verification will be ' 'disabled and may prevent correct media playback.') return self._play_default(media, player_name) rtmp += ' --quiet' if args is None: for (binary, stdin_args) in PLAYERS: if binary == player_name: args = stdin_args assert args is not None player_name = player_name.split(' ') args = args.split(' ') print(':: Streaming from %s' % media_url) print(':: to %s %s' % (player_name, args)) print(':: %s' % rtmp) p1 = Popen(rtmp.split(), stdout=PIPE) Popen(player_name + args, stdin=p1.stdout, stderr=PIPE) def _find_in_path(self, path, filename): for i in path.split(':'): if os.path.exists('/'.join([i, filename])): return True return False weboob-1.1/weboob/tools/application/qt/000077500000000000000000000000001265717027300202065ustar00rootroot00000000000000weboob-1.1/weboob/tools/application/qt/Makefile000066400000000000000000000002641265717027300216500ustar00rootroot00000000000000UI_FILES = $(wildcard *.ui) UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py) PYUIC = pyuic4 all: $(UI_PY_FILES) %_ui.py: %.ui $(PYUIC) -o $@ $^ clean: rm -f *.pyc rm -f $(UI_PY_FILES) weboob-1.1/weboob/tools/application/qt/__init__.py000066400000000000000000000003011265717027300223110ustar00rootroot00000000000000from .qt import QtApplication, QtMainWindow, QtDo, HTMLDelegate from .backendcfg import BackendCfg __all__ = ['QtApplication', 'QtMainWindow', 'QtDo', 'HTMLDelegate', 'BackendCfg'] weboob-1.1/weboob/tools/application/qt/backendcfg.py000066400000000000000000000506371265717027300226420ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from PyQt4.QtGui import QDialog, QTreeWidgetItem, QLabel, QFormLayout, \ QMessageBox, QPixmap, QImage, QIcon, QHeaderView, \ QListWidgetItem, QTextDocument, QVBoxLayout, \ QDialogButtonBox, QProgressDialog from PyQt4.QtCore import SIGNAL, Qt, QVariant, QUrl, QThread import re import os from logging import warning from weboob.core.modules import ModuleLoadError from weboob.core.repositories import IProgress, ModuleInstallError from weboob.core.backendscfg import BackendAlreadyExists from weboob.capabilities.account import CapAccount, Account, AccountRegisterError from weboob.tools.application.qt.backendcfg_ui import Ui_BackendCfg from weboob.tools.application.qt.reposdlg_ui import Ui_RepositoriesDlg from weboob.tools.ordereddict import OrderedDict from weboob.tools.misc import to_unicode from .qt import QtValue class RepositoriesDialog(QDialog): def __init__(self, filename, parent=None): QDialog.__init__(self, parent) self.filename = filename self.ui = Ui_RepositoriesDlg() self.ui.setupUi(self) self.connect(self.ui.buttonBox, SIGNAL('accepted()'), self.save) with open(self.filename, 'r') as fp: self.ui.reposEdit.setPlainText(fp.read()) def save(self): with open(self.filename, 'w') as fp: fp.write(self.ui.reposEdit.toPlainText()) self.accept() class IconFetcher(QThread): def __init__(self, weboob, item, minfo): QThread.__init__(self) self.weboob = weboob self.items = [item] self.minfo = minfo def run(self): self.weboob.repositories.retrieve_icon(self.minfo) self.emit(SIGNAL('retrieved'), self) class ProgressDialog(IProgress, QProgressDialog): def __init__(self, *args, **kwargs): QProgressDialog.__init__(self, *args, **kwargs) def progress(self, percent, message): self.setValue(int(percent * 100)) self.setLabelText(message) def error(self, message): QMessageBox.critical(self, self.tr('Error'), '%s' % message, QMessageBox.Ok) def prompt(self, message): reply = QMessageBox.question(self, '', unicode(message), QMessageBox.Yes|QMessageBox.No) return reply == QMessageBox.Yes class BackendCfg(QDialog): def __init__(self, weboob, caps=None, parent=None): QDialog.__init__(self, parent) self.ui = Ui_BackendCfg() self.ui.setupUi(self) self.ui.backendsList.sortByColumn(0, Qt.AscendingOrder) self.to_unload = set() self.to_load = set() self.weboob = weboob self.caps = caps self.config_widgets = {} # This attribute is set when itemChanged it called, because when # a backend is enabled/disabled, we don't want to display its config # frame, and the itemClicked event is always emit just after a # itemChanged event. # is_enabling is a counter to prevent race conditions. self.is_enabling = 0 self.ui.backendsList.header().setResizeMode(QHeaderView.ResizeToContents) self.ui.configFrame.hide() self.icon_cache = {} self.icon_threads = {} self.loadModules() self.loadBackendsList() self.connect(self.ui.updateButton, SIGNAL('clicked()'), self.updateModules) self.connect(self.ui.repositoriesButton, SIGNAL('clicked()'), self.editRepositories) self.connect(self.ui.backendsList, SIGNAL('itemClicked(QTreeWidgetItem *, int)'), self.backendClicked) self.connect(self.ui.backendsList, SIGNAL('itemChanged(QTreeWidgetItem *, int)'), self.backendEnabled) self.connect(self.ui.modulesList, SIGNAL('itemSelectionChanged()'), self.moduleSelectionChanged) self.connect(self.ui.proxyBox, SIGNAL('toggled(bool)'), self.proxyEditEnabled) self.connect(self.ui.addButton, SIGNAL('clicked()'), self.addEvent) self.connect(self.ui.removeButton, SIGNAL('clicked()'), self.removeEvent) self.connect(self.ui.registerButton, SIGNAL('clicked()'), self.registerEvent) self.connect(self.ui.configButtonBox, SIGNAL('accepted()'), self.acceptBackend) self.connect(self.ui.configButtonBox, SIGNAL('rejected()'), self.rejectBackend) def get_icon_cache(self, path): if path not in self.icon_cache: img = QImage(path) self.icon_cache[path] = QIcon(QPixmap.fromImage(img)) return self.icon_cache[path] def set_icon(self, item, minfo): icon_path = self.weboob.repositories.get_module_icon_path(minfo) icon = self.icon_cache.get(icon_path, None) if icon is None and not os.path.exists(icon_path): if minfo.name in self.icon_threads: self.icon_threads[minfo.name].items.append(item) else: thread = IconFetcher(self.weboob, item, minfo) self.connect(thread, SIGNAL('retrieved'), lambda t: self._set_icon(t.items, t.minfo)) self.icon_threads[minfo.name] = thread thread.start() return self._set_icon([item], minfo) def _set_icon(self, items, minfo): icon_path = self.weboob.repositories.get_module_icon_path(minfo) icon = self.get_icon_cache(icon_path) if icon is None: return for item in items: try: item.setIcon(icon) except TypeError: item.setIcon(0, icon) self.icon_threads.pop(minfo.name, None) def updateModules(self): self.ui.configFrame.hide() pd = ProgressDialog('Update of modules', "Cancel", 0, 100, self) pd.setWindowModality(Qt.WindowModal) try: self.weboob.repositories.update(pd) except ModuleInstallError as err: QMessageBox.critical(self, self.tr('Update error'), unicode(self.tr('Unable to update modules: %s' % (err))), QMessageBox.Ok) pd.setValue(100) self.loadModules() QMessageBox.information(self, self.tr('Update of modules'), self.tr('Modules updated!'), QMessageBox.Ok) def editRepositories(self): if RepositoriesDialog(self.weboob.repositories.sources_list).exec_(): self.updateModules() def loadModules(self): self.ui.modulesList.clear() for name, module in sorted(self.weboob.repositories.get_all_modules_info(self.caps).iteritems()): item = QListWidgetItem(name.capitalize()) self.set_icon(item, module) self.ui.modulesList.addItem(item) def askInstallModule(self, minfo): reply = QMessageBox.question(self, self.tr('Install a module'), unicode(self.tr("Module %s is not installed. Do you want to install it?")) % minfo.name, QMessageBox.Yes|QMessageBox.No) if reply != QMessageBox.Yes: return False return self.installModule(minfo) def installModule(self, minfo): pd = ProgressDialog('Installation of %s' % minfo.name, "Cancel", 0, 100, self) pd.setWindowModality(Qt.WindowModal) try: self.weboob.repositories.install(minfo, pd) except ModuleInstallError as err: QMessageBox.critical(self, self.tr('Install error'), unicode(self.tr('Unable to install module %s: %s' % (minfo.name, err))), QMessageBox.Ok) pd.setValue(100) return True def loadBackendsList(self): self.ui.backendsList.clear() for backend_name, module_name, params in self.weboob.backends_config.iter_backends(): info = self.weboob.repositories.get_module_info(module_name) if not info or (self.caps and not info.has_caps(self.caps)): continue item = QTreeWidgetItem(None, [backend_name, module_name]) item.setCheckState(0, Qt.Checked if params.get('_enabled', '1').lower() in ('1', 'y', 'true', 'on', 'yes') else Qt.Unchecked) self.set_icon(item, info) self.ui.backendsList.addTopLevelItem(item) def backendEnabled(self, item, col): self.is_enabling += 1 backend_name = unicode(item.text(0)) module_name = unicode(item.text(1)) if item.checkState(0) == Qt.Checked: self.to_load.add(backend_name) enabled = 'true' else: self.to_unload.add(backend_name) try: self.to_load.remove(backend_name) except KeyError: pass enabled = 'false' self.weboob.backends_config.edit_backend(backend_name, module_name, {'_enabled': enabled}) def backendClicked(self, item, col): if self.is_enabling: self.is_enabling -= 1 return backend_name = unicode(item.text(0)) self.editBackend(backend_name) def addEvent(self): self.editBackend() def removeEvent(self): item = self.ui.backendsList.currentItem() if not item: return backend_name = unicode(item.text(0)) reply = QMessageBox.question(self, self.tr('Remove a backend'), unicode(self.tr("Are you sure you want to remove the backend '%s'?")) % backend_name, QMessageBox.Yes|QMessageBox.No) if reply != QMessageBox.Yes: return self.weboob.backends_config.remove_backend(backend_name) self.to_unload.add(backend_name) try: self.to_load.remove(backend_name) except KeyError: pass self.ui.configFrame.hide() self.loadBackendsList() def editBackend(self, backend_name=None): self.ui.registerButton.hide() self.ui.configFrame.show() if backend_name is not None: module_name, params = self.weboob.backends_config.get_backend(backend_name) items = self.ui.modulesList.findItems(module_name, Qt.MatchFixedString) if not items: warning('Backend not found') else: self.ui.modulesList.setCurrentItem(items[0]) self.ui.modulesList.setEnabled(False) self.ui.nameEdit.setText(backend_name) self.ui.nameEdit.setEnabled(False) if '_proxy' in params: self.ui.proxyBox.setChecked(True) self.ui.proxyEdit.setText(params.pop('_proxy')) else: self.ui.proxyBox.setChecked(False) self.ui.proxyEdit.clear() params.pop('_enabled', None) info = self.weboob.repositories.get_module_info(module_name) if info and (info.is_installed() or self.installModule(info)): module = self.weboob.modules_loader.get_or_load_module(module_name) for key, value in module.config.load(self.weboob, module_name, backend_name, params, nofail=True).iteritems(): try: l, widget = self.config_widgets[key] except KeyError: warning('Key "%s" is not found' % key) else: # Do not prompt user for value (for example a password if it is empty). value.noprompt = True widget.set_value(value) return self.ui.nameEdit.clear() self.ui.nameEdit.setEnabled(True) self.ui.proxyBox.setChecked(False) self.ui.proxyEdit.clear() self.ui.modulesList.setEnabled(True) self.ui.modulesList.setCurrentRow(-1) def moduleSelectionChanged(self): for key, (label, value) in self.config_widgets.iteritems(): label.hide() value.hide() self.ui.configLayout.removeWidget(label) self.ui.configLayout.removeWidget(value) label.deleteLater() value.deleteLater() self.config_widgets = {} self.ui.moduleInfo.clear() selection = self.ui.modulesList.selectedItems() if not selection: return minfo = self.weboob.repositories.get_module_info(unicode(selection[0].text()).lower()) if not minfo: warning('Module not found') return if not minfo.is_installed() and not self.installModule(minfo): self.editBackend(None) return module = self.weboob.modules_loader.get_or_load_module(minfo.name) icon_path = os.path.join(self.weboob.repositories.icons_dir, '%s.png' % minfo.name) img = QImage(icon_path) self.ui.moduleInfo.document().addResource(QTextDocument.ImageResource, QUrl('mydata://logo.png'), QVariant(img)) if module.name not in [n for n, ign, ign2 in self.weboob.backends_config.iter_backends()]: self.ui.nameEdit.setText(module.name) else: self.ui.nameEdit.setText('') self.ui.moduleInfo.setText(to_unicode(self.tr( u'

%s Module %s

' 'Version: %s
' 'Maintainer: %s
' 'License: %s
' '%s' 'Description: %s
' 'Capabilities: %s
')) % ('', module.name.capitalize(), module.version, to_unicode(module.maintainer).replace(u'&', u'&').replace(u'<', u'<').replace(u'>', u'>'), module.license, (unicode(self.tr('Website: %s
')) % module.website) if module.website else '', module.description, ', '.join(sorted(cap.__name__.replace('Cap', '') for cap in module.iter_caps())))) if module.has_caps(CapAccount) and self.ui.nameEdit.isEnabled() and \ module.klass.ACCOUNT_REGISTER_PROPERTIES is not None: self.ui.registerButton.show() else: self.ui.registerButton.hide() for key, field in module.config.iteritems(): label = QLabel(u'%s:' % field.label) qvalue = QtValue(field) self.ui.configLayout.addRow(label, qvalue) self.config_widgets[key] = (label, qvalue) def proxyEditEnabled(self, state): self.ui.proxyEdit.setEnabled(state) def acceptBackend(self): backend_name = unicode(self.ui.nameEdit.text()) selection = self.ui.modulesList.selectedItems() if not selection: QMessageBox.critical(self, self.tr('Unable to add a backend'), self.tr('Please select a module')) return try: module = self.weboob.modules_loader.get_or_load_module(unicode(selection[0].text()).lower()) except ModuleLoadError: module = None if not module: QMessageBox.critical(self, self.tr('Unable to add a backend'), self.tr('The selected module does not exist.')) return params = {} if not backend_name: QMessageBox.critical(self, self.tr('Missing field'), self.tr('Please specify a backend name')) return if self.ui.nameEdit.isEnabled(): if not re.match(r'^[\w\-_]+$', backend_name): QMessageBox.critical(self, self.tr('Invalid value'), self.tr('The backend name can only contain letters and digits')) return if self.weboob.backends_config.backend_exists(backend_name): QMessageBox.critical(self, self.tr('Unable to create backend'), unicode(self.tr('Unable to create backend "%s": it already exists')) % backend_name) return if self.ui.proxyBox.isChecked(): params['_proxy'] = unicode(self.ui.proxyEdit.text()) if not params['_proxy']: QMessageBox.critical(self, self.tr('Missing field'), self.tr('Please specify a proxy URL')) return config = module.config.load(self.weboob, module.name, backend_name, {}, nofail=True) for key, field in config.iteritems(): label, qtvalue = self.config_widgets[key] try: value = qtvalue.get_value() except ValueError as e: QMessageBox.critical(self, self.tr('Invalid value'), unicode(self.tr('Invalid value for field "%s":

%s')) % (field.label, e)) return field.set(value.get()) try: config.save(edit=not self.ui.nameEdit.isEnabled(), params=params) except BackendAlreadyExists: QMessageBox.critical(self, self.tr('Unable to create backend'), unicode(self.tr('Unable to create backend "%s": it already exists')) % backend_name) return self.to_load.add(backend_name) self.ui.configFrame.hide() self.loadBackendsList() def rejectBackend(self): self.ui.configFrame.hide() def registerEvent(self): selection = self.ui.modulesList.selectedItems() if not selection: return try: module = self.weboob.modules_loader.get_or_load_module(unicode(selection[0].text()).lower()) except ModuleLoadError: module = None if not module: return dialog = QDialog(self) vbox = QVBoxLayout(dialog) if module.website: website = 'on the website %s' % module.website else: website = 'with the module %s' % module.name vbox.addWidget(QLabel('To create an account %s, please provide this information:' % website)) formlayout = QFormLayout() props_widgets = OrderedDict() for key, prop in module.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems(): widget = QtValue(prop) formlayout.addRow(QLabel(u'%s:' % prop.label), widget) props_widgets[prop.id] = widget vbox.addLayout(formlayout) buttonBox = QDialogButtonBox(dialog) buttonBox.setStandardButtons(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) self.connect(buttonBox, SIGNAL("accepted()"), dialog.accept) self.connect(buttonBox, SIGNAL("rejected()"), dialog.reject) vbox.addWidget(buttonBox) end = False while not end: end = True if dialog.exec_(): account = Account() account.properties = {} for key, widget in props_widgets.iteritems(): try: v = widget.get_value() except ValueError as e: QMessageBox.critical(self, self.tr('Invalid value'), unicode(self.tr('Invalid value for field "%s":

%s')) % (key, e)) end = False break else: account.properties[key] = v if end: try: module.klass.register_account(account) except AccountRegisterError as e: QMessageBox.critical(self, self.tr('Error during register'), unicode(self.tr('Unable to register account %s:

%s')) % (website, e)) end = False else: for key, value in account.properties.iteritems(): if key in self.config_widgets: self.config_widgets[key][1].set_value(value) def run(self): self.exec_() ret = (len(self.to_load) > 0 or len(self.to_unload) > 0) self.weboob.unload_backends(self.to_unload) self.weboob.load_backends(names=self.to_load) return ret weboob-1.1/weboob/tools/application/qt/backendcfg.ui000066400000000000000000000227641265717027300226270ustar00rootroot00000000000000 BackendCfg 0 0 622 516 Backends configuration 6 4 QFrame::StyledPanel QFrame::Raised 4 Update modules Repositories Qt::Horizontal 40 20 Qt::Vertical QAbstractItemView::NoEditTriggers 24 24 false false false true true false false false true Name Module QFrame::StyledPanel QFrame::Raised Add Remove Qt::Vertical 20 40 QFrame::StyledPanel QFrame::Raised Available modules: 0 0 24 24 1 true 1 0 QFrame::NoFrame QFrame::Plain 0 0 true QFormLayout::ExpandingFieldsGrow Proxy: false Register an account... Name: Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok QDialogButtonBox::Close backendsList addButton removeButton modulesList moduleInfo nameEdit proxyBox proxyEdit registerButton configButtonBox buttonBox buttonBox clicked(QAbstractButton*) BackendCfg accept() 312 591 312 306 weboob-1.1/weboob/tools/application/qt/qt.py000066400000000000000000000321201265717027300212020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import sys import logging import re from threading import Event from copy import copy from PyQt4.QtCore import QTimer, SIGNAL, QObject, QString, QSize, QVariant, QMutex, Qt from PyQt4.QtGui import QMainWindow, QApplication, QStyledItemDelegate, \ QStyleOptionViewItemV4, QTextDocument, QStyle, \ QAbstractTextDocumentLayout, QPalette, QMessageBox, \ QSpinBox, QLineEdit, QComboBox, QCheckBox, QInputDialog from weboob.core.ouiboube import Weboob, VersionsMismatchError from weboob.core.scheduler import IScheduler from weboob.core.repositories import ModuleInstallError from weboob.tools.config.iconfig import ConfigError from weboob.exceptions import BrowserUnavailable, BrowserIncorrectPassword, BrowserForbidden from weboob.tools.value import ValueInt, ValueBool, ValueBackendPassword from weboob.tools.misc import to_unicode from weboob.capabilities import UserError from ..base import Application, MoreResultsAvailable __all__ = ['QtApplication', 'QtMainWindow', 'QtDo', 'HTMLDelegate'] class QtScheduler(IScheduler): def __init__(self, app): self.app = app self.count = 0 self.timers = {} def schedule(self, interval, function, *args): timer = QTimer() timer.setInterval(interval * 1000) timer.setSingleShot(True) count = self.count self.count += 1 timer.start() self.app.connect(timer, SIGNAL("timeout()"), lambda: self.timeout(count, None, function, *args)) self.timers[count] = timer def repeat(self, interval, function, *args): timer = QTimer() timer.setSingleShot(False) count = self.count self.count += 1 timer.start(0) self.app.connect(timer, SIGNAL("timeout()"), lambda: self.timeout(count, interval, function, *args)) self.timers[count] = timer def timeout(self, _id, interval, function, *args): function(*args) if interval is None: self.timers.pop(_id) else: self.timers[_id].setInterval(interval * 1000) def want_stop(self): self.app.quit() def run(self): self.app.exec_() class QCallbacksManager(QObject): class Request(object): def __init__(self): self.event = Event() self.answer = None def __call__(self): raise NotImplementedError() class LoginRequest(Request): def __init__(self, backend_name, value): QCallbacksManager.Request.__init__(self) self.backend_name = backend_name self.value = value def __call__(self): password, ok = QInputDialog.getText(None, '%s request' % self.value.label, 'Please enter %s for %s' % (self.value.label, self.backend_name), QLineEdit.Password) return password def __init__(self, weboob, parent=None): QObject.__init__(self, parent) self.weboob = weboob self.weboob.callbacks['login'] = self.callback(self.LoginRequest) self.mutex = QMutex() self.requests = [] self.connect(self, SIGNAL('new_request'), self.do_request) def callback(self, klass): def cb(*args, **kwargs): return self.add_request(klass(*args, **kwargs)) return cb def do_request(self): self.mutex.lock() request = self.requests.pop() request.answer = request() request.event.set() self.mutex.unlock() def add_request(self, request): self.mutex.lock() self.requests.append(request) self.mutex.unlock() self.emit(SIGNAL('new_request')) request.event.wait() return request.answer class QtApplication(QApplication, Application): def __init__(self): QApplication.__init__(self, sys.argv) self.setApplicationName(self.APPNAME) Application.__init__(self) self.cbmanager = QCallbacksManager(self.weboob, self) def create_weboob(self): return Weboob(scheduler=QtScheduler(self)) def load_backends(self, *args, **kwargs): while True: try: return Application.load_backends(self, *args, **kwargs) except VersionsMismatchError as e: msg = 'Versions of modules mismatch with version of weboob.' except ConfigError as e: msg = unicode(e) res = QMessageBox.question(None, 'Configuration error', u'%s\n\nDo you want to update repositories?' % msg, QMessageBox.Yes|QMessageBox.No) if res == QMessageBox.No: raise e # Do not import it globally, it causes circular imports from .backendcfg import ProgressDialog pd = ProgressDialog('Update of repositories', "Cancel", 0, 100) pd.setWindowModality(Qt.WindowModal) try: self.weboob.update(pd) except ModuleInstallError as err: QMessageBox.critical(None, self.tr('Update error'), unicode(self.tr('Unable to update repositories: %s' % err)), QMessageBox.Ok) pd.setValue(100) QMessageBox.information(None, self.tr('Update of repositories'), self.tr('Repositories updated!'), QMessageBox.Ok) class QtMainWindow(QMainWindow): def __init__(self, parent=None): QMainWindow.__init__(self, parent) class QtDo(QObject): def __init__(self, weboob, cb, eb=None, fb=None): QObject.__init__(self) if not eb: eb = self.default_eb self.weboob = weboob self.process = None self.cb = cb self.eb = eb self.fb = fb self.connect(self, SIGNAL('cb'), self.local_cb) self.connect(self, SIGNAL('eb'), self.local_eb) self.connect(self, SIGNAL('fb'), self.local_fb) def do(self, *args, **kwargs): self.process = self.weboob.do(*args, **kwargs) self.process.callback_thread(self.thread_cb, self.thread_eb, self.thread_fb) def default_eb(self, backend, error, backtrace): if isinstance(error, MoreResultsAvailable): # This is not an error, ignore. return msg = unicode(error) if isinstance(error, BrowserIncorrectPassword): if not msg: msg = 'Invalid login/password.' elif isinstance(error, BrowserUnavailable): if not msg: msg = 'Website is unavailable.' elif isinstance(error, BrowserForbidden): if not msg: msg = 'This action is forbidden.' elif isinstance(error, NotImplementedError): msg = u'This feature is not supported by this backend.\n\n' \ u'To help the maintainer of this backend implement this feature, please contact: %s <%s>' % (backend.MAINTAINER, backend.EMAIL) elif isinstance(error, UserError): if not msg: msg = type(error).__name__ elif logging.root.level <= logging.DEBUG: msg += u'
' ul_opened = False for line in backtrace.split('\n'): m = re.match(' File (.*)', line) if m: if not ul_opened: msg += u'
    ' ul_opened = True else: msg += u'' msg += u'
  • %s' % m.group(1) else: msg += u'
    %s' % to_unicode(line) if ul_opened: msg += u'
' print(error, file=sys.stderr) print(backtrace, file=sys.stderr) QMessageBox.critical(None, unicode(self.tr('Error with backend %s')) % backend.name, msg, QMessageBox.Ok) def local_cb(self, data): if self.cb: self.cb(data) def local_eb(self, backend, error, backtrace): if self.eb: self.eb(backend, error, backtrace) def local_fb(self): if self.fb: self.fb() self.disconnect(self, SIGNAL('cb'), self.local_cb) self.disconnect(self, SIGNAL('eb'), self.local_eb) self.disconnect(self, SIGNAL('fb'), self.local_fb) self.process = None def thread_cb(self, data): self.emit(SIGNAL('cb'), data) def thread_eb(self, backend, error, backtrace): self.emit(SIGNAL('eb'), backend, error, backtrace) def thread_fb(self): self.emit(SIGNAL('fb')) class HTMLDelegate(QStyledItemDelegate): def paint(self, painter, option, index): optionV4 = QStyleOptionViewItemV4(option) self.initStyleOption(optionV4, index) style = optionV4.widget.style() if optionV4.widget else QApplication.style() doc = QTextDocument() doc.setHtml(optionV4.text) # painting item without text optionV4.text = QString() style.drawControl(QStyle.CE_ItemViewItem, optionV4, painter) ctx = QAbstractTextDocumentLayout.PaintContext() # Hilight text if item is selected if optionV4.state & QStyle.State_Selected: ctx.palette.setColor(QPalette.Text, optionV4.palette.color(QPalette.Active, QPalette.HighlightedText)) textRect = style.subElementRect(QStyle.SE_ItemViewItemText, optionV4) painter.save() painter.translate(textRect.topLeft()) painter.setClipRect(textRect.translated(-textRect.topLeft())) doc.documentLayout().draw(painter, ctx) painter.restore() def sizeHint(self, option, index): optionV4 = QStyleOptionViewItemV4(option) self.initStyleOption(optionV4, index) doc = QTextDocument() doc.setHtml(optionV4.text) doc.setTextWidth(optionV4.rect.width()) return QSize(doc.idealWidth(), max(doc.size().height(), optionV4.decorationSize.height())) class _QtValueStr(QLineEdit): def __init__(self, value): QLineEdit.__init__(self) self._value = value if value.default: self.setText(unicode(value.default)) if value.masked: self.setEchoMode(self.Password) def set_value(self, value): self._value = value self.setText(self._value.get()) def get_value(self): self._value.set(unicode(self.text())) return self._value class _QtValueBackendPassword(_QtValueStr): def get_value(self): self._value._domain = None return _QtValueStr.get_value(self) class _QtValueBool(QCheckBox): def __init__(self, value): QCheckBox.__init__(self) self._value = value if value.default: self.setChecked(True) def set_value(self, value): self._value = value self.setChecked(self._value.get()) def get_value(self): self._value.set(self.isChecked()) return self._value class _QtValueInt(QSpinBox): def __init__(self, value): QSpinBox.__init__(self) self._value = value if value.default: self.setValue(int(value.default)) def set_value(self, value): self._value = value self.setValue(self._value.get()) def get_value(self): self._value.set(self.getValue()) return self._value class _QtValueChoices(QComboBox): def __init__(self, value): QComboBox.__init__(self) self._value = value for k, l in value.choices.iteritems(): self.addItem(l, QVariant(k)) if value.default == k: self.setCurrentIndex(self.count()-1) def set_value(self, value): self._value = value for i in xrange(self.count()): if unicode(self.itemData(i).toString()) == self._value.get(): self.setCurrentIndex(i) return def get_value(self): self._value.set(unicode(self.itemData(self.currentIndex()).toString())) return self._value def QtValue(value): if isinstance(value, ValueBool): klass = _QtValueBool elif isinstance(value, ValueInt): klass = _QtValueInt elif isinstance(value, ValueBackendPassword): klass = _QtValueBackendPassword elif value.choices is not None: klass = _QtValueChoices else: klass = _QtValueStr return klass(copy(value)) weboob-1.1/weboob/tools/application/qt/reposdlg.ui000066400000000000000000000022351265717027300223660ustar00rootroot00000000000000 RepositoriesDlg 0 0 400 300 Repositories Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok buttonBox rejected() RepositoriesDlg reject() 316 260 286 274 weboob-1.1/weboob/tools/application/repl.py000066400000000000000000001343431265717027300211060ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Christophe Benz, Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import atexit from cmd import Cmd import logging import re from optparse import OptionGroup, OptionParser, IndentedHelpFormatter from datetime import datetime import os from weboob.capabilities.base import FieldNotFound, BaseObject, UserError from weboob.core import CallErrors from weboob.tools.application.formatters.iformatter import MandatoryFieldsNotFound from weboob.tools.misc import to_unicode from weboob.tools.path import WorkingPath from weboob.tools.ordereddict import OrderedDict from weboob.capabilities.collection import Collection, BaseCollection, CapCollection, CollectionNotFound from .console import BackendNotGiven, ConsoleApplication from .formatters.load import FormattersLoader, FormatterLoadError from .results import ResultsCondition, ResultsConditionError __all__ = ['NotEnoughArguments', 'ReplApplication'] class NotEnoughArguments(Exception): pass class ReplOptionParser(OptionParser): def format_option_help(self, formatter=None): if not formatter: formatter = self.formatter return '%s\n%s' % (formatter.format_commands(self.commands), OptionParser.format_option_help(self, formatter)) class ReplOptionFormatter(IndentedHelpFormatter): def format_commands(self, commands): s = u'' for section, cmds in commands.iteritems(): if len(cmds) == 0: continue if len(s) > 0: s += '\n' s += '%s Commands:\n' % section for c in cmds: c = c.split('\n')[0] s += ' %s\n' % c return s def defaultcount(default_count=10): def deco(f): def inner(self, *args, **kwargs): oldvalue = self.options.count if self._is_default_count: self.options.count = default_count try: return f(self, *args, **kwargs) finally: self.options.count = oldvalue inner.__doc__ = f.__doc__ assert inner.__doc__ is not None, "A command must have a docstring" inner.__doc__ += '\nDefault is limited to %s results.' % default_count return inner return deco class ReplApplication(Cmd, ConsoleApplication): """ Base application class for Repl applications. """ SYNOPSIS = 'Usage: %prog [-dqv] [-b backends] [-cnfs] [command [arguments..]]\n' SYNOPSIS += ' %prog [--help] [--version]' DISABLE_REPL = False EXTRA_FORMATTERS = {} DEFAULT_FORMATTER = 'multiline' COMMANDS_FORMATTERS = {} # Objects to allow in do_ls / do_cd COLLECTION_OBJECTS = tuple() weboob_commands = set(['backends', 'condition', 'count', 'formatter', 'logging', 'select', 'quit', 'ls', 'cd']) hidden_commands = set(['EOF']) def __init__(self): Cmd.__init__(self) ConsoleApplication.__init__(self, ReplOptionParser(self.SYNOPSIS, version=self._get_optparse_version())) copyright = self.COPYRIGHT.replace('YEAR', '%d' % datetime.today().year).encode(self.encoding) self.intro = '\n'.join(('Welcome to %s%s%s v%s' % (self.BOLD, self.APPNAME, self.NC, self.VERSION), '', copyright, 'This program is free software: you can redistribute it and/or modify', 'it under the terms of the GNU Affero General Public License as published by', 'the Free Software Foundation, either version 3 of the License, or', '(at your option) any later version.', '', 'Type "help" to display available commands.', '', )) self.formatters_loader = FormattersLoader() for key, klass in self.EXTRA_FORMATTERS.iteritems(): self.formatters_loader.register_formatter(key, klass) self.formatter = None self.commands_formatters = self.COMMANDS_FORMATTERS.copy() commands_help = self.get_commands_doc() self._parser.commands = commands_help self._parser.formatter = ReplOptionFormatter() results_options = OptionGroup(self._parser, 'Results Options') results_options.add_option('-c', '--condition', help='filter result items to display given a boolean expression. See CONDITION section for the syntax') results_options.add_option('-n', '--count', type='int', help='limit number of results (from each backends)') results_options.add_option('-s', '--select', help='select result item keys to display (comma separated)') self._parser.add_option_group(results_options) formatting_options = OptionGroup(self._parser, 'Formatting Options') available_formatters = self.formatters_loader.get_available_formatters() formatting_options.add_option('-f', '--formatter', choices=available_formatters, help='select output formatter (%s)' % u', '.join(available_formatters)) formatting_options.add_option('--no-header', dest='no_header', action='store_true', help='do not display header') formatting_options.add_option('--no-keys', dest='no_keys', action='store_true', help='do not display item keys') formatting_options.add_option('-O', '--outfile', dest='outfile', help='file to export result') self._parser.add_option_group(formatting_options) self._interactive = False self.working_path = WorkingPath() self._change_prompt() @property def interactive(self): return self._interactive def _change_prompt(self): self.objects = [] self.collections = [] # XXX can't use bold prompt because: # 1. it causes problems when trying to get history (lines don't start # at the right place). # 2. when typing a line longer than term width, cursor goes at start # of the same line instead of new line. #self.prompt = self.BOLD + '%s> ' % self.APPNAME + self.NC if len(self.working_path.get()): wp_enc = unicode(self.working_path).encode(self.encoding) self.prompt = '%s:%s> ' % (self.APPNAME, wp_enc) else: self.prompt = '%s> ' % (self.APPNAME) def change_path(self, split_path): self.working_path.location(split_path) self._change_prompt() def add_object(self, obj): self.objects.append(obj) def _complete_object(self): return [obj.fullid for obj in self.objects] def parse_id(self, id, unique_backend=False): if self.interactive: try: obj = self.objects[int(id) - 1] except (IndexError, ValueError): # Try to find a shortcut in the cache for obj in self.objects: if id in obj.id: id = obj.fullid break else: if isinstance(obj, BaseObject): id = obj.fullid try: return ConsoleApplication.parse_id(self, id, unique_backend) except BackendNotGiven as e: backend_name = None while not backend_name: print('This command works with an unique backend. Availables:') for index, (name, backend) in enumerate(e.backends): print('%s%d)%s %s%-15s%s %s' % (self.BOLD, index + 1, self.NC, self.BOLD, name, self.NC, backend.DESCRIPTION)) i = self.ask('Select a backend to proceed with "%s"' % id) if not i.isdigit(): if i not in dict(e.backends): print('Error: %s is not a valid backend' % i, file=self.stderr) continue backend_name = i else: i = int(i) if i < 0 or i > len(e.backends): print('Error: %s is not a valid choice' % i, file=self.stderr) continue backend_name = e.backends[i-1][0] return id, backend_name def get_object(self, _id, method, fields=None, caps=None): if self.interactive: try: obj = self.objects[int(_id) - 1] except (IndexError, ValueError): pass else: try: backend = self.weboob.get_backend(obj.backend) actual_method = getattr(backend, method, None) if actual_method is None: return None else: if callable(actual_method): return backend.fillobj(obj, fields) else: return None except UserError as e: self.bcall_error_handler(backend, e, '') _id, backend_name = self.parse_id(_id) kargs = {} if caps is not None: kargs = {'caps': caps} backend_names = (backend_name,) if backend_name is not None else self.enabled_backends # if backend's service returns several objects, try to find the one # with wanted ID. If not found, get the last not None object. obj = None # remove backends that do not have the required method new_backend_names = [] for backend in backend_names: if isinstance(backend, (str, unicode)): actual_backend = self.weboob.get_backend(backend) else: actual_backend = backend if getattr(actual_backend, method, None) is not None: new_backend_names.append(backend) backend_names = tuple(new_backend_names) try: for objiter in self.do(method, _id, backends=backend_names, fields=fields, **kargs): if objiter: obj = objiter if objiter.id == _id: return obj except CallErrors as e: if obj is not None: self.bcall_errors_handler(e) else: raise return obj def get_object_list(self, method=None, *args, **kwargs): # return cache if not empty if len(self.objects) > 0: return self.objects elif method is not None: kwargs['backends'] = self.enabled_backends for _object in self.weboob.do(self._do_complete, None, None, method, *args, **kwargs): self.add_object(_object) return self.objects # XXX: what can we do without method? else: return tuple() def unload_backends(self, *args, **kwargs): self.objects = [] self.collections = [] return ConsoleApplication.unload_backends(self, *args, **kwargs) def load_backends(self, *args, **kwargs): self.objects = [] self.collections = [] return ConsoleApplication.load_backends(self, *args, **kwargs) def main(self, argv): cmd_args = argv[1:] if cmd_args: cmd_line = u' '.join(cmd_args) cmds = cmd_line.split(';') for cmd in cmds: ret = self.onecmd(cmd) if ret: return ret elif self.DISABLE_REPL: self._parser.print_help() self._parser.exit() else: try: import readline except ImportError: pass else: # Remove '-' from delims readline.set_completer_delims(readline.get_completer_delims().replace('-', '')) history_filepath = os.path.join(self.weboob.workdir, '%s_history' % self.APPNAME) try: readline.read_history_file(history_filepath) except IOError: pass def savehist(): readline.write_history_file(history_filepath) atexit.register(savehist) self.intro += '\nLoaded backends: %s\n' % ', '.join(sorted(backend.name for backend in self.weboob.iter_backends())) self._interactive = True self.cmdloop() def do(self, function, *args, **kwargs): """ Call Weboob.do(), passing count and selected fields given by user. """ backends = kwargs.pop('backends', None) if backends is None: kwargs['backends'] = [] for backend in self.enabled_backends: actual_function = getattr(backend, function, None) if isinstance(function, basestring) else function if callable(actual_function): kwargs['backends'].append(backend) else: kwargs['backends'] = backends fields = kwargs.pop('fields', self.selected_fields) if not fields and fields != []: fields = self.selected_fields fields = self.parse_fields(fields) if fields and self.formatter.MANDATORY_FIELDS is not None: missing_fields = set(self.formatter.MANDATORY_FIELDS) - set(fields) # If a mandatory field is not selected, do not use the customized formatter if missing_fields: print('Warning: you do not select enough mandatory fields for the formatter. Fallback to another. Hint: use option -f', file=self.stderr) self.formatter = self.formatters_loader.build_formatter(ReplApplication.DEFAULT_FORMATTER) if self.formatter.DISPLAYED_FIELDS is not None: if fields is None: missing_fields = True else: missing_fields = set(fields) - set(self.formatter.DISPLAYED_FIELDS + self.formatter.MANDATORY_FIELDS) # If a selected field is not displayed, do not use the customized formatter if missing_fields: print('Warning: some selected fields will not be displayed by the formatter. Fallback to another. Hint: use option -f', file=self.stderr) self.formatter = self.formatters_loader.build_formatter(ReplApplication.DEFAULT_FORMATTER) return self.weboob.do(self._do_complete, self.options.count, fields, function, *args, **kwargs) # -- command tools ------------ def parse_command_args(self, line, nb, req_n=None): if line.strip() == '': # because ''.split() = [''] args = [] else: args = line.strip().split(' ', nb - 1) if req_n is not None and (len(args) < req_n): raise NotEnoughArguments('Command needs %d arguments' % req_n) if len(args) < nb: args += tuple(None for i in xrange(nb - len(args))) return args # -- cmd.Cmd methods --------- def postcmd(self, stop, line): """ This REPL method is overrided to return None instead of integers to prevent stopping cmdloop(). """ if not isinstance(stop, bool): stop = None return stop def parseline(self, line): """ This REPL method is overrided to search "short" alias of commands """ cmd, arg, ignored = Cmd.parseline(self, line) if cmd is not None: names = set(name for name in self.get_names() if name.startswith('do_')) if 'do_' + cmd not in names: long = set(name for name in names if name.startswith('do_' + cmd)) # if more than one result, ambiguous command, do nothing (error will display suggestions) if len(long) == 1: cmd = long.pop()[3:] return cmd, arg, ignored def onecmd(self, line): """ This REPL method is overrided to catch some particular exceptions. """ line = to_unicode(line) cmd, arg, ignored = self.parseline(line) # Set the right formatter for the command. try: formatter_name = self.commands_formatters[cmd] except KeyError: formatter_name = self.DEFAULT_FORMATTER self.set_formatter(formatter_name) try: try: return super(ReplApplication, self).onecmd(line) except CallErrors as e: self.bcall_errors_handler(e) except BackendNotGiven as e: print('Error: %s' % str(e), file=self.stderr) except NotEnoughArguments as e: print('Error: not enough arguments. %s' % str(e), file=self.stderr) except (KeyboardInterrupt, EOFError): # ^C during a command process doesn't exit application. print('\nAborted.') finally: self.flush() def emptyline(self): """ By default, an emptyline repeats the previous command. Overriding this function disables this behaviour. """ pass def default(self, line): print('Unknown command: "%s"' % line, file=self.stderr) cmd, arg, ignore = Cmd.parseline(self, line) if cmd is not None: names = set(name[3:] for name in self.get_names() if name.startswith('do_' + cmd)) if len(names) > 0: print('Do you mean: %s?' % ', '.join(names), file=self.stderr) return 2 def completenames(self, text, *ignored): return [name for name in Cmd.completenames(self, text, *ignored) if name not in self.hidden_commands] def path_completer(self, arg): dirname = os.path.dirname(arg) try: children = os.listdir(dirname or '.') except OSError: return () l = [] for child in children: path = os.path.join(dirname, child) if os.path.isdir(path): child += '/' l.append(child) return l def complete(self, text, state): """ Override of the Cmd.complete() method to: * add a space at end of proposals * display only proposals for words which match the text already written by user. """ super(ReplApplication, self).complete(text, state) # When state = 0, Cmd.complete() set the 'completion_matches' attribute by # calling the completion function. Then, for other states, it only tries to # get the right item in list. # So that's the good place to rework the choices. if state == 0: self.completion_matches = [choice for choice in self.completion_matches if choice.startswith(text)] try: match = self.completion_matches[state] except IndexError: return None else: if match[-1] != '/': return '%s ' % match return match # -- errors management ------------- def bcall_error_handler(self, backend, error, backtrace): """ Handler for an exception inside the CallErrors exception. This method can be overrided to support more exceptions types. """ return super(ReplApplication, self).bcall_error_handler(backend, error, backtrace) def bcall_errors_handler(self, errors, ignore=()): if self.interactive: ConsoleApplication.bcall_errors_handler(self, errors, 'Use "logging debug" option to print backtraces.', ignore) else: ConsoleApplication.bcall_errors_handler(self, errors, ignore=ignore) # -- options related methods ------------- def _handle_options(self): if self.options.formatter: self.commands_formatters = {} self.DEFAULT_FORMATTER = self.options.formatter self.set_formatter(self.DEFAULT_FORMATTER) if self.options.select: self.selected_fields = self.options.select.split(',') else: self.selected_fields = ['$direct'] if self.options.count is not None: self._is_default_count = False if self.options.count <= 0: # infinite search self.options.count = None if self.options.condition: self.condition = ResultsCondition(self.options.condition) else: self.condition = None return super(ReplApplication, self)._handle_options() def get_command_help(self, command, short=False): try: func = getattr(self, 'do_' + command) except AttributeError: return None doc = func.__doc__ assert doc is not None, "A command must have a docstring" lines = [line.strip() for line in doc.strip().split('\n')] if not lines[0].startswith(command): lines = [command, ''] + lines if short: return lines[0] return '\n'.join(lines) def get_commands_doc(self): names = set(name for name in self.get_names() if name.startswith('do_')) appname = self.APPNAME.capitalize() d = OrderedDict(((appname, []), ('Weboob', []))) for name in sorted(names): cmd = name[3:] if cmd in self.hidden_commands.union(self.weboob_commands).union(['help']): continue d[appname].append(self.get_command_help(cmd)) if not self.DISABLE_REPL: for cmd in self.weboob_commands: d['Weboob'].append(self.get_command_help(cmd)) return d # -- default REPL commands --------- def do_quit(self, arg): """ Quit the application. """ return True def do_EOF(self, arg): """ Quit the command line interpreter when ^D is pressed. """ # print empty line for the next shell prompt to appear on the first column of the terminal print() return self.do_quit(arg) def do_help(self, arg=None): """ help [COMMAND] List commands, or get information about a command. """ if arg: cmd_names = set(name[3:] for name in self.get_names() if name.startswith('do_')) if arg in cmd_names: command_help = self.get_command_help(arg) if command_help is None: logging.warning(u'Command "%s" is undocumented' % arg) else: lines = command_help.split('\n') lines[0] = '%s%s%s' % (self.BOLD, lines[0], self.NC) self.stdout.write('%s\n' % '\n'.join(lines)) else: print('Unknown command: "%s"' % arg, file=self.stderr) else: cmds = self._parser.formatter.format_commands(self._parser.commands) self.stdout.write('%s\n' % cmds) self.stdout.write('Type "help " for more info about a command.\n') return 2 def complete_backends(self, text, line, begidx, endidx): choices = [] commands = ['enable', 'disable', 'only', 'list', 'add', 'register', 'edit', 'remove', 'list-modules'] available_backends_names = set(backend.name for backend in self.weboob.iter_backends()) enabled_backends_names = set(backend.name for backend in self.enabled_backends) args = line.split(' ') if len(args) == 2: choices = commands elif len(args) >= 3: if args[1] == 'enable': choices = sorted(available_backends_names - enabled_backends_names) elif args[1] == 'only': choices = sorted(available_backends_names) elif args[1] == 'disable': choices = sorted(enabled_backends_names) elif args[1] in ('add', 'register') and len(args) == 3: for name, module in sorted(self.weboob.repositories.get_all_modules_info(self.CAPS).iteritems()): choices.append(name) elif args[1] == 'edit': choices = sorted(available_backends_names) elif args[1] == 'remove': choices = sorted(available_backends_names) return choices def do_backends(self, line): """ backends [ACTION] [BACKEND_NAME]... Select used backends. ACTION is one of the following (default: list): * enable enable given backends * disable disable given backends * only enable given backends and disable the others * list list backends * add add a backend * register register a new account on a website * edit edit a backend * remove remove a backend * list-modules list modules """ line = line.strip() if line: args = line.split() else: args = ['list'] action = args[0] given_backend_names = args[1:] for backend_name in given_backend_names: if action in ('add', 'register'): minfo = self.weboob.repositories.get_module_info(backend_name) if minfo is None: print('Module "%s" does not exist.' % backend_name, file=self.stderr) return 1 else: if not minfo.has_caps(self.CAPS): print('Module "%s" is not supported by this application => skipping.' % backend_name, file=self.stderr) return 1 else: if backend_name not in [backend.name for backend in self.weboob.iter_backends()]: print('Backend "%s" does not exist => skipping.' % backend_name, file=self.stderr) return 1 if action in ('enable', 'disable', 'only', 'add', 'register', 'edit', 'remove'): if not given_backend_names: print('Please give at least a backend name.', file=self.stderr) return 2 given_backends = set(backend for backend in self.weboob.iter_backends() if backend.name in given_backend_names) if action == 'enable': for backend in given_backends: self.enabled_backends.add(backend) elif action == 'disable': for backend in given_backends: try: self.enabled_backends.remove(backend) except KeyError: print('%s is not enabled' % backend.name, file=self.stderr) elif action == 'only': self.enabled_backends = set() for backend in given_backends: self.enabled_backends.add(backend) elif action == 'list': enabled_backends_names = set(backend.name for backend in self.enabled_backends) disabled_backends_names = set(backend.name for backend in self.weboob.iter_backends()) - enabled_backends_names print('Enabled: %s' % ', '.join(enabled_backends_names)) if len(disabled_backends_names) > 0: print('Disabled: %s' % ', '.join(disabled_backends_names)) elif action == 'add': for name in given_backend_names: instname = self.add_backend(name, name) if instname: self.load_backends(names=[instname]) elif action == 'register': for name in given_backend_names: instname = self.register_backend(name) if isinstance(instname, basestring): self.load_backends(names=[instname]) elif action == 'edit': for backend in given_backends: enabled = backend in self.enabled_backends self.unload_backends(names=[backend.name]) self.edit_backend(backend.name) for newb in self.load_backends(names=[backend.name]).itervalues(): if not enabled: self.enabled_backends.remove(newb) elif action == 'remove': for backend in given_backends: self.weboob.backends_config.remove_backend(backend.name) self.unload_backends(backend.name) elif action == 'list-modules': modules = [] print('Modules list:') for name, info in sorted(self.weboob.repositories.get_all_modules_info().iteritems()): if not self.is_module_loadable(info): continue modules.append(name) loaded = ' ' for bi in self.weboob.iter_backends(): if bi.NAME == name: if loaded == ' ': loaded = 'X' elif loaded == 'X': loaded = 2 else: loaded += 1 print('[%s] %s%-15s%s %s' % (loaded, self.BOLD, name, self.NC, info.description)) else: print('Unknown action: "%s"' % action, file=self.stderr) return 1 if len(self.enabled_backends) == 0: print('Warning: no more backends are loaded. %s is probably unusable.' % self.APPNAME.capitalize(), file=self.stderr) def complete_logging(self, text, line, begidx, endidx): levels = ('debug', 'info', 'warning', 'error', 'quiet', 'default') args = line.split(' ') if len(args) == 2: return levels return () def do_logging(self, line): """ logging [LEVEL] Set logging level. Availables: debug, info, warning, error. * quiet is an alias for error * default is an alias for warning """ args = self.parse_command_args(line, 1, 0) levels = (('debug', logging.DEBUG), ('info', logging.INFO), ('warning', logging.WARNING), ('error', logging.ERROR), ('quiet', logging.ERROR), ('default', logging.WARNING) ) if not args[0]: current = None for label, level in levels: if logging.root.level == level: current = label break print('Current level: %s' % current) return levels = dict(levels) try: level = levels[args[0]] except KeyError: print('Level "%s" does not exist.' % args[0], file=self.stderr) print('Availables: %s' % ' '.join(levels.iterkeys()), file=self.stderr) return 2 else: logging.root.setLevel(level) for handler in logging.root.handlers: handler.setLevel(level) def do_condition(self, line): """ condition [EXPRESSION | off] If an argument is given, set the condition expression used to filter the results. See CONDITION section for more details and the expression. If the "off" value is given, conditional filtering is disabled. If no argument is given, print the current condition expression. """ line = line.strip() if line: if line == 'off': self.condition = None else: try: self.condition = ResultsCondition(line) except ResultsConditionError as e: print('%s' % e, file=self.stderr) return 2 else: if self.condition is None: print('No condition is set.') else: print(str(self.condition)) def do_count(self, line): """ count [NUMBER | off] If an argument is given, set the maximum number of results fetched. NUMBER must be at least 1. "off" value disables counting, and allows infinite searches. If no argument is given, print the current count value. """ line = line.strip() if line: if line == 'off': self.options.count = None self._is_default_count = False else: try: count = int(line) except ValueError: print('Could not interpret "%s" as a number.' % line, file=self.stderr) return 2 else: if count > 0: self.options.count = count self._is_default_count = False else: self.options.count = None self._is_default_count = False else: if self.options.count is None: print('Counting disabled.') else: print(self.options.count) def complete_formatter(self, text, line, *ignored): formatters = self.formatters_loader.get_available_formatters() commands = ['list', 'option'] + formatters options = ['header', 'keys'] option_values = ['on', 'off'] args = line.split(' ') if len(args) == 2: return commands if args[1] == 'option': if len(args) == 3: return options if len(args) == 4: return option_values elif args[1] in formatters: return list(set(name[3:] for name in self.get_names() if name.startswith('do_'))) def do_formatter(self, line): """ formatter [list | FORMATTER [COMMAND] | option OPTION_NAME [on | off]] If a FORMATTER is given, set the formatter to use. You can add a COMMAND to apply the formatter change only to a given command. If the argument is "list", print the available formatters. If the argument is "option", set the formatter options. Valid options are: header, keys. If on/off value is given, set the value of the option. If not, print the current value for the option. If no argument is given, print the current formatter. """ args = line.strip().split() if args: if args[0] == 'list': print(', '.join(self.formatters_loader.get_available_formatters())) elif args[0] == 'option': if len(args) > 1: if len(args) == 2: if args[1] == 'header': print('off' if self.options.no_header else 'on') elif args[1] == 'keys': print('off' if self.options.no_keys else 'on') else: if args[2] not in ('on', 'off'): print('Invalid value "%s". Please use "on" or "off" values.' % args[2], file=self.stderr) return 2 else: if args[1] == 'header': self.options.no_header = True if args[2] == 'off' else False elif args[1] == 'keys': self.options.no_keys = True if args[2] == 'off' else False else: print('Don\'t know which option to set. Available options: header, keys.', file=self.stderr) return 2 else: if args[0] in self.formatters_loader.get_available_formatters(): if len(args) > 1: self.commands_formatters[args[1]] = self.set_formatter(args[0]) else: self.commands_formatters = {} self.DEFAULT_FORMATTER = self.set_formatter(args[0]) else: print('Formatter "%s" is not available.\n' 'Available formatters: %s.' % (args[0], ', '.join(self.formatters_loader.get_available_formatters())), file=self.stderr) return 1 else: print('Default formatter: %s' % self.DEFAULT_FORMATTER) for key, klass in self.commands_formatters.iteritems(): print('Command "%s": %s' % (key, klass)) def do_select(self, line): """ select [FIELD_NAME]... | "$direct" | "$full" If an argument is given, set the selected fields. $direct selects all fields loaded in one http request. $full selects all fields using as much http requests as necessary. If no argument is given, print the currently selected fields. """ line = line.strip() if line: split = line.split() self.selected_fields = split else: print(' '.join(self.selected_fields)) # First sort in alphabetical of backend # Second, sort with ID def comp_object(self, obj1, obj2): if obj1.backend == obj2.backend: if obj1.id == obj2.id: return 0 elif obj1.id > obj2.id: return 1 else: return -1 elif obj1.backend > obj2.backend: return 1 else: return -1 @defaultcount(40) def do_ls(self, line): """ ls [-d] [-U] [PATH] List objects in current path. If an argument is given, list the specified path. Use -U option to not sort results. It allows you to use a "fast path" to return results as soon as possible. Use -d option to display information about a collection (and to not display the content of it). It has the same behavior than the well know UNIX "ls" command. """ # TODO: real parsing of options path = line.strip() only = False sort = True if '-U' in line.strip().partition(' '): path = line.strip().partition(' ')[-1] sort = False if '-d' in line.strip().partition(' '): path = None only = line.strip().partition(' ')[-1] if path: for _path in path.split('/'): # We have an argument, let's ch to the directory before the ls self.working_path.cd1(_path) objects = [] collections = [] self.objects = [] self.start_format() for res in self._fetch_objects(objs=self.COLLECTION_OBJECTS): if isinstance(res, Collection): collections.append(res) if sort is False: self.formatter.format_collection(res, only) else: if sort: objects.append(res) else: self._format_obj(res, only) if sort: objects.sort(cmp=self.comp_object) collections = self._merge_collections_with_same_path(collections) collections.sort(cmp=self.comp_object) for collection in collections: self.formatter.format_collection(collection, only) for obj in objects: self._format_obj(obj, only) if path: for _path in path.split('/'): # Let's go back to the parent directory self.working_path.up() else: # Save collections only if we listed the current path. self.collections = collections def _find_collection(self, collection, collections): for col in collections: if col.split_path == collection.split_path: return col return None def _merge_collections_with_same_path(self, collections): to_return = [] for collection in collections: col = self._find_collection(collection, to_return) if col: col.backend += " %s" % collection.backend else: to_return.append(collection) return to_return def _format_obj(self, obj, only): if only is False or not hasattr(obj, 'id') or obj.id in only: self.cached_format(obj) def do_cd(self, line): """ cd [PATH] Follow a path. ".." is a special case and goes up one directory. "" is a special case and goes home. """ if not len(line.strip()): self.working_path.home() elif line.strip() == '..': self.working_path.up() else: self.working_path.cd1(line) collections = [] try: for res in self.do('get_collection', objs=self.COLLECTION_OBJECTS, split_path=self.working_path.get(), caps=CapCollection): if res: collections.append(res) except CallErrors as errors: self.bcall_errors_handler(errors, CollectionNotFound) if len(collections): # update the path from the collection if possible if len(collections) == 1: self.working_path.split_path = collections[0].split_path else: print(u"Path: %s not found" % unicode(self.working_path), file=self.stderr) self.working_path.restore() return 1 self._change_prompt() def _fetch_objects(self, objs): split_path = self.working_path.get() try: for res in self.do('iter_resources', objs=objs, split_path=split_path, caps=CapCollection): yield res except CallErrors as errors: self.bcall_errors_handler(errors, CollectionNotFound) def all_collections(self): """ Get all objects that are collections: regular objects and fake dumb objects. """ obj_collections = [obj for obj in self.objects if isinstance(obj, BaseCollection)] return obj_collections + self.collections def obj_to_filename(self, obj, dest=None, default=None): """ This method can be used to get a filename from an object, using a mask filled by information of this object. All patterns are braces-enclosed, and are name of available fields in the object. :param obj: object :type obj: BaseObject :param dest: dest given by user (default None) :type dest: str :param default: default file mask (if not given, this is '{id}-{title}.{ext}') :type default: str :rtype: str """ if default is None: default = '{id}-{title}.{ext}' if dest is None: dest = '.' if os.path.isdir(dest): dest = os.path.join(dest, default) def repl(m): field = m.group(1) if hasattr(obj, field): return re.sub('[?:/]', '-', '%s' % getattr(obj, field)) else: return m.group(0) return re.sub(r'\{(.+?)\}', repl, dest) # for cd & ls def complete_path(self, text, line, begidx, endidx): directories = set() if len(self.working_path.get()): directories.add('..') mline = line.partition(' ')[2] offs = len(mline) - len(text) # refresh only if needed if len(self.objects) == 0 and len(self.collections) == 0: try: self.objects, self.collections = self._fetch_objects(objs=self.COLLECTION_OBJECTS) except CallErrors as errors: self.bcall_errors_handler(errors, CollectionNotFound) collections = self.all_collections() for collection in collections: directories.add(collection.basename.encode(self.encoding)) return [s[offs:] for s in directories if s.startswith(mline)] def complete_ls(self, text, line, begidx, endidx): return self.complete_path(text, line, begidx, endidx) def complete_cd(self, text, line, begidx, endidx): return self.complete_path(text, line, begidx, endidx) # -- formatting related methods ------------- def set_formatter(self, name): """ Set the current formatter from name. It returns the name of the formatter which has been really set. """ try: self.formatter = self.formatters_loader.build_formatter(name) except FormatterLoadError as e: print('%s' % e, file=self.stderr) if self.DEFAULT_FORMATTER == name: self.DEFAULT_FORMATTER = ReplApplication.DEFAULT_FORMATTER print('Falling back to "%s".' % (self.DEFAULT_FORMATTER), file=self.stderr) self.formatter = self.formatters_loader.build_formatter(self.DEFAULT_FORMATTER) name = self.DEFAULT_FORMATTER if self.options.no_header: self.formatter.display_header = False if self.options.no_keys: self.formatter.display_keys = False if self.options.outfile: self.formatter.outfile = self.options.outfile if self.interactive: self.formatter.interactive = True return name def set_formatter_header(self, string): pass def start_format(self, **kwargs): self.formatter.start_format(**kwargs) def cached_format(self, obj): self.add_object(obj) alias = None if self.interactive: alias = '%s' % len(self.objects) self.format(obj, alias=alias) def parse_fields(self, fields): if '$direct' in fields: return [] if '$full' in fields: return None return fields def format(self, result, alias=None): fields = self.parse_fields(self.selected_fields) try: self.formatter.format(obj=result, selected_fields=fields, alias=alias) except FieldNotFound as e: print(e, file=self.stderr) except MandatoryFieldsNotFound as e: print('%s Hint: select missing fields or use another formatter (ex: multiline).' % e, file=self.stderr) def flush(self): self.formatter.flush() weboob-1.1/weboob/tools/application/results.py000066400000000000000000000136401265717027300216410ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities import UserError __all__ = ['ResultsCondition', 'ResultsConditionError'] class IResultsCondition(object): def is_valid(self, obj): raise NotImplementedError() class ResultsConditionError(UserError): pass class Condition(object): def __init__(self, left, op, right): self.left = left # Field of the object to test self.op = op self.right = right def is_egal(left, right): return left == right def is_notegal(left, right): return left != right def is_sup(left, right): return left < right def is_inf(left, right): return left > right def is_in(left, right): return left in right functions = {'!=': is_notegal, '=': is_egal, '>': is_sup, '<': is_inf, '|': is_in} class ResultsCondition(IResultsCondition): condition_str = None # Supported operators # =, !=, <, > for float/int/decimal # =, != for strings # We build a list of list. Return true if each conditions of one list is TRUE def __init__(self, condition_str): self.limit = None or_list = [] _condition_str = condition_str.split(' LIMIT ') if len(_condition_str) == 2: try: self.limit = int(_condition_str[1]) except ValueError: raise ResultsConditionError(u'Syntax error in the condition expression, please check documentation') condition_str= _condition_str[0] for _or in condition_str.split(' OR '): and_list = [] for _and in _or.split(' AND '): operator = None for op in ['!=', '=', '>', '<', '|']: if op in _and: operator = op break if operator is None: raise ResultsConditionError(u'Could not find a valid operator in sub-expression "%s". Protect the complete condition expression with quotes, or read the documentation in the man manual.' % _and) try: l, r = _and.split(operator) except ValueError: raise ResultsConditionError(u'Syntax error in the condition expression, please check documentation') and_list.append(Condition(l, operator, r)) or_list.append(and_list) self.condition = or_list self.condition_str = condition_str def is_valid(self, obj): import weboob.tools.date as date_utils import re from datetime import date, datetime, timedelta d = obj.to_dict() # We evaluate all member of a list at each iteration. for _or in self.condition: myeval = True for condition in _or: if condition.left in d: # in the case of id, test id@backend and id if condition.left == 'id': tocompare = condition.right evalfullid = functions[condition.op](tocompare, d['id']) evalid = functions[condition.op](tocompare, obj.id) myeval = evalfullid or evalid else: # We have to change the type of v, always gived as string by application typed = type(d[condition.left]) try: if isinstance(d[condition.left], date_utils.date): tocompare = date(*[int(x) for x in condition.right.split('-')]) elif isinstance(d[condition.left], date_utils.datetime): splitted_datetime = condition.right.split(' ') tocompare = datetime(*([int(x) for x in splitted_datetime[0].split('-')] + [int(x) for x in splitted_datetime[1].split(':')])) elif isinstance(d[condition.left], timedelta): time_dict = re.match('^\s*((?P\d+)\s*h)?\s*((?P\d+)\s*m)?\s*((?P\d+)\s*s)?\s*$', condition.right).groupdict() tocompare = timedelta(seconds=int(time_dict['seconds'] or "0"), minutes=int(time_dict['minutes'] or "0"), hours=int(time_dict['hours'] or "0")) else: tocompare = typed(condition.right) myeval = functions[condition.op](tocompare, d[condition.left]) except: myeval = False else: raise ResultsConditionError(u'Field "%s" is not valid.' % condition.left) # Do not try all AND conditions if one is false if not myeval: break # Return True at the first OR valid condition if myeval: return True # If we are here, all OR conditions are False return False def __str__(self): return unicode(self).encode('utf-8') def __unicode__(self): return self.condition_str weboob-1.1/weboob/tools/backend.py000066400000000000000000000335531265717027300172310ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import os from threading import RLock from copy import copy from weboob.capabilities.base import BaseObject, FieldNotFound, \ Capability, NotLoaded, NotAvailable from weboob.tools.misc import iter_fields from weboob.tools.log import getLogger from weboob.tools.value import ValuesDict __all__ = ['BackendStorage', 'BackendConfig', 'Module'] class BackendStorage(object): """ This is an abstract layer to store data in storages (:mod:`weboob.tools.storage`) easily. It is instancied automatically in constructor of :class:`Module`, in the :attr:`Module.storage` attribute. :param name: name of backend :param storage: storage object :type storage: :class:`weboob.tools.storage.IStorage` """ def __init__(self, name, storage): self.name = name self.storage = storage def set(self, *args): """ Set value in the storage. Example: >>> from weboob.tools.storage import StandardStorage >>> backend = BackendStorage('blah', StandardStorage('/tmp/cfg')) >>> backend.storage.set('config', 'nb_of_threads', 10) >>> :param args: the path where to store value """ if self.storage: return self.storage.set('backends', self.name, *args) def delete(self, *args): """ Delete a value from the storage. :param args: path to delete. """ if self.storage: return self.storage.delete('backends', self.name, *args) def get(self, *args, **kwargs): """ Get a value or a dict of values in storage. Example: >>> from weboob.tools.storage import StandardStorage >>> backend = BackendStorage('blah', StandardStorage('/tmp/cfg')) >>> backend.storage.get('config', 'nb_of_threads') 10 >>> backend.storage.get('config', 'unexistant', 'path', default='lol') 'lol' >>> backend.storage.get('config') {'nb_of_threads': 10, 'other_things': 'blah'} :param args: path to get :param default: if specified, default value when path is not found """ if self.storage: return self.storage.get('backends', self.name, *args, **kwargs) else: return kwargs.get('default', None) def load(self, default): """ Load storage. It is made automatically when your backend is created, and use the ``STORAGE`` class attribute as default. :param default: this is the default tree if storage is empty :type default: :class:`dict` """ if self.storage: return self.storage.load('backends', self.name, default) def save(self): """ Save storage. """ if self.storage: return self.storage.save('backends', self.name) class BackendConfig(ValuesDict): """ Configuration of a backend. This class is firstly instanced as a :class:`weboob.tools.value.ValuesDict`, containing some :class:`weboob.tools.value.Value` (and derivated) objects. Then, using the :func:`load` method will load configuration from file and create a copy of the :class:`BackendConfig` object with the loaded values. """ modname = None instname = None weboob = None def load(self, weboob, modname, instname, config, nofail=False): """ Load configuration from dict to create an instance. :param weboob: weboob object :type weboob: :class:`weboob.core.ouiboube.Weboob` :param modname: name of the module :type modname: :class:`str` :param instname: name of this backend :type instname: :class:`str` :param params: parameters to load :type params: :class:`dict` :param nofail: if true, this call can't fail :type nofail: :class:`bool` :rtype: :class:`BackendConfig` """ cfg = BackendConfig() cfg.modname = modname cfg.instname = instname cfg.weboob = weboob for name, field in self.iteritems(): value = config.get(name, None) if value is None: if not nofail and field.required: raise Module.ConfigError('Backend(%s): Configuration error: Missing parameter "%s" (%s)' % (cfg.instname, name, field.description)) value = field.default field = copy(field) try: field.load(cfg.instname, value, cfg.weboob.callbacks) except ValueError as v: if not nofail: raise Module.ConfigError( 'Backend(%s): Configuration error for field "%s": %s' % (cfg.instname, name, v)) cfg[name] = field return cfg def dump(self): """ Dump config in a dictionary. :rtype: :class:`dict` """ settings = {} for name, value in self.iteritems(): settings[name] = value.dump() return settings def save(self, edit=True, params=None): """ Save backend config. :param edit: if true, it changes config of an existing backend :type edit: :class:`bool` :param params: if specified, params to merge with the ones of the current object :type params: :class:`dict` """ assert self.modname is not None assert self.instname is not None assert self.weboob is not None dump = self.dump() if params is not None: dump.update(params) self.weboob.backends_config.add_backend(self.instname, self.modname, dump, edit) class Module(object): """ Base class for modules. You may derivate it, and also all capabilities you want to implement. :param weboob: weboob instance :type weboob: :class:`weboob.core.ouiboube.Weboob` :param name: name of backend :type name: :class:`str` :param config: configuration of backend :type config: :class:`dict` :param storage: storage object :type storage: :class:`weboob.tools.storage.IStorage` :param logger: logger :type logger: :class:`logging.Logger` """ # Module name. NAME = None # Name of the maintainer of this module. MAINTAINER = u'' # Email address of the maintainer. EMAIL = '' # Version of module (for information only). VERSION = '' # Description DESCRIPTION = '' # License of this module. LICENSE = '' # Configuration required for backends. # Values must be weboob.tools.value.Value objects. CONFIG = BackendConfig() # Storage STORAGE = {} # Browser class BROWSER = None # URL to an optional icon. # If you want to create your own icon, create a 'favicon.ico' ico in # the module's directory, and keep the ICON value to None. ICON = None # Supported objects to fill # The key is the class and the value the method to call to fill # Method prototype: method(object, fields) # When the method is called, fields are only the one which are # NOT yet filled. OBJECTS = {} class ConfigError(Exception): """ Raised when the config can't be loaded. """ def __enter__(self): self.lock.acquire() def __exit__(self, t, v, tb): self.lock.release() def __repr__(self): return u"" % self.name def __init__(self, weboob, name, config=None, storage=None, logger=None): self.logger = getLogger(name, parent=logger) self.weboob = weboob self.name = name self.lock = RLock() if config is None: config = {} # Private fields (which start with '_') self._private_config = dict((key, value) for key, value in config.iteritems() if key.startswith('_')) # Load configuration of backend. self.config = self.CONFIG.load(weboob, self.NAME, self.name, config) self.storage = BackendStorage(self.name, storage) self.storage.load(self.STORAGE) def deinit(self): """ This abstract method is called when the backend is unloaded. """ if self._browser is None: return if hasattr(self.browser, 'dump_state'): self.storage.set('browser_state', self.browser.dump_state()) self.storage.save() if hasattr(self.browser, 'deinit'): self.browser.deinit() _browser = None @property def browser(self): """ Attribute 'browser'. The browser is created at the first call of this attribute, to avoid useless pages access. Note that the :func:`create_default_browser` method is called to create it. """ if self._browser is None: self._browser = self.create_default_browser() return self._browser def create_default_browser(self): """ Method to overload to build the default browser in attribute 'browser'. """ return self.create_browser() def create_browser(self, *args, **kwargs): """ Build a browser from the BROWSER class attribute and the given arguments. """ if not self.BROWSER: return None tmpproxy = None tmpproxys = None if '_proxy' in self._private_config: tmpproxy = self._private_config['_proxy'] elif 'http_proxy' in os.environ: tmpproxy = os.environ['http_proxy'] elif 'HTTP_PROXY' in os.environ: tmpproxy = os.environ['HTTP_PROXY'] if '_proxy_ssl' in self._private_config: tmpproxys = self._private_config['_proxy_ssl'] elif 'https_proxy' in os.environ: tmpproxys = os.environ['https_proxy'] elif 'HTTPS_PROXY' in os.environ: tmpproxys = os.environ['HTTPS_PROXY'] if any((tmpproxy, tmpproxys)): kwargs['proxy'] = {} if tmpproxy is not None: kwargs['proxy']['http'] = tmpproxy if tmpproxys is not None: kwargs['proxy']['https'] = tmpproxys kwargs['logger'] = self.logger if self.logger.settings['responses_dirname']: kwargs.setdefault('responses_dirname', os.path.join(self.logger.settings['responses_dirname'], self._private_config.get('_debug_dir', self.name))) browser = self.BROWSER(*args, **kwargs) if hasattr(browser, 'load_state'): browser.load_state(self.storage.get('browser_state', default={})) return browser @classmethod def iter_caps(klass): """ Iter capabilities implemented by this backend. :rtype: iter[:class:`weboob.capabilities.base.Capability`] """ def iter_caps(cls): for base in cls.__bases__: if issubclass(base, Capability) and base != Capability: yield base for cap in iter_caps(base): yield cap return iter_caps(klass) def has_caps(self, *caps): """ Check if this backend implements at least one of these capabilities. """ for c in caps: if (isinstance(c, basestring) and c in [cap.__name__ for cap in self.iter_caps()]) or \ isinstance(self, c): return True return False def fillobj(self, obj, fields=None): """ Fill an object with the wanted fields. :param fields: what fields to fill; if None, all fields are filled :type fields: :class:`list` """ if obj is None: return obj def not_loaded(v): return (v is NotLoaded or isinstance(v, BaseObject) and not v.__iscomplete__()) if isinstance(fields, basestring): fields = (fields,) missing_fields = [] if fields is None: # Select all fields if isinstance(obj, BaseObject): fields = [item[0] for item in obj.iter_fields()] else: fields = [item[0] for item in iter_fields(obj)] for field in fields: if not hasattr(obj, field): raise FieldNotFound(obj, field) value = getattr(obj, field) missing = False if hasattr(value, '__iter__'): for v in (value.itervalues() if isinstance(value, dict) else value): if not_loaded(v): missing = True break elif not_loaded(value): missing = True if missing: missing_fields.append(field) if not missing_fields: return obj for key, value in self.OBJECTS.iteritems(): if isinstance(obj, key): self.logger.debug(u'Fill %r with fields: %s' % (obj, missing_fields)) return value(self, obj, missing_fields) or obj # Object is not supported by backend. Do not notice it to avoid flooding user. # That's not so bad. for field in missing_fields: setattr(obj, field, NotAvailable) return obj weboob-1.1/weboob/tools/capabilities/000077500000000000000000000000001265717027300177105ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/__init__.py000066400000000000000000000000001265717027300220070ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/audio/000077500000000000000000000000001265717027300210115ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/audio/__init__.py000077500000000000000000000000001265717027300231130ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/audio/audio.py000077500000000000000000000025211265717027300224670ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2015 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.browser.filters.standard import Format class AlbumIdFilter(Format): """ Filter that help to fill Albums id field """ def __init__(self, *args): super(AlbumIdFilter, self).__init__(u'album.%s', *args) class PlaylistIdFilter(Format): """ Filter that help to fill Albums id field """ def __init__(self, *args): super(PlaylistIdFilter, self).__init__(u'playlist.%s', *args) class BaseAudioIdFilter(Format): """ Filter that help to fill Albums id field """ def __init__(self, *args): super(BaseAudioIdFilter, self).__init__(u'audio.%s', *args) weboob-1.1/weboob/tools/capabilities/bank/000077500000000000000000000000001265717027300206235ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/bank/__init__.py000066400000000000000000000000001265717027300227220ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/bank/transactions.py000066400000000000000000000315301265717027300237070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2009-2012 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from decimal import Decimal, InvalidOperation import datetime import re from weboob.capabilities.bank import Transaction, Account from weboob.capabilities import NotAvailable, NotLoaded from weboob.tools.misc import to_unicode from weboob.tools.log import getLogger from weboob.exceptions import ParseError from weboob.browser.elements import TableElement, ItemElement from weboob.browser.filters.standard import Filter, CleanText, CleanDecimal, TableCell __all__ = ['FrenchTransaction', 'AmericanTransaction'] class classproperty(object): def __init__(self, f): self.f = f def __get__(self, obj, owner): return self.f(owner) class FrenchTransaction(Transaction): """ Transaction with some helpers for french bank websites. """ PATTERNS = [] def __init__(self, id='', *args, **kwargs): Transaction.__init__(self, id, *args, **kwargs) self._logger = getLogger('FrenchTransaction') @classmethod def clean_amount(klass, text): """ Clean a string containing an amount. """ text = text.replace('.','').replace(',','.') return re.sub(u'[^\d\-\.]', '', text) def set_amount(self, credit='', debit=''): """ Set an amount value from a string. Can take two strings if there are both credit and debit columns. """ credit = self.clean_amount(credit) debit = self.clean_amount(debit) if len(debit) > 0: self.amount = - abs(Decimal(debit)) elif len(credit) > 0: self.amount = Decimal(credit) else: self.amount = Decimal('0') def parse_date(self, date): if date is None: return NotAvailable if not isinstance(date, (datetime.date, datetime.datetime)): if date.isdigit() and len(date) == 8: date = datetime.date(int(date[4:8]), int(date[2:4]), int(date[0:2])) elif '/' in date: date = datetime.date(*reversed(map(int, date.split('/')))) if not isinstance(date, (datetime.date, datetime.datetime)): self._logger.warning('Unable to parse date %r' % date) date = NotAvailable elif date.year < 100: date = date.replace(year=2000 + date.year) return date def parse(self, date, raw, vdate=None): """ Parse date and raw strings to create datetime.date objects, determine the type of transaction, and create a simplified label When calling this method, you should have defined patterns (in the PATTERN class attribute) with a list containing tuples of regexp and the associated type, for example:: PATTERNS = [(re.compile(r'^VIR(EMENT)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(r'^PRLV (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile(r'^(?P.*) CARTE \d+ PAIEMENT CB (?P
\d{2})(?P\d{2}) ?(.*)$'), FrenchTransaction.TYPE_CARD) ] In regexps, you can define this patterns: * text: part of label to store in simplified label * category: part of label representing the category * yy, mm, dd, HH, MM: date and time parts """ self.date = self.parse_date(date) self.vdate = self.parse_date(vdate) self.rdate = self.date self.raw = to_unicode(raw.replace(u'\n', u' ').strip()) self.category = NotAvailable if ' ' in self.raw: self.category, _, self.label = [part.strip() for part in self.raw.partition(' ')] else: self.label = self.raw for pattern, _type in self.PATTERNS: m = pattern.match(self.raw) if m: args = m.groupdict() def inargs(key): """ inner function to check if a key is in args, and is not None. """ return args.get(key, None) is not None self.type = _type if inargs('text'): self.label = args['text'].strip() if inargs('category'): self.category = args['category'].strip() # Set date from information in raw label. if inargs('dd') and inargs('mm'): dd = int(args['dd']) mm = int(args['mm']) if inargs('yy'): yy = int(args['yy']) else: d = self.date try: d = d.replace(month=mm, day=dd) except ValueError: d = d.replace(year=d.year-1, month=mm, day=dd) yy = d.year if d > self.date: yy -= 1 if yy < 100: yy += 2000 try: if inargs('HH') and inargs('MM'): self.rdate = datetime.datetime(yy, mm, dd, int(args['HH']), int(args['MM'])) else: self.rdate = datetime.date(yy, mm, dd) except ValueError as e: self._logger.warning('Unable to date in label %r: %s' % (self.raw, e)) return @classproperty def TransactionElement(k): class _TransactionElement(ItemElement): klass = k obj_date = klass.Date(TableCell('date')) obj_vdate = klass.Date(TableCell('vdate', 'date')) obj_raw = klass.Raw(TableCell('raw')) obj_amount = klass.Amount(TableCell('credit'), TableCell('debit', default='')) return _TransactionElement @classproperty def TransactionsElement(klass): class _TransactionsElement(TableElement): col_date = [u'Date'] col_vdate = [u'Valeur'] col_raw = [u'Opération', u'Libellé', u'Intitulé opération'] col_credit = [u'Crédit', u'Montant'] col_debit = [u'Débit'] item = klass.TransactionElement return _TransactionsElement class Date(CleanText): def __call__(self, item): date = super(FrenchTransaction.Date, self).__call__(item) return date def filter(self, date): date = super(FrenchTransaction.Date, self).filter(date) if date is None: return NotAvailable if not isinstance(date, (datetime.date, datetime.datetime)): if date.isdigit() and len(date) == 8: date = datetime.date(int(date[4:8]), int(date[2:4]), int(date[0:2])) elif '/' in date: date = datetime.date(*reversed(map(int, date.split('/')))) if not isinstance(date, (datetime.date, datetime.datetime)): date = NotAvailable elif date.year < 100: date = date.replace(year=2000 + date.year) return date @classmethod def Raw(klass, *args, **kwargs): patterns = klass.PATTERNS class Filter(CleanText): def __call__(self, item): raw = super(Filter, self).__call__(item) if item.obj.rdate is NotLoaded: item.obj.rdate = item.obj.date item.obj.category = NotAvailable if ' ' in raw: item.obj.category, useless, item.obj.label = [part.strip() for part in raw.partition(' ')] else: item.obj.label = raw for pattern, _type in patterns: m = pattern.match(raw) if m: args = m.groupdict() def inargs(key): """ inner function to check if a key is in args, and is not None. """ return args.get(key, None) is not None item.obj.type = _type if inargs('text'): item.obj.label = args['text'].strip() if inargs('category'): item.obj.category = args['category'].strip() # Set date from information in raw label. if inargs('dd') and inargs('mm'): dd = int(args['dd']) mm = int(args['mm']) if inargs('yy'): yy = int(args['yy']) else: d = item.obj.date try: d = d.replace(month=mm, day=dd) except ValueError: d = d.replace(year=d.year-1, month=mm, day=dd) yy = d.year if d > item.obj.date: yy -= 1 if yy < 100: yy += 2000 try: if inargs('HH') and inargs('MM'): item.obj.rdate = datetime.datetime(yy, mm, dd, int(args['HH']), int(args['MM'])) else: item.obj.rdate = datetime.date(yy, mm, dd) except ValueError as e: raise ParseError('Unable to parse date in label %r: %s' % (raw, e)) break return raw def filter(self, text): text = super(Filter, self).filter(text) return to_unicode(text.replace(u'\n', u' ').strip()) return Filter(*args, **kwargs) class Currency(CleanText): def filter(self, text): text = super(FrenchTransaction.Currency, self).filter(text) return Account.get_currency(text) class Amount(Filter): def __init__(self, credit, debit=None, replace_dots=True): self.credit_selector = credit self.debit_selector = debit self.replace_dots = replace_dots def __call__(self, item): if self.debit_selector: try: return - abs(CleanDecimal(self.debit_selector, replace_dots=self.replace_dots)(item)) except InvalidOperation: pass if self.credit_selector: try: return CleanDecimal(self.credit_selector, replace_dots=self.replace_dots)(item) except InvalidOperation: pass return Decimal('0') class AmericanTransaction(Transaction): """ Transaction with some helpers for american bank websites. """ @classmethod def clean_amount(klass, text): """ Clean a string containing an amount. """ # Convert "American" UUU.CC format to "French" UUU,CC format if re.search(r'\d\.\d\d(?: [A-Z]+)?$', text): text = text.replace(',', ' ').replace('.', ',') return FrenchTransaction.clean_amount(text) @classmethod def decimal_amount(klass, text): """ Convert a string containing an amount to Decimal. """ amnt = AmericanTransaction.clean_amount(text) return Decimal(amnt) if amnt else Decimal('0') def test(): clean_amount = AmericanTransaction.clean_amount assert clean_amount('42') == '42' assert clean_amount('42,12') == '42.12' assert clean_amount('42.12') == '42.12' assert clean_amount('$42.12 USD') == '42.12' assert clean_amount('$12.442,12 USD') == '12442.12' assert clean_amount('$12,442.12 USD') == '12442.12' decimal_amount = AmericanTransaction.decimal_amount assert decimal_amount('$12,442.12 USD') == Decimal('12442.12') assert decimal_amount('') == Decimal('0') weboob-1.1/weboob/tools/capabilities/gallery/000077500000000000000000000000001265717027300213475ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/gallery/__init__.py000066400000000000000000000000001265717027300234460ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/gallery/genericcomicreader.py000066400000000000000000000067331265717027300255440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re from weboob.capabilities.gallery import CapGallery, BaseGallery, BaseImage from weboob.tools.backend import Module from weboob.deprecated.browser import Browser, Page __all__ = ['GenericComicReaderModule'] class DisplayPage(Page): def get_page(self, gallery): src = self.document.xpath(self.browser.params['img_src_xpath'])[0] return BaseImage(src, gallery=gallery, url=src) def page_list(self): return self.document.xpath(self.browser.params['page_list_xpath']) class GenericComicReaderBrowser(Browser): def __init__(self, browser_params, *args, **kwargs): self.params = browser_params Browser.__init__(self, *args, **kwargs) def iter_gallery_images(self, gallery): self.location(gallery.url) assert self.is_on_page(DisplayPage) for p in self.page.page_list(): if 'page_to_location' in self.params: self.location(self.params['page_to_location'] % p) else: self.location(p) assert self.is_on_page(DisplayPage) yield self.page.get_page(gallery) def fill_image(self, image, fields): if 'data' in fields: image.data = self.readurl(image.url) class GenericComicReaderModule(Module, CapGallery): NAME = 'genericcomicreader' MAINTAINER = u'Noé Rubinstein' EMAIL = 'noe.rubinstein@gmail.com' VERSION = '1.1' DESCRIPTION = 'Generic comic reader backend; subclasses implement specific sites' LICENSE = 'AGPLv3+' BROWSER = GenericComicReaderBrowser BROWSER_PARAMS = {} ID_REGEXP = None URL_REGEXP = None ID_TO_URL = None PAGES = {} def create_default_browser(self): b = self.create_browser(self.BROWSER_PARAMS) b.PAGES = self.PAGES try: b.DOMAIN = self.DOMAIN except AttributeError: pass return b def iter_gallery_images(self, gallery): with self.browser: return self.browser.iter_gallery_images(gallery) def get_gallery(self, _id): match = re.match(r'^%s$' % self.URL_REGEXP, _id) if match: _id = match.group(1) else: match = re.match(r'^%s$' % self.ID_REGEXP, _id) if match: _id = match.group(0) else: return None gallery = BaseGallery(_id, url=(self.ID_TO_URL % _id)) with self.browser: return gallery def fill_gallery(self, gallery, fields): gallery.title = gallery.id def fill_image(self, image, fields): with self.browser: self.browser.fill_image(image, fields) OBJECTS = { BaseGallery: fill_gallery, BaseImage: fill_image} weboob-1.1/weboob/tools/capabilities/gallery/genericcomicreadertest.py000066400000000000000000000020231265717027300264300ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.tools.test import BackendTest class GenericComicReaderTest(BackendTest): def _test_download(self, _id): g = self.backend.get_gallery(_id) it = self.backend.iter_gallery_images(g) it.next() img = it.next() self.backend.fillobj(img, ('url', 'data')) weboob-1.1/weboob/tools/capabilities/messages/000077500000000000000000000000001265717027300215175ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/messages/GenericModule.py000066400000000000000000000077311265717027300246230ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import time from weboob.capabilities.messages import CapMessages, Message, Thread from weboob.capabilities.base import find_object from weboob.tools.backend import Module from weboob.tools.newsfeed import Newsfeed class GenericNewspaperModule(Module, CapMessages): """ GenericNewspaperModule class """ MAINTAINER = u'Julien Hebert' EMAIL = 'juke@free.fr' VERSION = '1.1' LICENSE = 'AGPLv3+' STORAGE = {'seen': {}} RSS_FEED = None RSSID = None URL2ID = None RSSSIZE = 0 def get_thread(self, _id): if isinstance(_id, Thread): thread = _id id = thread.id else: thread = find_object(self.iter_threads(), id=_id) id = _id with self.browser: content = self.browser.get_content(id) if content is None: return None if not thread: thread = Thread(id) flags = Message.IS_HTML if thread.id not in self.storage.get('seen', default={}): flags |= Message.IS_UNREAD thread.title = content.title if not thread.date: thread.date = content.date thread.root = Message( thread=thread, id=0, title=content.title, sender=content.author, receivers=None, date=thread.date, parent=None, content=content.body, signature= u'URL \n' % content.url, flags=flags, children=[]) return thread def iter_threads(self): for article in Newsfeed(self.RSS_FEED, GenericNewspaperModule.RSSID).iter_entries(): thread = Thread(article.id) thread.title = article.title thread.date = article.datetime yield(thread) def fill_thread(self, thread, fields): "fill the thread" t = self.get_thread(thread) return t or thread def iter_unread_messages(self): for thread in self.iter_threads(): if thread.id in self.storage.get('seen', default={}): continue self.fill_thread(thread, 'root') for msg in thread.iter_all_messages(): yield msg def set_message_read(self, message): self.storage.set( 'seen', message.thread.id, 'comments', self.storage.get( 'seen', message.thread.id, 'comments', default=[]) + [message.id]) if self.URL2ID and self.RSSSIZE != 0: url2id = self.URL2ID lastpurge = self.storage.get('lastpurge', default=0) l = [] if time.time() - lastpurge > 7200: self.storage.set('lastpurge', time.time()) for id in self.storage.get('seen', default={}): l.append((int(url2id(id)), id)) l.sort() l.reverse() tosave = [v[1] for v in l[0:self.RSSSIZE + 10]] toremove = set([v for v in self.storage.get('seen', default={})]).difference(tosave) for id in toremove: self.storage.delete('seen', id) self.storage.save() OBJECTS = {Thread: fill_thread} weboob-1.1/weboob/tools/capabilities/messages/__init__.py000066400000000000000000000000001265717027300236160ustar00rootroot00000000000000weboob-1.1/weboob/tools/capabilities/messages/genericArticle.py000066400000000000000000000116061265717027300250150ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Julien Hebert # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.deprecated.browser import Page from weboob.deprecated.browser import BrokenPageError from lxml.etree import Comment def try_remove(parser, base_element, selector): try: base_element.remove(parser.select(base_element, selector, 1)) except (BrokenPageError, ValueError): pass def try_drop_tree(parser, base_element, selector): for el in parser.select(base_element, selector): el.drop_tree() def remove_from_selector_list(parser, base_element, selector_list): for selector in selector_list: base_element.remove(parser.select(base_element, selector, 1)) def try_remove_from_selector_list(parser, base_element, selector_list): for selector in selector_list: try_remove(parser, base_element, selector) def drop_comments(base_element): for comment in base_element.getiterator(Comment): comment.drop_tree() # Replace relative url in link and image with a complete url # Arguments: the html element to clean, and the domain name (with http:// prefix) def clean_relativ_urls(base_element, domain): for a in base_element.findall('.//a'): if "href" in a.attrib: if a.attrib["href"] and a.attrib["href"][0:7] != "http://" and a.attrib["href"][0:7] != "https://": a.attrib["href"] = domain + a.attrib["href"] for img in base_element.findall('.//img'): if img.attrib["src"][0:7] != "http://" and img.attrib["src"][0:7] != "https://": img.attrib["src"] = domain + img.attrib["src"] class NoAuthorElement(BrokenPageError): pass class NoBodyElement(BrokenPageError): pass class NoTitleException(BrokenPageError): pass class NoneMainDiv(AttributeError): pass class Article(object): author = u'' title = u'' def __init__(self, browser, _id): self.browser = browser self.id = _id self.body = u'' self.url = u'' self.date = None class GenericNewsPage(Page): __element_body = NotImplementedError __article = Article element_title_selector = NotImplementedError main_div = NotImplementedError element_body_selector = NotImplementedError element_author_selector = NotImplementedError def get_body(self): return self.parser.tostring(self.get_element_body()) def get_author(self): try: return u'%s' % self.get_element_author().text_content().strip() except (NoAuthorElement, NoneMainDiv): #TODO: Mettre un warning return self.__article.author def get_title(self): try: return u'%s' % self.parser.select( self.main_div, self.element_title_selector, 1).text_content().strip() except AttributeError: if self.main_div is None: #TODO: Mettre un warning return self.__article.title else: raise except BrokenPageError: if self.element_title_selector == 'h1': raise NoTitleException("no title on %s" % (self.browser)) self.element_title_selector = "h1" return self.get_title() def get_element_body(self): try: return self.parser.select(self.main_div, self.element_body_selector, 1) except BrokenPageError: raise NoBodyElement("no body on %s" % (self.browser)) except AttributeError: if self.main_div is None: raise NoneMainDiv("main_div is none on %s" % (self.browser)) else: raise def get_element_author(self): try: return self.parser.select(self.main_div, self.element_author_selector, 1) except BrokenPageError: raise NoAuthorElement() except AttributeError: if self.main_div is None: raise NoneMainDiv("main_div is none on %s" % (self.browser)) else: raise def get_article(self, _id): __article = Article(self.browser, _id) __article.author = self.get_author() __article.title = self.get_title() __article.url = self.url __article.body = self.get_body() return __article weboob-1.1/weboob/tools/capabilities/paste.py000066400000000000000000000073421265717027300214040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.paste import CapPaste import binascii class BasePasteModule(CapPaste): EXPIRATIONS = {} """ List of expirations and their corresponding remote codes (any type can be used). The expirations, i.e. the keys, are integers representing the duration in seconds. There also can be one False key, for the "forever" expiration. """ def get_closest_expiration(self, max_age): """ Get the expiration closest (and less or equal to) max_age (int, in seconds). max_age set to False means we want it to never expire. @return int or False if found, else None """ # "forever" if max_age is False and False in self.EXPIRATIONS: return max_age # get timed expirations, longest first expirations = sorted([e for e in self.EXPIRATIONS if e is not False], reverse=True) # find the first expiration that is below or equal to the maximum wanted age for e in expirations: if max_age is False or max_age >= e: return e def image_mime(data_base64, supported_formats=('gif', 'jpeg', 'png')): """ Return the MIME type of an image or None. :param data_base64: data to detect, base64 encoded :type data_base64: str :param supported_formats: restrict list of formats to test """ try: beginning = data_base64[:24].decode('base64') except binascii.Error: return None if 'gif' in supported_formats and 'GIF8' in beginning: return 'image/gif' elif 'jpeg' in supported_formats and 'JFIF' in beginning: return 'image/jpeg' elif 'png' in supported_formats and '\x89PNG' in beginning: return 'image/png' elif 'xcf' in supported_formats and 'gimp xcf' in beginning: return 'image/x-xcf' elif 'pdf' in supported_formats and '%PDF' in beginning: return 'application/pdf' elif 'tiff' in supported_formats and ('II\x00\x2a' in beginning or 'MM\x2a\x00' in beginning): return 'image/tiff' def test(): class MockPasteModule(BasePasteModule): def __init__(self, expirations): self.EXPIRATIONS = expirations # all expirations are too high assert MockPasteModule({1337: '', 42: '', False: ''}).get_closest_expiration(1) is None # we found a suitable lower or equal expiration assert MockPasteModule({1337: '', 42: '', False: ''}).get_closest_expiration(84) is 42 assert MockPasteModule({1337: '', 42: '', False: ''}).get_closest_expiration(False) is False assert MockPasteModule({1337: '', 42: ''}).get_closest_expiration(False) is 1337 assert MockPasteModule({1337: '', 42: '', False: ''}).get_closest_expiration(1336) is 42 assert MockPasteModule({1337: '', 42: '', False: ''}).get_closest_expiration(1337) is 1337 assert MockPasteModule({1337: '', 42: '', False: ''}).get_closest_expiration(1338) is 1337 # this format should work, though of doubtful usage assert MockPasteModule([1337, 42, False]).get_closest_expiration(84) is 42 weboob-1.1/weboob/tools/capabilities/streaminfo.py000066400000000000000000000023561265717027300224370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2013 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.base import BaseObject, StringField __all__ = ['StreamInfo'] class StreamInfo(BaseObject): """ Stream related information. """ who = StringField('Who is currently on air') what = StringField('What is currently on air') def __iscomplete__(self): # This volatile information may be reloaded everytimes. return False def __unicode__(self): if self.who: return u'%s - %s' % (self.who, self.what) else: return self.what weboob-1.1/weboob/tools/capabilities/thumbnail.py000066400000000000000000000024251265717027300222500ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Romain Bignon, Noé Rubinstein # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from weboob.capabilities.base import NotLoaded, BytesField from weboob.capabilities.image import _BaseImage __all__ = ['Thumbnail'] class Thumbnail(_BaseImage): """ Thumbnail of an image. """ data = BytesField('Data') def __init__(self, url): super(Thumbnail, self).__init__(url) self.url = url.replace(u' ', u'%20') def __str__(self): return self.url def __repr__(self): return '' % self.url def __iscomplete__(self): return self.data is not NotLoaded weboob-1.1/weboob/tools/captcha/000077500000000000000000000000001265717027300166625ustar00rootroot00000000000000weboob-1.1/weboob/tools/captcha/__init__.py000066400000000000000000000000001265717027300207610ustar00rootroot00000000000000weboob-1.1/weboob/tools/captcha/virtkeyboard.py000066400000000000000000000211041265717027300217370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2011 Pierre Mazière # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import hashlib import tempfile try: from PIL import Image except ImportError: raise ImportError('Please install python-imaging') class VirtKeyboardError(Exception): pass class VirtKeyboard(object): """ Handle a virtual keyboard. :attribute margin: Margin used by :meth:`get_symbol_coords̀` to reduce size of each "key" of the virtual keyboard. This attribute is always converted to a 4-tuple, and has the same semantic as the CSS ``margin`` property (top, right, bottom, right), in pixels. :type margin: int or float or (2|3|4)-tuple """ margin = None def __init__(self, file=None, coords=None, color=None, convert=None): # file: virtual keyboard image # coords: dictionary : # color: color of the symbols in the image # depending on the image, it can be a single value or a tuple # convert: if not None, convert image to this target type (for example 'RGB') if file is not None: assert color, 'No color provided !' self.load_image(file, color, convert) if type(self.margin) in (int, float): self.margin = (self.margin,) * 4 elif self.margin is not None: if len(self.margin) == 2: self.margin = self.margin + self.margin elif len(self.margin) == 3: self.margin = self.margin + (self.margin[1],) assert len(self.margin) == 4 if coords is not None: self.load_symbols(coords) def load_image(self, file, color, convert=None): self.image = Image.open(file) if convert is not None: self.image = self.image.convert(convert) self.bands = self.image.getbands() if isinstance(color, int) and not isinstance(self.bands, str) and len(self.bands) != 1: raise VirtKeyboardError("Color requires %i component but only 1 is provided" % len(self.bands)) if not isinstance(color, int) and len(color) != len(self.bands): raise VirtKeyboardError("Color requires %i components but %i are provided" % (len(self.bands), len(color))) self.color = color self.width, self.height = self.image.size self.pixar = self.image.load() def load_symbols(self, coords): self.coords = {} self.md5 = {} for i in coords: coord = self.get_symbol_coords(coords[i]) if coord == (-1, -1, -1, -1): continue self.coords[i] = coord self.md5[i] = self.checksum(self.coords[i]) def check_color(self, pixel): return pixel == self.color def get_symbol_coords(self, coords): (x1, y1, x2, y2) = coords if self.margin: top, right, bottom, left = self.margin x1, y1, x2, y2 = x1 + left, y1 + top, x2 - right, y2 - bottom newY1 = -1 newY2 = -1 for y in range(y1, min(y2 + 1, self.height)): empty_line = True for x in range(x1, min(x2 + 1, self.width)): if self.check_color(self.pixar[x, y]): empty_line = False if newY1 < 0: newY1 = y break if newY1 >= 0 and not empty_line: newY2 = y newX1 = -1 newX2 = -1 for x in range(x1, min(x2 + 1, self.width)): empty_column = True for y in range(y1, min(y2 + 1, self.height)): if self.check_color(self.pixar[x, y]): empty_column = False if newX1 < 0: newX1 = x break if newX1 >= 0 and not empty_column: newX2 = x return (newX1, newY1, newX2, newY2) def checksum(self, coords): (x1, y1, x2, y2) = coords s = '' for y in range(y1, min(y2 + 1, self.height)): for x in range(x1, min(x2 + 1, self.width)): if self.check_color(self.pixar[x, y]): s += "." else: s += " " return hashlib.md5(s).hexdigest() def get_symbol_code(self, md5sum_list): if isinstance(md5sum_list, basestring): md5sum_list = [md5sum_list] for md5sum in md5sum_list: for i in self.md5: if md5sum == self.md5[i]: return i raise VirtKeyboardError('Symbol not found for hash "%s".' % md5sum) def get_string_code(self, string): return ''.join((self.get_symbol_code(self.symbols[c]) for c in string)) def check_symbols(self, symbols, dirname): # symbols: dictionary : for s in symbols: try: self.get_symbol_code(symbols[s]) except VirtKeyboardError: if dirname is None: dirname = tempfile.mkdtemp(prefix='weboob_session_') self.generate_MD5(dirname) raise VirtKeyboardError("Symbol '%s' not found; all symbol hashes are available in %s" % (s, dirname)) def generate_MD5(self, dir): for i in self.coords: width = self.coords[i][2] - self.coords[i][0] + 1 height = self.coords[i][3] - self.coords[i][1] + 1 img = Image.new(''.join(self.bands), (width, height)) matrix = img.load() for y in range(height): for x in range(width): matrix[x, y] = self.pixar[self.coords[i][0] + x, self.coords[i][1] + y] img.save(dir + "/" + self.md5[i] + ".png") self.image.save(dir + "/image.png") class MappedVirtKeyboard(VirtKeyboard): def __init__(self, file, document, img_element, color, map_attr="onclick", convert=None): map_id = img_element.attrib.get("usemap")[1:] map = document.find("//map[@id='" + map_id + "']") if map is None: map = document.find("//map[@name='" + map_id + "']") coords = {} for area in map.getiterator("area"): code = area.attrib.get(map_attr) area_coords = [] for coord in area.attrib.get("coords").split(' ')[0].split(','): area_coords.append(int(coord)) coords[code] = tuple(area_coords) super(MappedVirtKeyboard, self).__init__(file, coords, color, convert) class GridVirtKeyboard(VirtKeyboard): """ Make a virtual keyboard where "keys" are distributed on a grid. For example: https://www.esgbl.com/part/fr/idehom.html Parameters: :param symbols: Sequence of symbols, ordered in the grid from left to right and up to down :type symbols: iterable :param cols: Column count of the grid :type cols: int :param rows: Row count of the grid :type rows: int :param image: File-like object to be used as data source :type image: file :param color: Color of the meaningful pixels :type color: 3-tuple :param convert: Mode to which convert color of pixels, see :meth:`Image.Image.convert` for more information Attributes: :attribute symbols: Association table between symbols and md5s :type symbols: dict """ symbols = {} def __init__(self, symbols, cols, rows, image, color, convert=None): self.load_image(image, color, convert) tileW = float(self.width) / cols tileH = float(self.height) / rows positions = ((s, i * tileW % self.width, i / cols * tileH) for i, s in enumerate(symbols)) coords = dict((s, tuple(map(int, (x, y, x + tileW, y + tileH)))) for (s, x, y) in positions) super(GridVirtKeyboard, self).__init__() self.load_symbols(coords) weboob-1.1/weboob/tools/compat.py000066400000000000000000000032671265717027300171240ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . __all__ = ['unicode', 'long', 'basestring', 'check_output'] try: unicode = unicode except NameError: unicode = str try: long = long except NameError: long = int try: basestring = basestring except NameError: basestring = str try: from subprocess import check_output except ImportError: import subprocess def check_output(*popenargs, **kwargs): r"""Run command with arguments and return its output as a byte string. Backported from Python 2.7 as it's implemented as pure python on stdlib. """ process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) output, unused_err = process.communicate() retcode = process.poll() if retcode: cmd = kwargs.get("args") if cmd is None: cmd = popenargs[0] error = subprocess.CalledProcessError(retcode, cmd) error.output = output raise error return output weboob-1.1/weboob/tools/config/000077500000000000000000000000001265717027300165245ustar00rootroot00000000000000weboob-1.1/weboob/tools/config/__init__.py000066400000000000000000000000001265717027300206230ustar00rootroot00000000000000weboob-1.1/weboob/tools/config/iconfig.py000066400000000000000000000036231265717027300205200ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . class ConfigError(Exception): pass class IConfig(object): """ Interface for config storage. Config stores keys and values. Each key is a path of components, allowing to group multiple options. """ def load(self, default={}): """ Load config. :param default: default values for the config :type default: dict[:class:`str`] """ raise NotImplementedError() def save(self): """Save config.""" raise NotImplementedError() def set(self, *args): """ Set a config value. :param args: all args except the last arg are the path of the option key. :type args: str or object """ raise NotImplementedError() def delete(self, *args): """ Delete an option from config. :param args: path to the option key. :type args: str """ raise NotImplementedError() def get(self, *args, **kwargs): """ Get the value of an option. :param args: path of the option key. :param default: if specified, default value when path is not found """ raise NotImplementedError() weboob-1.1/weboob/tools/config/iniconfig.py000066400000000000000000000077301265717027300210520ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from ConfigParser import RawConfigParser, DEFAULTSECT from decimal import Decimal import logging import os from weboob.tools.ordereddict import OrderedDict from .iconfig import IConfig __all__ = ['INIConfig'] class INIConfig(IConfig): ROOTSECT = 'ROOT' def __init__(self, path): self.path = path self.values = OrderedDict() self.config = RawConfigParser() def load(self, default={}): self.values = OrderedDict(default) if os.path.exists(self.path): logging.debug(u'Loading application configuration file: %s.' % self.path) self.config.read(self.path) for section in self.config.sections(): args = section.split(':') if args[0] == self.ROOTSECT: args.pop(0) for key, value in self.config.items(section): self.set(*(args + [key, value])) # retro compatibility if len(self.config.sections()) == 0: first = True for key, value in self.config.items(DEFAULTSECT): if first: logging.warning('The configuration file "%s" uses an old-style' % self.path) logging.warning('Please rename the %s section to %s' % (DEFAULTSECT, self.ROOTSECT)) first = False self.set(key, value) logging.debug(u'Application configuration file loaded: %s.' % self.path) else: self.save() logging.debug(u'Application configuration file created with default values: %s. ' 'Please customize it.' % self.path) return self.values def save(self): def save_section(values, root_section=self.ROOTSECT): for k, v in values.iteritems(): if isinstance(v, (int, Decimal, float, basestring)): if not self.config.has_section(root_section): self.config.add_section(root_section) self.config.set(root_section, k, unicode(v)) elif isinstance(v, dict): new_section = ':'.join((root_section, k)) if (root_section != self.ROOTSECT or k == self.ROOTSECT) else k if not self.config.has_section(new_section): self.config.add_section(new_section) save_section(v, new_section) save_section(self.values) with open(self.path, 'w') as f: self.config.write(f) def get(self, *args, **kwargs): default = None if 'default' in kwargs: default = kwargs['default'] v = self.values for k in args[:-1]: if k in v: v = v[k] else: return default try: return v[args[-1]] except KeyError: return default def set(self, *args): v = self.values for k in args[:-2]: if k not in v: v[k] = OrderedDict() v = v[k] v[args[-2]] = args[-1] def delete(self, *args): v = self.values for k in args[:-1]: if k not in v: return v = v[k] v.pop(args[-1], None) weboob-1.1/weboob/tools/config/yamlconfig.py000066400000000000000000000065071265717027300212360ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import logging import os import tempfile import weboob.tools.date import yaml from .iconfig import ConfigError, IConfig try: from yaml import CLoader as Loader from yaml import CDumper as Dumper except ImportError: from yaml import Loader from yaml import Dumper __all__ = ['YamlConfig'] class WeboobDumper(Dumper): pass WeboobDumper.add_representer(weboob.tools.date.date, WeboobDumper.represent_date) WeboobDumper.add_representer(weboob.tools.date.datetime, WeboobDumper.represent_datetime) class YamlConfig(IConfig): def __init__(self, path): self.path = path self.values = {} def load(self, default={}): self.values = default.copy() logging.debug(u'Loading application configuration file: %s.' % self.path) try: with open(self.path, 'r') as f: self.values = yaml.load(f, Loader=Loader) logging.debug(u'Application configuration file loaded: %s.' % self.path) except IOError: self.save() logging.debug(u'Application configuration file created with default values: %s. Please customize it.' % self.path) if self.values is None: self.values = {} def save(self): # write in a temporary file to avoid corruption problems with tempfile.NamedTemporaryFile(dir=os.path.dirname(self.path), delete=False) as f: yaml.dump(self.values, f, Dumper=WeboobDumper, default_flow_style=False) os.rename(f.name, self.path) def get(self, *args, **kwargs): v = self.values for a in args[:-1]: try: v = v[a] except KeyError: if 'default' in kwargs: v[a] = {} v = v[a] else: raise ConfigError() except TypeError: raise ConfigError() try: v = v[args[-1]] except KeyError: v = kwargs.get('default') return v def set(self, *args): v = self.values for a in args[:-2]: try: v = v[a] except KeyError: v[a] = {} v = v[a] except TypeError: raise ConfigError() v[args[-2]] = args[-1] def delete(self, *args): v = self.values for a in args[:-1]: try: v = v[a] except KeyError: return except TypeError: raise ConfigError() v.pop(args[-1], None) weboob-1.1/weboob/tools/date.py000066400000000000000000000327131265717027300165540ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2013 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import dateutil.parser from datetime import date as real_date, datetime as real_datetime, timedelta import time import re try: from dateutil import tz except ImportError: raise ImportError('Please install python-dateutil') __all__ = ['local2utc', 'utc2local', 'LinearDateGuesser', 'date', 'datetime', 'new_date', 'new_datetime', 'closest_date'] def local2utc(dateobj): dateobj = dateobj.replace(tzinfo=tz.tzlocal()) dateobj = dateobj.astimezone(tz.tzutc()) return dateobj def utc2local(dateobj): dateobj = dateobj.replace(tzinfo=tz.tzutc()) dateobj = dateobj.astimezone(tz.tzlocal()) return dateobj class date(real_date): def strftime(self, fmt): return strftime(self, fmt) @classmethod def from_date(cls, d): return cls(d.year, d.month, d.day) class datetime(real_datetime): def strftime(self, fmt): return strftime(self, fmt) def combine(self, date, time): return datetime(date.year, date.month, date.day, time.hour, time.minute, time.microsecond, time.tzinfo) def date(self): return date(self.year, self.month, self.day) @classmethod def from_datetime(cls, dt): return cls(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond, dt.tzinfo) def new_date(d): """ Generate a safe date from a datetime.date object """ return date(d.year, d.month, d.day) def new_datetime(d): """ Generate a safe datetime from a datetime.date or datetime.datetime object """ kw = [d.year, d.month, d.day] if isinstance(d, real_datetime): kw.extend([d.hour, d.minute, d.second, d.microsecond, d.tzinfo]) return datetime(*kw) # No support for strftime's "%s" or "%y". # Allowed if there's an even number of "%"s because they are escaped. _illegal_formatting = re.compile(r"((^|[^%])(%%)*%[sy])") def _findall(text, substr): # Also finds overlaps sites = [] i = 0 while True: j = text.find(substr, i) if j == -1: break sites.append(j) i = j+1 return sites def strftime(dt, fmt): if dt.year >= 1900: return super(type(dt), dt).strftime(fmt) illegal_formatting = _illegal_formatting.search(fmt) if illegal_formatting: raise TypeError("strftime of dates before 1900 does not handle" + illegal_formatting.group(0)) year = dt.year # For every non-leap year century, advance by # 6 years to get into the 28-year repeat cycle delta = 2000 - year off = 6*(delta // 100 + delta // 400) year = year + off # Move to around the year 2000 year = year + ((2000 - year)//28)*28 timetuple = dt.timetuple() s1 = time.strftime(fmt, (year,) + timetuple[1:]) sites1 = _findall(s1, str(year)) s2 = time.strftime(fmt, (year+28,) + timetuple[1:]) sites2 = _findall(s2, str(year+28)) sites = [] for site in sites1: if site in sites2: sites.append(site) s = s1 syear = "%4d" % (dt.year,) for site in sites: s = s[:site] + syear + s[site+4:] return s class LinearDateGuesser(object): """ The aim of this class is to guess the exact date object from a day and a month, but not a year. It works with a start date (default is today), and all dates must be sorted from recent to older. """ def __init__(self, current_date=None, date_max_bump=timedelta(31)): self.date_max_bump = date_max_bump if current_date is None: current_date = date.today() self.current_date = current_date def try_assigning_year(self, day, month, start_year, max_year): """ Tries to create a date object with day, month and start_year and returns it. If it fails due to the year not matching the day+month combination (i.e. due to a ValueError -- TypeError and OverflowError are not handled), the previous or next years are tried until max_year is reached. In case initialization still fails with max_year, this function raises a ValueError. """ while True: try: return date(start_year, month, day) except ValueError as e: if start_year == max_year: raise e start_year += cmp(max_year, start_year) def set_current_date(self, current_date): self.current_date = current_date def guess_date(self, day, month, change_current_date=True): """ Returns a date object built from a given day/month pair. """ today = self.current_date # The website only provides dates using the 'DD/MM' string, so we have to # determine the most possible year by ourselves. This implies tracking # the current date. # However, we may also encounter "bumps" in the dates, e.g. "12/11, # 10/11, 10/11, 12/11, 09/11", so we have to be, well, quite tolerant, # by accepting dates in the near future (say, 7 days) of the current # date. (Please, kill me...) # We first try to keep the current year naively_parsed_date = self.try_assigning_year(day, month, today.year, today.year - 5) if (naively_parsed_date.year != today.year): # we most likely hit a 29/02 leading to a change of year if change_current_date: self.set_current_date(naively_parsed_date) return naively_parsed_date if (naively_parsed_date > today + self.date_max_bump): # if the date ends up too far in the future, consider it actually # belongs to the previous year parsed_date = date(today.year - 1, month, day) if change_current_date: self.set_current_date(parsed_date) elif (naively_parsed_date > today and naively_parsed_date <= today + self.date_max_bump): # if the date is in the near future, consider it is a bump parsed_date = naively_parsed_date # do not keep it as current date though else: # if the date is in the past, as expected, simply keep it parsed_date = naively_parsed_date # and make it the new current date if change_current_date: self.set_current_date(parsed_date) return parsed_date class ChaoticDateGuesser(LinearDateGuesser): """ This class aim to find the guess the date when you know the day and month and the minimum year """ def __init__(self, min_date, current_date=None, date_max_bump=timedelta(31)): if min_date is None: raise ValueError("min_date is not set") self.min_date = min_date super(ChaoticDateGuesser, self).__init__(current_date, date_max_bump) def guess_date(self, day, month): """Returns a possible date between min_date and current_date""" parsed_date = super(ChaoticDateGuesser, self).guess_date(day, month, False) if parsed_date >= self.min_date: return parsed_date else: raise ValueError("%s is inferior to min_date %s" % (parsed_date, self.min_date)) DATE_TRANSLATE_FR = [(re.compile(ur'janvier', re.I), ur'january'), (re.compile(ur'février', re.I), ur'february'), (re.compile(ur'mars', re.I), ur'march'), (re.compile(ur'avril', re.I), ur'april'), (re.compile(ur'mai', re.I), ur'may'), (re.compile(ur'juin', re.I), ur'june'), (re.compile(ur'juillet', re.I), ur'july'), (re.compile(ur'août?', re.I), ur'august'), (re.compile(ur'septembre', re.I), ur'september'), (re.compile(ur'octobre', re.I), ur'october'), (re.compile(ur'novembre', re.I), ur'november'), (re.compile(ur'décembre', re.I), ur'december'), (re.compile(ur'jan\.', re.I), ur'january'), (re.compile(ur'janv\.', re.I), ur'january'), (re.compile(ur'\bjan\b', re.I), ur'january'), (re.compile(ur'fév\.', re.I), ur'february'), (re.compile(ur'févr\.', re.I), ur'february'), (re.compile(ur'\bfév\b', re.I), ur'february'), (re.compile(ur'avr\.', re.I), ur'april'), (re.compile(ur'\bavr\b', re.I), ur'april'), (re.compile(ur'juil\.', re.I), ur'july'), (re.compile(ur'juill\.', re.I), ur'july'), (re.compile(ur'\bjuil\b', re.I), ur'july'), (re.compile(ur'sep\.', re.I), ur'september'), (re.compile(ur'sept\.', re.I), ur'september'), (re.compile(ur'\bsep\b', re.I), ur'september'), (re.compile(ur'oct\.', re.I), ur'october'), (re.compile(ur'\boct\b', re.I), ur'october'), (re.compile(ur'nov\.', re.I), ur'november'), (re.compile(ur'\bnov\b', re.I), ur'november'), (re.compile(ur'déc\.', re.I), ur'december'), (re.compile(ur'\bdéc\b', re.I), ur'december'), (re.compile(ur'lundi', re.I), ur'monday'), (re.compile(ur'mardi', re.I), ur'tuesday'), (re.compile(ur'mercredi', re.I), ur'wednesday'), (re.compile(ur'jeudi', re.I), ur'thursday'), (re.compile(ur'vendredi', re.I), ur'friday'), (re.compile(ur'samedi', re.I), ur'saturday'), (re.compile(ur'dimanche', re.I), ur'sunday')] def parse_french_date(date, **kwargs): for fr, en in DATE_TRANSLATE_FR: date = fr.sub(en, date) if 'dayfirst' not in kwargs: kwargs['dayfirst'] = True return dateutil.parser.parse(date, **kwargs) WEEK = {'MONDAY': 0, 'TUESDAY': 1, 'WEDNESDAY': 2, 'THURSDAY': 3, 'FRIDAY': 4, 'SATURDAY': 5, 'SUNDAY': 6, 'LUNDI': 0, 'MARDI': 1, 'MERCREDI': 2, 'JEUDI': 3, 'VENDREDI': 4, 'SAMEDI': 5, 'DIMANCHE': 6, } def get_date_from_day(day): today = date.today() today_day_number = today.weekday() requested_day_number = WEEK[day.upper()] if today_day_number < requested_day_number: day_to_go = requested_day_number - today_day_number else: day_to_go = 7 - today_day_number + requested_day_number requested_date = today + timedelta(day_to_go) return date(requested_date.year, requested_date.month, requested_date.day) def parse_date(string): matches = re.search('\s*([012]?[0-9]|3[01])\s*/\s*(0?[1-9]|1[012])\s*/?(\d{2}|\d{4})?$', string) if matches: year = matches.group(3) if not year: year = date.today().year elif len(year) == 2: year = 2000 + int(year) return date(int(year), int(matches.group(2)), int(matches.group(1))) elif string.upper() in WEEK.keys(): return get_date_from_day(string) elif string.upper() == "TODAY": return date.today() def closest_date(date, date_from, date_to): """ Adjusts year so that the date is closest to the given range. Transactions dates in a statement usually contain only day and month. Statement dates range have a year though. Merge them all together to get a full transaction date. """ # If the date is within given range, we're done. if date_from <= date <= date_to: return date dates = [real_datetime(year, date.month, date.day) for year in xrange(date_from.year, date_to.year+1)] # Ideally, pick the date within given range. for d in dates: if date_from <= d <= date_to: return d # Otherwise, return the most recent date in the past. return min(dates, key=lambda d: abs(d-date_from)) def test(): dt = real_datetime range1 = [dt(2012,12,20), dt(2013,1,10)] assert closest_date(dt(2012,12,15), *range1) == dt(2012,12,15) assert closest_date(dt(2000,12,15), *range1) == dt(2012,12,15) assert closest_date(dt(2020,12,15), *range1) == dt(2012,12,15) assert closest_date(dt(2013,1,15), *range1) == dt(2013,1,15) assert closest_date(dt(2000,1,15), *range1) == dt(2013,1,15) assert closest_date(dt(2020,1,15), *range1) == dt(2013,1,15) assert closest_date(dt(2013,1,1), *range1) == dt(2013,1,1) assert closest_date(dt(2000,1,1), *range1) == dt(2013,1,1) assert closest_date(dt(2020,1,1), *range1) == dt(2013,1,1) range2 = [dt(2012,12,20), dt(2014,1,10)] assert closest_date(dt(2012,12,15), *range2) == dt(2013,12,15) assert closest_date(dt(2014,1,15), *range2) == dt(2013,1,15) weboob-1.1/weboob/tools/decorators.py000066400000000000000000000037331265717027300200040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import logging import time __all__ = ['retry'] def retry(ExceptionToCheck, tries=4, delay=3, backoff=2): """ Retry decorator from http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/ original from http://wiki.python.org/moin/PythonDecoratorLibrary#Retry """ def deco_retry(f): def f_retry(*args, **kwargs): mtries, mdelay = tries, delay mtries = kwargs.pop('_tries', mtries) mdelay = kwargs.pop('_delay', mdelay) try_one_last_time = True while mtries > 1: try: return f(*args, **kwargs) try_one_last_time = False break except ExceptionToCheck as e: try: logging.debug(u'%s, Retrying in %d seconds...' % (e, mdelay)) except UnicodeDecodeError: logging.debug(u'%s, Retrying in %d seconds...' % (repr(e), mdelay)) time.sleep(mdelay) mtries -= 1 mdelay *= backoff if try_one_last_time: return f(*args, **kwargs) return return f_retry # true decorator return deco_retry weboob-1.1/weboob/tools/html.py000066400000000000000000000030541265717027300165770ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import warnings __all__ = ['html2text'] try: from html2text import HTML2Text def html2text(html): h = HTML2Text() h.unicode_snob = True h.skip_internal_links = True h.inline_links = False h.links_each_paragraph = True return unicode(h.handle(html)) except ImportError: # Older versions of html2text do not have a class, so we have # to configure the module globally. try: import html2text as h2t h2t.UNICODE_SNOB = 1 h2t.SKIP_INTERNAL_LINKS = True h2t.INLINE_LINKS = False h2t.LINKS_EACH_PARAGRAPH = True html2text = h2t.html2text except ImportError: def html2text(html): warnings.warn('python-html2text is not present. HTML pages are not converted into text.', stacklevel=2) return html weboob-1.1/weboob/tools/js.py000066400000000000000000000032131265717027300162440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2015 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . __all__ = ['Javascript'] from weboob.tools.log import getLogger class Javascript(object): HEADER = """ function btoa(str) { var buffer ; if (str instanceof Buffer) { buffer = str; } else { buffer = new Buffer(str.toString(), 'binary'); } return buffer.toString('base64'); } function atob(str) { return new Buffer(str, 'base64').toString('binary'); } var document = {}; """ def __init__(self, script, logger=None): try: import execjs except ImportError: raise ImportError('Please install PyExecJS') self.runner = execjs.get() self.logger = getLogger('js', logger) self.ctx = self.runner.compile(self.HEADER + script) def call(self, *args, **kwargs): retval = self.ctx.call(*args, **kwargs) self.logger.debug('Calling %s%s = %s', args[0], args[1:], retval) return retval weboob-1.1/weboob/tools/json.py000066400000000000000000000044321265717027300166050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2012 Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . # because we don't want to import this file by "import json" from __future__ import absolute_import __all__ = ['json', 'mini_jsonpath'] try: # try simplejson first because it is faster import simplejson as json except ImportError: # Python 2.6+ has a module similar to simplejson import json def mini_jsonpath(node, path): """ Evaluates a dot separated path against JSON data. Path can contains star wilcards. Always returns a generator. Relates to http://goessner.net/articles/JsonPath/ but in a really basic and simpler form. >>> list(mini_jsonpath({"x": 95, "y": 77, "z": 68}, 'y')) [77] >>> list(mini_jsonpath({"x": {"y": {"z": "nested"}}}, 'x.y.z')) ['nested'] >>> list(mini_jsonpath('{"data": [{"x": "foo", "y": 13}, {"x": "bar", "y": 42}, {"x": "baz", "y": 128}]}', 'data.*.y')) [13, 42, 128] """ def iterkeys(i): return range(len(i)) if type(i) is list else i.iterkeys() def cut(s): p = s.split('.', 1) if s else [None] return p + [None] if len(p) == 1 else p if isinstance(node, basestring): node = json.loads(node) queue = [(node, cut(path))] while queue: node, (name, rest) = queue.pop(0) if name is None: yield node continue elif name == '*': keys = iterkeys(node) elif type(node) not in (dict, list) or name not in node: continue else: keys = [int(name) if type(node) is list else name] for k in keys: queue.append((node[k], cut(rest))) weboob-1.1/weboob/tools/log.py000066400000000000000000000043261265717027300164170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import print_function import sys from collections import defaultdict from logging import addLevelName, Formatter, getLogger as _getLogger __all__ = ['getLogger', 'createColoredFormatter', 'settings'] RESET_SEQ = "\033[0m" COLOR_SEQ = "%s%%s" + RESET_SEQ COLORS = { 'DEBUG': COLOR_SEQ % "\033[0;36m", 'INFO': COLOR_SEQ % "\033[32m", 'WARNING': COLOR_SEQ % "\033[1;33m", 'ERROR': COLOR_SEQ % "\033[1;31m", 'CRITICAL': COLOR_SEQ % ("\033[1;33m\033[1;41m"), 'DEBUG_FILTERS': COLOR_SEQ % "\033[0;35m", } DEBUG_FILTERS = 8 addLevelName(DEBUG_FILTERS, 'DEBUG_FILTERS') # Global settings f logger. settings = defaultdict(lambda: None) def getLogger(name, parent=None): if parent: name = parent.name + '.' + name logger = _getLogger(name) logger.settings = settings return logger class ColoredFormatter(Formatter): """ Class written by airmind: http://stackoverflow.com/questions/384076/how-can-i-make-the-python-logging-output-to-be-colored """ def format(self, record): levelname = record.levelname msg = Formatter.format(self, record) if levelname in COLORS: msg = COLORS[levelname] % msg return msg def createColoredFormatter(stream, format): if (sys.platform != 'win32') and stream.isatty(): return ColoredFormatter(format) else: return Formatter(format) if __name__ == '__main__': for levelname, cs in COLORS.items(): print(cs % levelname, end=' ') weboob-1.1/weboob/tools/misc.py000066400000000000000000000122101265717027300165600ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2014 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from time import time, sleep import locale import os import sys import traceback import types # keep compatibility from .compat import unicode __all__ = ['get_backtrace', 'get_bytes_size', 'iter_fields', 'to_unicode', 'limit', 'find_exe'] def get_backtrace(empty="Empty backtrace."): """ Try to get backtrace as string. Returns "Error while trying to get backtrace" on failure. """ try: info = sys.exc_info() trace = traceback.format_exception(*info) sys.exc_clear() if trace[0] != "None\n": return "".join(trace) except: return "Error while trying to get backtrace" return empty def get_bytes_size(size, unit_name): r"""Converts a unit and a number into a number of bytes. >>> get_bytes_size(2, 'KB') 2048 """ unit_data = { 'bytes': 1, 'KB': 1024, 'MB': 1024 * 1024, 'GB': 1024 * 1024 * 1024, 'TB': 1024 * 1024 * 1024 * 1024, } return float(size * unit_data.get(unit_name, 1)) def iter_fields(obj): for attribute_name in dir(obj): if attribute_name.startswith('_'): continue attribute = getattr(obj, attribute_name) if not isinstance(attribute, types.MethodType): yield attribute_name, attribute def to_unicode(text): r""" >>> to_unicode('ascii') u'ascii' >>> to_unicode(u'utf\xe9'.encode('UTF-8')) u'utf\xe9' >>> to_unicode(u'unicode') u'unicode' """ if isinstance(text, unicode): return text if not isinstance(text, str): try: text = str(text) except UnicodeError: return unicode(text) try: return unicode(text, 'utf-8') except UnicodeError: try: return unicode(text, 'iso-8859-15') except UnicodeError: return unicode(text, 'windows-1252', 'replace') def guess_encoding(stdio): try: encoding = stdio.encoding or locale.getpreferredencoding() except AttributeError: encoding = None # ASCII or ANSII is most likely a user mistake if not encoding or encoding.lower() == 'ascii' or encoding.lower().startswith('ansi'): encoding = 'UTF-8' return encoding def limit(iterator, lim): """Iterate on the lim first elements of iterator.""" count = 0 iterator = iter(iterator) while count < lim: yield iterator.next() count += 1 def ratelimit(group, delay): """ Simple rate limiting. Waits if the last call of lastlimit with this group name was less than delay seconds ago. The rate limiting is global, shared between any instance of the application and any call to this function sharing the same group name. The same group name should not be used with different delays. This function is intended to be called just before the code that should be rate-limited. This function is not thread-safe. For reasonably non-critical rate limiting (like accessing a website), it should be sufficient nevertheless. @param group [string] rate limiting group name, alphanumeric @param delay [int] delay in seconds between each call """ from tempfile import gettempdir path = os.path.join(gettempdir(), 'weboob_ratelimit.%s' % group) while True: try: offset = time() - os.stat(path).st_mtime except OSError: with open(path, 'w'): pass offset = 0 if delay < offset: break sleep(delay - offset) os.utime(path, None) def find_exe(basename): """ Find the path to an executable by its base name (such as 'gpg'). The executable can be overriden using an environment variable in the form `NAME_EXECUTABLE` where NAME is the specified base name in upper case. If the environment variable is not provided, the PATH will be searched both without and with a ".exe" suffix for Windows compatibility. If the executable can not be found, None is returned. """ env_exe = os.getenv('%s_EXECUTABLE' % basename.upper()) if env_exe and os.path.exists(env_exe) and os.access(env_exe, os.X_OK): return env_exe paths = os.getenv('PATH', os.defpath).split(os.pathsep) for path in paths: for ex in (basename, basename + '.exe'): fpath = os.path.join(path, ex) if os.path.exists(fpath) and os.access(fpath, os.X_OK): return fpath weboob-1.1/weboob/tools/newsfeed.py000066400000000000000000000055731265717027300174430ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Clément Schreiner # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import datetime try: import feedparser except ImportError: raise ImportError('Please install python-feedparser') if '5.1' > feedparser.__version__ >= '5.0': # feedparser 5.0.x replaces this regexp on sgmllib # and mechanize < 0.2 fails with malformed pages. import sgmllib import re sgmllib.endbracket = re.compile('[<>]') __all__ = ['Entry', 'Newsfeed'] class Entry(object): def __init__(self, entry, rssid_func=None): if hasattr(entry, 'id'): self.id = entry.id else: self.id = None if "link" in entry: self.link = entry["link"] if not self.id: self.id = entry["link"] else: self.link = None if "title" in entry: self.title = entry["title"] else: self.title = None if "author" in entry: self.author = entry["author"] else: self.author = None if "updated_parsed" in entry: self.datetime = datetime.datetime(*entry['updated_parsed'][:7]) elif "published_parsed" in entry: self.datetime = datetime.datetime(*entry['published_parsed'][:7]) else: self.datetime = None if "summary" in entry: self.summary = entry["summary"] else: self.summary = None self.content = [] if "content" in entry: for i in entry["content"]: self.content.append(i.value) elif self.summary: self.content.append(self.summary) if "wfw_commentrss" in entry: self.rsscomment = entry["wfw_commentrss"] else: self.rsscomment = None if rssid_func: self.id = rssid_func(self) class Newsfeed(object): def __init__(self, url, rssid_func=None): self.feed = feedparser.parse(url) self.rssid_func = rssid_func def iter_entries(self): for entry in self.feed['entries']: yield Entry(entry, self.rssid_func) def get_entry(self, id): for entry in self.iter_entries(): if entry.id == id: return entry weboob-1.1/weboob/tools/ordereddict.py000066400000000000000000000116031265717027300201220ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from __future__ import absolute_import __all__ = ['OrderedDict'] try: from collections import OrderedDict except ImportError: try: from simplejson import OrderedDict except ImportError: try: from ordereddict import OrderedDict except ImportError: # {{{ http://code.activestate.com/recipes/576693/ (r6) from UserDict import DictMixin class OrderedDict(dict, DictMixin): def __init__(self, *args, **kwds): if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) try: self.__end except AttributeError: self.clear() self.update(*args, **kwds) def clear(self): self.__end = end = [] end += [None, end, end] # sentinel node for doubly linked list self.__map = {} # key --> [key, prev, next] dict.clear(self) def __setitem__(self, key, value): if key not in self: end = self.__end curr = end[1] curr[2] = end[1] = self.__map[key] = [key, curr, end] dict.__setitem__(self, key, value) def __delitem__(self, key): dict.__delitem__(self, key) key, prev, next = self.__map.pop(key) prev[2] = next next[1] = prev def __iter__(self): end = self.__end curr = end[2] while curr is not end: yield curr[0] curr = curr[2] def __reversed__(self): end = self.__end curr = end[1] while curr is not end: yield curr[0] curr = curr[1] def popitem(self, last=True): if not self: raise KeyError('dictionary is empty') if last: key = reversed(self).next() else: key = iter(self).next() value = self.pop(key) return key, value def __reduce__(self): items = [[k, self[k]] for k in self] tmp = self.__map, self.__end del self.__map, self.__end inst_dict = vars(self).copy() self.__map, self.__end = tmp if inst_dict: return (self.__class__, (items,), inst_dict) return self.__class__, (items,) def keys(self): return list(self) setdefault = DictMixin.setdefault update = DictMixin.update pop = DictMixin.pop values = DictMixin.values items = DictMixin.items iterkeys = DictMixin.iterkeys itervalues = DictMixin.itervalues iteritems = DictMixin.iteritems def __repr__(self): if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, self.items()) def copy(self): return self.__class__(self) @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d def __eq__(self, other): if isinstance(other, OrderedDict): return len(self) == len(other) and self.items() == other.items() return dict.__eq__(self, other) def __ne__(self, other): return not self == other # end of http://code.activestate.com/recipes/576693/ }}} weboob-1.1/weboob/tools/path.py000066400000000000000000000051321265717027300165660ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2012 Nicolas Duhamel, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from copy import copy from posixpath import sep, join class WorkingPath(object): def __init__(self): self.split_path = [] self.previous = copy(self.split_path) def cd1(self, user_input): """ Append *one* level to the current path. This means that separators (/) will get escaped. """ split_path = self.get() split_path.append(user_input) self.location(split_path) def location(self, split_path): """ Go to a new path, and store the previous path. """ self.previous = self.get() self.split_path = split_path def restore(self): """ Go to the previous path """ self.split_path, self.previous = self.previous, self.split_path def home(self): """ Go to the root """ self.location([]) def up(self): """ Go up one directory """ self.location(self.split_path[:-1]) def get(self): """ Get the current working path """ return copy(self.split_path) def __unicode__(self): return join(sep, *[s.replace(u'/', u'\/') for s in self.split_path]) def test(): wp = WorkingPath() assert wp.get() == [] assert unicode(wp) == u'/' wp.cd1(u'lol') assert wp.get() == [u'lol'] assert unicode(wp) == u'/lol' wp.cd1(u'cat') assert wp.get() == [u'lol', u'cat'] assert unicode(wp) == u'/lol/cat' wp.restore() assert unicode(wp) == u'/lol' wp.home() assert wp.get() == [] assert unicode(wp) == u'/' wp.up() assert wp.get() == [] assert unicode(wp) == u'/' wp.location(['aa / aa', 'bbbb']) assert unicode(wp) == u'/aa \/ aa/bbbb' wp.up() assert unicode(wp) == u'/aa \/ aa' wp.cd1(u'héhé/hé') assert unicode(wp) == u'/aa \/ aa/héhé\/hé' weboob-1.1/weboob/tools/pdf.py000066400000000000000000000025511265717027300164050ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import os import subprocess from tempfile import mkstemp __all__ = ['decompress_pdf'] def decompress_pdf(inpdf): """ Takes PDF file contents as a string and returns decompressed version of the file contents, suitable for text parsing. External dependencies: MuPDF (http://www.mupdf.com). """ inh, inname = mkstemp(suffix='.pdf') outh, outname = mkstemp(suffix='.pdf') os.write(inh, inpdf) os.close(inh) os.close(outh) subprocess.call(['mutool', 'clean', '-d', inname, outname]) with open(outname) as f: outpdf = f.read() os.remove(inname) os.remove(outname) return outpdf weboob-1.1/weboob/tools/property.py000066400000000000000000000033421265717027300175170ustar00rootroot00000000000000# -*- coding: utf-8 -*- # For Python 2.5-, this will enable the similar property mechanism as in # Python 2.6+/3.0+. The code is based on # http://bruynooghe.blogspot.com/2008/04/xsetter-syntax-in-python-25.html # Copyright(C) 2010-2011 Christophe Benz # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import sys import __builtin__ class property(property): def __init__(self, fget, *args, **kwargs): self.__doc__ = fget.__doc__ super(property, self).__init__(fget, *args, **kwargs) def setter(self, fset): cls_ns = sys._getframe(1).f_locals for k, v in cls_ns.iteritems(): if v == self: propname = k break cls_ns[propname] = property(self.fget, fset, self.fdel, self.__doc__) return cls_ns[propname] def deleter(self, fdel): cls_ns = sys._getframe(1).f_locals for k, v in cls_ns.iteritems(): if v == self: propname = k break cls_ns[propname] = property(self.fget, self.fset, fdel, self.__doc__) return cls_ns[propname] __builtin__.property = property weboob-1.1/weboob/tools/regex_helper.py000066400000000000000000000336051265717027300203110ustar00rootroot00000000000000# Copyright (c) Django Software Foundation and individual contributors. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # 3. Neither the name of Django nor the names of its contributors may be used # to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ Functions for reversing a regular expression (used in reverse URL resolving). Used internally by Django and not intended for external use. This is not, and is not intended to be, a complete reg-exp decompiler. It should be good enough for a large class of URLS, however. """ # Mapping of an escape character to a representative of that class. So, e.g., # "\w" is replaced by "x" in a reverse URL. A value of None means to ignore # this sequence. Any missing key is mapped to itself. ESCAPE_MAPPINGS = { "A": None, "b": None, "B": None, "d": u"0", "D": u"x", "s": u" ", "S": u"x", "w": u"x", "W": u"!", "Z": None, } class Choice(list): """ Used to represent multiple possibilities at this point in a pattern string. We use a distinguished type, rather than a list, so that the usage in the code is clear. """ class Group(list): """ Used to represent a capturing group in the pattern string. """ class NonCapture(list): """ Used to represent a non-capturing group in the pattern string. """ def normalize(pattern): """ Given a reg-exp pattern, normalizes it to a list of forms that suffice for reverse matching. This does the following: (1) For any repeating sections, keeps the minimum number of occurrences permitted (this means zero for optional groups). (2) If an optional group includes parameters, include one occurrence of that group (along with the zero occurrence case from step (1)). (3) Select the first (essentially an arbitrary) element from any character class. Select an arbitrary character for any unordered class (e.g. '.' or '\w') in the pattern. (4) Ignore comments and any of the reg-exp flags that won't change what we construct ("iLmsu"). "(?x)" is an error, however. (5) Raise an error on all other non-capturing (?...) forms (e.g. look-ahead and look-behind matches) and any disjunctive ('|') constructs. Django's URLs for forward resolving are either all positional arguments or all keyword arguments. That is assumed here, as well. Although reverse resolving can be done using positional args when keyword args are specified, the two cannot be mixed in the same reverse() call. """ # Do a linear scan to work out the special features of this pattern. The # idea is that we scan once here and collect all the information we need to # make future decisions. result = [] non_capturing_groups = [] consume_next = True pattern_iter = next_char(iter(pattern)) num_args = 0 # A "while" loop is used here because later on we need to be able to peek # at the next character and possibly go around without consuming another # one at the top of the loop. try: ch, escaped = pattern_iter.next() except StopIteration: return zip([u''], [[]]) try: while True: if escaped: result.append(ch) elif ch == '.': # Replace "any character" with an arbitrary representative. result.append(u".") elif ch == '|': # FIXME: One day we'll should do this, but not in 1.0. raise NotImplementedError() elif ch == "^": pass elif ch == '$': break elif ch == ')': # This can only be the end of a non-capturing group, since all # other unescaped parentheses are handled by the grouping # section later (and the full group is handled there). # # We regroup everything inside the capturing group so that it # can be quantified, if necessary. start = non_capturing_groups.pop() inner = NonCapture(result[start:]) result = result[:start] + [inner] elif ch == '[': # Replace ranges with the first character in the range. ch, escaped = pattern_iter.next() result.append(ch) ch, escaped = pattern_iter.next() while escaped or ch != ']': ch, escaped = pattern_iter.next() elif ch == '(': # Some kind of group. ch, escaped = pattern_iter.next() if ch != '?' or escaped: # A positional group name = "_%d" % num_args num_args += 1 result.append(Group(((u"%%(%s)s" % name), name))) walk_to_end(ch, pattern_iter) else: ch, escaped = pattern_iter.next() if ch in "iLmsu#": # All of these are ignorable. Walk to the end of the # group. walk_to_end(ch, pattern_iter) elif ch == ':': # Non-capturing group non_capturing_groups.append(len(result)) elif ch != 'P': # Anything else, other than a named group, is something # we cannot reverse. raise ValueError("Non-reversible reg-exp portion: '(?%s'" % ch) else: ch, escaped = pattern_iter.next() if ch not in ('<', '='): raise ValueError("Non-reversible reg-exp portion: '(?P%s'" % ch) # We are in a named capturing group. Extra the name and # then skip to the end. if ch == '<': terminal_char = '>' # We are in a named backreference. else: terminal_char = ')' name = [] ch, escaped = pattern_iter.next() while ch != terminal_char: name.append(ch) ch, escaped = pattern_iter.next() param = ''.join(name) # Named backreferences have already consumed the # parenthesis. if terminal_char != ')': result.append(Group(((u"%%(%s)s" % param), param))) walk_to_end(ch, pattern_iter) else: result.append(Group(((u"%%(%s)s" % param), None))) elif ch in "*?+{": # Quanitifers affect the previous item in the result list. count, ch = get_quantifier(ch, pattern_iter) if ch: # We had to look ahead, but it wasn't need to compute the # quanitifer, so use this character next time around the # main loop. consume_next = False if count == 0: if contains(result[-1], Group): # If we are quantifying a capturing group (or # something containing such a group) and the minimum is # zero, we must also handle the case of one occurrence # being present. All the quantifiers (except {0,0}, # which we conveniently ignore) that have a 0 minimum # also allow a single occurrence. result[-1] = Choice([None, result[-1]]) else: result.pop() elif count > 1: result.extend([result[-1]] * (count - 1)) else: # Anything else is a literal. result.append(ch) if consume_next: ch, escaped = pattern_iter.next() else: consume_next = True except StopIteration: pass except NotImplementedError: # A case of using the disjunctive form. No results for you! return zip([u''], [[]]) return zip(*flatten_result(result)) def next_char(input_iter): """ An iterator that yields the next character from "pattern_iter", respecting escape sequences. An escaped character is replaced by a representative of its class (e.g. \w -> "x"). If the escaped character is one that is skipped, it is not returned (the next character is returned instead). Yields the next character, along with a boolean indicating whether it is a raw (unescaped) character or not. """ for ch in input_iter: if ch != '\\': yield ch, False continue ch = input_iter.next() representative = ESCAPE_MAPPINGS.get(ch, ch) if representative is None: continue yield representative, True def walk_to_end(ch, input_iter): """ The iterator is currently inside a capturing group. We want to walk to the close of this group, skipping over any nested groups and handling escaped parentheses correctly. """ if ch == '(': nesting = 1 else: nesting = 0 for ch, escaped in input_iter: if escaped: continue elif ch == '(': nesting += 1 elif ch == ')': if not nesting: return nesting -= 1 def get_quantifier(ch, input_iter): """ Parse a quantifier from the input, where "ch" is the first character in the quantifier. Returns the minimum number of occurences permitted by the quantifier and either None or the next character from the input_iter if the next character is not part of the quantifier. """ if ch in '*?+': try: ch2, escaped = input_iter.next() except StopIteration: ch2 = None if ch2 == '?': ch2 = None if ch == '+': return 1, ch2 return 0, ch2 quant = [] while ch != '}': ch, escaped = input_iter.next() quant.append(ch) quant = quant[:-1] values = ''.join(quant).split(',') # Consume the trailing '?', if necessary. try: ch, escaped = input_iter.next() except StopIteration: ch = None if ch == '?': ch = None return int(values[0]), ch def contains(source, inst): """ Returns True if the "source" contains an instance of "inst". False, otherwise. """ if isinstance(source, inst): return True if isinstance(source, NonCapture): for elt in source: if contains(elt, inst): return True return False def flatten_result(source): """ Turns the given source sequence into a list of reg-exp possibilities and their arguments. Returns a list of strings and a list of argument lists. Each of the two lists will be of the same length. """ if source is None: return [u''], [[]] if isinstance(source, Group): if source[1] is None: params = [] else: params = [source[1]] return [source[0]], [params] result = [u''] result_args = [[]] pos = last = 0 for pos, elt in enumerate(source): if isinstance(elt, basestring): continue piece = u''.join(source[last:pos]) if isinstance(elt, Group): piece += elt[0] param = elt[1] else: param = None last = pos + 1 for i in range(len(result)): result[i] += piece if param: result_args[i].append(param) if isinstance(elt, (Choice, NonCapture)): if isinstance(elt, NonCapture): elt = [elt] inner_result, inner_args = [], [] for item in elt: res, args = flatten_result(item) inner_result.extend(res) inner_args.extend(args) new_result = [] new_args = [] for item, args in zip(result, result_args): for i_item, i_args in zip(inner_result, inner_args): new_result.append(item + i_item) new_args.append(args[:] + i_args) result = new_result result_args = new_args if pos >= last: piece = u''.join(source[last:]) for i in range(len(result)): result[i] += piece return result, result_args weboob-1.1/weboob/tools/storage.py000066400000000000000000000043761265717027300173070ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . from copy import deepcopy from .config.yamlconfig import YamlConfig class IStorage(object): def load(self, what, name, default={}): """ Load data from storage. """ raise NotImplementedError() def save(self, what, name): """ Write changes in storage on the disk. """ raise NotImplementedError() def set(self, what, name, *args): """ Set data in a path. """ raise NotImplementedError() def delete(self, what, name, *args): """ Delete a value or a path. """ raise NotImplementedError() def get(self, what, name, *args, **kwargs): """ Get a value or a path. """ raise NotImplementedError() class StandardStorage(IStorage): def __init__(self, path): self.config = YamlConfig(path) self.config.load() def load(self, what, name, default={}): d = {} if what not in self.config.values: self.config.values[what] = {} else: d = self.config.values[what].get(name, {}) self.config.values[what][name] = deepcopy(default) self.config.values[what][name].update(d) def save(self, what, name): self.config.save() def set(self, what, name, *args): self.config.set(what, name, *args) def delete(self, what, name, *args): self.config.delete(what, name, *args) def get(self, what, name, *args, **kwargs): return self.config.get(what, name, *args, **kwargs) weboob-1.1/weboob/tools/test.py000066400000000000000000000050101265717027300166040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import sys from random import choice from unittest import TestCase from weboob.core import Weboob # This is what nose does for Python 2.6 and lower compatibility # We do the same so nose becomes optional try: from unittest.case import SkipTest except: from nose.plugins.skip import SkipTest __all__ = ['BackendTest', 'SkipTest'] class BackendTest(TestCase): MODULE = None def __init__(self, *args, **kwargs): TestCase.__init__(self, *args, **kwargs) self.backends = {} self.backend_instance = None self.backend = None self.weboob = Weboob() if self.weboob.load_backends(modules=[self.MODULE]): # provide the tests with all available backends self.backends = self.weboob.backend_instances # chose one backend (enough for most tests) self.backend_instance = choice(self.backends.keys()) self.backend = self.backends[self.backend_instance] def run(self, result): """ Call the parent run() for each backend instance. Skip the test if we have no backends. """ # This is a hack to fix an issue with nosetests running # with many tests. The default is 1000. sys.setrecursionlimit(10000) try: if not len(self.backends): result.startTest(self) result.stopTest(self) raise SkipTest('No backends configured for this module.') TestCase.run(self, result) finally: self.weboob.deinit() def shortDescription(self): """ Generate a description with the backend instance name. """ # do not use TestCase.shortDescription as it returns None return '%s [%s]' % (str(self), self.backend_instance) weboob-1.1/weboob/tools/tokenizer.py000066400000000000000000000063341265717027300176510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2014 Oleg Plakhotniuk # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re __all__ = ['ReTokenizer'] class ReTokenizer(object): """ Simple regex-based tokenizer (AKA lexer or lexical analyser). Useful for PDF statements parsing. 1. There's a lexing table consisting of type-regex tuples. 2. Lexer splits text into chunks using the separator character. 3. Text chunk is sequentially matched against regexes and first successful match defines the type of the token. Check out test() function below for examples. """ def __init__(self, text, sep, lex): self._lex = lex self._tok = [ReToken(lex, chunk) for chunk in text.split(sep)] def tok(self, index): if 0 <= index < len(self._tok): return self._tok[index] else: return ReToken(self._lex, eof=True) def simple_read(self, token_type, pos, transform=lambda v: v): t = self.tok(pos) is_type = getattr(t, 'is_%s' % token_type)() return (pos+1, transform(t.value())) if is_type else (pos, None) class ReToken(object): def __init__(self, lex, chunk=None, eof=False): self._lex = lex self._eof = eof self._value = None self._type = None if chunk is not None: for type_, regex in self._lex: m = re.match(regex, chunk, flags=re.UNICODE) if m: self._type = type_ if len(m.groups()) == 1: self._value = m.groups()[0] elif m.groups(): self._value = m.groups() else: self._value = m.group(0) break def is_eof(self): return self._eof def value(self): return self._value def __getattr__(self, name): if name.startswith('is_'): return lambda: self._type == name[3:] raise AttributeError() def test(): t = ReTokenizer('foo bar baz', ' ', [('f', r'^f'), ('b', r'^b')]) assert t.tok(0).is_f() assert t.tok(1).is_b() assert t.tok(2).is_b() assert t.tok(-1).is_eof() assert t.tok(3).is_eof() assert not t.tok(-1).is_f() assert not t.tok(0).is_b() assert not t.tok(0).is_eof() t = ReTokenizer('nogroup onegroup multigroup', ' ', [ ('ng', r'^n.*$'), ('og', r'^one(g.*)$'), ('mg', r'^(m.*)(g.*)$')]) assert t.tok(-1).value() is None assert t.tok(0).value() == 'nogroup' assert t.tok(1).value() == 'group' assert t.tok(2).value() == ('multi', 'group') weboob-1.1/weboob/tools/value.py000066400000000000000000000211011265717027300167400ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright(C) 2010-2011 Romain Bignon # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . import re import subprocess from .compat import check_output from .misc import to_unicode from .ordereddict import OrderedDict __all__ = ['ValuesDict', 'Value', 'ValueBackendPassword', 'ValueInt', 'ValueFloat', 'ValueBool'] class ValuesDict(OrderedDict): """ Ordered dictionarry which can take values in constructor. >>> ValuesDict(Value('a', label='Test'), ValueInt('b', label='Test2')) """ def __init__(self, *values): OrderedDict.__init__(self) for v in values: self[v.id] = v class Value(object): """ Value. :param label: human readable description of a value :type label: str :param required: if ``True``, the backend can't load if the key isn't found in its configuration :type required: bool :param default: an optional default value, used when the key is not in config. If there is no default value and the key is not found in configuration, the **required** parameter is implicitly set :param masked: if ``True``, the value is masked. It is useful for applications to know if this key is a password :type masked: bool :param regexp: if specified, on load the specified value is checked against this regexp, and an error is raised if it doesn't match :type regexp: str :param choices: if this parameter is set, the value must be in the list :param tiny: the value of choices can be entered by an user (as they are small) :type choices: (list,dict) """ def __init__(self, *args, **kwargs): if len(args) > 0: self.id = args[0] else: self.id = '' self.label = kwargs.get('label', kwargs.get('description', None)) self.description = kwargs.get('description', kwargs.get('label', None)) self.default = kwargs.get('default', None) if isinstance(self.default, str): self.default = to_unicode(self.default) self.regexp = kwargs.get('regexp', None) self.choices = kwargs.get('choices', None) if isinstance(self.choices, (list, tuple)): self.choices = OrderedDict(((v, v) for v in self.choices)) self.tiny = kwargs.get('tiny', None) self.masked = kwargs.get('masked', False) self.required = kwargs.get('required', self.default is None) self._value = kwargs.get('value', None) def show_value(self, v): if self.masked: return len(unicode(v)) * '*' else: return v def check_valid(self, v): """ Check if the given value is valid. :raises: ValueError """ if self.default is not None and v == self.default: return if v == '' and self.default != '' and (self.choices is None or v not in self.choices): raise ValueError('Value can\'t be empty') if self.regexp is not None and not re.match(self.regexp, unicode(v)): raise ValueError('Value "%s" does not match regexp "%s"' % (self.show_value(v), self.regexp)) if self.choices is not None and v not in self.choices: raise ValueError('Value "%s" is not in list: %s' % ( self.show_value(v), ', '.join(unicode(s) for s in self.choices))) def load(self, domain, v, callbacks): """ Load value. :param domain: what is the domain of this value :type domain: str :param v: value to load :param callbacks: list of weboob callbacks :type callbacks: dict """ return self.set(v) def set(self, v): """ Set a value. """ if isinstance(v, str): v = to_unicode(v) self.check_valid(v) self._value = v def dump(self): """ Dump value to be stored. """ return self.get() def get(self): """ Get the value. """ return self._value def is_command(self, v): """ Test if a value begin with ` and end with ` (`command` is used to call external programms) """ return isinstance(v, basestring) and v.startswith(u'`') and v.endswith(u'`') class ValueBackendPassword(Value): _domain = None _callbacks = {} _stored = True def __init__(self, *args, **kwargs): kwargs['masked'] = kwargs.pop('masked', True) self.noprompt = kwargs.pop('noprompt', False) Value.__init__(self, *args, **kwargs) def load(self, domain, password, callbacks): if self.is_command(password): cmd = password[1:-1] try: password = check_output(cmd, shell=True) except subprocess.CalledProcessError as e: raise ValueError(u'The call to the external tool failed: %s' % e) else: password = password.partition('\n')[0].strip('\r\n\t') self.check_valid(password) self._domain = domain self._value = to_unicode(password) self._callbacks = callbacks def check_valid(self, passwd): if passwd == '': # always allow empty passwords return True return Value.check_valid(self, passwd) def set(self, passwd): if self.is_command(passwd): self._value = passwd return self.check_valid(passwd) if passwd is None: # no change return self._value = '' if passwd == '': return if self._domain is None: self._value = to_unicode(passwd) return try: raise ImportError('Keyrings are disabled (see #706)') import keyring keyring.set_password(self._domain, self.id, passwd) except Exception: self._value = to_unicode(passwd) else: self._value = '' def dump(self): if self._stored: return self._value else: return '' def get(self): if self._value != '' or self._domain is None: return self._value try: raise ImportError('Keyrings are disabled (see #706)') import keyring except ImportError: passwd = None else: passwd = keyring.get_password(self._domain, self.id) if passwd is not None: # Password has been read in the keyring. return to_unicode(passwd) # Prompt user to enter password by hand. if not self.noprompt and 'login' in self._callbacks: self._value = to_unicode(self._callbacks['login'](self._domain, self)) if self._value is None: self._value = '' else: self._stored = False return self._value class ValueInt(Value): def __init__(self, *args, **kwargs): kwargs['regexp'] = '^\d+$' Value.__init__(self, *args, **kwargs) def get(self): return int(self._value) class ValueFloat(Value): def __init__(self, *args, **kwargs): kwargs['regexp'] = '^[\d\.]+$' Value.__init__(self, *args, **kwargs) def check_valid(self, v): try: float(v) except ValueError: raise ValueError('Value "%s" is not a float value' % self.show_value(v)) def get(self): return float(self._value) class ValueBool(Value): def __init__(self, *args, **kwargs): kwargs['choices'] = {'y': 'True', 'n': 'False'} Value.__init__(self, *args, **kwargs) def check_valid(self, v): if not isinstance(v, bool) and \ unicode(v).lower() not in ('y', 'yes', '1', 'true', 'on', 'n', 'no', '0', 'false', 'off'): raise ValueError('Value "%s" is not a boolean (y/n)' % self.show_value(v)) def get(self): return (isinstance(self._value, bool) and self._value) or \ unicode(self._value).lower() in ('y', 'yes', '1', 'true', 'on')