diff -Nru glyr-0.9.8~git20120430.26294fe/CMakeLists.txt glyr-0.9.8~git20120501.caeee4e/CMakeLists.txt --- glyr-0.9.8~git20120430.26294fe/CMakeLists.txt 2012-04-30 02:42:56.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/CMakeLists.txt 2012-05-02 06:24:55.000000000 +0000 @@ -56,8 +56,13 @@ ENDIF() MESSAGE("-- Building Target: ${CMAKE_BUILD_TYPE}") -SET(COMMON_FLAGS "-Wall -Wextra -Wstrict-prototypes -std=c99 -W -Wno-unused-parameter -Wno-strict-prototypes") -SET(CMAKE_C_FLAGS_RELEASE "${COMMON_FLAGS} ${CMAKE_C_FLAGS} -Os -s") +IF(CMAKE_COMPILER_IS_GNUCC) + SET(GCC_ONLY_FLAGS "-std=c99") + SET(GCC_ONLY_OPT "-s") +ENDIF() + +SET(COMMON_FLAGS "${GCC_ONLY_FLAGS} -Wall -Wextra -Wstrict-prototypes -W -Wno-unused-parameter -Wno-strict-prototypes -fvisibility=hidden") +SET(CMAKE_C_FLAGS_RELEASE "${COMMON_FLAGS} ${CMAKE_C_FLAGS} -Os ${GCC_ONLY_OPT}") SET(CMAKE_C_FLAGS_DEBUG "${COMMON_FLAGS} ${CMAKE_C_FLAGS} -ggdb3") SET(CMAKE_C_FLAGS "${COMMON_FLAGS} ${CMAKE_C_FLAGS}") # ------------------------------------------------ @@ -167,6 +172,7 @@ "${DIR_COVER}/rhapsody.c" "${DIR_COVER}/picsearch.c" "${DIR_COVER}/musicbrainz.c" + "${DIR_COVER}/slothradio.c" "${DIR_LYRICS}/lyrdb.c" "${DIR_LYRICS}/metallum.c" "${DIR_LYRICS}/magistrix.c" diff -Nru glyr-0.9.8~git20120430.26294fe/debian/changelog glyr-0.9.8~git20120501.caeee4e/debian/changelog --- glyr-0.9.8~git20120430.26294fe/debian/changelog 2012-05-01 01:44:08.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/debian/changelog 2012-05-02 06:25:14.000000000 +0000 @@ -1,8 +1,8 @@ -glyr (0.9.8~git20120430.26294fe-0ubuntu1~ripps1) precise; urgency=low +glyr (0.9.8~git20120501.caeee4e-0ubuntu1~ripps1) precise; urgency=low * New upstream snapshot - -- Taylor LeMasurier-Wren Mon, 30 Apr 2012 20:43:33 -0500 + -- Taylor LeMasurier-Wren Wed, 02 May 2012 01:24:42 -0500 glyr (0.0.1-1) unstable; urgency=low Binary files /tmp/toMTbVWJG0/glyr-0.9.8~git20120430.26294fe/doc/screenshot.png and /tmp/hspeG9umqv/glyr-0.9.8~git20120501.caeee4e/doc/screenshot.png differ diff -Nru glyr-0.9.8~git20120430.26294fe/lib/cache.c glyr-0.9.8~git20120501.caeee4e/lib/cache.c --- glyr-0.9.8~git20120430.26294fe/lib/cache.c 2012-03-30 18:11:52.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/cache.c 2012-05-02 06:24:55.000000000 +0000 @@ -292,6 +292,7 @@ //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// +__attribute__((visibility("default"))) GlyrDatabase * glyr_db_init(const char * root_path) { GlyrDatabase * to_return = NULL; @@ -360,6 +361,7 @@ //////////////////////////////////// +__attribute__((visibility("default"))) void glyr_db_destroy(GlyrDatabase * db_object) { if(db_object != NULL) @@ -381,6 +383,7 @@ //////////////////////////////////// //////////////////////////////////// +__attribute__((visibility("default"))) int glyr_db_edit(GlyrDatabase * db, GlyrQuery * query, GlyrMemCache * edited) { int result = 0; @@ -402,6 +405,7 @@ //////////////////////////////////// //////////////////////////////////// +__attribute__((visibility("default"))) void glyr_db_replace(GlyrDatabase * db, unsigned char * md5sum, GlyrQuery * query, GlyrMemCache * data) { if(db != NULL && md5sum != NULL) @@ -430,6 +434,7 @@ //////////////////////////////////// +__attribute__((visibility("default"))) gint glyr_db_delete(GlyrDatabase * db, GlyrQuery * query) { gint result = 0; @@ -530,6 +535,7 @@ //////////////////////////////////// +__attribute__((visibility("default"))) void glyr_db_foreach(GlyrDatabase * db, glyr_foreach_callback cb, void * userptr) { if(db != NULL && cb != NULL) @@ -561,6 +567,7 @@ //////////////////////////////////// //////////////////////////////////// +__attribute__((visibility("default"))) GlyrMemCache * glyr_db_lookup(GlyrDatabase * db, GlyrQuery * query) { GlyrMemCache * result = NULL; @@ -662,6 +669,7 @@ //////////////////////////////////// +__attribute__((visibility("default"))) void glyr_db_insert(GlyrDatabase * db, GlyrQuery * q, GlyrMemCache * cache) { if(db && q && cache) @@ -694,6 +702,7 @@ //////////////////////////////////// //////////////////////////////////// +__attribute__((visibility("default"))) GlyrMemCache * glyr_db_make_dummy(void) { GlyrMemCache * c = glyr_cache_new(); diff -Nru glyr-0.9.8~git20120430.26294fe/lib/core.c glyr-0.9.8~git20120501.caeee4e/lib/core.c --- glyr-0.9.8~git20120430.26294fe/lib/core.c 2012-03-30 02:08:57.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/core.c 2012-05-02 06:24:55.000000000 +0000 @@ -36,7 +36,7 @@ /* Somehow needed to prevent some compiler warning.. */ #include -/*--------------------------------------------------------*/ +////////////////////////////////////// static int _msg(const char * fmt, va_list params) @@ -55,17 +55,7 @@ return written; } -/*--------------------------------------------------------*/ - -void panic(const char * fmt, ...) -{ - va_list list; - va_start(list,fmt); - _msg(fmt,list); - va_end(list); -} - -/*--------------------------------------------------------*/ +////////////////////////////////////// int glyr_message(int verbosity, GlyrQuery * s, const char * fmt, ...) { @@ -87,23 +77,7 @@ return written; } -/*--------------------------------------------------------*/ - -int glyr_puts(int verbosity, GlyrQuery * s, const char * string) -{ - gint written = 0; - if(s != NULL || verbosity == -1) - { - if(string && (verbosity == -1 || verbosity <= s->verbosity)) - { - fputs(string,GLYR_OUTPUT); - fputs("\n",GLYR_OUTPUT); - } - } - return written; -} - -/*--------------------------------------------------------*/ +////////////////////////////////////// /** * Check if the size of a cover fits the specs @@ -119,7 +93,7 @@ return FALSE; } -/*--------------------------------------------------------*/ +////////////////////////////////////// /* cache incoming data in a GlyrMemCache * libglyr is spending quite some time here @@ -158,7 +132,7 @@ return realsize; } -/*--------------------------------------------------------*/ +////////////////////////////////////// void DL_set_data(GlyrMemCache * cache, const gchar * data, gint len) { @@ -180,7 +154,7 @@ } } -/*--------------------------------------------------------*/ +////////////////////////////////////// GlyrMemCache * DL_copy(GlyrMemCache * cache) { @@ -207,7 +181,7 @@ return result; } -/*--------------------------------------------------------*/ +////////////////////////////////////// // cleanup internal buffer if no longer used void DL_free(GlyrMemCache *cache) @@ -240,7 +214,7 @@ } } -/*--------------------------------------------------------*/ +////////////////////////////////////// // Use this to init the internal buffer GlyrMemCache* DL_init(void) @@ -256,7 +230,7 @@ return cache; } -/*--------------------------------------------------------*/ +////////////////////////////////////// // Splits http_proxy to libcurl conform represantation static gboolean proxy_to_curl(gchar * proxystring, char ** userpwd, char ** server) @@ -298,7 +272,7 @@ } -/*--------------------------------------------------------*/ +////////////////////////////////////// struct header_data { @@ -307,7 +281,7 @@ gchar * extra; }; -/*--------------------------------------------------------*/ +////////////////////////////////////// /* Parse header file. Get Contenttype from it and save it in the header_data struct */ gsize header_cb(void *ptr, gsize size, gsize nmemb, void *userdata) @@ -379,7 +353,7 @@ return bytes; } -/*--------------------------------------------------------*/ +////////////////////////////////////// /* empty callback just prevent writing header to stdout */ gsize nearly_empty_callback(void * p, gsize size, gsize numb, void * pp_Query) @@ -388,7 +362,7 @@ return (query && GET_ATOMIC_SIGNAL_EXIT(query)) ? 0 : (size * numb); } -/*--------------------------------------------------------*/ +////////////////////////////////////// static void DL_setproxy(CURL *eh, gchar * proxystring) { @@ -405,7 +379,7 @@ } else { - panic("glyr: Warning: Invalid proxy string.\n"); + glyr_message(-1,NULL,"Warning: Invalid proxy string.\n"); } if(userpwd != NULL) @@ -416,7 +390,7 @@ } } -/*--------------------------------------------------------*/ +////////////////////////////////////// static struct header_data * retrieve_content_info(gchar * url, gchar * proxystring, gchar * useragent, GlyrQuery * query) { @@ -468,7 +442,7 @@ { if(GET_ATOMIC_SIGNAL_EXIT(query) == FALSE) { - panic("- g_ping: E: %s [%d]\n",curl_easy_strerror(rc),rc); + glyr_message(1,query,"- DLError: %s [%d]\n",curl_easy_strerror(rc),rc); } g_free(info); info = NULL; @@ -486,7 +460,7 @@ return info; } -/*--------------------------------------------------------*/ +////////////////////////////////////// // Init an easyhandler with all relevant options static DLBufferContainer * DL_setopt(CURL *eh, GlyrMemCache * cache, const char * url, GlyrQuery * s, void * magic_private_ptr, long timeout, gchar * endmarker) @@ -533,7 +507,7 @@ return dlbuffer; } -/*--------------------------------------------------------*/ +////////////////////////////////////// gboolean continue_search(gint current, GlyrQuery * s) { @@ -556,9 +530,9 @@ return decision; } -/*--------------------------------------------------------*/ +////////////////////////////////////// // Bad data checker mehods: -/*--------------------------------------------------------*/ +////////////////////////////////////// /* Check for dupes. This does not affect the HEAD of the list, therefore no GList return */ gsize delete_dupes(GList * result, GlyrQuery * s) @@ -623,7 +597,7 @@ return double_items; } -/*--------------------------------------------------------*/ +////////////////////////////////////// // Download a singe file NOT in parallel GlyrMemCache * download_single(const char* url, GlyrQuery * s, const char * end) @@ -683,7 +657,7 @@ return NULL; } -/*--------------------------------------------------------*/ +////////////////////////////////////// // Init a callback object and a curl_easy_handle static GlyrMemCache * init_async_cache(CURLM * cm, cb_object * capo, GlyrQuery *s, long timeout, gchar * endmark) @@ -716,7 +690,7 @@ return dlcache; } -/*--------------------------------------------------------*/ +////////////////////////////////////// static GList * init_async_download(GList * url_list, GList * endmark_list, CURLM * cmHandle, GlyrQuery * s, int abs_timeout) { @@ -741,7 +715,7 @@ return cb_list; } -/*--------------------------------------------------------*/ +////////////////////////////////////// static void destroy_async_download(GList * cb_list, CURLM * cmHandle, gboolean free_caches) { @@ -775,9 +749,9 @@ } } -/*--------------------------------------------------------*/ +////////////////////////////////////// /* ----------------- THE HEART OF GOLD ------------------ */ -/*--------------------------------------------------------*/ +////////////////////////////////////// GList * async_download(GList * url_list, GList * endmark_list, GlyrQuery * s, long parallel_fac, long timeout_fac, AsyncDLCB asdl_callback, void * userptr, gboolean free_caches) { /* Storage for result items */ @@ -814,7 +788,7 @@ } if(merr != CURLM_OK) { - panic("curl_multi_perform() failed!"); + glyr_message(1,s,"Error: curl_multi_perform() failed!"); return NULL; } @@ -828,7 +802,7 @@ if (curl_multi_fdset(cmHandle, &ReadFDS, &WriteFDS, &ErrorFDS, &max_fd) || curl_multi_timeout(cmHandle, &wait_time)) { - panic("glyr: error while selecting stream. Might be a bug.\n"); + glyr_message(1,s,"Error while selecting stream. Might be a bug.\n"); return NULL; } @@ -849,7 +823,7 @@ /* Now block till something interesting happens with the download */ if (select(max_fd+1, &ReadFDS, &WriteFDS, &ErrorFDS, &Tmax) == -1) { - panic("glyr: E: select(%i <=> %li): %i: %s\n",max_fd+1, wait_time, errno, strerror(errno)); + glyr_message(1,s,"Error: select(%i <=> %li): %i: %s\n",max_fd+1, wait_time, errno, strerror(errno)); return NULL; } } @@ -948,7 +922,7 @@ msg->data.result); glyr_message(3,capo->s," On URL: "); - glyr_puts(3,capo->s,capo->url); + glyr_message(3,capo->s,"%s\n",capo->url); DL_free(capo->cache); capo->cache = NULL; @@ -963,7 +937,7 @@ else { /* Something in the multidownloading gone wrong */ - panic("glyrE: multiDL-errorcode: %d\n",msg->msg); + glyr_message(1,s,"Error: multiDownload-errorcode: %d\n",msg->msg); } } } @@ -972,7 +946,7 @@ return item_list; } -/*--------------------------------------------------------*/ +////////////////////////////////////// struct wrap_retrieve_pass_data { @@ -994,7 +968,7 @@ return head; } -/*--------------------------------------------------------*/ +////////////////////////////////////// static void check_all_types_in_url_list(GList * cache_list, GlyrQuery * s) { @@ -1040,7 +1014,7 @@ } else { - panic("glyr: Uh oh.. empty link in hashtable..\n"); + glyr_message(1,s,"glyr: Uh oh.. empty link in hashtable..\n"); } g_free(info->format); g_free(info->type); @@ -1056,7 +1030,7 @@ } } -/*--------------------------------------------------------*/ +////////////////////////////////////// static gboolean format_is_allowed(gchar * format, gchar * allowed) { @@ -1083,7 +1057,7 @@ } -/*--------------------------------------------------------*/ +////////////////////////////////////// static gint delete_wrong_formats(GList ** list, GlyrQuery * s) { @@ -1122,7 +1096,7 @@ return invalid_format_counter; } -/*--------------------------------------------------------*/ +////////////////////////////////////// static GList * kick_out_wrong_formats(GList * data_list, GlyrQuery * s) { @@ -1138,7 +1112,7 @@ return new_head; } -/*--------------------------------------------------------*/ +////////////////////////////////////// static void do_charset_conversion(MetaDataSource * source, GList * text_list) { @@ -1166,7 +1140,7 @@ } } -/*--------------------------------------------------------*/ +////////////////////////////////////// static GList * check_for_forced_utf8(GlyrQuery * query, GList * text_list) { @@ -1206,7 +1180,7 @@ return new_head; } -/*--------------------------------------------------------*/ +////////////////////////////////////// static void normalize_utf8(GList * text_list) { @@ -1230,7 +1204,7 @@ } } -/*--------------------------------------------------------*/ +////////////////////////////////////// static gint delete_already_cached_items(cb_object * capo, GList ** list) { @@ -1267,7 +1241,7 @@ return deleted; } -/*--------------------------------------------------------*/ +////////////////////////////////////// static void fix_data_types(GList * list, MetaDataSource * src, GlyrQuery * query) { @@ -1289,7 +1263,7 @@ } -/*--------------------------------------------------------*/ +////////////////////////////////////// /* The actual call to the metadata provider here, coming from the downloader, triggered by start_engine() */ static GList * call_provider_callback(cb_object * capo, void * userptr, bool * stop_download, gint * to_add) @@ -1379,7 +1353,7 @@ } else { - panic("glyr: hashmap lookup failed. Cannot call plugin => Bug.\n"); + glyr_message(1,capo->s,"glyr: hashmap lookup failed. Cannot call plugin => Bug.\n"); } } @@ -1399,7 +1373,7 @@ return parsed; } -/*--------------------------------------------------------*/ +////////////////////////////////////// gboolean provider_is_enabled(GlyrQuery * q, MetaDataSource * f) { @@ -1456,7 +1430,7 @@ return (all_occured) ? (is_excluded == FALSE) : is_found; } -/*--------------------------------------------------------*/ +////////////////////////////////////// /* GnuPlot: plot3d(1/X*Y + (100-Y)*1/(1-X) + 1000,[X,0.1,0.9],[Y,0,100]); */ static gfloat calc_rating(gfloat qsratio, gint quality, gint speed) @@ -1465,7 +1439,7 @@ return 1000.0f + ((1.0/(1-cratio)*quality) + (1.0/cratio*speed)); } -/*--------------------------------------------------------*/ +////////////////////////////////////// static GList * get_queued(GlyrQuery * s, MetaDataFetcher * fetcher, gint * fired) { @@ -1512,7 +1486,7 @@ return source_list; } -/*--------------------------------------------------------*/ +////////////////////////////////////// gboolean is_in_result_list(GlyrMemCache * cache, GList * result_list) { @@ -1531,7 +1505,7 @@ return result; } -/*--------------------------------------------------------*/ +////////////////////////////////////// static void execute_query(GlyrQuery * query, MetaDataFetcher * fetcher, GList * source_list, gboolean * stop_me, GList ** result_list) { @@ -1695,7 +1669,7 @@ } g_list_free(sub_result_list); } -/*--------------------------------------------------------*/ +////////////////////////////////////// static void print_trigger(GlyrQuery * query, GList * src_list) { @@ -1708,7 +1682,7 @@ glyr_message(2,query,"\n"); } -/*--------------------------------------------------------*/ +////////////////////////////////////// GList * start_engine(GlyrQuery * query, MetaDataFetcher * fetcher, GLYR_ERROR * err) { @@ -1751,7 +1725,7 @@ } -/*--------------------------------------------------------*/ +////////////////////////////////////// /* New glib implementation, thanks to Etienne Millon */ void update_md5sum(GlyrMemCache * c) @@ -1767,7 +1741,7 @@ } } -/*--------------------------------------------------------*/ +////////////////////////////////////// void glist_free_full(GList * List, void (* free_func)(void * ptr)) { @@ -1790,4 +1764,4 @@ #endif } -/*--------------------------------------------------------*/ +////////////////////////////////////// diff -Nru glyr-0.9.8~git20120430.26294fe/lib/core.h glyr-0.9.8~git20120501.caeee4e/lib/core.h --- glyr-0.9.8~git20120430.26294fe/lib/core.h 2012-04-29 08:55:24.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/core.h 2012-05-02 06:24:55.000000000 +0000 @@ -186,7 +186,6 @@ void update_md5sum(GlyrMemCache * c); void glist_free_full(GList * List, void (* free_func)(void * ptr)); -int glyr_puts(int verbosity, GlyrQuery * s, const char * string); /*------------------------------------------------------*/ diff -Nru glyr-0.9.8~git20120430.26294fe/lib/glyr.c glyr-0.9.8~git20120501.caeee4e/lib/glyr.c --- glyr-0.9.8~git20120430.26294fe/lib/glyr.c 2012-04-29 08:55:24.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/glyr.c 2012-05-02 06:24:55.000000000 +0000 @@ -197,6 +197,7 @@ /*--------------------------------------------------------*/ // return a descriptive string on error ID +__attribute__((visibility("default"))) const char * glyr_strerror(GLYR_ERROR ID) { if(ID < (sizeof(err_strings)/sizeof(const char *))) @@ -208,6 +209,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) void glyr_signal_exit(GlyrQuery * query) { SET_ATOMIC_SIGNAL_EXIT(query,1); @@ -215,6 +217,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) void glyr_cache_update_md5sum(GlyrMemCache * cache) { update_md5sum(cache); @@ -222,6 +225,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) void glyr_cache_set_data(GlyrMemCache * cache, const char * data, int len) { DL_set_data(cache,data,len); @@ -229,6 +233,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GlyrMemCache * glyr_cache_copy(GlyrMemCache * cache) { return DL_copy(cache); @@ -236,6 +241,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) const char * glyr_version(void) { return "Version "GLYR_VERSION_MAJOR"."GLYR_VERSION_MINOR"."GLYR_VERSION_MICRO" ("GLYR_VERSION_NAME") of ["__DATE__"] compiled at ["__TIME__"]"; @@ -246,6 +252,7 @@ /*-----------------------------------------------*/ // Seperate method because va_arg struggles with function pointers +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_dlcallback(GlyrQuery * settings, DL_callback dl_cb, void * userp) { if(settings) @@ -259,6 +266,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_type(GlyrQuery * s, GLYR_GET_TYPE type) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -272,6 +280,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_artist(GlyrQuery * s, char * artist) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -281,6 +290,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_album(GlyrQuery * s, char * album) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -290,6 +300,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_title(GlyrQuery * s, char * title) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -317,6 +328,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_img_maxsize(GlyrQuery * s, int size) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -325,6 +337,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_img_minsize(GlyrQuery * s, int size) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -333,6 +346,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_parallel(GlyrQuery * s, unsigned long val) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -342,6 +356,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_timeout(GlyrQuery * s, unsigned long val) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -351,6 +366,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_redirects(GlyrQuery * s, unsigned long val) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -360,6 +376,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_useragent(GlyrQuery * s, const char * useragent) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -369,6 +386,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_lang(GlyrQuery * s, char * langcode) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -391,6 +409,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_lang_aware_only(GlyrQuery * s, bool lang_aware_only) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -400,6 +419,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_number(GlyrQuery * s, unsigned int num) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -409,6 +429,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_verbosity(GlyrQuery * s, unsigned int level) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -418,6 +439,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_from(GlyrQuery * s, const char * from) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -431,6 +453,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_allowed_formats(GlyrQuery * s, const char * formats) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -440,6 +463,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_musictree_path(GlyrQuery * s, const char * musictree_path) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -449,6 +473,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_plugmax(GlyrQuery * s, int plugmax) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -463,6 +488,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_qsratio(GlyrQuery * s, float ratio) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -472,6 +498,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_proxy(GlyrQuery * s, const char * proxystring) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -481,6 +508,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_fuzzyness(GlyrQuery * s, int fuzz) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -490,6 +518,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_download(GlyrQuery * s, bool download) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -499,6 +528,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_force_utf8(GlyrQuery * s, bool force_utf8) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -508,6 +538,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_lookup_db(GlyrQuery * s, GlyrDatabase * db) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -521,6 +552,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_db_autowrite(GlyrQuery * s, bool db_autowrite) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -530,6 +562,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GLYR_ERROR glyr_opt_db_autoread(GlyrQuery * s, bool db_autoread) { if(s == NULL) return GLYRE_EMPTY_STRUCT; @@ -590,6 +623,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) void glyr_query_init(GlyrQuery * glyrs) { if(glyrs != NULL) @@ -600,6 +634,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) void glyr_query_destroy(GlyrQuery * sets) { if(sets != NULL && QUERY_IS_INITALIZED(sets)) @@ -621,6 +656,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GlyrMemCache * glyr_download(const char * url, GlyrQuery * s) { return download_single(url,s,NULL); @@ -628,6 +664,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) void glyr_free_list(GlyrMemCache * head) { if(head != NULL) @@ -653,6 +690,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) void glyr_cache_free(GlyrMemCache * c) { DL_free(c); @@ -660,6 +698,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GlyrMemCache * glyr_cache_new(void) { return DL_init(); @@ -668,6 +707,7 @@ /*-----------------------------------------------*/ // !! NOT THREADSAFE !! // +__attribute__((visibility("default"))) void glyr_init(void) { /* Protect agains double initialization */ @@ -706,6 +746,7 @@ /*-----------------------------------------------*/ // !! NOT THREADSAFE !! // +__attribute__((visibility("default"))) void glyr_cleanup(void) { if(is_initalized == TRUE) @@ -779,6 +820,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) GlyrMemCache * glyr_get(GlyrQuery * settings, GLYR_ERROR * e, int * length) { if(is_initalized == FALSE || QUERY_IS_INITALIZED(settings) == FALSE) @@ -812,22 +854,22 @@ if(settings->artist != NULL) { glyr_message(2,settings,"- Artist : "); - glyr_puts(2,settings,settings->artist); + glyr_message(2,settings,"%s\n",settings->artist); } if(settings->album != NULL) { glyr_message(2,settings,"- Album : "); - glyr_puts(2,settings,settings->album); + glyr_message(2,settings,"%s\n",settings->album); } if(settings->title != NULL) { glyr_message(2,settings,"- Title : "); - glyr_puts(2,settings,settings->title); + glyr_message(2,settings,"%s\n",settings->title); } if(settings->lang != NULL) { glyr_message(2,settings,"- Language : "); - glyr_puts(2,settings,settings->lang); + glyr_message(2,settings,"%s\n",settings->lang); } if(e) *e = GLYRE_OK; @@ -920,6 +962,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) int glyr_cache_write(GlyrMemCache * data, const char * path) { int bytes = -1; @@ -1014,6 +1057,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) const char * glyr_get_type_to_string(GLYR_GET_TYPE type) { const gchar * result = "unknown"; @@ -1033,6 +1077,7 @@ /*-----------------------------------------------*/ +__attribute__((visibility("default"))) const char * glyr_data_type_to_string(GLYR_DATA_TYPE type) { if(type > 0 && type < (sizeof(type_strings)/sizeof(const char*))) @@ -1046,6 +1091,7 @@ } /*-----------------------------------------------*/ +__attribute__((visibility("default"))) void glyr_cache_print(GlyrMemCache * cacheditem) { if(cacheditem != NULL) @@ -1092,6 +1138,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) GlyrFetcherInfo * glyr_info_get(void) { return get_plugin_info(); @@ -1099,6 +1146,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) void glyr_info_free(GlyrFetcherInfo * info) { free_plugin_info(info); @@ -1106,6 +1154,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) char * glyr_md5sum_to_string(unsigned char * md5sum) { gchar * md5str = NULL; @@ -1127,6 +1176,7 @@ #define CHAR_TO_NUM(c) (unsigned char)(g_ascii_isdigit(c) ? c - '0' : (c - 'a') + 10) +__attribute__((visibility("default"))) void glyr_string_to_md5sum(const char * string, unsigned char * md5sum) { if(string != NULL && strlen(string) >= 32 && md5sum) @@ -1142,6 +1192,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) GLYR_FIELD_REQUIREMENT glyr_get_requirements(GLYR_GET_TYPE type) { GLYR_FIELD_REQUIREMENT result = 0; @@ -1177,6 +1228,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) void glyr_cache_set_dsrc(GlyrMemCache * cache, const char * download_source) { SET_CACHE_STRING(cache,cache->dsrc,download_source); @@ -1184,6 +1236,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) void glyr_cache_set_prov(GlyrMemCache * cache, const char * provider) { SET_CACHE_STRING(cache,cache->prov,provider); @@ -1191,6 +1244,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) void glyr_cache_set_img_format(GlyrMemCache * cache, const char * img_format) { SET_CACHE_STRING(cache,cache->img_format,img_format); @@ -1198,6 +1252,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) void glyr_cache_set_type(GlyrMemCache * cache, GLYR_DATA_TYPE type) { if(cache != NULL) @@ -1206,6 +1261,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) void glyr_cache_set_rating(GlyrMemCache * cache, int rating) { if(cache != NULL) @@ -1214,6 +1270,7 @@ /* --------------------------------------------------------- */ +__attribute__((visibility("default"))) bool glyr_type_is_image(GLYR_GET_TYPE type) { return TYPE_IS_IMAGE(type); diff -Nru glyr-0.9.8~git20120430.26294fe/lib/intern/common/picsearch.c glyr-0.9.8~git20120501.caeee4e/lib/intern/common/picsearch.c --- glyr-0.9.8~git20120430.26294fe/lib/intern/common/picsearch.c 2012-01-30 07:29:10.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/intern/common/picsearch.c 2012-05-02 06:24:55.000000000 +0000 @@ -43,27 +43,29 @@ /* ------------------------- */ -#define IMG_HOOK "Image URL:" +#define IMG_HOOK "div class=\"thumbnailTop\">" +#define IMG_HOOK_BEGIN "data,IMG_HOOK); - if(hook != NULL) - { - gchar * img_url = get_search_value(hook,"href=\"","\">"); - if(img_url != NULL) - { - result = DL_init(); - result->data = img_url; - result->size = strlen(img_url); - result->dsrc = g_strdup(to_parse->dsrc); - } - } - } - return result; + char * start = strstr(to_parse->data,IMG_HOOK); + if(start != NULL) + { + char * img_url = get_search_value(start,IMG_HOOK_BEGIN,IMG_HOOK_ENDIN); + if(img_url != NULL) + { + result = DL_init(); + result->data = img_url; + result->size = strlen(img_url); + result->dsrc = g_strdup(to_parse->dsrc); + } + } + } + return result; } /* ------------------------- */ @@ -73,19 +75,24 @@ GList * generic_picsearch_parse(cb_object * capo) { - GList * result_list = NULL; + GList * result_list = NULL; - gchar * node = capo->cache->data; - gint nodelen = (sizeof NODE) - 1; + gchar * node = capo->cache->data; + gint nodelen = (sizeof NODE) - 1; node = strstr(node,"
"); - while(continue_search(g_list_length(result_list),capo->s) && (node = strstr(node, "s->number * 4; + + while(continue_search(items,capo->s) && + (node = strstr(node, "" -#define CA_BEGIN "\"Cover" +#define AMZ_URL_START "\"http://ecx.images-amazon.com/" +/* + * This is silly overall, + * but coverartarchive.org does not seem to work fully yet. + */ static GlyrMemCache * parse_web_page(GlyrMemCache * page) { GlyrMemCache * retv = NULL; @@ -42,20 +45,16 @@ char * begin = strstr(page->data,COVERART); if(begin != NULL) { - char * img_url = get_search_value(begin,CA_BEGIN,CA_ENDIN); - if(img_url != NULL) + char * amz_url = strstr(begin,AMZ_URL_START); + if(amz_url != NULL) { - gsize img_url_len = strlen(img_url); - if(img_url_len < 100) + char * img_url = get_search_value(amz_url,"\"","\""); + if(img_url != NULL) { retv = DL_init(); retv->dsrc = g_strdup(page->dsrc); retv->data = img_url; - retv->size = img_url_len; - } - else - { - g_free(img_url); + retv->size = strlen(img_url); } } } @@ -97,7 +96,6 @@ } } g_free(url); - } g_free(ID); } diff -Nru glyr-0.9.8~git20120430.26294fe/lib/intern/cover/slothradio.c glyr-0.9.8~git20120501.caeee4e/lib/intern/cover/slothradio.c --- glyr-0.9.8~git20120430.26294fe/lib/intern/cover/slothradio.c 1970-01-01 00:00:00.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/intern/cover/slothradio.c 2012-05-02 06:24:55.000000000 +0000 @@ -0,0 +1,146 @@ +/*********************************************************** +* This file is part of glyr +* + a commnadline tool and library to download various sort of musicrelated metadata. +* + Copyright (C) [2011] [Christopher Pahl] +* + Hosted at: https://github.com/sahib/glyr +* +* glyr is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* glyr is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with glyr. If not, see . +**************************************************************/ + +#include "../../stringlib.h" +#include "../../core.h" + +#define API_URL "http://www.slothradio.com/covers/?adv=1&artist=%s&album=%s&imgsize=%c&locale=%s&sort=salesrank" + +#define RESULT_LIST_START "" +#define RESULT_ITEM_START "" + +#define RESULT_LIST_END "" +#define RESULT_ITEM_END "" + +/////////////////////// + +#define STREQ(s1,s2) (g_ascii_strcasecmp(s1,s2) == 0) + +static const char * cover_slothradio_url(GlyrQuery * s) +{ + const char * locale = "us"; + if(STREQ(s->lang,"uk") || STREQ(s->lang,"de")) + locale = s->lang; + + /* + * Possible image sizes: + * x = largest available + * l = large (300**2) + * m = medium (130**2) + * s = small (50 **2) + **/ + char image_size = 'x'; + if(s->img_max_size != -1) + { + if(s->img_max_size < 75) + image_size = 's'; + else + if(s->img_max_size < 150) + image_size = 'm'; + else + if(s->img_max_size < 350) + image_size = 'l'; + } + + return g_strdup_printf(API_URL,s->artist,s->album,image_size,locale); +} + +/////////////////////// + +static bool check_size(GlyrQuery * q, char * node) +{ + bool rc = false; + char * width = get_search_value(node,"width=\"", "\""); + char * height = get_search_value(node,"height=\"","\""); + + if(width && height) + { + int w = strtol(width, NULL,10); + int h = strtol(height,NULL,10); + + if(size_is_okay(w,q->img_min_size,q->img_max_size) && + size_is_okay(h,q->img_min_size,q->img_max_size)) + rc = true; + } + g_free(width); + g_free(height); + + return rc; +} + +/////////////////////// + +static GList * cover_slothradio_parse(cb_object * capo) +{ + GList * result_list = NULL; + + const char * bound_start = strstr(capo->cache->data,RESULT_LIST_START); + if(bound_start == NULL) + return NULL; + + const char * bound_end = strstr(bound_start,RESULT_LIST_END); + if(bound_end == NULL) + return NULL; + + char * node = (char*)bound_start; + while((node = strstr(node + sizeof(RESULT_ITEM_START),RESULT_ITEM_START)) != NULL) + { + if(node >= bound_end) + break; + + char * url = get_search_value(node,"img src=\"","\""); + if(url != NULL) + { + if(check_size(capo->s,node)) + { + GlyrMemCache * result = DL_init(); + result->dsrc = g_strdup(capo->url); + result->data = url; + result->size = strlen(url); + + result_list = g_list_prepend(result_list,result); + } + else + { + g_free(url); + } + } + + if(continue_search(g_list_length(result_list),capo->s) == false) + break; + } + + return result_list; +} + +/////////////////////// + +MetaDataSource cover_slothradio_src = +{ + .name = "slothradio", + .key = 's', + .parser = cover_slothradio_parse, + .get_url = cover_slothradio_url, + .type = GLYR_GET_COVERART, + .quality = 80, + .speed = 80, + .endmarker = NULL, + .free_url = true +}; diff -Nru glyr-0.9.8~git20120430.26294fe/lib/misc.c glyr-0.9.8~git20120501.caeee4e/lib/misc.c --- glyr-0.9.8~git20120430.26294fe/lib/misc.c 2012-04-30 02:42:56.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/misc.c 2012-05-02 06:24:55.000000000 +0000 @@ -21,11 +21,13 @@ #include "stringlib.h" #include "misc.h" +__attribute__((visibility("default"))) size_t glyr_levenshtein_strcmp(const char * string, const char * other) { return levenshtein_strcmp(string,other); } +__attribute__((visibility("default"))) size_t glyr_levenshtein_strnormcmp(const char * string, const char * other) { return levenshtein_strnormcmp(NULL,string,other); diff -Nru glyr-0.9.8~git20120430.26294fe/lib/misc.h glyr-0.9.8~git20120501.caeee4e/lib/misc.h --- glyr-0.9.8~git20120430.26294fe/lib/misc.h 2012-04-30 02:42:56.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/misc.h 2012-05-02 06:24:55.000000000 +0000 @@ -101,7 +101,7 @@ * * Returns: the levenshtein distance */ -gsize glyr_levenshtein_strnormcmp(const char * string, const char * other); +size_t glyr_levenshtein_strnormcmp(const char * string, const char * other); #ifdef __cplusplus } diff -Nru glyr-0.9.8~git20120430.26294fe/lib/register_plugins.c glyr-0.9.8~git20120501.caeee4e/lib/register_plugins.c --- glyr-0.9.8~git20120430.26294fe/lib/register_plugins.c 2012-03-12 09:10:34.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/register_plugins.c 2012-05-02 06:24:55.000000000 +0000 @@ -67,6 +67,7 @@ extern MetaDataSource cover_rhapsody_src; extern MetaDataSource cover_picsearch_src; extern MetaDataSource cover_musicbrainz_src; +extern MetaDataSource cover_slothradio_src; extern MetaDataSource lyrics_lipwalk_src; extern MetaDataSource lyrics_lyrdb_src; extern MetaDataSource lyrics_lyricsreg_src; @@ -159,6 +160,7 @@ plugin_add_to_list(&glyrMetaDataSourceList,&cover_rhapsody_src); plugin_add_to_list(&glyrMetaDataSourceList,&cover_picsearch_src); plugin_add_to_list(&glyrMetaDataSourceList,&cover_musicbrainz_src); + plugin_add_to_list(&glyrMetaDataSourceList,&cover_slothradio_src); plugin_add_to_list(&glyrMetaDataSourceList,&lyrics_lipwalk_src); plugin_add_to_list(&glyrMetaDataSourceList,&lyrics_lyrdb_src); plugin_add_to_list(&glyrMetaDataSourceList,&lyrics_lyricsreg_src); diff -Nru glyr-0.9.8~git20120430.26294fe/lib/testing.c glyr-0.9.8~git20120501.caeee4e/lib/testing.c --- glyr-0.9.8~git20120430.26294fe/lib/testing.c 2011-10-29 09:49:22.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/testing.c 2012-05-02 06:24:55.000000000 +0000 @@ -51,6 +51,7 @@ /*-----------------------------------*/ +__attribute__((visibility("default"))) const char * glyr_testing_call_url(const char * provider_name, GLYR_GET_TYPE type, GlyrQuery * query) { const char * result = NULL; @@ -76,6 +77,7 @@ /*-----------------------------------*/ +__attribute__((visibility("default"))) GlyrMemCache * glyr_testing_call_parser(const char * provider_name, GLYR_GET_TYPE type, GlyrQuery * query, GlyrMemCache * cache) { GlyrMemCache * result = NULL; diff -Nru glyr-0.9.8~git20120430.26294fe/lib/types.h glyr-0.9.8~git20120501.caeee4e/lib/types.h --- glyr-0.9.8~git20120430.26294fe/lib/types.h 2012-04-30 02:42:56.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/lib/types.h 2012-05-02 06:24:55.000000000 +0000 @@ -465,75 +465,6 @@ */ typedef GLYR_ERROR (*DL_callback)(GlyrMemCache * dl, struct _GlyrQuery * s); - -/* This is confusing gtk-doc */ -#ifndef __GTK_DOC_IGNORE__ - -/* - * SWIG STUFF - * Usually not worth viewing. - */ - - #ifdef COMING_FROM_SWIG - %extend GlyrQuery - { - GlyrQuery() - { - GlyrQuery my_query; - glyr_query_init(&my_query); - GlyrQuery * copy = malloc(sizeof(GlyrQuery)); - memcpy(copy,&my_query,sizeof(GlyrQuery)); - return copy; - } - - ~GlyrQuery() - { - glyr_query_destroy($self); - if($self != NULL) - free($self); - } - } - - %extend GlyrMemCache - { - GlyrMemCache() - { - return glyr_cache_new(); - } - ~GlyrMemCache() - { - glyr_cache_free($self); - } - } - - %extend GlyrFetcherInfo - { - GlyrFetcherInfo() - { - return glyr_info_get(); - } - - ~GlyrFetcherInfo() - { - glyr_info_free($self); - } - } - - %extend GlyrDatabase - { - GlyrDatabase() - { - return glyr_db_new(); - } - - ~GlyrDatabase() - { - glyr_db_destroy($self); - } - } - #endif -#endif - #ifdef __cplusplus } #endif diff -Nru glyr-0.9.8~git20120430.26294fe/README.textile glyr-0.9.8~git20120501.caeee4e/README.textile --- glyr-0.9.8~git20120430.26294fe/README.textile 2012-02-14 20:48:11.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/README.textile 2012-05-02 06:24:55.000000000 +0000 @@ -1,24 +1,33 @@ h1. Glyr is a searcheninge for musicrelated metadata -_The finest search you can buy for no money_ +The finest search you can buy for no money ^TM^ + +!https://github.com/sahib/glyr/blob/master/doc/screenshot.png([screenshot])! It comes both in a commandline interface tool and as a C library, both with an easy to use interface. The sort of metadata glyr is searching (and downloading) is usually the data you see in your musicplayer. And indeed, originally it was written to serve as internally library for a musicplayer, but has been extended to work as a standalone program which is able to download: -* cover art -* lyrics -* bandphotos -* artist biography -* album reviews -* tracklists of an album -* a list of albums from a specific artist. -* Tags, either related to artist, album or title -* relations, for example links to wikipedia -* similar artists -* similar songs -* guitartabs -* backdrops (large artist photos) +

+ + + + + + + + + + + + + + + + + +
GetterDescription
coverCoverart (front images supported only)
lyricsSongtext
artistphotosPhotos of a certain band (press or live)
artistbioArtist biography from various sites
reviewalbum reviews from various sites
albumlistA list of albums from a specific artist.
tagsTags, either related to artist, album or title
relationslinks to wikipedia, myspace, musicbrainz ...
similarartistssimilar artists
similarsongssimilar songs
tracklisttracklists of an album
guitartabsguitartabs in textual form
backdrops Large artist photos, suitable for backgrounds
+

*Terminology*: To prevent disambiguation the following terms are used below: @@ -30,13 +39,13 @@ h2. FEATURES -* Many built-in providers (38 at this time), high success-rate -* Portable: Windows and Linux are supported (Developement on Linux) see [1] for Mac OSX, +* Many built-in providers (46 at time of writing, ~30 distinct sites), high success-rate (the longer the search, the higher the risk :)) +* Portable: Windows and Linux are supported (Developement on Linux) see ~[1]~ for Mac OSX, * Fuzzy matching: Search providers with Levenshtein algorithm to eliminate typos and enhance search results. * Decent Unicode support: All sort of valid UTF8 is taken, and UTf8 output can be forced. * Fast Download: libcurl is used internally, and sources are searched in parallel, unneeded data is not downloaded if possible. -* Lightweight dependencies: libcurl and glib - typical linux systems have those installed. -* Download of a user defined amount of items, @glyrc cover -a Foo -b Bar -n 30@ loads 30 covers of album 'Bar' by artist 'Foo'. +* Lightweight dependencies: libcurl, glib and sqlite (for caching) - typical linux systems have those installed. +* Download of a user defined amount of items, @glyrc cover -a Foo -b Bar -n 30@ tries to load 30 covers of album 'Bar' by artist 'Foo'. * Grouped download: Query providers by descending Accuray / Speed; controllable by the user over the @qsratio@ * Optional download of images, URL is returned otherwise - so it can act a bit like a search-engine. * Free Software licensed under the terms of the GPLv3 @@ -55,7 +64,7 @@ See the "examples in src/examples":https://github.com/sahib/glyr/wiki for a quickstart. There's also a more "gentle (and brief) introduction.":https://github.com/sahib/glyr/wiki/Introduction-to-libglyr Also see the "API Reference":http://sahib.github.com/glyr/doc/html/index.html -*Please note:* The Api won't be guaranteed to be stable before version 1.0. +*Please note:* The Api won't be guaranteed to be stable before version 1.0. (currently 0.9.8) h3. glyrc: @@ -66,20 +75,20 @@ h3. Anyone using it already? -"GMPC":http://gmpc.wikia.com/wiki/Gnome_Music_Player_Client and "Pragha":http://pragha.wikispaces.com/, -and soon "Freya":https://github.com/studentkittens/Freya +"GMPC":http://gmpc.wikia.com/wiki/Gnome_Music_Player_Client, "Pragha":http://pragha.wikispaces.com/, and "Freya":https://github.com/studentkittens/Freya . h3. Glyr.. such a silly name! Why? -Indeed. Should have named it 'Glyros'. +Indeed. Should have named it 'Glyros' (too late, damnit). h3. Is it hard to write something with it? -A decent knowledge of C might be required, but the code is straight forward most of the time. -In the ruby wrapper you can almost use "english to order covers":http://sahib.github.com/glyr/ruby_example.html . +Some knowledge of C might be required, but the code is straight forward most of the time. + +Bash scripts are pretty straight-forward: +@glyrc cover --artist Equilibrium --album Sagas --write '/tmp/:artist:_:album:.:format:' --callback 'sxiv ":path:"'@ -Bash scripts are even easier: -@glyrc cover --artist Equilibrium --album Sagas@ +Additionally there are bindings to Python and Ruby (or there will be soon) h3. How..how am I supposed to use it? @@ -95,18 +104,19 @@ # Musicbrainz runs remotely on some server and uses a large database which is searched through lucene. Glyr is a client program which hops over several sites and does not cache anything, unless you do it yourself. You could of course let glyr run on a (remote) server, and cache all results to do something similiar. +# There is "coverarchive.org":www.coverartarchive.org , but it does not seem to fully work yet. But it will be accessible once it does. h2. AUTHOR See the AUTHORS file that comes in glyr's distribution. See also COPYING to know about your rights. -h2. CAN I HELP? +h2. I CAN HAZ HELP? h3. BUGS If you found one: _Meh. Sorry for that._ -If you file a bugreport: _Wow, thank you!_ +If you file a bugreport: _Hey, thank you!_ Use the "Issue Tracker":https://github.com/sahib/glyr/issues to share your find. Alternatively you may drop me a mail at @@ -118,12 +128,12 @@ Starting with lib/cover/lastfm.c isn't a bad idea either, because it is one of the very simple ones. __Take the usual Git(Hub) approach:__ -- Fork this project -- Make your changes -- Make a Pull request +# Fork this project +# Make your changes +# Make a Pull request If you're not familiar with git, or just don't like it, -you can also drop me a mail: +you can also send me the patch via mail: Thanks for any help in advance! @@ -145,15 +155,14 @@ As usual, no warranty is granted that this software works like expected. Refer to the GPLv3 copy you got with libglyr. It is "here.":https://github.com/sahib/glyr/blob/master/COPYING Glyr is just a way to find the data, it does not own any rights on the data it found. -Refer to the provider's terms of use. Every item you get from libglyr contains the name and a url to the provider. -
-
+**All retrieved items are copyrighted by their respective copyright owners.** + +Refer to the provider's terms of use. Every item you get from libglyr contains the name and a url to the provider, so lookup there terms of use there. +

h3. -h4. @footnotes@ - [1] Glyr has not been tested on Mac OSX yet. If you own a Mac, any help with 'porting' glyr is highly appreciated. My guess would be that no to almost no changes need to be done though. diff -Nru glyr-0.9.8~git20120430.26294fe/spec/C/check_api.c glyr-0.9.8~git20120501.caeee4e/spec/C/check_api.c --- glyr-0.9.8~git20120430.26294fe/spec/C/check_api.c 2012-01-30 07:29:10.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/spec/C/check_api.c 2012-05-02 06:24:55.000000000 +0000 @@ -102,9 +102,6 @@ GlyrMemCache * copy = glyr_cache_copy(test); fail_unless(memcmp(copy->data,test->data,test->size) == 0,"Should have the same data"); -#include -#include -#include fail_unless(copy->next == NULL,NULL); fail_unless(copy->prev == NULL,NULL); @@ -224,6 +221,8 @@ int main(void) { + init(); + int number_failed; Suite *s = create_test_suite(); diff -Nru glyr-0.9.8~git20120430.26294fe/spec/C/check_dbc.c glyr-0.9.8~git20120501.caeee4e/spec/C/check_dbc.c --- glyr-0.9.8~git20120430.26294fe/spec/C/check_dbc.c 2012-02-22 09:17:05.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/spec/C/check_dbc.c 2012-05-02 06:24:55.000000000 +0000 @@ -47,6 +47,14 @@ system("rm -rf /tmp/check/"); } + +static GlyrDatabase * setup_db(void) +{ + cleanup_db(); + system("mkdir -p /tmp/check"); + return glyr_db_init("/tmp/check"); +} + //-------------------- //-------------------- //-------------------- @@ -54,12 +62,12 @@ START_TEST(test_create_db) { - init(); - glyr_db_init(NULL); - GlyrDatabase * db = glyr_db_init("/tmp"); + GlyrDatabase * db = glyr_db_init("/tmp/"); glyr_db_destroy(db); glyr_db_destroy(NULL); + + system("rm /tmp/metadata.db"); } END_TEST @@ -67,16 +75,13 @@ START_TEST(test_simple_db) { - init(); GlyrQuery q; setup(&q,GLYR_GET_LYRICS,10); glyr_opt_artist(&q,"Equi"); glyr_opt_title(&q,"lala"); - cleanup_db(); + GlyrDatabase * db = setup_db(); - system("mkdir -p /tmp/check"); - GlyrDatabase * db = glyr_db_init("/tmp/check"); GlyrMemCache * ct = glyr_cache_new(); glyr_cache_set_data(ct,g_strdup("test"),-1); @@ -97,7 +102,6 @@ glyr_db_destroy(db); glyr_cache_free(ct); glyr_query_destroy(&q); - system("rm -r /tmp/check"); } END_TEST @@ -105,23 +109,18 @@ START_TEST(test_iter_db) { - init(); GlyrQuery q; setup(&q,GLYR_GET_LYRICS,10); glyr_opt_artist(&q,"Equi"); glyr_opt_title(&q,"lala"); + GlyrDatabase * db = setup_db(); GlyrQuery nugget; setup(&nugget,GLYR_GET_COVERART,40); glyr_opt_artist(&nugget,"A very special artist"); glyr_opt_album(&nugget,"A very special album"); - cleanup_db(); - - system("mkdir -p /tmp/check"); - GlyrDatabase * db = glyr_db_init("/tmp/check"); - GTimer * insert_time = g_timer_new(); const int N = 5000; @@ -206,7 +205,6 @@ g_timer_destroy(insert_time); g_timer_destroy(grain_time); - cleanup_db(); } END_TEST @@ -216,14 +214,12 @@ { const int N = 10; - system("mkdir -p /tmp/check"); + GlyrDatabase * db = setup_db(); GlyrQuery q; glyr_query_init(&q); setup(&q,GLYR_GET_LYRICS,N); - GlyrDatabase * db = glyr_db_init("/tmp/check"); - for(int i = 0; i < N; ++i) { int rate = (i / 2) + 1; @@ -260,7 +256,6 @@ } glyr_free_list(list); - cleanup_db(); } END_TEST @@ -269,7 +264,7 @@ /* Write artist|album|title, select only artist|title */ START_TEST(test_intelligent_lookup) { - init(); + GlyrDatabase * db = setup_db(); GlyrQuery alt; glyr_query_init(&alt); @@ -286,9 +281,6 @@ GlyrMemCache * subject = glyr_cache_new(); glyr_cache_set_data(subject,g_strdup("These are lyrics. Really."),-1); - cleanup_db(); - system("mkdir -p /tmp/check"); - GlyrDatabase * db = glyr_db_init("/tmp/check"); glyr_db_insert(db,&alt,subject); GlyrMemCache * one = glyr_db_lookup(db,&alt); @@ -309,7 +301,6 @@ glyr_query_destroy(&alt); glyr_db_destroy(db); - cleanup_db(); } END_TEST @@ -317,11 +308,8 @@ START_TEST(test_db_editplace) { - cleanup_db(); - init(); - system("mkdir -p /tmp/check"); - GlyrDatabase * db = glyr_db_init("/tmp/check"); + GlyrDatabase * db = setup_db(); if(db != NULL) { fail_unless(count_db_items(db) == 0, NULL); @@ -357,7 +345,6 @@ glyr_cache_free(test_data); glyr_db_destroy(db); } - cleanup_db(); } END_TEST @@ -385,6 +372,8 @@ int main(void) { + init(); + int number_failed; Suite * s = create_test_suite(); @@ -394,5 +383,7 @@ number_failed = srunner_ntests_failed(sr); srunner_free (sr); + + cleanup_db(); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }; diff -Nru glyr-0.9.8~git20120430.26294fe/spec/C/check_opt.c glyr-0.9.8~git20120501.caeee4e/spec/C/check_opt.c --- glyr-0.9.8~git20120430.26294fe/spec/C/check_opt.c 2011-12-20 10:59:19.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/spec/C/check_opt.c 2012-05-02 06:24:55.000000000 +0000 @@ -55,9 +55,6 @@ START_TEST(test_glyr_opt_dlcallback) { - glyr_init(); - atexit(glyr_cleanup); - GlyrQuery q; GlyrMemCache * list; gint length = -1; @@ -127,9 +124,6 @@ START_TEST(test_glyr_opt_number) { - glyr_init(); - atexit(glyr_cleanup); - GlyrQuery q; int length = 0; setup(&q,GLYR_GET_ARTIST_PHOTOS,4); @@ -147,9 +141,6 @@ START_TEST(test_glyr_opt_allowed_formats) { - glyr_init(); - atexit(glyr_cleanup); - GlyrQuery q; setup(&q,GLYR_GET_COVERART,1); glyr_opt_verbosity(&q,0); @@ -168,9 +159,6 @@ START_TEST(test_glyr_opt_proxy) { - glyr_init(); - atexit(glyr_cleanup); - GlyrQuery q; setup(&q,GLYR_GET_COVERART,1); glyr_opt_verbosity(&q,0); @@ -206,6 +194,8 @@ int main(void) { + init(); + int number_failed; Suite * s = create_test_suite(); diff -Nru glyr-0.9.8~git20120430.26294fe/spec/C/test_common.c glyr-0.9.8~git20120501.caeee4e/spec/C/test_common.c --- glyr-0.9.8~git20120430.26294fe/spec/C/test_common.c 2012-01-30 07:29:10.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/spec/C/test_common.c 2012-05-02 06:24:55.000000000 +0000 @@ -26,12 +26,9 @@ void setup(GlyrQuery * q, GLYR_GET_TYPE type, int num) { - glyr_init(); - atexit(glyr_cleanup); - glyr_query_init(q); glyr_opt_artist(q,"Equilibrium"); - //glyr_opt_album(q, "Sagas"); + glyr_opt_album(q, "Sagas"); glyr_opt_title(q, "Wurzelbert"); glyr_opt_type(q, type); glyr_opt_number(q,num); diff -Nru glyr-0.9.8~git20120430.26294fe/spec/Ruby/cover_spec.rb glyr-0.9.8~git20120501.caeee4e/spec/Ruby/cover_spec.rb --- glyr-0.9.8~git20120430.26294fe/spec/Ruby/cover_spec.rb 2012-03-30 02:08:57.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/spec/Ruby/cover_spec.rb 2012-05-02 06:24:55.000000000 +0000 @@ -47,7 +47,7 @@ list.should be_an_instance_of Array list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 + list.size.should == 1 show_in_sxiv(list.first) end @@ -58,7 +58,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end @@ -74,7 +74,7 @@ list.should be_an_instance_of Array list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 + list.size.should == 1 show_in_sxiv(list.first) end @@ -85,7 +85,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end @@ -101,35 +101,7 @@ list.should be_an_instance_of Array list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 - - show_in_sxiv(list.first) - end - - it "Don't know this cover" do - @spit.artist = "The band they called horst" - @spit.album = "Album" - list = @spit.get - - list.should be_an_instance_of Array - list.size.should equal 0 - end - end - -=begin - describe "amazon" do - before :each do - @spit.from = "amazon" - end - - it "should test a pagehit" do - @spit.artist = "Adele" - @spit.album = "21" - list = @spit.get - - list.should be_an_instance_of Array - list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 + list.size.should == 1 show_in_sxiv(list.first) end @@ -140,12 +112,9 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end -=end - - # coverhnt seems to be down. describe "discogs" do before :each do @@ -159,7 +128,7 @@ list.should be_an_instance_of Array list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 + list.size.should == 1 show_in_sxiv(list.first) end @@ -170,7 +139,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end @@ -186,7 +155,7 @@ list.should be_an_instance_of Array list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 + list.size.should == 1 show_in_sxiv(list.first) end @@ -197,7 +166,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end @@ -213,7 +182,7 @@ list.should be_an_instance_of Array list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 + list.size.should == 1 show_in_sxiv(list.first) end @@ -227,7 +196,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end @@ -243,7 +212,7 @@ list.should be_an_instance_of Array list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 + list.size.should == 1 show_in_sxiv(list.first) end @@ -257,7 +226,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end @@ -272,7 +241,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 1 + list.size.should == 1 list.first.should be_an_instance_of Glyros::GlyrMemCache show_in_sxiv(list.first) @@ -284,7 +253,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end @@ -312,7 +281,7 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 end end @@ -328,7 +297,7 @@ list.should be_an_instance_of Array list.first.should be_an_instance_of Glyros::GlyrMemCache - list.size.should equal 1 + list.size.should == 1 show_in_sxiv(list.first) end @@ -342,7 +311,37 @@ list = @spit.get list.should be_an_instance_of Array - list.size.should equal 0 + list.size.should == 0 + end + end + + describe "slothradio" do + before :each do + @spit.from = "slothradio" + end + + it "should test a pagehit" do + @spit.artist = "Akrea" + @spit.album = "Lebenslinie" + list = @spit.get + + list.should be_an_instance_of Array + list.first.should be_an_instance_of Glyros::GlyrMemCache + list.size.should == 1 + + show_in_sxiv(list.first) + end + + it "Don't know this cover" do + @spit.artist = "RandomArtist" + + # Yes, Im cheating here, but did you tried to + # get 0 results with an valid album name? no? + @spit.album = "Bloghregnfehegle" + list = @spit.get + + list.should be_an_instance_of Array + list.size.should == 0 end end end diff -Nru glyr-0.9.8~git20120430.26294fe/src/glyrc/autohelp.c glyr-0.9.8~git20120501.caeee4e/src/glyrc/autohelp.c --- glyr-0.9.8~git20120430.26294fe/src/glyrc/autohelp.c 2012-02-04 03:41:10.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/src/glyrc/autohelp.c 2012-05-02 06:24:55.000000000 +0000 @@ -1,177 +1,107 @@ /*********************************************************** -* This file is part of glyr -* + a commnadline tool and library to download various sort of musicrelated metadata. -* + Copyright (C) [2011] [Christopher Pahl] -* + Hosted at: https://github.com/sahib/glyr -* -* glyr is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* glyr is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with glyr. If not, see . -**************************************************************/ + * This file is part of glyr + * + a commnadline tool and library to download various sort of musicrelated metadata. + * + Copyright (C) [2011] [Christopher Pahl] + * + Hosted at: https://github.com/sahib/glyr + * + * glyr is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * glyr is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with glyr. If not, see . + **************************************************************/ #include -#include "autohelp.h" +#include +#include "../../lib/glyr.h" +#include "../../lib/misc.h" -#include "../../lib/stringlib.h" - -/* Copied from lib/stringlib.c - more details there */ -gsize levenshtein_strcmp(const gchar * s, const gchar * t) +void suggest_other_getter(GlyrQuery * query, const char * wrong_input) { - /* Get strlen */ - int n = (s) ? strlen(s)+1 : 0; - int m = (t) ? strlen(t)+1 : 0; - - /* Nothing to compute really */ - if (n == 0) return m; - if (m == 0) return n; - - /* String matrix */ - int d[n][m]; - int i,j; - - /* Init first row|column to 0...n|m */ - for (i = 0; i < n; i++) d[i][0] = i; - for (j = 0; j < m; j++) d[0][j] = j; - - for (i = 1; i < n; i++) + if(query->verbosity <= 0) { - /* Current char in string s */ - char cats = s[i-1]; + return; + } - for (j = 1; j < m; j++) + GlyrFetcherInfo * fetcher = glyr_info_get(); + if(fetcher != NULL) + { + gboolean did_you_mean_printed = FALSE; + GlyrFetcherInfo * it = fetcher; + while(it != NULL) { - /* Do -1 only once */ - int jm1 = j-1, - im1 = i-1; - - /* a = above cell, b = left cell, c = left above cell */ - int a = d[im1][j] + 1, - b = d[i][jm1] + 1, - c = d[im1][jm1] + (t[jm1] != cats); - - /* Now compute the minimum of a,b,c and set MIN(a,b,c) to cell d[i][j] */ - d[i][j] = (a < b) ? MIN(a,c) : MIN(b,c); + if(glyr_levenshtein_strnormcmp(wrong_input,it->name) < 7) + { + if(did_you_mean_printed == FALSE) + { + g_print("\nDid you mean this?\n"); + did_you_mean_printed = TRUE; + } + g_print(" - %s\n",it->name); + } + it = it->next; } + glyr_info_free(fetcher); } - - /* The result is stored in the very right down cell */ - return d[n-1][m-1]; } -/* ------------------------------------------------------------- */ +/*-----------------------------------------*/ -gsize levenshtein_strcasecmp(const gchar * string, const gchar * other) +void suggest_other_provider(GlyrQuery * query, const char * wrong_input) { - gsize diff = 100; - if(string != NULL && other != NULL) - { - /* Lowercase UTF8 string might have more or less bytes! */ - gchar * lower_string = g_ascii_strdown(string,-1); - gchar * lower_other = g_ascii_strdown(other, -1); - - if(lower_string && lower_other) - { - diff = levenshtein_strcmp(lower_string, lower_other); - } - - /* Free 'em */ - g_free(lower_string); - g_free(lower_other); - } - return diff; -} - -/* ------------------------------------------------------------- */ + if(query->verbosity <= 0) + { + return; + } -void suggest_other_getter(GlyrQuery * query, const char * wrong_input) -{ - if(query->verbosity <= 0) - { - return; - } - - GlyrFetcherInfo * fetcher = glyr_info_get(); - if(fetcher != NULL) - { - gboolean did_you_mean_printed = FALSE; - GlyrFetcherInfo * it = fetcher; - while(it != NULL) - { - if(levenshtein_strcasecmp(wrong_input,it->name) < 7) - { - if(did_you_mean_printed == FALSE) - { - g_print("\nDid you mean this?\n"); - did_you_mean_printed = TRUE; - } - g_print(" - %s\n",it->name); - } - it = it->next; - } - glyr_info_free(fetcher); - } -} + GlyrFetcherInfo * fetcher = glyr_info_get(); + GlyrFetcherInfo * it = fetcher; + while(it != NULL) + { + if(it->type == query->type) + { + break; + } -/*-----------------------------------------*/ + it = it->next; + } -void suggest_other_provider(GlyrQuery * query, const char * wrong_input) -{ - if(query->verbosity <= 0) - { - return; - } - - GlyrFetcherInfo * fetcher = glyr_info_get(); - GlyrFetcherInfo * it = fetcher; - while(it != NULL) - { - if(it->type == query->type) - { - break; - } - - it = it->next; - } - - if(it != NULL && wrong_input) - { - gboolean did_you_mean_printed = FALSE; - GlyrSourceInfo * head = it->head; - GHashTable * key_table = g_hash_table_new(g_direct_hash,g_direct_equal); - while(head != NULL) - { - gsize offset = 0; - gsize length = strlen(wrong_input); - gchar *token = NULL; - while((token = get_next_word(wrong_input,GLYR_DEFAULT_FROM_ARGUMENT_DELIM,&offset,length)) != NULL) - { - if(levenshtein_strcasecmp(token,head->name) < 5 && - g_hash_table_lookup(key_table,head->name) == NULL) - { - if(did_you_mean_printed == FALSE) - { - g_print("\nDid you mean this?\n"); - did_you_mean_printed = TRUE; - } - g_print(" - %s\n",head->name); - g_hash_table_insert(key_table,head->name,head); - } - g_free(token); - } - head = head->next; - } - g_hash_table_destroy(key_table); - } - glyr_info_free(fetcher); + if(it != NULL && wrong_input) + { + gboolean did_you_mean_printed = FALSE; + GlyrSourceInfo * head = it->head; + GHashTable * key_table = g_hash_table_new(g_direct_hash,g_direct_equal); + while(head != NULL) + { + gchar ** tokens = g_strsplit(wrong_input,GLYR_DEFAULT_FROM_ARGUMENT_DELIM,0); + for(int i = 0; tokens[i] != NULL; i++) + { + gchar * token = tokens[i]; + if(glyr_levenshtein_strnormcmp(token,head->name) < 5 && + g_hash_table_lookup(key_table,head->name) == NULL) + { + if(did_you_mean_printed == FALSE) + { + g_print("\nDid you mean this?\n"); + did_you_mean_printed = TRUE; + } + g_print(" - %s\n",head->name); + g_hash_table_insert(key_table,head->name,head); + } + } + head = head->next; + g_strfreev(tokens); + } + g_hash_table_destroy(key_table); + } + glyr_info_free(fetcher); } /*-----------------------------------------*/ diff -Nru glyr-0.9.8~git20120430.26294fe/src/glyrc/escape.c glyr-0.9.8~git20120501.caeee4e/src/glyrc/escape.c --- glyr-0.9.8~git20120430.26294fe/src/glyrc/escape.c 2012-05-01 01:43:47.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/src/glyrc/escape.c 2012-05-02 06:24:55.000000000 +0000 @@ -18,7 +18,6 @@ * along with glyr. If not, see . **************************************************************/ - #include #include #include @@ -96,7 +95,7 @@ .escape_slashes = escp \ } \ -struct { +struct escape_table { const char * name; ExpandFunction func; bool escape_slashes; @@ -116,6 +115,8 @@ EXPAND(path,false) }; +const size_t _escape_table_size = (sizeof(_escapes)/sizeof(struct escape_table)); + //////////////////////// static void replace_char(char * string, gchar a, gchar b) @@ -123,7 +124,7 @@ if(string != NULL) { gsize str_len = strlen(string); - for(gsize i = 0; i < str_len; i++) + for(size_t i = 0; i < str_len; i++) { if(string[i] == a) { @@ -135,13 +136,16 @@ //////////////////////// -static char * lookup_escape(const char * escape, size_t escape_len, GlyrQuery * q, GlyrMemCache * c) +static char * lookup_escape(const char * escape, size_t escape_len, GlyrQuery * q, GlyrMemCache * c, bool * is_valid) { - size_t table_size = sizeof(_escapes) / (sizeof(char*) + sizeof(ExpandFunction)); - for(size_t i = 0; i < table_size; ++i) + for(size_t i = 0; i < _escape_table_size; ++i) { + if(_escapes[i].name == NULL) + continue; + if(strncmp(escape,_escapes[i].name,escape_len) == 0) { + *is_valid = true; char * result = _escapes[i].func(q,c); if(_escapes[i].escape_slashes) { @@ -150,6 +154,7 @@ return result; } } + *is_valid = false; return NULL; } @@ -176,22 +181,24 @@ { size_t maxbufsize = estimate_alloc_size(path); size_t off = 0; + bool always_copy = false; retv = g_malloc0(maxbufsize+1); size_t path_len = strlen(path); for(size_t i = 0; i < path_len; ++i) { - if(path[i] == ':') + if(always_copy == false && path[i] == ':') { const char * escape_begin = &path[i+1]; char * end_colon = strchr(escape_begin,':'); if(end_colon != NULL) { + bool is_valid = false; size_t escape_len = end_colon - escape_begin; if(escape_len == 0) continue; - char * subsitution = lookup_escape(escape_begin,escape_len,q,c); + char * subsitution = lookup_escape(escape_begin,escape_len,q,c,&is_valid); if(subsitution != NULL) { size_t subs_len = strlen(subsitution); @@ -199,8 +206,18 @@ off += subs_len; g_free(subsitution); } + else if(is_valid == false) + { + strncpy(retv+off,&path[i],escape_len + 2); + off += escape_len + 2; + } i += escape_len + 1; } + else + { + always_copy = true; + i--; + } } else { diff -Nru glyr-0.9.8~git20120430.26294fe/src/glyrc/glyrc.c glyr-0.9.8~git20120501.caeee4e/src/glyrc/glyrc.c --- glyr-0.9.8~git20120430.26294fe/src/glyrc/glyrc.c 2012-05-01 01:43:47.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/src/glyrc/glyrc.c 2012-05-02 06:24:55.000000000 +0000 @@ -49,18 +49,18 @@ /* --callback and --write escape strings */ #include "escape.h" -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// #define SET_IF_NULL(VAR, SET_TO) (VAR) = ((VAR) ? (VAR) : (SET_TO)) #define LOG_DOMAIN "Glyrc" -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// /* Shared data of main/callback */ typedef struct @@ -86,17 +86,17 @@ static GlyrQuery * glob_lastQuery = NULL; -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ -//* ------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// void log_func(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message, gpointer user_data) { fputs(message,GLYR_OUTPUT); } -//* ------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// static void message(gint verbosity, GlyrQuery * s, const char * fmt, ...) { @@ -109,7 +109,7 @@ } } -//* ------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// #ifndef G_OS_WIN32 #define STACK_FRAME_SIZE 20 @@ -134,9 +134,9 @@ } #endif -//* --------------------------------------------------------- */ -//* --------------------------------------------------------- */ -//* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// static void sig_handler(int signal) { @@ -160,7 +160,7 @@ exit(EXIT_FAILURE); } -/* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// static void init_signals(void) { @@ -170,7 +170,7 @@ signal(SIGFPE, sig_handler); } -//* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// static void handle_cancel(int signo) { @@ -181,7 +181,7 @@ } } -//* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// static void init_cancel_handler(GlyrQuery * p_lastQuery) { @@ -189,7 +189,7 @@ signal(SIGINT, handle_cancel); } -//* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// // --------------------------------------------------------- // // --------------------------------------------------------- // @@ -204,9 +204,9 @@ } -//* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// // --------------------------------------------------------- // -/* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// void help_short(GlyrQuery * s) { @@ -243,7 +243,7 @@ IN" * cksum : a md5sum of the data\n" IN" * rating : (Usually 0)\n" IN" * duration : (Only for tracks) Duration in seconds\n" - IN" * number : An index incremented with each item (starting with 0)\n" + IN" * number : An index incremented with each item (starting with 1)\n" IN"\n" IN" The default format is ':artist:_:album:_:title:_:type:_:number:.:format:'\n" IN" Strings containing '/' are replaced with '|' automatically,\n" @@ -300,7 +300,7 @@ #undef IN } -/* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// static void visualize_from_options(void) { @@ -319,7 +319,7 @@ message(-1,NULL," # %s [%c]\n",elem1->name,elem1->key); message(-1,NULL," - Quality: %d\n",elem1->quality); message(-1,NULL," - Speed: %d\n",elem1->speed); - message(-1,NULL," - Type: %d\n",elem1->type); + message(-1,NULL," - Type: %s\n",glyr_get_type_to_string(elem1->type)); } message(-1,NULL," + Requires: (%s%s%s)\n", @@ -347,7 +347,7 @@ glyr_info_free(info); } -/* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// static void parse_commandline_general(int argc, char * const * argv, GlyrQuery * glyrs, callback_data_t * CBData, GlyrDatabase ** db) { @@ -527,9 +527,9 @@ } } -/* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// // --------------------------------------------------------- // -/* -------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// static GLYR_ERROR callback(GlyrMemCache * c, GlyrQuery * s) { @@ -608,9 +608,9 @@ return GLYRE_OK; } -/* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// // --------------------------------------------------------- // -/* -------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// GLYR_GET_TYPE get_type_from_string(const char * string) { @@ -638,9 +638,9 @@ return result; } -/* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// // --------------------------------------------------------- // -/* -------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// static gint db_foreach_callback(GlyrQuery * q, GlyrMemCache * c, void * p) { @@ -653,7 +653,7 @@ return 0; } -/*----------------------*/ +////////////////////////////////////// static void do_iterate_over_db(GlyrDatabase * db) { @@ -665,7 +665,7 @@ message(-1,NULL,"\n"); } -/*----------------------*/ +////////////////////////////////////// static void do_cache_interface(const char * operation, GlyrQuery * q, GlyrDatabase * db) { @@ -720,7 +720,7 @@ } -/*----------------------*/ +////////////////////////////////////// static bool parse_type_argument(const char * argvi, GlyrQuery * qp) { @@ -748,7 +748,7 @@ return retv; } -/*----------------------*/ +////////////////////////////////////// static GlyrMemCache * concatenate_list(GlyrMemCache * list) { @@ -778,14 +778,14 @@ return retv; } -/*----------------------*/ +////////////////////////////////////// static void global_cleanup(void) { set_write_path(NULL); } -/*----------------------*/ +////////////////////////////////////// int main(int argc, char * argv[]) { @@ -913,6 +913,6 @@ return exit_code; } -//* --------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// // ------------------End of program-------------------------- // -/* ---------------------------------------------------------- */ +//////////////////////////////////////////////////////////////// diff -Nru glyr-0.9.8~git20120430.26294fe/swig/README.textile glyr-0.9.8~git20120501.caeee4e/swig/README.textile --- glyr-0.9.8~git20120430.26294fe/swig/README.textile 2012-04-02 23:09:52.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/swig/README.textile 2012-05-02 06:24:55.000000000 +0000 @@ -1,28 +1,11 @@ h2. SWIG BINDINGS -Glyr provides a interface file (glyr.i) to provide bindings for languages other than C/C++ +Glyr provides a interface file (generic_glyr.i) to provide bindings for languages other than C/C++ To generate the wrapping code you should install SWIG and the devel headers of your scripting language. (+ all dependecies of glyr..) -h4. Self compiling: +Currently these languages have "supported" bindings: +* Python +* Ruby -You don't need this, except if you want write bindings to other languages. - -# let SWIG generate the wrapper code -# This will create a file called glyr_wrap.c -# @swig -ruby ruby_glyr.i@ - -# Compile the wrapper code, -I is the includedir of the Ruby headers, -fpic is needed -> @gcc -c ruby_glyr_wrap.c -I/usr/include/ruby-1.9.1/ -o glyr_wrap.o $(pkg-config --cflags libglyr) -fPIC -Wall -W -Wno-unused-parameter@ - -# Create the library by linking the .o against all needed libs: -> @gcc -shared -Wl,-soname,glyros -o glyros.so glyr_wrap.o $(pkg-config --libs libglyr) -lruby@ - -If everything went fine you should have a 'glubyr.so' in this directory. -Now you can load it in Ruby: - -> irb -r rubygems ->>> require './glyros.so' ->>> Glubyr::version() -=> "Version 0.8.7 (Horny Hornet [beta]) of [Sep 19 2011] compiled at [12:04:08]" ->>> exit +Each of them have a subdirectory here. diff -Nru glyr-0.9.8~git20120430.26294fe/swig/ruby/README.textile glyr-0.9.8~git20120501.caeee4e/swig/ruby/README.textile --- glyr-0.9.8~git20120430.26294fe/swig/ruby/README.textile 1970-01-01 00:00:00.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/swig/ruby/README.textile 2012-05-02 06:24:55.000000000 +0000 @@ -0,0 +1,29 @@ +h2. Ruby bindings to libglyr + +(Not really useful yet, only used for the testcases at the moment) + +h4. Self compiling: + +You don't need this, except if you want write bindings to other languages. + +# let SWIG generate the wrapper code +# This will create a file called glyr_wrap.c +# @swig -ruby ruby_glyr.i@ + +# Compile the wrapper code, -I is the includedir of the Ruby headers, -fpic is needed +> @gcc -c ruby_glyr_wrap.c -o glyr_wrap.o $(pkg-config --cflags libglyr ruby-1.9) -fPIC -Wall@ + +# Create the library by linking the .o against all needed libs: +> @gcc -shared -Wl,-soname,glyros -o glyros.so glyr_wrap.o $(pkg-config --libs libglyr ruby-1.9)@ + +If everything went fine you should have a 'glyros.so' in this directory. +Now you can load it in Ruby: + +@> irb -r rubygems@ +@>>> require './glyros.so'@ +@>>> Glyros::glyr_version() @ +@=> "Version 0.8.7 (Horny Hornet [beta]) of [Sep 19 2011] compiled at [12:04:08]"@ +@>>> exit@ + +Note that this is outdated, but will be moved to an separate repository with a proper gem, +and perhaps even a nice wrapper class. diff -Nru glyr-0.9.8~git20120430.26294fe/swig/ruby/ruby_glyr.i glyr-0.9.8~git20120501.caeee4e/swig/ruby/ruby_glyr.i --- glyr-0.9.8~git20120430.26294fe/swig/ruby/ruby_glyr.i 2012-04-30 02:42:56.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/swig/ruby/ruby_glyr.i 2012-05-02 06:24:55.000000000 +0000 @@ -7,20 +7,17 @@ /* module name */ %module glyros -/* Inform headers */ -#define COMING_FROM_SWIG - /* let wrapper file compile */ -%{ #include "../lib/glyr.h" %} -%{ #include "../lib/cache.h" %} -%{ #include "../lib/testing.h" %} +%{ #include "../../lib/glyr.h" %} +%{ #include "../../lib/cache.h" %} +%{ #include "../../lib/testing.h" %} /* parse headers */ -%include "../lib/glyr.h" -%include "../lib/cache.h" -%include "../lib/types.h" -%include "../lib/config.h" -%include "../lib/testing.h" +%include "../../lib/glyr.h" +%include "../../lib/cache.h" +%include "../../lib/types.h" +%include "../../lib/config.h" +%include "../../lib/testing.h" %{ diff -Nru glyr-0.9.8~git20120430.26294fe/TODO glyr-0.9.8~git20120501.caeee4e/TODO --- glyr-0.9.8~git20120430.26294fe/TODO 2012-04-29 08:55:24.000000000 +0000 +++ glyr-0.9.8~git20120501.caeee4e/TODO 2012-05-02 06:24:55.000000000 +0000 @@ -1,2 +1,3 @@ - Keep providers updated :) -- Expose utils like levenshtein to the API +- Replace cover:musicbrainz with coverartarchive once they got it working... (d'oh') +- Fix magistrix and minor lyrics annoyance