[vlc-commits] acoustid: parametrize server options
Francois Cartegnie
git at videolan.org
Fri May 31 15:24:08 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May 31 15:13:56 2019 +0200| [06e1aafd0d7d39db236723fa394205d956404070] | committer: Francois Cartegnie
acoustid: parametrize server options
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=06e1aafd0d7d39db236723fa394205d956404070
---
modules/misc/fingerprinter.c | 4 +++-
modules/misc/webservices/acoustid.c | 41 +++++++++++++++++++++++++++----------
modules/misc/webservices/acoustid.h | 12 +++++++++--
3 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/modules/misc/fingerprinter.c b/modules/misc/fingerprinter.c
index c91f7e4a72..9bdd06b91b 100644
--- a/modules/misc/fingerprinter.c
+++ b/modules/misc/fingerprinter.c
@@ -353,7 +353,9 @@ static void *Run( void *opaque )
DoFingerprint( p_fingerprinter, &acoustid_print, psz_uri );
free( psz_uri );
- acoustid_lookup_fingerprint( VLC_OBJECT(p_fingerprinter), &acoustid_print );
+ acoustid_config_t cfg = { .p_obj = VLC_OBJECT(p_fingerprinter),
+ .psz_server = NULL, .psz_apikey = NULL };
+ acoustid_lookup_fingerprint( &cfg, &acoustid_print );
fill_metas_with_results( p_data, &acoustid_print );
for( unsigned j = 0; j < acoustid_print.results.count; j++ )
diff --git a/modules/misc/webservices/acoustid.c b/modules/misc/webservices/acoustid.c
index c7710a27d1..8a8bb98eb4 100644
--- a/modules/misc/webservices/acoustid.c
+++ b/modules/misc/webservices/acoustid.c
@@ -121,28 +121,47 @@ error:
return false;
}
-int acoustid_lookup_fingerprint( vlc_object_t *p_obj, acoustid_fingerprint_t *p_data )
+int acoustid_lookup_fingerprint( const acoustid_config_t *p_cfg, acoustid_fingerprint_t *p_data )
{
if ( !p_data->psz_fingerprint )
return VLC_SUCCESS;
char *psz_url;
- if( unlikely(asprintf( &psz_url, "https://fingerprint.videolan.org/"
- "acoustid.php?meta=recordings+tracks+usermeta+"
- "releases&duration=%d&fingerprint=%s",
- p_data->i_duration, p_data->psz_fingerprint ) < 1 ) )
- return VLC_EGENERIC;
+ if( p_cfg->psz_server )
+ {
+ if( unlikely(asprintf( &psz_url, "https://%s/v2/lookup"
+ "?client=%s"
+ "&meta=recordings+tracks+usermeta+releases"
+ "&duration=%d"
+ "&fingerprint=%s",
+ p_cfg->psz_server,
+ p_cfg->psz_apikey ? p_cfg->psz_apikey : "",
+ p_data->i_duration,
+ p_data->psz_fingerprint ) < 1 ) )
+ return VLC_EGENERIC;
+ }
+ else /* Use VideoLAN anonymized requests proxy */
+ {
+ if( unlikely(asprintf( &psz_url, "https://" ACOUSTID_ANON_SERVER
+ ACOUSTID_ANON_SERVER_PATH
+ "?meta=recordings+tracks+usermeta+releases"
+ "&duration=%d"
+ "&fingerprint=%s",
+ p_data->i_duration,
+ p_data->psz_fingerprint ) < 1 ) )
+ return VLC_EGENERIC;
+ }
- msg_Dbg( p_obj, "Querying AcoustID from %s", psz_url );
- void *p_buffer = json_retrieve_document( p_obj, psz_url );
+ msg_Dbg( p_cfg->p_obj, "Querying AcoustID from %s", psz_url );
+ void *p_buffer = json_retrieve_document( p_cfg->p_obj, psz_url );
free( psz_url );
if( !p_buffer )
return VLC_EGENERIC;
- if ( ParseJson( p_obj, p_buffer, & p_data->results ) )
- msg_Dbg( p_obj, "results count == %d", p_data->results.count );
+ if ( ParseJson( p_cfg->p_obj, p_buffer, & p_data->results ) )
+ msg_Dbg( p_cfg->p_obj, "results count == %d", p_data->results.count );
else
- msg_Dbg( p_obj, "No results" );
+ msg_Dbg( p_cfg->p_obj, "No results" );
free( p_buffer );
return VLC_SUCCESS;
diff --git a/modules/misc/webservices/acoustid.h b/modules/misc/webservices/acoustid.h
index abae220f96..8ab111de82 100644
--- a/modules/misc/webservices/acoustid.h
+++ b/modules/misc/webservices/acoustid.h
@@ -17,7 +17,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-
+#define ACOUSTID_ANON_SERVER "fingerprint.videolan.org"
+#define ACOUSTID_ANON_SERVER_PATH "/acoustid.php"
#define MB_ID_SIZE 36
struct acoustid_mb_result_t
@@ -55,5 +56,12 @@ struct acoustid_fingerprint_t
};
typedef struct acoustid_fingerprint_t acoustid_fingerprint_t;
-int acoustid_lookup_fingerprint( vlc_object_t *, acoustid_fingerprint_t * );
+typedef struct
+{
+ vlc_object_t *p_obj;
+ char *psz_server;
+ char *psz_apikey;
+} acoustid_config_t;
+
+int acoustid_lookup_fingerprint( const acoustid_config_t *, acoustid_fingerprint_t * );
void acoustid_result_release( acoustid_result_t * );
More information about the vlc-commits
mailing list