clientcodes.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /* GNU FM -- a free network service for sharing your music listening habits
  3. Copyright (C) 2013 Free Software Foundation, Inc
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. //placeholder for non-free clients with unknown code
  16. $nonfree_code = '';
  17. //placeholder for non-free clients with unknown api keys
  18. $nonfree_apikey = 'thisisafakekeyfornonfreeclients';
  19. // TODO We could return this instead of real name if apikey = $nonfree_apikey
  20. $nonfree_name = 'Unknown non-free client';
  21. // TODO We could return this instead of real url if apikey = $nonfree_apikey
  22. $nonfree_url = 'urltosomethinghere';
  23. //placeholder for free clients with unknown client codes
  24. $free_code = '';
  25. //placeholder for free clients with unknown api keys
  26. $free_apikey = '';
  27. /* Array of client arrays (client code, api key, name, url, free software)
  28. *
  29. * If we can find a free client's api key in their source code repo we consider it ok to add the api key here.
  30. * It is ok for clients to only have a code or a apikey or both, as some clients will use the 1.2 and/or the 2.0 API.
  31. * For non-free clients we default to a fake api key for now, which we'll change on request(?).
  32. */
  33. $clients = array(
  34. array('code' => 'amk', 'api_key' => $free_apikey, 'name' => 'Amarok 1.4.x plugin', 'url' => 'http://amarok.kde.org/', 'free' => True),
  35. array('code' => 'amp', 'api_key' => $nonfree_apikey, 'name' => 'Aimp2', 'url' => 'http://www.aimp.ru/', 'free' => False),
  36. array('code' => 'amy', 'api_key' => $free_apikey, 'name' => 'Anomaly', 'url' => 'https://chrome.google.com/webstore/detail/ajbkmdgmhbjjhephmgbpgialfbnjbmkb', 'free' => True),
  37. array('code' => 'ark', 'api_key' => $free_apikey, 'name' => 'Amarok', 'url' => 'http://amarok.kde.org/', 'free' => True),
  38. array('code' => 'ass', 'api_key' => $free_apikey, 'name' => 'Last.fm player', 'url' => 'http://www.last.fm/download', 'free' => True),
  39. array('code' => 'atu', 'api_key' => $free_apikey, 'name' => 'aTunes', 'url' => 'http://www.atunes.org/', 'free' => True),
  40. array('code' => 'aud', 'api_key' => $free_apikey, 'name' => 'Audacious', 'url' => 'http://audacious-media-player.org/', 'free' => True),
  41. array('code' => 'bil', 'api_key' => $nonfree_apikey, 'name' => 'billy', 'url' => 'http://www.sheepfriends.com/?page=billy', 'free' => False),
  42. array('code' => 'blu', 'api_key' => $free_apikey, 'name' => 'Bluemindo', 'url' => 'http://bluemindo.codingteam.net/', 'free' => True),
  43. array('code' => 'bsh', 'api_key' => $free_apikey, 'name' => 'Banshee', 'url' => 'http://banshee-project.org/', 'free' => True),
  44. array('code' => 'bwt', 'api_key' => $nonfree_apikey, 'name' => 'Bowtie', 'url' => 'http://www.bowtieapp.com/', 'free' => False),
  45. array('code' => 'cmu', 'api_key' => $free_apikey, 'name' => 'CmuScrobbler', 'url' => 'http://n.ethz.ch/%7edflatz/cmuscrobbler/', 'free' => True),
  46. array('code' => 'cpl', 'api_key' => $free_apikey, 'name' => 'cplay scrobbler', 'url' => 'http://sebi.tla.ro/cplay_scrobbler', 'free' => True),
  47. array('code' => 'cub', 'api_key' => $free_apikey, 'name' => 'Cuberok', 'url' => 'http://code.google.com/p/cuberok/', 'free' => True),
  48. array('code' => 'dbl', 'api_key' => $free_apikey, 'name' => 'Decibel Audio Player', 'url' => 'http://decibel.silent-blade.org/', 'free' => True),
  49. array('code' => 'ddb', 'api_key' => $free_apikey, 'name' => 'DeaDBeeF', 'url' => 'http://deadbeef.sourceforge.net/', 'free' => True),
  50. array('code' => 'dms', 'api_key' => $free_apikey, 'name' => 'donky mpdscrob', 'url' => 'http://github.com/mjhayes/donky/tree/master', 'free' => True),
  51. array('code' => 'ecm', 'api_key' => $nonfree_apikey, 'name' => 'Electrocompaniet Network Media Player', 'url' => 'http://www.electrocompaniet.no', 'free' => False),
  52. array('code' => 'ems', 'api_key' => $free_apikey, 'name' => 'EMMS', 'url' => 'http://www.gnu.org/software/emms/', 'free' => True),
  53. array('code' => 'exa', 'api_key' => $free_apikey, 'name' => 'Exaile', 'url' => 'http://www.exaile.org/', 'free' => True),
  54. array('code' => 'foo', 'api_key' => $free_apikey, 'name' => 'foobar2000', 'url' => 'http://www.foobar2000.org/', 'free' => True),
  55. array('code' => 'gmb', 'api_key' => $free_apikey, 'name' => 'gmusicbrowser', 'url' => 'http://gmusicbrowser.org/', 'free' => True),
  56. array('code' => 'gmm', 'api_key' => $free_apikey, 'name' => 'Goggles Music Manager', 'url' => 'http://code.google.com/p/gogglesmm/', 'free' => True),
  57. array('code' => 'gst', 'api_key' => $nonfree_apikey, 'name' => 'GimmeSome Tune', 'url' => 'http://www.eternalstorms.at/gimmesometune/', 'free' => False),
  58. array('code' => 'gua', 'api_key' => $free_apikey, 'name' => 'Guayadeque', 'url' => 'http://sourceforge.net/projects/guayadeque/', 'free' => True),
  59. array('code' => 'her', 'api_key' => $free_apikey, 'name' => 'Herrie', 'url' => 'http://herrie.info', 'free' => True),
  60. array('code' => 'isp', 'api_key' => $free_apikey, 'name' => 'iSproggler', 'url' => 'http://iSproggler.org/', 'free' => True),
  61. array('code' => 'jaj', 'api_key' => $free_apikey, 'name' => 'Jajuk', 'url' => 'http://jajuk.info/', 'free' => True),
  62. array('code' => 'ldr', 'api_key' => $free_apikey, 'name' => 'Libre Droid', 'url' => 'http://linux.mikeasoft.com/libredroid/', 'free' => True),
  63. array('code' => '', 'api_key' => 'default_gnufm_32_char_identifier', 'name' => $site_name, 'url' => $base_url, 'free' => True),
  64. array('code' => 'lfm', 'api_key' => 'werereallylibrefmhonestwouldilie', 'name' => 'Libre.fm', 'url' => 'http://libre.fm', 'free' => True),
  65. array('code' => 'lib', 'api_key' => $free_apikey, 'name' => 'LibreTunes', 'url' => 'http://libretunes.sourceforge.net/', 'free' => True),
  66. array('code' => 'liv', 'api_key' => $free_apikey, 'name' => 'Livewwwire', 'url' => 'http://ciarang.com', 'free' => True),
  67. array('code' => 'lpd', 'api_key' => $free_apikey, 'name' => 'lastPod', 'url' => 'http://www.lastpod.org', 'free' => True),
  68. array('code' => 'lsb', 'api_key' => $free_apikey, 'name' => 'libreScrobbleBerry', 'url' => 'https://gitorious.org/librescrobbleberry', 'free' => True),
  69. array('code' => 'lsd', 'api_key' => $free_apikey, 'name' => 'lastfmsubmitd', 'url' => 'http://www.red-bean.com/decklin/lastfmsubmitd/', 'free' => True),
  70. array('code' => 'mae', 'api_key' => $free_apikey, 'name' => 'maemoscrobbler', 'url' => 'https://garage.maemo.org/projects/maemoscrobbler', 'free' => True),
  71. array('code' => 'maf', 'api_key' => $free_apikey, 'name' => 'mafw-lastfm', 'url' => 'https://garage.maemo.org/projects/mafw-lastfm', 'free' => True),
  72. array('code' => 'mcl', 'api_key' => $nonfree_apikey, 'name' => 'MOCp-Scrobbler', 'url' => 'http://github.com/fluxid/mocp-scrobbler', 'free' => False),
  73. array('code' => 'mcn', 'api_key' => $free_apikey, 'name' => 'mpdcron', 'url' => 'http://mpd.wikia.com/wiki/Client:MPDCRON', 'free' => True),
  74. array('code' => 'mdc', 'api_key' => $free_apikey, 'name' => 'mpdscribble', 'url' => 'http://musicpd.org/', 'free' => True),
  75. array('code' => 'mlr', 'api_key' => $free_apikey, 'name' => 'mobbler', 'url' => 'http://code.google.com/p/mobbler/', 'free' => True),
  76. array('code' => 'mmo', 'api_key' => $nonfree_apikey, 'name' => 'MediaMonkey', 'url' => 'http://www.mediamonkey.com/', 'free' => False),
  77. array('code' => 'mms', 'api_key' => $free_apikey, 'name' => 'Maemo Scrobbler', 'url' => 'http://github.com/felipec/maemo-scrobbler', 'free' => True),
  78. array('code' => 'moc', 'api_key' => $free_apikey, 'name' => 'music on console', 'url' => 'http://moc.daper.net/', 'free' => True),
  79. array('code' => 'mp5', 'api_key' => 'a0ed2629d3d28606f67d7214c916788d', 'name' => 'mpdas', 'url' => 'http://50hz.ws/mpdas/', 'free' => True),
  80. array('code' => 'mpc', 'api_key' => $free_apikey, 'name' => 'Scrobby', 'url' => 'http://unkart.ovh.org/scrobby/', 'free' => True),
  81. array('code' => 'osx', 'api_key' => $nonfree_apikey, 'name' => 'iTunes', 'url' => 'http://www.apple.com/itunes/', 'free' => False),
  82. array('code' => 'pyj', 'api_key' => $free_apikey, 'name' => 'pyjama', 'url' => 'https://launchpad.net/pyjama', 'free' => True),
  83. array('code' => 'qcd', 'api_key' => $nonfree_apikey, 'name' => 'Quintessential Media Player', 'url' => 'http://www.quinnware.com/', 'free' => False),
  84. array('code' => 'qlb', 'api_key' => $free_apikey, 'name' => 'Quod Libet', 'url' => 'http://code.google.com/p/quodlibet/', 'free' => True),
  85. array('code' => 'qmm', 'api_key' => $free_apikey, 'name' => 'Qmmp', 'url' => 'http://qmmp.ylsoftware.com', 'free' => True),
  86. array('code' => 'qmn', 'api_key' => $free_apikey, 'name' => 'QMPDClient', 'url' => 'http://bitcheese.net/wiki/QMPDClient', 'free' => True),
  87. array('code' => 'qts', 'api_key' => $free_apikey, 'name' => 'QTScrobbler', 'url' => 'http://qtscrob.sourceforge.net/', 'free' => True),
  88. array('code' => 'rbx', 'api_key' => 'a string 32 characters in length', 'name' => 'Rhythmbox', 'url' => 'http://projects.gnome.org/rhythmbox/', 'free' => True),
  89. array('code' => 'sbd', 'api_key' => $free_apikey, 'name' => 'Songbird', 'url' => 'http://www.getsongbird.com/', 'free' => True),
  90. array('code' => 'scb', 'api_key' => $free_apikey, 'name' => 'Scrobbl', 'url' => 'http://www.last.fm/group/scrobbl', 'free' => True),
  91. array('code' => 'sfm', 'api_key' => $free_apikey, 'name' => 'shell-fm', 'url' => 'http://nex.scrapping.cc/shell-fm/', 'free' => True),
  92. array('code' => 'sls', 'api_key' => $free_apikey, 'name' => 'Simple Last.fm Scrobbler', 'url' => 'http://code.google.com/p/a-simple-lastfm-scrobbler/', 'free' => True),
  93. array('code' => 'sna', 'api_key' => $free_apikey, 'name' => 'Sonata', 'url' => 'http://sonata.berlios.de/', 'free' => True),
  94. array('code' => 'srd', 'api_key' => $free_apikey, 'name' => 'scrobd', 'url' => 'http://codingteam.net/project/scrobd', 'free' => True),
  95. array('code' => 'spc', 'api_key' => $free_apikey, 'name' => 'scmpc', 'url' => 'http://ngls.zakx.de/scmpc/', 'free' => True),
  96. array('code' => 'spm', 'api_key' => $nonfree_apikey, 'name' => 'Spotify Mobile', 'url' => 'http://www.spotify.com/uk/mobile/overview/', 'free' => False),
  97. array('code' => 'spy', 'api_key' => $nonfree_apikey, 'name' => 'Spotify', 'url' => 'http://spotify.com/', 'free' => False),
  98. array('code' => 'ss7', 'api_key' => $free_apikey, 'name' => 'SqueezeScrobbler 7', 'url' => 'http://www.slimdevices.com/pi_features.html', 'free' => True),
  99. array('code' => 'sub', 'api_key' => $free_apikey, 'name' => 'Subsonic', 'url' => 'http://www.subsonic.org', 'free' => True),
  100. array('code' => 'tmh', 'api_key' => $free_apikey, 'name' => 'scrobble for iPhone', 'url' => 'http://www.nodomain.org/scrobble/', 'free' => True),
  101. array('code' => 'tng', 'api_key' => '75d20fb472be99275392aefa2760ea09', 'name' => 'Clementine Player', 'url' => 'http://code.google.com/p/clementine-player/', 'free' => True),
  102. array('code' => 'trt', 'api_key' => $nonfree_apikey, 'name' => 'Trout', 'url' => 'http://skwire.dcmembers.com/wb/pages/software/trout.php', 'free' => False),
  103. // TST IS FOR TESTING array('code' => 'tst', 'api_key' => $nonfree_apikey', 'name' => 'Ecoute', 'url' => 'http://ecouteapp.com/', 'free' => False),
  104. array('code' => 'vag', 'api_key' => $free_apikey, 'name' => 'vagalume', 'url' => 'http://vagalume.igalia.com/', 'free' => True),
  105. array('code' => 'vlc', 'api_key' => $free_apikey, 'name' => 'VLC', 'url' => 'http://videolan.org', 'free' => True),
  106. array('code' => 'wa2', 'api_key' => $nonfree_apikey, 'name' => 'WinAmp 2', 'url' => 'http://www.winamp.com/', 'free' => False),
  107. array('code' => 'wmp', 'api_key' => $nonfree_apikey, 'name' => 'Windows Media Player', 'url' => 'http://www.microsoft.com/windows/WindowsMedia/', 'free' => False),
  108. array('code' => 'xbm', 'api_key' => $free_apikey, 'name' => 'XBMC Media Center', 'url' => 'http://xbmc.org', 'free' => True),
  109. array('code' => 'xm2', 'api_key' => $free_apikey, 'name' => 'XMMS2', 'url' => 'http://www.xmms2.org/', 'free' => True),
  110. array('code' => 'xmp', 'api_key' => $free_apikey, 'name' => 'xmp-scrobbler', 'url' => 'http://www.un4seen.com/forum/?topic=5398.0', 'free' => True),
  111. array('code' => 'xsp', 'api_key' => $free_apikey, 'name' => 'xmms2-scrobbler-py', 'url' => 'http://code.google.com/p/xmms2-scrobbler-py/', 'free' => True),
  112. array('code' => 'yan', 'api_key' => $free_apikey, 'name' => 'Jerboa', 'url' => 'http://git.fredemmott.co.uk/?ph1.yanihp;asummary', 'free' => True),
  113. array('code' => 'you', 'api_key' => $free_apikey, 'name' => 'Youamp', 'url' => 'http://www.rojtberg.net/workspace/youamp/', 'free' => True),
  114. array('code' => 'zom', 'api_key' => $free_apikey, 'name' => 'ZOMG', 'url' => 'http://zomg.alioth.debian.org/', 'free' => True),
  115. array('code' => $free_code, 'api_key' => 'thisisthelibreimport2pythonthing', 'name' => 'libreimport v2', 'url' => 'https://gitorious.org/fmthings/lasttolibre', 'free' => True),
  116. array('code' => $free_code, 'api_key' => 'thisisthelibrelovepythonthing123', 'name' => 'librelove', 'url' => 'https://gitorious.org/fmthings/misc', 'free' => True),
  117. );
  118. /**
  119. * Get name, url and license type of a scrobble client based on client code or api key
  120. *
  121. * @param string $code Client code
  122. * @param string $apikey Client api key
  123. * @return array ('code' => string, 'api_key' => string, 'name' => string, 'url' => string, 'free' => boolean)
  124. *
  125. * @todo Rework our wiki page at http://bugs.foocorp.net/projects/librefm/wiki/Clients
  126. * and create a nixtape page with general info on how to get unknown clients identified,
  127. * wiki doesnt consider api keys and is a pain to work with so we should point to bug tracker
  128. * instead and remove client codes from wiki
  129. */
  130. function getClientData($code=null, $apikey=null) {
  131. global $clients;
  132. // We return a 'Unknown client' array if both code and api key is invalid or not known to us
  133. $unknown_client = array('code' => $code, 'api_key' => $apikey, 'name' => 'Unknown client', 'url' => 'http://bugs.foocorp.net/projects/librefm/wiki/Clients', 'free' => False);
  134. if ((strlen($code) != 3) && (strlen($apikey) != 32)) {
  135. return $unknown_client;
  136. }
  137. for($i = 0; $i < count($clients); $i++) {
  138. if (strlen($code) == 3 && $clients[$i]['code'] == $code) {
  139. return $clients[$i];
  140. } else if (strlen($apikey) == 32 && $clients[$i]['api_key'] == $apikey) {
  141. return $clients[$i];
  142. }
  143. }
  144. return $unknown_client;
  145. }