Changeset 2404498
- Timestamp:
- 10/22/2020 09:39:08 AM (5 years ago)
- Location:
- wp-soundsystem/trunk
- Files:
-
- 6 edited
-
classes/wpsstm-post-tracklist-class.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
wp-soundsystem.php (modified) (2 diffs)
-
wpsstm-core-api.php (modified) (8 diffs)
-
wpsstm-core-importer.php (modified) (1 diff)
-
wpsstm-settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-soundsystem/trunk/classes/wpsstm-post-tracklist-class.php
r2377957 r2404498 806 806 807 807 //links 808 if ( $link_urls = wpsstm_get_array_value('l ink',$track_arr) ){808 if ( $link_urls = wpsstm_get_array_value('location',$track_arr) ){ 809 809 810 810 $addlinks = array(); … … 963 963 */ 964 964 965 $response = WPSSTM_Core_API::api_request(' tracklist/import',$params);965 $response = WPSSTM_Core_API::api_request('v2/playlist/import',$params); 966 966 if ( is_wp_error($response) ){ 967 967 … … 1379 1379 if ( !$slug = get_post_meta( $this->post_id,WPSSTM_Core_Radios::$importer_slug_meta_name,true) ){ 1380 1380 1381 $response = WPSSTM_Core_API::api_request(' importer/',array('url'=>$this->feed_url));1381 $response = WPSSTM_Core_API::api_request('v2/importer/',array('url'=>$this->feed_url)); 1382 1382 1383 1383 if ( is_wp_error($response) ) return $response; … … 1495 1495 if ( wpsstm_is_local_file($feed_url) ) return $feed_url; 1496 1496 if ( !WPSSTM_Core_API::is_premium() ) return; 1497 return WPSSTM_API_URL . sprintf(' tracklist/body?url=%s',urlencode($this->feed_url));1497 return WPSSTM_API_URL . sprintf('v2/tracklist/body?url=%s',urlencode($this->feed_url)); 1498 1498 } 1499 1499 -
wp-soundsystem/trunk/readme.txt
r2375557 r2404498 148 148 149 149 == Changelog == 150 151 = 3.3.9 = 152 * API update 150 153 151 154 = 3.3.7 = -
wp-soundsystem/trunk/wp-soundsystem.php
r2377957 r2404498 6 6 Author: G.Breant 7 7 Author URI: https://profiles.wordpress.org/grosbouff/#content-plugins 8 Version: 3.3. 88 Version: 3.3.9 9 9 License: GPL2 10 10 */ … … 37 37 * @public string plugin version 38 38 */ 39 public $version = '3.3. 8';39 public $version = '3.3.9'; 40 40 /** 41 41 * @public string plugin DB version -
wp-soundsystem/trunk/wpsstm-core-api.php
r2375557 r2404498 19 19 WP_SoundSystem::debug_log('get api user datas...'); 20 20 21 $datas = WPSSTM_Core_API::api_request('auth/userdata'); 21 $datas = WPSSTM_Core_API::api_request('v2/auth/userdata'); 22 22 23 if ( is_wp_error($datas) ) return $datas; 23 24 … … 34 35 35 36 if ( is_wp_error($membership) ){ 36 WP_SoundSystem::debug_log($membership->get_error_message());37 37 return false; 38 38 } … … 52 52 if ( false === ( $token = get_transient(self::$token_transient_name ) ) ) { 53 53 54 $url = WPSSTM_API_URL . ' auth/token';54 $url = WPSSTM_API_URL . 'v2/auth/token'; 55 55 56 56 //build headers … … 63 63 $request = wp_remote_post($url,$args); 64 64 if ( is_wp_error($request) ) return $request; 65 66 $response_code = wp_remote_retrieve_response_code($request); 67 68 if ( $response_code == 503 ){ 69 $message = __('API unavailable','wpsstm'); 70 WP_SoundSystem::debug_log($message); 71 return new WP_Error('api_error',$message ); 72 } 65 73 66 74 $response = wp_remote_retrieve_body( $request ); … … 92 100 if (!$endpoint){ 93 101 return new WP_Error('wpsstmapi_no_api_url',__("Missing API endpoint",'wpsstm')); 102 } 103 104 //TOUFIX URGENT we don't need this premium check : request should be (or not) accepted at the API url. 105 $premium_endpoints = array( 106 'v2/playlist/import', 107 'v2/track/links' 108 ); 109 110 if ( in_array($endpoint,$premium_endpoints) && !self::is_premium() ){ 111 return new WP_Error('api_key_required',__("An API key is required.",'wpsstm')); 94 112 } 95 113 … … 134 152 $headers = wp_remote_retrieve_headers($request); 135 153 $response_code = wp_remote_retrieve_response_code($request); 136 $response = wp_remote_retrieve_body( $request ); 137 $response = json_decode($response, true); 154 155 if ( $response_code == 503 ){ 156 $message = __('API unavailable','wpsstm'); 157 WP_SoundSystem::debug_log($message); 158 return new WP_Error('api_error',$message ); 159 } 138 160 139 161 //invalid token, redo. … … 143 165 } 144 166 167 $response = wp_remote_retrieve_body( $request ); 168 $response = json_decode($response, true); 169 145 170 //api error 146 171 if ( $error_msg = wpsstm_get_array_value('error',$response) ){ 147 172 $error = sprintf(__('Error %s: %s','wpsstm'),$response_code,$error_msg); 173 WP_SoundSystem::debug_log($error); 148 174 return new WP_Error('api_error',$error ); 149 175 } … … 176 202 } 177 203 178 $args = array('spotify_id'=>$music_id); 179 $response = self::api_request('track/links',$args); 204 $args = [ 205 'track' => [ //jspf track 206 'creator'=>$track->artist, 207 'title'=>$track->title, 208 'identifier'=>(array)sprintf('https://open.spotify.com/track/%s',$music_id) 209 ] 210 ]; 211 212 $response = self::api_request('v2/track/links',$args,'POST'); 180 213 181 214 if ( is_wp_error($response) ){ 182 215 WP_SoundSystem::debug_log('Error while filtering autolinks'); 183 216 }else{ 184 $new_links = wpsstm_get_array_value(' items',$response);217 $new_links = wpsstm_get_array_value('links',$response); 185 218 $links = array_merge((array)$links,(array)$new_links); 186 219 } -
wp-soundsystem/trunk/wpsstm-core-importer.php
r2375557 r2404498 652 652 653 653 if (false === $importers){ 654 $importers = WPSSTM_Core_API::api_request(' importers');654 $importers = WPSSTM_Core_API::api_request('v2/importers'); 655 655 if ( is_wp_error($importers) || !$importers ) return $importers; 656 656 set_transient( self::$importers_transient_name, $importers, 1 * DAY_IN_SECONDS ); -
wp-soundsystem/trunk/wpsstm-settings.php
r2375557 r2404498 629 629 } 630 630 631 /*632 errors633 */634 635 //display errors636 settings_errors('api_premium');631 /* 632 errors 633 */ 634 635 //display errors 636 settings_errors('api_premium'); 637 637 638 638 }
Note: See TracChangeset
for help on using the changeset viewer.