├── .gitignore ├── LICENSE ├── README.rst ├── pyfm ├── __init__.py ├── config.py ├── douban.py ├── fm.py ├── notifier.py ├── player.py ├── scrobbler.py ├── song.py └── ui.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Config and log file 9 | *.json 10 | *.log 11 | 12 | # Distribution / packaging 13 | .Python 14 | env/ 15 | bin/ 16 | build/ 17 | develop-eggs/ 18 | dist/ 19 | eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | 29 | # Installer logs 30 | pip-log.txt 31 | pip-delete-this-directory.txt 32 | 33 | # Unit test / coverage reports 34 | htmlcov/ 35 | .tox/ 36 | .coverage 37 | .cache 38 | nosetests.xml 39 | coverage.xml 40 | 41 | # Translations 42 | *.mo 43 | 44 | # Mr Developer 45 | .mr.developer.cfg 46 | .project 47 | .pydevproject 48 | 49 | # Rope 50 | .ropeproject 51 | 52 | # Django stuff: 53 | *.log 54 | *.pot 55 | 56 | # Sphinx documentation 57 | docs/_build/ 58 | 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 skyline75489 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | Scrobbler.py contains code from the following libraries which applies GPLv3: 24 | 25 | * http://hg.user1.be/ScrobblerPlugin 26 | 27 | GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 28 | 29 | Copyright (C) 2007 Free Software Foundation, Inc. 30 | Everyone is permitted to copy and distribute verbatim copies 31 | of this license document, but changing it is not allowed. 32 | 33 | Preamble 34 | 35 | The GNU General Public License is a free, copyleft license for 36 | software and other kinds of works. 37 | 38 | The licenses for most software and other practical works are designed 39 | to take away your freedom to share and change the works. By contrast, 40 | the GNU General Public License is intended to guarantee your freedom to 41 | share and change all versions of a program--to make sure it remains free 42 | software for all its users. We, the Free Software Foundation, use the 43 | GNU General Public License for most of our software; it applies also to 44 | any other work released this way by its authors. You can apply it to 45 | your programs, too. 46 | 47 | When we speak of free software, we are referring to freedom, not 48 | price. Our General Public Licenses are designed to make sure that you 49 | have the freedom to distribute copies of free software (and charge for 50 | them if you wish), that you receive source code or can get it if you 51 | want it, that you can change the software or use pieces of it in new 52 | free programs, and that you know you can do these things. 53 | 54 | To protect your rights, we need to prevent others from denying you 55 | these rights or asking you to surrender the rights. Therefore, you have 56 | certain responsibilities if you distribute copies of the software, or if 57 | you modify it: responsibilities to respect the freedom of others. 58 | 59 | For example, if you distribute copies of such a program, whether 60 | gratis or for a fee, you must pass on to the recipients the same 61 | freedoms that you received. You must make sure that they, too, receive 62 | or can get the source code. And you must show them these terms so they 63 | know their rights. 64 | 65 | Developers that use the GNU GPL protect your rights with two steps: 66 | (1) assert copyright on the software, and (2) offer you this License 67 | giving you legal permission to copy, distribute and/or modify it. 68 | 69 | For the developers' and authors' protection, the GPL clearly explains 70 | that there is no warranty for this free software. For both users' and 71 | authors' sake, the GPL requires that modified versions be marked as 72 | changed, so that their problems will not be attributed erroneously to 73 | authors of previous versions. 74 | 75 | Some devices are designed to deny users access to install or run 76 | modified versions of the software inside them, although the manufacturer 77 | can do so. This is fundamentally incompatible with the aim of 78 | protecting users' freedom to change the software. The systematic 79 | pattern of such abuse occurs in the area of products for individuals to 80 | use, which is precisely where it is most unacceptable. Therefore, we 81 | have designed this version of the GPL to prohibit the practice for those 82 | products. If such problems arise substantially in other domains, we 83 | stand ready to extend this provision to those domains in future versions 84 | of the GPL, as needed to protect the freedom of users. 85 | 86 | Finally, every program is threatened constantly by software patents. 87 | States should not allow patents to restrict development and use of 88 | software on general-purpose computers, but in those that do, we wish to 89 | avoid the special danger that patents applied to a free program could 90 | make it effectively proprietary. To prevent this, the GPL assures that 91 | patents cannot be used to render the program non-free. 92 | 93 | The precise terms and conditions for copying, distribution and 94 | modification follow. 95 | 96 | TERMS AND CONDITIONS 97 | 98 | 0. Definitions. 99 | 100 | "This License" refers to version 3 of the GNU General Public License. 101 | 102 | "Copyright" also means copyright-like laws that apply to other kinds of 103 | works, such as semiconductor masks. 104 | 105 | "The Program" refers to any copyrightable work licensed under this 106 | License. Each licensee is addressed as "you". "Licensees" and 107 | "recipients" may be individuals or organizations. 108 | 109 | To "modify" a work means to copy from or adapt all or part of the work 110 | in a fashion requiring copyright permission, other than the making of an 111 | exact copy. The resulting work is called a "modified version" of the 112 | earlier work or a work "based on" the earlier work. 113 | 114 | A "covered work" means either the unmodified Program or a work based 115 | on the Program. 116 | 117 | To "propagate" a work means to do anything with it that, without 118 | permission, would make you directly or secondarily liable for 119 | infringement under applicable copyright law, except executing it on a 120 | computer or modifying a private copy. Propagation includes copying, 121 | distribution (with or without modification), making available to the 122 | public, and in some countries other activities as well. 123 | 124 | To "convey" a work means any kind of propagation that enables other 125 | parties to make or receive copies. Mere interaction with a user through 126 | a computer network, with no transfer of a copy, is not conveying. 127 | 128 | An interactive user interface displays "Appropriate Legal Notices" 129 | to the extent that it includes a convenient and prominently visible 130 | feature that (1) displays an appropriate copyright notice, and (2) 131 | tells the user that there is no warranty for the work (except to the 132 | extent that warranties are provided), that licensees may convey the 133 | work under this License, and how to view a copy of this License. If 134 | the interface presents a list of user commands or options, such as a 135 | menu, a prominent item in the list meets this criterion. 136 | 137 | 1. Source Code. 138 | 139 | The "source code" for a work means the preferred form of the work 140 | for making modifications to it. "Object code" means any non-source 141 | form of a work. 142 | 143 | A "Standard Interface" means an interface that either is an official 144 | standard defined by a recognized standards body, or, in the case of 145 | interfaces specified for a particular programming language, one that 146 | is widely used among developers working in that language. 147 | 148 | The "System Libraries" of an executable work include anything, other 149 | than the work as a whole, that (a) is included in the normal form of 150 | packaging a Major Component, but which is not part of that Major 151 | Component, and (b) serves only to enable use of the work with that 152 | Major Component, or to implement a Standard Interface for which an 153 | implementation is available to the public in source code form. A 154 | "Major Component", in this context, means a major essential component 155 | (kernel, window system, and so on) of the specific operating system 156 | (if any) on which the executable work runs, or a compiler used to 157 | produce the work, or an object code interpreter used to run it. 158 | 159 | The "Corresponding Source" for a work in object code form means all 160 | the source code needed to generate, install, and (for an executable 161 | work) run the object code and to modify the work, including scripts to 162 | control those activities. However, it does not include the work's 163 | System Libraries, or general-purpose tools or generally available free 164 | programs which are used unmodified in performing those activities but 165 | which are not part of the work. For example, Corresponding Source 166 | includes interface definition files associated with source files for 167 | the work, and the source code for shared libraries and dynamically 168 | linked subprograms that the work is specifically designed to require, 169 | such as by intimate data communication or control flow between those 170 | subprograms and other parts of the work. 171 | 172 | The Corresponding Source need not include anything that users 173 | can regenerate automatically from other parts of the Corresponding 174 | Source. 175 | 176 | The Corresponding Source for a work in source code form is that 177 | same work. 178 | 179 | 2. Basic Permissions. 180 | 181 | All rights granted under this License are granted for the term of 182 | copyright on the Program, and are irrevocable provided the stated 183 | conditions are met. This License explicitly affirms your unlimited 184 | permission to run the unmodified Program. The output from running a 185 | covered work is covered by this License only if the output, given its 186 | content, constitutes a covered work. This License acknowledges your 187 | rights of fair use or other equivalent, as provided by copyright law. 188 | 189 | You may make, run and propagate covered works that you do not 190 | convey, without conditions so long as your license otherwise remains 191 | in force. You may convey covered works to others for the sole purpose 192 | of having them make modifications exclusively for you, or provide you 193 | with facilities for running those works, provided that you comply with 194 | the terms of this License in conveying all material for which you do 195 | not control copyright. Those thus making or running the covered works 196 | for you must do so exclusively on your behalf, under your direction 197 | and control, on terms that prohibit them from making any copies of 198 | your copyrighted material outside their relationship with you. 199 | 200 | Conveying under any other circumstances is permitted solely under 201 | the conditions stated below. Sublicensing is not allowed; section 10 202 | makes it unnecessary. 203 | 204 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 205 | 206 | No covered work shall be deemed part of an effective technological 207 | measure under any applicable law fulfilling obligations under article 208 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 209 | similar laws prohibiting or restricting circumvention of such 210 | measures. 211 | 212 | When you convey a covered work, you waive any legal power to forbid 213 | circumvention of technological measures to the extent such circumvention 214 | is effected by exercising rights under this License with respect to 215 | the covered work, and you disclaim any intention to limit operation or 216 | modification of the work as a means of enforcing, against the work's 217 | users, your or third parties' legal rights to forbid circumvention of 218 | technological measures. 219 | 220 | 4. Conveying Verbatim Copies. 221 | 222 | You may convey verbatim copies of the Program's source code as you 223 | receive it, in any medium, provided that you conspicuously and 224 | appropriately publish on each copy an appropriate copyright notice; 225 | keep intact all notices stating that this License and any 226 | non-permissive terms added in accord with section 7 apply to the code; 227 | keep intact all notices of the absence of any warranty; and give all 228 | recipients a copy of this License along with the Program. 229 | 230 | You may charge any price or no price for each copy that you convey, 231 | and you may offer support or warranty protection for a fee. 232 | 233 | 5. Conveying Modified Source Versions. 234 | 235 | You may convey a work based on the Program, or the modifications to 236 | produce it from the Program, in the form of source code under the 237 | terms of section 4, provided that you also meet all of these conditions: 238 | 239 | a) The work must carry prominent notices stating that you modified 240 | it, and giving a relevant date. 241 | 242 | b) The work must carry prominent notices stating that it is 243 | released under this License and any conditions added under section 244 | 7. This requirement modifies the requirement in section 4 to 245 | "keep intact all notices". 246 | 247 | c) You must license the entire work, as a whole, under this 248 | License to anyone who comes into possession of a copy. This 249 | License will therefore apply, along with any applicable section 7 250 | additional terms, to the whole of the work, and all its parts, 251 | regardless of how they are packaged. This License gives no 252 | permission to license the work in any other way, but it does not 253 | invalidate such permission if you have separately received it. 254 | 255 | d) If the work has interactive user interfaces, each must display 256 | Appropriate Legal Notices; however, if the Program has interactive 257 | interfaces that do not display Appropriate Legal Notices, your 258 | work need not make them do so. 259 | 260 | A compilation of a covered work with other separate and independent 261 | works, which are not by their nature extensions of the covered work, 262 | and which are not combined with it such as to form a larger program, 263 | in or on a volume of a storage or distribution medium, is called an 264 | "aggregate" if the compilation and its resulting copyright are not 265 | used to limit the access or legal rights of the compilation's users 266 | beyond what the individual works permit. Inclusion of a covered work 267 | in an aggregate does not cause this License to apply to the other 268 | parts of the aggregate. 269 | 270 | 6. Conveying Non-Source Forms. 271 | 272 | You may convey a covered work in object code form under the terms 273 | of sections 4 and 5, provided that you also convey the 274 | machine-readable Corresponding Source under the terms of this License, 275 | in one of these ways: 276 | 277 | a) Convey the object code in, or embodied in, a physical product 278 | (including a physical distribution medium), accompanied by the 279 | Corresponding Source fixed on a durable physical medium 280 | customarily used for software interchange. 281 | 282 | b) Convey the object code in, or embodied in, a physical product 283 | (including a physical distribution medium), accompanied by a 284 | written offer, valid for at least three years and valid for as 285 | long as you offer spare parts or customer support for that product 286 | model, to give anyone who possesses the object code either (1) a 287 | copy of the Corresponding Source for all the software in the 288 | product that is covered by this License, on a durable physical 289 | medium customarily used for software interchange, for a price no 290 | more than your reasonable cost of physically performing this 291 | conveying of source, or (2) access to copy the 292 | Corresponding Source from a network server at no charge. 293 | 294 | c) Convey individual copies of the object code with a copy of the 295 | written offer to provide the Corresponding Source. This 296 | alternative is allowed only occasionally and noncommercially, and 297 | only if you received the object code with such an offer, in accord 298 | with subsection 6b. 299 | 300 | d) Convey the object code by offering access from a designated 301 | place (gratis or for a charge), and offer equivalent access to the 302 | Corresponding Source in the same way through the same place at no 303 | further charge. You need not require recipients to copy the 304 | Corresponding Source along with the object code. If the place to 305 | copy the object code is a network server, the Corresponding Source 306 | may be on a different server (operated by you or a third party) 307 | that supports equivalent copying facilities, provided you maintain 308 | clear directions next to the object code saying where to find the 309 | Corresponding Source. Regardless of what server hosts the 310 | Corresponding Source, you remain obligated to ensure that it is 311 | available for as long as needed to satisfy these requirements. 312 | 313 | e) Convey the object code using peer-to-peer transmission, provided 314 | you inform other peers where the object code and Corresponding 315 | Source of the work are being offered to the general public at no 316 | charge under subsection 6d. 317 | 318 | A separable portion of the object code, whose source code is excluded 319 | from the Corresponding Source as a System Library, need not be 320 | included in conveying the object code work. 321 | 322 | A "User Product" is either (1) a "consumer product", which means any 323 | tangible personal property which is normally used for personal, family, 324 | or household purposes, or (2) anything designed or sold for incorporation 325 | into a dwelling. In determining whether a product is a consumer product, 326 | doubtful cases shall be resolved in favor of coverage. For a particular 327 | product received by a particular user, "normally used" refers to a 328 | typical or common use of that class of product, regardless of the status 329 | of the particular user or of the way in which the particular user 330 | actually uses, or expects or is expected to use, the product. A product 331 | is a consumer product regardless of whether the product has substantial 332 | commercial, industrial or non-consumer uses, unless such uses represent 333 | the only significant mode of use of the product. 334 | 335 | "Installation Information" for a User Product means any methods, 336 | procedures, authorization keys, or other information required to install 337 | and execute modified versions of a covered work in that User Product from 338 | a modified version of its Corresponding Source. The information must 339 | suffice to ensure that the continued functioning of the modified object 340 | code is in no case prevented or interfered with solely because 341 | modification has been made. 342 | 343 | If you convey an object code work under this section in, or with, or 344 | specifically for use in, a User Product, and the conveying occurs as 345 | part of a transaction in which the right of possession and use of the 346 | User Product is transferred to the recipient in perpetuity or for a 347 | fixed term (regardless of how the transaction is characterized), the 348 | Corresponding Source conveyed under this section must be accompanied 349 | by the Installation Information. But this requirement does not apply 350 | if neither you nor any third party retains the ability to install 351 | modified object code on the User Product (for example, the work has 352 | been installed in ROM). 353 | 354 | The requirement to provide Installation Information does not include a 355 | requirement to continue to provide support service, warranty, or updates 356 | for a work that has been modified or installed by the recipient, or for 357 | the User Product in which it has been modified or installed. Access to a 358 | network may be denied when the modification itself materially and 359 | adversely affects the operation of the network or violates the rules and 360 | protocols for communication across the network. 361 | 362 | Corresponding Source conveyed, and Installation Information provided, 363 | in accord with this section must be in a format that is publicly 364 | documented (and with an implementation available to the public in 365 | source code form), and must require no special password or key for 366 | unpacking, reading or copying. 367 | 368 | 7. Additional Terms. 369 | 370 | "Additional permissions" are terms that supplement the terms of this 371 | License by making exceptions from one or more of its conditions. 372 | Additional permissions that are applicable to the entire Program shall 373 | be treated as though they were included in this License, to the extent 374 | that they are valid under applicable law. If additional permissions 375 | apply only to part of the Program, that part may be used separately 376 | under those permissions, but the entire Program remains governed by 377 | this License without regard to the additional permissions. 378 | 379 | When you convey a copy of a covered work, you may at your option 380 | remove any additional permissions from that copy, or from any part of 381 | it. (Additional permissions may be written to require their own 382 | removal in certain cases when you modify the work.) You may place 383 | additional permissions on material, added by you to a covered work, 384 | for which you have or can give appropriate copyright permission. 385 | 386 | Notwithstanding any other provision of this License, for material you 387 | add to a covered work, you may (if authorized by the copyright holders of 388 | that material) supplement the terms of this License with terms: 389 | 390 | a) Disclaiming warranty or limiting liability differently from the 391 | terms of sections 15 and 16 of this License; or 392 | 393 | b) Requiring preservation of specified reasonable legal notices or 394 | author attributions in that material or in the Appropriate Legal 395 | Notices displayed by works containing it; or 396 | 397 | c) Prohibiting misrepresentation of the origin of that material, or 398 | requiring that modified versions of such material be marked in 399 | reasonable ways as different from the original version; or 400 | 401 | d) Limiting the use for publicity purposes of names of licensors or 402 | authors of the material; or 403 | 404 | e) Declining to grant rights under trademark law for use of some 405 | trade names, trademarks, or service marks; or 406 | 407 | f) Requiring indemnification of licensors and authors of that 408 | material by anyone who conveys the material (or modified versions of 409 | it) with contractual assumptions of liability to the recipient, for 410 | any liability that these contractual assumptions directly impose on 411 | those licensors and authors. 412 | 413 | All other non-permissive additional terms are considered "further 414 | restrictions" within the meaning of section 10. If the Program as you 415 | received it, or any part of it, contains a notice stating that it is 416 | governed by this License along with a term that is a further 417 | restriction, you may remove that term. If a license document contains 418 | a further restriction but permits relicensing or conveying under this 419 | License, you may add to a covered work material governed by the terms 420 | of that license document, provided that the further restriction does 421 | not survive such relicensing or conveying. 422 | 423 | If you add terms to a covered work in accord with this section, you 424 | must place, in the relevant source files, a statement of the 425 | additional terms that apply to those files, or a notice indicating 426 | where to find the applicable terms. 427 | 428 | Additional terms, permissive or non-permissive, may be stated in the 429 | form of a separately written license, or stated as exceptions; 430 | the above requirements apply either way. 431 | 432 | 8. Termination. 433 | 434 | You may not propagate or modify a covered work except as expressly 435 | provided under this License. Any attempt otherwise to propagate or 436 | modify it is void, and will automatically terminate your rights under 437 | this License (including any patent licenses granted under the third 438 | paragraph of section 11). 439 | 440 | However, if you cease all violation of this License, then your 441 | license from a particular copyright holder is reinstated (a) 442 | provisionally, unless and until the copyright holder explicitly and 443 | finally terminates your license, and (b) permanently, if the copyright 444 | holder fails to notify you of the violation by some reasonable means 445 | prior to 60 days after the cessation. 446 | 447 | Moreover, your license from a particular copyright holder is 448 | reinstated permanently if the copyright holder notifies you of the 449 | violation by some reasonable means, this is the first time you have 450 | received notice of violation of this License (for any work) from that 451 | copyright holder, and you cure the violation prior to 30 days after 452 | your receipt of the notice. 453 | 454 | Termination of your rights under this section does not terminate the 455 | licenses of parties who have received copies or rights from you under 456 | this License. If your rights have been terminated and not permanently 457 | reinstated, you do not qualify to receive new licenses for the same 458 | material under section 10. 459 | 460 | 9. Acceptance Not Required for Having Copies. 461 | 462 | You are not required to accept this License in order to receive or 463 | run a copy of the Program. Ancillary propagation of a covered work 464 | occurring solely as a consequence of using peer-to-peer transmission 465 | to receive a copy likewise does not require acceptance. However, 466 | nothing other than this License grants you permission to propagate or 467 | modify any covered work. These actions infringe copyright if you do 468 | not accept this License. Therefore, by modifying or propagating a 469 | covered work, you indicate your acceptance of this License to do so. 470 | 471 | 10. Automatic Licensing of Downstream Recipients. 472 | 473 | Each time you convey a covered work, the recipient automatically 474 | receives a license from the original licensors, to run, modify and 475 | propagate that work, subject to this License. You are not responsible 476 | for enforcing compliance by third parties with this License. 477 | 478 | An "entity transaction" is a transaction transferring control of an 479 | organization, or substantially all assets of one, or subdividing an 480 | organization, or merging organizations. If propagation of a covered 481 | work results from an entity transaction, each party to that 482 | transaction who receives a copy of the work also receives whatever 483 | licenses to the work the party's predecessor in interest had or could 484 | give under the previous paragraph, plus a right to possession of the 485 | Corresponding Source of the work from the predecessor in interest, if 486 | the predecessor has it or can get it with reasonable efforts. 487 | 488 | You may not impose any further restrictions on the exercise of the 489 | rights granted or affirmed under this License. For example, you may 490 | not impose a license fee, royalty, or other charge for exercise of 491 | rights granted under this License, and you may not initiate litigation 492 | (including a cross-claim or counterclaim in a lawsuit) alleging that 493 | any patent claim is infringed by making, using, selling, offering for 494 | sale, or importing the Program or any portion of it. 495 | 496 | 11. Patents. 497 | 498 | A "contributor" is a copyright holder who authorizes use under this 499 | License of the Program or a work on which the Program is based. The 500 | work thus licensed is called the contributor's "contributor version". 501 | 502 | A contributor's "essential patent claims" are all patent claims 503 | owned or controlled by the contributor, whether already acquired or 504 | hereafter acquired, that would be infringed by some manner, permitted 505 | by this License, of making, using, or selling its contributor version, 506 | but do not include claims that would be infringed only as a 507 | consequence of further modification of the contributor version. For 508 | purposes of this definition, "control" includes the right to grant 509 | patent sublicenses in a manner consistent with the requirements of 510 | this License. 511 | 512 | Each contributor grants you a non-exclusive, worldwide, royalty-free 513 | patent license under the contributor's essential patent claims, to 514 | make, use, sell, offer for sale, import and otherwise run, modify and 515 | propagate the contents of its contributor version. 516 | 517 | In the following three paragraphs, a "patent license" is any express 518 | agreement or commitment, however denominated, not to enforce a patent 519 | (such as an express permission to practice a patent or covenant not to 520 | sue for patent infringement). To "grant" such a patent license to a 521 | party means to make such an agreement or commitment not to enforce a 522 | patent against the party. 523 | 524 | If you convey a covered work, knowingly relying on a patent license, 525 | and the Corresponding Source of the work is not available for anyone 526 | to copy, free of charge and under the terms of this License, through a 527 | publicly available network server or other readily accessible means, 528 | then you must either (1) cause the Corresponding Source to be so 529 | available, or (2) arrange to deprive yourself of the benefit of the 530 | patent license for this particular work, or (3) arrange, in a manner 531 | consistent with the requirements of this License, to extend the patent 532 | license to downstream recipients. "Knowingly relying" means you have 533 | actual knowledge that, but for the patent license, your conveying the 534 | covered work in a country, or your recipient's use of the covered work 535 | in a country, would infringe one or more identifiable patents in that 536 | country that you have reason to believe are valid. 537 | 538 | If, pursuant to or in connection with a single transaction or 539 | arrangement, you convey, or propagate by procuring conveyance of, a 540 | covered work, and grant a patent license to some of the parties 541 | receiving the covered work authorizing them to use, propagate, modify 542 | or convey a specific copy of the covered work, then the patent license 543 | you grant is automatically extended to all recipients of the covered 544 | work and works based on it. 545 | 546 | A patent license is "discriminatory" if it does not include within 547 | the scope of its coverage, prohibits the exercise of, or is 548 | conditioned on the non-exercise of one or more of the rights that are 549 | specifically granted under this License. You may not convey a covered 550 | work if you are a party to an arrangement with a third party that is 551 | in the business of distributing software, under which you make payment 552 | to the third party based on the extent of your activity of conveying 553 | the work, and under which the third party grants, to any of the 554 | parties who would receive the covered work from you, a discriminatory 555 | patent license (a) in connection with copies of the covered work 556 | conveyed by you (or copies made from those copies), or (b) primarily 557 | for and in connection with specific products or compilations that 558 | contain the covered work, unless you entered into that arrangement, 559 | or that patent license was granted, prior to 28 March 2007. 560 | 561 | Nothing in this License shall be construed as excluding or limiting 562 | any implied license or other defenses to infringement that may 563 | otherwise be available to you under applicable patent law. 564 | 565 | 12. No Surrender of Others' Freedom. 566 | 567 | If conditions are imposed on you (whether by court order, agreement or 568 | otherwise) that contradict the conditions of this License, they do not 569 | excuse you from the conditions of this License. If you cannot convey a 570 | covered work so as to satisfy simultaneously your obligations under this 571 | License and any other pertinent obligations, then as a consequence you may 572 | not convey it at all. For example, if you agree to terms that obligate you 573 | to collect a royalty for further conveying from those to whom you convey 574 | the Program, the only way you could satisfy both those terms and this 575 | License would be to refrain entirely from conveying the Program. 576 | 577 | 13. Use with the GNU Affero General Public License. 578 | 579 | Notwithstanding any other provision of this License, you have 580 | permission to link or combine any covered work with a work licensed 581 | under version 3 of the GNU Affero General Public License into a single 582 | combined work, and to convey the resulting work. The terms of this 583 | License will continue to apply to the part which is the covered work, 584 | but the special requirements of the GNU Affero General Public License, 585 | section 13, concerning interaction through a network will apply to the 586 | combination as such. 587 | 588 | 14. Revised Versions of this License. 589 | 590 | The Free Software Foundation may publish revised and/or new versions of 591 | the GNU General Public License from time to time. Such new versions will 592 | be similar in spirit to the present version, but may differ in detail to 593 | address new problems or concerns. 594 | 595 | Each version is given a distinguishing version number. If the 596 | Program specifies that a certain numbered version of the GNU General 597 | Public License "or any later version" applies to it, you have the 598 | option of following the terms and conditions either of that numbered 599 | version or of any later version published by the Free Software 600 | Foundation. If the Program does not specify a version number of the 601 | GNU General Public License, you may choose any version ever published 602 | by the Free Software Foundation. 603 | 604 | If the Program specifies that a proxy can decide which future 605 | versions of the GNU General Public License can be used, that proxy's 606 | public statement of acceptance of a version permanently authorizes you 607 | to choose that version for the Program. 608 | 609 | Later license versions may give you additional or different 610 | permissions. However, no additional obligations are imposed on any 611 | author or copyright holder as a result of your choosing to follow a 612 | later version. 613 | 614 | 15. Disclaimer of Warranty. 615 | 616 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 617 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 618 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 619 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 620 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 621 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 622 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 623 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 624 | 625 | 16. Limitation of Liability. 626 | 627 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 628 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 629 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 630 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 631 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 632 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 633 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 634 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 635 | SUCH DAMAGES. 636 | 637 | 17. Interpretation of Sections 15 and 16. 638 | 639 | If the disclaimer of warranty and limitation of liability provided 640 | above cannot be given local legal effect according to their terms, 641 | reviewing courts shall apply local law that most closely approximates 642 | an absolute waiver of all civil liability in connection with the 643 | Program, unless a warranty or assumption of liability accompanies a 644 | copy of the Program in return for a fee. 645 | 646 | END OF TERMS AND CONDITIONS 647 | 648 | How to Apply These Terms to Your New Programs 649 | 650 | If you develop a new program, and you want it to be of the greatest 651 | possible use to the public, the best way to achieve this is to make it 652 | free software which everyone can redistribute and change under these terms. 653 | 654 | To do so, attach the following notices to the program. It is safest 655 | to attach them to the start of each source file to most effectively 656 | state the exclusion of warranty; and each file should have at least 657 | the "copyright" line and a pointer to where the full notice is found. 658 | 659 | 660 | Copyright (C) 661 | 662 | This program is free software: you can redistribute it and/or modify 663 | it under the terms of the GNU General Public License as published by 664 | the Free Software Foundation, either version 3 of the License, or 665 | (at your option) any later version. 666 | 667 | This program is distributed in the hope that it will be useful, 668 | but WITHOUT ANY WARRANTY; without even the implied warranty of 669 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 670 | GNU General Public License for more details. 671 | 672 | You should have received a copy of the GNU General Public License 673 | along with this program. If not, see . 674 | 675 | Also add information on how to contact you by electronic and paper mail. 676 | 677 | If the program does terminal interaction, make it output a short 678 | notice like this when it starts in an interactive mode: 679 | 680 | Copyright (C) 681 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 682 | This is free software, and you are welcome to redistribute it 683 | under certain conditions; type `show c' for details. 684 | 685 | The hypothetical commands `show w' and `show c' should show the appropriate 686 | parts of the General Public License. Of course, your program's commands 687 | might be different; for a GUI interface, you would use an "about box". 688 | 689 | You should also get your employer (if you work as a programmer) or school, 690 | if any, to sign a "copyright disclaimer" for the program, if necessary. 691 | For more information on this, and how to apply and follow the GNU GPL, see 692 | . 693 | 694 | The GNU General Public License does not permit incorporating your program 695 | into proprietary programs. If your program is a subroutine library, you 696 | may consider it more useful to permit linking proprietary applications with 697 | the library. If this is what you want to do, use the GNU Lesser General 698 | Public License instead of this License. But first, please read 699 | . 700 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | 豆瓣FM命令行播放器 2 | ================== 3 | 4 | **2015-11-16 更新:豆瓣客户端接口被封锁,本项目处于不可用状态。** 5 | 6 | **可用的类似项目(目前使用网易云音乐): https://github.com/taizilongxu/douban.fm** 7 | 8 | .. image:: https://badge.fury.io/py/pyfm.png 9 | :target: http://badge.fury.io/py/pyfm 10 | 11 | 使用Python编写的豆瓣FM命令行播放器 12 | 13 | |Screenshot| 14 | 15 | 16 | 特性 17 | ---- 18 | 19 | - 依赖较少,易于安装和运行 20 | - 支持私人兆赫,红心兆赫 21 | - 支持豆瓣歌曲加心 22 | - 支持Last.fm Scrobble 23 | 24 | 运行环境 25 | -------- 26 | 27 | - Linux/Mac OS X 28 | - Python 2.7+ , 3.3+ 29 | 30 | 依赖 31 | ---- 32 | 33 | - `mpg123 `__ (如果安装了 `mpv `__ 或 `mplayer `__ 亦会自动使用) 34 | - `requests `__ 35 | - `urwid `__ 36 | 37 | 安装 38 | ---- 39 | 40 | 请首先安装支持的后端播放器中的某一个,然后使用pip安装本软件: 41 | 42 | :: 43 | 44 | (sudo)pip install pyfm 45 | 46 | 47 | 如果选择直接git clone整个仓库的方法安装,请先安装相关依赖,然后把pyfm目录下的fm.py移动到上层目录,最后执行 `python fm.py` 48 | 49 | 50 | 使用 51 | ---- 52 | 53 | 在终端中输入 54 | 55 | :: 56 | 57 | $ pyfm 58 | 59 | 配置 60 | ---- 61 | 62 | :: 63 | 64 | $ pyfm config 65 | 66 | 根据提示输入账户,密码等,豆瓣账户密码不会保存在本地,豆瓣Token,Cookie,Last.fm账户名,Last.fm密码的md5值等保存在$HOME/.pyfm/中。 67 | 68 | 快捷键 69 | ------ 70 | 71 | :: 72 | 73 | [n] -> 跳过当前歌曲 74 | [l] -> 给当前歌曲添加红心或删除红心 75 | [t] -> 不再播放当前歌曲 76 | [q] -> 退出播放器 77 | 78 | 79 | 出现问题? 80 | ----------- 81 | 82 | 请尝试清空$HOME/.pyfm/目录下的所有内容,重新安装等,如还不能解决,欢迎向我提issue。 83 | 84 | 致谢 85 | ---- 86 | 87 | 本项目主要参考了以下几个项目 88 | 89 | - https://github.com/josephok/doubanfm 90 | - https://github.com/zonyitoo/doubanfm-qt 91 | - https://github.com/turingou/douban.fm 92 | - http://hg.user1.be/ScrobblerPlugin/ 93 | 94 | 感谢以上项目的作者,开源万岁! 95 | 96 | Changelog 97 | --------- 98 | 99 | - 0.2.4 修复若干问题,支持关闭通知 100 | - 0.2.3 修复若干Bug,加入红心兆赫,支持使用mpv和mplayer作为播放后端(`felixonmars `__) 101 | - 0.2.2 修复登陆失败时登陆状态不能正确显示的Bug 102 | - 0.2.1 修复Last.fm密码为空时报错的Bug 103 | - 0.2 代码大规模重构 104 | - 0.1 第一个正式版本 105 | 106 | 协议 107 | ---- 108 | 109 | The MIT License 110 | 111 | 其中\ `scrobbler.py `__\ 遵循GPLv3协议 112 | 113 | .. |Screenshot| image:: https://skyline75489.github.io/img/pyfm/screenshot.png 114 | -------------------------------------------------------------------------------- /pyfm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skyline75489/pyfm/bbd5a18ba9c7948af4fd23b6abf5afc58ac52de4/pyfm/__init__.py -------------------------------------------------------------------------------- /pyfm/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | import json 4 | import logging 5 | 6 | from hashlib import md5 7 | from getpass import getpass 8 | from collections import deque 9 | 10 | try: 11 | input = raw_input 12 | except NameError: 13 | pass 14 | 15 | HOME_PATH = os.getenv('HOME') 16 | BASIC_PATH = os.path.join(HOME_PATH, '.pyfm') 17 | ACCOUNT_CACHE_PATH = os.path.join(BASIC_PATH, 'account_cache.json') 18 | CHANNELS_CACHE_PATH = os.path.join(BASIC_PATH, 'channels_cache.json') 19 | 20 | if not os.path.isdir(BASIC_PATH): 21 | os.mkdir(BASIC_PATH) 22 | 23 | logging.basicConfig(format='[%(asctime)s] %(filename)s:%(lineno)d %(levelname)s %(message)s', 24 | filename=os.path.join(BASIC_PATH, 'fm.log'), 25 | level=logging.DEBUG) 26 | 27 | logger = logging.getLogger() 28 | 29 | 30 | class Config(object): 31 | 32 | def __init__(self): 33 | self.email = None 34 | self.password = None 35 | self.user_name = None 36 | self.user_id = None 37 | self.expire = None 38 | self.token = None 39 | self.cookies = None 40 | self.enable_notify = True 41 | 42 | self.last_fm_username = None 43 | self.last_fm_password = None 44 | self.scrobbling = True 45 | self.douban_account = True 46 | 47 | self.account_cache_path = ACCOUNT_CACHE_PATH 48 | self.channels_cache_path = CHANNELS_CACHE_PATH 49 | 50 | def do_config(self): 51 | self.email = input('豆瓣账户 (Email地址): ') or None 52 | self.password = getpass('豆瓣密码: ') or None 53 | self.last_fm_username = input('Last.fm 用户名: ') or None 54 | password = getpass('Last.fm 密码: ') or None 55 | if password is None: 56 | self.last_fm_password = None 57 | else: 58 | self.last_fm_password = md5(password.encode('utf-8')).hexdigest() 59 | self.enable_notify = input('是否允许系统通知? (Y/n)').lower() != "n" 60 | 61 | def load_config(self): 62 | try: 63 | with open(self.channels_cache_path, 'r') as f: 64 | self.cached_channels = deque(json.load(f)) 65 | logger.debug("Load channel file.") 66 | except: 67 | logger.debug("Channels file not found.") 68 | 69 | try: 70 | with open(self.account_cache_path, 'r') as f: 71 | cache = json.load(f) 72 | try: 73 | self.user_name = cache['user_name'] 74 | self.user_id = cache['user_id'] 75 | self.expire = cache['expire'] 76 | self.token = cache['token'] 77 | self.cookies = cache['cookies'] 78 | except (KeyError, ValueError): 79 | self.douban_account = False 80 | try: 81 | self.last_fm_username = cache['last_fm_username'] 82 | self.last_fm_password = cache['last_fm_password'] 83 | except (KeyError, ValueError): 84 | self.scrobbling = False 85 | except: 86 | logger.debug("Cache file not found.") 87 | 88 | def save_channel_cache(self, channels): 89 | try: 90 | with open(self.channels_cache_path, 'w') as f: 91 | json.dump(list(channels), f) 92 | except IOError: 93 | raise Exception("Unable to write cache file") 94 | 95 | def save_account_cache(self, user_name=None, user_id=None, expire=None, token=None, cookies=None, last_fm_username=None, last_fm_password=None, enable_notify=None): 96 | if not (user_name or last_fm_username): 97 | return 98 | try: 99 | with open(self.account_cache_path, 'w') as f: 100 | json.dump({ 101 | 'user_name': user_name, 102 | 'user_id': user_id, 103 | 'expire': expire, 104 | 'token': token, 105 | 'cookies': cookies, 106 | 'last_fm_username': last_fm_username, 107 | 'last_fm_password': last_fm_password, 108 | 'enable_notify': enable_notify, 109 | }, f) 110 | except IOError: 111 | raise Exception("Unable to write cache file") 112 | -------------------------------------------------------------------------------- /pyfm/douban.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import requests 3 | import json 4 | 5 | 6 | class Douban: 7 | 8 | """ Douban class, provides some APIs. 9 | """ 10 | 11 | def __init__(self, email, password, user_id=None, expire=None, token=None, user_name=None, cookies=None): 12 | self.login_url = 'https://www.douban.com/j/app/login' 13 | self.channel_url = 'https://www.douban.com/j/app/radio/channels' 14 | self.api_url = 'https://www.douban.com/j/app/radio/people' 15 | self.app_name = 'radio_desktop_win' 16 | self.version = '100' 17 | self.type_map = { 18 | 'new': 'n', 19 | 'playing': 'p', 20 | 'rate': 'r', 21 | 'unrate': 'u', 22 | 'end': 'e', 23 | 'bye': 'b', 24 | 'skip': 's', 25 | } 26 | 27 | self.email = email 28 | self.password = password 29 | 30 | self.user_id = user_id 31 | self.expire = expire 32 | self.token = token 33 | self.user_name = user_name 34 | self.cookies = cookies 35 | 36 | self.logged_in = False 37 | self.channels = None 38 | 39 | def _do_api_request(self, _type, sid=None, channel=None, kbps=64): 40 | payload = {'app_name': self.app_name, 'version': self.version, 'user_id': self.user_id, 41 | 'expire': self.expire, 'token': self.token, 'sid': sid, 'h': '', 'channel': channel, 'type': _type} 42 | 43 | r = requests.get(self.api_url, params=payload, cookies=self.cookies) 44 | return r 45 | 46 | def do_login(self): 47 | # Has cookies already. No need to login again. 48 | if self.cookies: 49 | self.logged_in = True 50 | return True, None 51 | payload = {'email': self.email, 'password': self.password, 52 | 'app_name': self.app_name, 'version': self.version} 53 | r = requests.post(self.login_url, params=payload, headers={ 54 | 'Content-Type': 'application/x-www-form-urlencoded'}) 55 | if r.json()['r'] == 0: 56 | self.user_name = r.json()['user_name'] 57 | self.user_id = r.json()['user_id'] 58 | self.expire = r.json()['expire'] 59 | self.token = r.json()['token'] 60 | self.cookies = r.cookies.get_dict() 61 | self.logged_in = True 62 | return True, None 63 | else: 64 | return False, r.json()['err'] 65 | 66 | def _get_type(self, option): 67 | return self.type_map[option] 68 | 69 | def get_channels(self): 70 | """ Return a list of channels 71 | """ 72 | if self.channels is None: 73 | r = requests.get(self.channel_url) 74 | # Cache channels 75 | channels = r.json()['channels'] 76 | if self.logged_in: 77 | # No api for this. 78 | # We have to manually add this. 79 | heart = {u'seq_id': -3, 80 | u'name_en': u'Heart', 81 | u'abbr_en': u'Heart', 82 | u'name': u'红心兆赫', 83 | u'channel_id': -3} 84 | channels.insert(0, heart) 85 | self.channels = channels 86 | return self.channels 87 | else: 88 | return self.channels 89 | 90 | def get_new_play_list(self, channel, kbps=64): 91 | _type = self._get_type('new') 92 | payload = {'app_name': self.app_name, 'version': self.version, 'user_id': self.user_id, 93 | 'expire': self.expire, 'token': self.token, 'sid': '', 'h': '', 'channel': channel, 'kbps': kbps, 'type': _type} 94 | 95 | r = requests.get(self.api_url, params=payload) 96 | if r.json()['r'] == 0: 97 | songs = r.json()['song'] 98 | return songs 99 | 100 | def get_playing_list(self, sid, channel, kbps=64): 101 | _type = self._get_type('playing') 102 | payload = {'app_name': self.app_name, 'version': self.version, 'user_id': self.user_id, 103 | 'expire': self.expire, 'token': self.token, 'sid': sid, 'h': '', 'channel': channel, 'kbps': kbps, 'type': _type} 104 | 105 | r = requests.get(self.api_url, params=payload) 106 | if r.json()['r'] == 0: 107 | songs = r.json()['song'] 108 | return songs 109 | 110 | def rate_song(self, sid, channel): 111 | _type = self._get_type('rate') 112 | r = self._do_api_request(sid=sid, channel=channel, _type=_type) 113 | if r.json()['r'] == 0: 114 | return True, None 115 | else: 116 | return False, r.json()['err'] 117 | 118 | def unrate_song(self, sid, channel): 119 | _type = self._get_type('unrate') 120 | r = self._do_api_request(sid=sid, channel=channel, _type=_type) 121 | if r.json()['r'] == 0: 122 | return True, None 123 | else: 124 | return False, r.json()['err'] 125 | 126 | def skip_song(self, sid, channel): 127 | _type = self._get_type('skip') 128 | r = self._do_api_request(sid=sid, channel=channel, _type=_type) 129 | if r.json()['r'] == 0: 130 | return True, None 131 | else: 132 | return False, r.json()['err'] 133 | 134 | def end_song(self, sid, channel): 135 | _type = self._get_type('end') 136 | r = self._do_api_request(sid=sid, channel=channel, _type=_type) 137 | if r.json()['r'] == 0: 138 | return True, None 139 | else: 140 | return False, r.json()['err'] 141 | 142 | def bye_song(self, sid, channel): 143 | """No longer play this song 144 | """ 145 | _type = self._get_type('bye') 146 | r = self._do_api_request(sid=sid, channel=channel, _type=_type) 147 | if r.json()['r'] == 0: 148 | return True, None 149 | else: 150 | return False, r.json()['err'] 151 | -------------------------------------------------------------------------------- /pyfm/fm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from __future__ import print_function 4 | 5 | import sys 6 | import subprocess 7 | import time 8 | import json 9 | import logging 10 | 11 | from hashlib import md5 12 | from collections import deque 13 | from functools import wraps 14 | 15 | import urwid 16 | 17 | from .douban import Douban 18 | from .song import Song 19 | from .player import Player 20 | from .scrobbler import Scrobbler 21 | from .notifier import Notifier 22 | from .config import Config 23 | from .ui import ChannelButton, ChannelListBox 24 | 25 | logger = logging.getLogger() 26 | 27 | 28 | __version__ = '0.2.4' 29 | 30 | WHITE_HEART = u'\N{WHITE HEART SUIT}' 31 | BLACK_HEART = u'\N{BLACK HEART SUIT}' 32 | 33 | HELP = """ 34 | pyfm 0.2.4 使用Python编写的豆瓣FM命令行播放器 35 | 36 | 更新或安装: 37 | $ [sudo] pip install pyfm --upgrade 38 | 39 | 配置: 40 | $ pyfm config 41 | 42 | 操作快捷键: 43 | [n] -> 跳过当前歌曲 44 | [l] -> 给当前歌曲添加红心或删除红心 45 | [t] -> 不再播放当前歌曲 46 | [q] -> 退出播放器 47 | """ 48 | 49 | 50 | class Doubanfm(object): 51 | 52 | def __init__(self): 53 | self.douban = None 54 | self.player = None 55 | self.config = None 56 | self.scrobbler = None 57 | 58 | self.channels = None 59 | self.current_channel = 0 60 | self.current_song = None 61 | self.current_play_list = None 62 | 63 | self._setup_config() 64 | self._setup_api_tools() 65 | self._setup_ui() 66 | self._setup_signals() 67 | 68 | def _setup_config(self): 69 | self.config = Config() 70 | # Set up config 71 | try: 72 | arg = sys.argv[1] 73 | if arg == 'config': 74 | self.config.do_config() 75 | elif arg in ['help', '-h', '--help']: 76 | print(HELP) 77 | raise SystemExit() 78 | else: 79 | raise SystemExit('Bad arguments. Try "help" for more info.') 80 | except IndexError: 81 | self.config.load_config() 82 | 83 | def _setup_api_tools(self): 84 | # Init API tools 85 | self.player = Player() 86 | self.douban = Douban( 87 | self.email, self.password, self.user_id, self.expire, self.token, self.user_name, self.cookies) 88 | 89 | if self.last_fm_username is None or self.last_fm_username == "": 90 | self.scrobbling = False 91 | if (self.email is None or self.email == "") and self.cookies == None: 92 | self.douban_account = False 93 | 94 | # Try to login 95 | if self.scrobbling: 96 | self.scrobbler = Scrobbler( 97 | self.last_fm_username, self.last_fm_password) 98 | r, err = self.scrobbler.handshake() 99 | if r: 100 | logger.debug("Last.fm logged in.") 101 | else: 102 | print("Last.FM 登录失败: " + err) 103 | self.scrobbling = False 104 | 105 | if self.douban_account: 106 | r, err = self.douban.do_login() 107 | if r: 108 | logger.debug("Douban logged in") 109 | else: 110 | print("Douban 登录失败: " + err) 111 | self.douban_account = False 112 | 113 | # Refresh account cache 114 | self.config.save_account_cache(self.douban.user_name, self.douban.user_id, self.douban.expire, self.douban.token, self.douban.cookies, 115 | self.last_fm_username, self.last_fm_password, self.enable_notify) 116 | 117 | def _setup_ui(self): 118 | # Init terminal UI 119 | self.palette = [('selected', 'bold', 'default'), 120 | ('title', 'yellow', 'default')] 121 | self.selected_button = None 122 | self.main_loop = None 123 | self.song_change_alarm = None 124 | 125 | self.get_channels() 126 | 127 | title = '豆瓣FM' + ' ' * 32 128 | if self.douban_account: 129 | title += '豆瓣已登录' 130 | else: 131 | title += '豆瓣未登陆' 132 | title += ' ' * 3 133 | if self.scrobbling: 134 | title += 'Last.fm 已登录' 135 | else: 136 | title += 'Last.fm 未登录' 137 | 138 | self.title = urwid.AttrMap(urwid.Text(title), 'title') 139 | self.divider = urwid.Divider() 140 | self.pile = urwid.Padding( 141 | urwid.Pile([self.divider, self.title, self.divider]), left=4, right=4) 142 | self.channel_list_box = self.getChannelListBox() 143 | self.box = urwid.Padding(self.channel_list_box, left=2, right=4) 144 | 145 | self.frame = urwid.Frame( 146 | self.box, header=self.pile, footer=self.divider) 147 | 148 | self.main_loop = urwid.MainLoop( 149 | self.frame, self.palette, handle_mouse=False) 150 | 151 | # Cache the channel list 152 | self.config.save_channel_cache(self.channels) 153 | 154 | def _setup_signals(self): 155 | urwid.register_signal( 156 | ChannelListBox, ['exit', 'skip', 'rate', 'trash']) 157 | 158 | urwid.connect_signal(self.channel_list_box, 'exit', self.on_exit) 159 | urwid.connect_signal(self.channel_list_box, 'skip', self.on_skip) 160 | urwid.connect_signal( 161 | self.channel_list_box, 'rate', self.on_rate_and_unrate) 162 | urwid.connect_signal(self.channel_list_box, 'trash', self.on_trash) 163 | 164 | def __getattr__(self, name): 165 | try: 166 | return self.__dict__[name] 167 | except KeyError: 168 | # Combine self.config.__dict__ and self.config.__dict__ for convenience 169 | return self.config.__dict__[name] 170 | 171 | # Some useful decorators 172 | def current_song_required(f): 173 | @wraps(f) 174 | def wrapper(self, *args, **kwds): 175 | if self.current_song is None: 176 | return 177 | return f(self, *args, **kwds) 178 | return wrapper 179 | 180 | def last_fm_account_required(f): 181 | @wraps(f) 182 | def wrapper(self, *args, **kwds): 183 | if not self.scrobbling: 184 | return 185 | return f(self, *args, **kwds) 186 | return wrapper 187 | 188 | def douban_account_required(f): 189 | @wraps(f) 190 | def wrapper(self, *args, **kwds): 191 | if not self.douban_account: 192 | return 193 | return f(self, *args, **kwds) 194 | return wrapper 195 | 196 | def get_channels(self): 197 | if self.channels is None: 198 | try: 199 | self.channels = self.cached_channels 200 | except KeyError: 201 | self.channels = deque(self.douban.get_channels()) 202 | 203 | def _choose_channel(self, channel): 204 | self.current_channel = channel 205 | self.current_play_list = deque( 206 | self.douban.get_new_play_list(self.current_channel)) 207 | 208 | def extend_playlist_if_needed(self): 209 | count_of_remaining_songs = len(self.current_play_list) 210 | logger.debug( 211 | '{0} tracks remaining in the playlist'.format(count_of_remaining_songs)) 212 | if count_of_remaining_songs == 1: 213 | # There is only one track remaining in queue, extend the playing list 214 | playing_list = self.douban.get_playing_list( 215 | self.current_song.sid, self.current_channel) 216 | logger.debug('Got {0} more tracks'.format(len(playing_list))) 217 | self.current_play_list.extend(deque(playing_list)) 218 | 219 | def _play_track(self): 220 | _song = self.current_play_list.popleft() 221 | self.current_song = Song(_song) 222 | 223 | self.notify_now_playing() 224 | self.song_change_alarm = self.main_loop.set_alarm_in(self.current_song.length_in_sec, 225 | self.next_song, None) 226 | self.update_ui_for_now_playing() 227 | self.scrobble_now_playing() 228 | # Stop current song if any song is playing 229 | self.player.stop() 230 | self.player.play(self.current_song) 231 | self.extend_playlist_if_needed() 232 | 233 | def update_ui_for_now_playing(self): 234 | self.selected_button.set_text(self.selected_button.text[0:11].strip()) 235 | heart = WHITE_HEART 236 | if self.current_song.like: 237 | heart = BLACK_HEART 238 | if not self.douban_account: 239 | heart = ' ' 240 | self.selected_button.set_text(self.selected_button.text + ' ' + heart + ' ' + 241 | self.current_song.artist + ' - ' + 242 | self.current_song.song_title) 243 | 244 | def notify_now_playing(self): 245 | if self.enable_notify: 246 | Notifier.notify("", self.current_song.song_title, self.current_song.artist + ' — ' + 247 | self.current_song.album_title, appIcon=self.current_song.picture, open_URL=self.current_song.album) 248 | 249 | def next_song(self, loop, user_data): 250 | self.submit_current_song() 251 | self.end_current_song 252 | if self.song_change_alarm: 253 | self.main_loop.remove_alarm(self.song_change_alarm) 254 | self._play_track() 255 | 256 | @last_fm_account_required 257 | def submit_current_song(self): 258 | # Submit the track if total playback time of the track > 30s 259 | if self.current_song.length_in_sec > 30: 260 | self.scrobbler.submit(self.current_song.artist, self.current_song.song_title, 261 | self.current_song.album_title, self.current_song.length_in_sec) 262 | 263 | @last_fm_account_required 264 | def scrobble_now_playing(self): 265 | self.scrobbler.now_playing(self.current_song.artist, self.current_song.song_title, 266 | self.current_song.album_title, self.current_song.length_in_sec) 267 | 268 | @current_song_required 269 | def skip_current_song(self): 270 | if self.douban_account: 271 | r, err = self.douban.skip_song( 272 | self.current_song.sid, self.current_channel) 273 | if r: 274 | logger.debug('Skip song OK') 275 | else: 276 | logger.error(err) 277 | if self.song_change_alarm: 278 | self.main_loop.remove_alarm(self.song_change_alarm) 279 | self._play_track() 280 | 281 | @current_song_required 282 | @douban_account_required 283 | def rate_current_song(self): 284 | r, err = self.douban.rate_song( 285 | self.current_song.sid, self.current_channel) 286 | if r: 287 | self.current_song.like = True 288 | self.selected_button.set_text(self.selected_button.text.replace( 289 | WHITE_HEART, BLACK_HEART)) 290 | logger.debug('Rate song OK') 291 | else: 292 | logger.error(err) 293 | 294 | @current_song_required 295 | @douban_account_required 296 | def unrate_current_song(self): 297 | r, err = self.douban.unrate_song( 298 | self.current_song.sid, self.current_channel) 299 | if r: 300 | self.current_song.like = False 301 | self.selected_button.set_text(self.selected_button.text.replace( 302 | BLACK_HEART, WHITE_HEART)) 303 | logger.debug('Unrate song OK') 304 | else: 305 | logger.error(err) 306 | 307 | @current_song_required 308 | @douban_account_required 309 | def end_current_song(self): 310 | r, err = self.douban.end_song( 311 | self.current_song.sid, self.current_channel) 312 | if r: 313 | logger.debug('End song OK') 314 | else: 315 | logger.error(err) 316 | 317 | @current_song_required 318 | @douban_account_required 319 | def trash_current_song(self): 320 | r, err = self.douban.bye_song( 321 | self.current_song.sid, self.current_channel) 322 | if r: 323 | # play next song 324 | if self.song_change_alarm: 325 | self.main_loop.remove_alarm(self.song_change_alarm) 326 | self._play_track() 327 | logger.debug('Trash song OK') 328 | else: 329 | logger.error(err) 330 | 331 | def getChannelListBox(self): 332 | body = [] 333 | for c in self.channels: 334 | _channel = ChannelButton(c['name']) 335 | urwid.connect_signal( 336 | _channel, 'click', self.on_channel_chosen, c['channel_id']) 337 | body.append(urwid.AttrMap(_channel, None, focus_map="channel")) 338 | return ChannelListBox(urwid.SimpleFocusListWalker(body)) 339 | 340 | def on_channel_chosen(self, button, choice): 341 | # Choose the channel which is playing right now, ignore it 342 | if self.selected_button == button: 343 | return 344 | if self.player.is_playing: 345 | self.player.stop() 346 | self._choose_channel(choice) 347 | # Update UI 348 | if self.selected_button != None and button != self.selected_button: 349 | self.selected_button.set_text( 350 | self.selected_button.text[0:11].strip()) 351 | self.selected_button = button 352 | if self.song_change_alarm: 353 | self.main_loop.remove_alarm(self.song_change_alarm) 354 | self._play_track() 355 | 356 | def on_skip(self): 357 | self.skip_current_song() 358 | 359 | def on_rate_and_unrate(self): 360 | if self.current_song.like: 361 | self.unrate_current_song() 362 | else: 363 | self.rate_current_song() 364 | 365 | def on_trash(self): 366 | self.trash_current_song() 367 | 368 | def on_exit(self): 369 | self.exit() 370 | 371 | def exit(self): 372 | logger.debug('Exit') 373 | self.player.stop() 374 | raise urwid.ExitMainLoop() 375 | 376 | def start(self): 377 | self.main_loop.run() 378 | 379 | 380 | def main(): 381 | fm = Doubanfm() 382 | fm.start() 383 | 384 | if __name__ == "__main__": 385 | main() 386 | -------------------------------------------------------------------------------- /pyfm/notifier.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | import platform 4 | import subprocess 5 | import tempfile 6 | 7 | SYSTEM = platform.system() 8 | PY_MAIN_VERSION = int(platform.python_version_tuple()[0]) 9 | PYOBJC = False 10 | 11 | if PY_MAIN_VERSION < 3: 12 | import sys 13 | reload(sys) 14 | sys.setdefaultencoding('utf-8') 15 | 16 | if SYSTEM == 'Darwin': 17 | try: 18 | import objc 19 | from Foundation import NSDate, NSURL, NSUserNotification, NSUserNotificationCenter 20 | from AppKit import NSImage 21 | PYOBJC = True 22 | 23 | def swizzle(cls, SEL, func): 24 | old_IMP = cls.instanceMethodForSelector_(SEL) 25 | 26 | def wrapper(self, *args, **kwargs): 27 | return func(self, old_IMP, *args, **kwargs) 28 | new_IMP = objc.selector(wrapper, selector=old_IMP.selector, 29 | signature=old_IMP.signature) 30 | objc.classAddMethod(cls, SEL, new_IMP) 31 | 32 | def swizzled_bundleIdentifier(self, original): 33 | # Use iTunes icon for notification 34 | return 'com.apple.itunes' 35 | 36 | except ImportError: 37 | PYOBJC = False 38 | 39 | 40 | class Notifier(object): 41 | 42 | def __init__(self): 43 | self.tempfile_dir = None 44 | self.notify = None 45 | self.bin_path = None 46 | self.notify_available = True 47 | 48 | if SYSTEM == 'Darwin' and PYOBJC: 49 | def _pyobjc_notify(message, title=None, subtitle=None, appIcon=None, contentImage=None, open_URL=None, delay=0, sound=False): 50 | 51 | swizzle(objc.lookUpClass('NSBundle'), 52 | b'bundleIdentifier', 53 | swizzled_bundleIdentifier) 54 | notification = NSUserNotification.alloc().init() 55 | notification.setInformativeText_(message) 56 | if title: 57 | notification.setTitle_(title) 58 | if subtitle: 59 | notification.setSubtitle_(subtitle) 60 | if appIcon: 61 | url = NSURL.alloc().initWithString_(appIcon) 62 | image = NSImage.alloc().initWithContentsOfURL_(url) 63 | notification.set_identityImage_(image) 64 | if contentImage: 65 | url = NSURL.alloc().initWithString_(contentImage) 66 | image = NSImage.alloc().initWithContentsOfURL_(url) 67 | notification.setContentImage_(image) 68 | 69 | if sound: 70 | notification.setSoundName_( 71 | "NSUserNotificationDefaultSoundName") 72 | notification.setDeliveryDate_( 73 | NSDate.dateWithTimeInterval_sinceDate_(delay, NSDate.date())) 74 | NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_( 75 | notification) 76 | 77 | self.notify = _pyobjc_notify 78 | else: 79 | self.notify_available = False 80 | 81 | if SYSTEM == "Linux": 82 | proc = subprocess.Popen( 83 | ["which", "notify-send"], stdout=subprocess.PIPE) 84 | env_bin_path = proc.communicate()[0].strip() 85 | if env_bin_path and os.path.exists(env_bin_path): 86 | self.bin_path = os.path.realpath(env_bin_path) 87 | self.notify = self._notify_send_notify 88 | self.notify_available = True 89 | elif os.path.exists("/usr/bin/notify-send"): 90 | self.bin_path = os.path.join("/usr/bin/", "notify-send") 91 | self.notify = self._notify_send_notify 92 | self.notify_available = True 93 | else: 94 | self.notify_available = False 95 | 96 | if not self.notify_available: 97 | print("Notify not available.") 98 | self.notify = self._notify_not_available 99 | 100 | def _notify_not_available(self, *args, **kwargs): 101 | pass 102 | 103 | def _notify_send_notify(self, message, title=None, subtitle=None, appIcon=None, contentImage=None, open_URL=None, delay=0, sound=False): 104 | # Download the image 105 | self.tempfile_dir = tempfile.mkdtemp() 106 | subprocess.Popen([ 107 | 'curl', 108 | '-o', 109 | self.tempfile_dir + '/' + str(title.__hash__()) + '.jpg', 110 | appIcon], 111 | stdout=subprocess.PIPE, 112 | stderr=subprocess.STDOUT 113 | ) 114 | 115 | import time 116 | time.sleep(0.5) 117 | 118 | subprocess.Popen([ 119 | self.bin_path, 120 | '-i', 121 | self.tempfile_dir + '/' + str(title.__hash__()) + '.jpg', 122 | title, 123 | subtitle], 124 | stdout=subprocess.PIPE, 125 | stderr=subprocess.STDOUT 126 | ) 127 | 128 | 129 | Notifier = Notifier() 130 | -------------------------------------------------------------------------------- /pyfm/player.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | 4 | 5 | class Player(object): 6 | 7 | def __init__(self): 8 | self.is_playing = False 9 | self.current_song = None 10 | self.player_process = None 11 | self.return_code = 0 12 | self.detect_external_players() 13 | 14 | def detect_external_players(self): 15 | supported_external_players = [ 16 | ["mpv", "--really-quiet"], 17 | ["mplayer", "-really-quiet"], 18 | ["mpg123", "-q"], 19 | ] 20 | 21 | for external_player in supported_external_players: 22 | proc = subprocess.Popen( 23 | ["which", external_player[0]], stdout=subprocess.PIPE) 24 | env_bin_path = proc.communicate()[0].strip() 25 | if (env_bin_path and os.path.exists(env_bin_path)): 26 | self.external_player = external_player 27 | break 28 | 29 | else: 30 | print("no supported player found. Exit.") 31 | raise SystemExit() 32 | 33 | def play(self, song): 34 | self.current_song = song 35 | self.player_process = subprocess.Popen( 36 | self.external_player + [self.current_song.url], 37 | stdin=subprocess.PIPE) 38 | self.is_playing = True 39 | 40 | def stop(self): 41 | if self.player_process is None: 42 | return 43 | try: 44 | self.player_process.terminate() 45 | except: 46 | pass 47 | -------------------------------------------------------------------------------- /pyfm/scrobbler.py: -------------------------------------------------------------------------------- 1 | # Scrobbler protocol v1.2 2 | # See http://www.audioscrobbler.net/development/protocol/ 3 | import logging 4 | 5 | from hashlib import md5 6 | from time import time 7 | 8 | import requests 9 | 10 | logger = logging.getLogger() 11 | 12 | 13 | class Scrobbler(object): 14 | 15 | # client : 3 chars 16 | # DEPRECATED : tst 1.0 - lastfm clientId for dev. Lastfm threats to disable it for version 1.2 http://www.last.fm/api/submissions 17 | # So, now use the client id of mpdscribble : mdc 0.22 18 | # http://git.musicpd.org/cgit/master/mpdscribble.git/tree/src/scrobbler.c#n45 19 | 20 | def __init__(self, user, password, client="mdc", version="0.22"): 21 | self.url = "http://post.audioscrobbler.com/" 22 | self.user = user 23 | self.password = password 24 | self.client = client 25 | self.version = version 26 | 27 | def handshake(self): 28 | logger.debug('Scrobbler handshake') 29 | timestamp = int(time()).__str__() 30 | logger.debug(timestamp) 31 | 32 | inner_md5 = (self.password + timestamp).encode('utf-8') 33 | auth = md5(inner_md5).hexdigest() 34 | logger.debug(auth) 35 | 36 | payload = { 37 | "hs": "true", 38 | "p": "1.2", 39 | "c": self.client, 40 | "v": self.version, 41 | "u": self.user, 42 | "t": timestamp, 43 | "a": auth 44 | } 45 | 46 | r = requests.get(self.url, params=payload) 47 | resp = r.text 48 | 49 | if resp.startswith("OK"): 50 | logger.debug('Handshake OK') 51 | resp_info = resp.split("\n") 52 | self.session_id = resp_info[1].rstrip() 53 | self.now_playing_url = resp_info[2].rstrip() 54 | self.submission_url = resp_info[3].rstrip() 55 | return True, None 56 | 57 | err = None 58 | if resp.startswith("BANNED"): 59 | err = "BANNED" 60 | 61 | if resp.startswith("BADTIME"): 62 | err = "BADTIME" 63 | 64 | if resp.startswith("FAILED"): 65 | err = "FAILED" 66 | 67 | if resp.startswith("BADAUTH"): 68 | err = "BADAUTH" 69 | 70 | return False, err 71 | 72 | def now_playing(self, artist, title, album="", length="", tracknumber="", mb_trackid=""): 73 | logger.debug("Now Playing %s - %s - %s" % (artist, title, album)) 74 | 75 | payload = { 76 | "s": self.session_id, 77 | "a": artist, 78 | "t": title, 79 | "b": album, 80 | "l": length, 81 | "n": tracknumber, 82 | "m": mb_trackid 83 | } 84 | 85 | r = requests.post(self.now_playing_url, params=payload) 86 | resp = r.text 87 | 88 | if resp.startswith("OK"): 89 | logger.debug('Now Playing OK') 90 | return True 91 | 92 | if resp.startswith("FAILED"): 93 | logger.debug('Now Playing FAILED') 94 | return False 95 | 96 | def submit(self, artist, title, album="", length="", tracknumber="", mb_trackid=""): 97 | logger.debug("Submitting %s - %s" % (artist, title)) 98 | 99 | timestamp = int(time()) 100 | 101 | payload = { 102 | "s": self.session_id, 103 | "a[0]": artist, 104 | "t[0]": title, 105 | "i[0]": timestamp - length, 106 | "o[0]": "R", 107 | "r[0]": "", 108 | "l[0]": length, 109 | "b[0]": album, 110 | "n[0]": tracknumber, 111 | "m[0]": mb_trackid 112 | } 113 | 114 | r = requests.post(self.submission_url, params=payload) 115 | resp = r.text 116 | 117 | if resp.startswith("OK"): 118 | logger.debug("Submitting OK") 119 | return True 120 | 121 | if resp.startswith("FAILED"): 122 | logger.debug("Submitting FAILED") 123 | return False 124 | -------------------------------------------------------------------------------- /pyfm/song.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logger = logging.getLogger() 4 | 5 | 6 | class Song(object): 7 | 8 | def __init__(self, song_json): 9 | logger.debug(song_json) 10 | try: 11 | self._parse(song_json) 12 | except KeyError: 13 | pass 14 | 15 | def _parse(self, song_json): 16 | self.artist = song_json['artist'] 17 | self.song_title = song_json['title'] 18 | # All-uppercase title. Make it normal 19 | if self.song_title.isupper(): 20 | self.song_title = self.song_title.title() 21 | 22 | self.album_title = song_json['albumtitle'] 23 | 24 | self.length_in_sec = song_json['length'] 25 | 26 | # Process the length of the song 27 | self.length_minute = divmod(self.length_in_sec, 60)[0] 28 | self.length_sec = divmod(self.length_in_sec, 60)[1] 29 | self.length_in_str = str( 30 | self.length_minute) + ":" + str(self.length_sec) 31 | 32 | self.like = True and song_json['like'] == 1 or False 33 | self.url = song_json['url'] 34 | self.album = 'http://music.douban.com' + song_json['album'] 35 | self.picture = song_json['picture'] 36 | self.sid = song_json['sid'] 37 | self.aid = song_json['aid'] 38 | self.ssid = song_json['ssid'] -------------------------------------------------------------------------------- /pyfm/ui.py: -------------------------------------------------------------------------------- 1 | import urwid 2 | 3 | 4 | class ChannelButton(urwid.Button): 5 | 6 | """ 7 | A urwid.Button that can easily change its text 8 | """ 9 | 10 | def __init__(self, caption): 11 | super(ChannelButton, self).__init__("") 12 | self._text = urwid.SelectableIcon([u'\N{BULLET} ', caption], 0) 13 | self._w = urwid.AttrMap(self._text, None, focus_map='selected') 14 | 15 | @property 16 | def text(self): 17 | return self._text.text 18 | 19 | def set_text(self, text): 20 | self._text.set_text(text) 21 | 22 | 23 | class ChannelListBox(urwid.ListBox): 24 | 25 | """ 26 | A urwid.ListBox that can control player by emitting signals 27 | """ 28 | 29 | def __init__(self, body): 30 | super(ChannelListBox, self).__init__(body) 31 | self._command_map['j'] = 'cursor down' 32 | self._command_map['k'] = 'cursor up' 33 | self._command_map['q'] = 'exit' 34 | self._command_map['Q'] = 'exit' 35 | 36 | def keypress(self, size, key): 37 | if key in ('up', 'down', 'page up', 'page down', 'enter', 'j', 'k'): 38 | return super(ChannelListBox, self).keypress(size, key) 39 | 40 | if key in ('q', 'Q'): 41 | urwid.emit_signal(self, 'exit') 42 | 43 | if key == ('n'): 44 | urwid.emit_signal(self, 'skip') 45 | 46 | if key == ('l'): 47 | urwid.emit_signal(self, 'rate') 48 | 49 | if key == ('t'): 50 | urwid.emit_signal(self, 'trash') 51 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | with open('README.rst') as f: 4 | long_description = f.read() 5 | 6 | setup( 7 | name="pyfm", 8 | version="0.2.4", 9 | license="MIT", 10 | description="A Tiny and Smart Terminal Player of douban.fm ", 11 | author='skyline75489', 12 | author_email='skyline75489@outlook.com', 13 | url='https://github.com/skyline75489/pyfm', 14 | packages=['pyfm'], 15 | install_requires=[ 16 | 'requests>=2.0.0', 17 | 'urwid>=1.2.1' 18 | ], 19 | entry_points={ 20 | 'console_scripts': ['pyfm = pyfm.fm:main'], 21 | }, 22 | classifiers=[ 23 | 'Environment :: Console', 24 | 'Environment :: Console :: Curses', 25 | 'Intended Audience :: End Users/Desktop', 26 | 'License :: OSI Approved :: MIT License', 27 | 'Natural Language :: Chinese (Simplified)', 28 | 'Operating System :: MacOS :: MacOS X', 29 | 'Operating System :: POSIX', 30 | 'Operating System :: Unix', 31 | 'Programming Language :: Python :: 2', 32 | 'Programming Language :: Python :: 2.7', 33 | 'Programming Language :: Python :: 3.4', 34 | 'Topic :: Multimedia :: Sound/Audio :: Players' 35 | ], 36 | long_description=long_description, 37 | ) 38 | --------------------------------------------------------------------------------