Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sahib committed May 17, 2011
1 parent 22693f8 commit 7ebf353
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 109 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Expand Up @@ -79,3 +79,7 @@ Found some time to work a bit here :-)
For normal users: Well, the duplicate check is now as fast as rmlint :-P
+ getopt_long is now getopt_long_only (no --arguments, just -argument or -a)
+ removed call_direct. It's of no use. Not even for devs.

2011/05/16
----------
+ removed wikipedia.c for ainfo - never worked. Better provide a link and (relation getter) and let the user render the site (too many information would get lost if glyr would need to parse it)
1 change: 0 additions & 1 deletion CMakeLists.txt
Expand Up @@ -76,7 +76,6 @@ SET(LIB_SOURCE_LOCATIONS
"${DIR_ROOT}/md5.c"
# extensions
"${DIR_AINFO}/lastfm.c"
"${DIR_AINFO}/wikipedia.c"
"${DIR_AINFO}/allmusic_com.c"
"${DIR_AINFO}/lyricsreg.c"
"${DIR_SIMILIAR}/lastfm.c"
Expand Down
8 changes: 1 addition & 7 deletions TODO
@@ -1,16 +1,10 @@
-------- future
- Take a random musicplayer project and devel a glyr-plugin (hi there gmpc..)
- cmake install -- done
- cmake portable..
- docu

------ plans
- paths for tag/relations in glyrc
- default settings for getters (like number=-1 for track/albumlist)
- ainfo/wikipedia.c still not working

------- urgent
- test lyrics (klingelt�ne... *chrm*)
- rewrite of GUI in C and gtk3 (Modi get your ass here!)
- full amazon support
- full amazon support *sigh* - this API just sucks and is applied Brain-BDSM
- update swig
4 changes: 1 addition & 3 deletions lib/ainfo.c
Expand Up @@ -28,7 +28,6 @@

#include "ainfo/lastfm.h"
#include "ainfo/allmusic_com.h"
#include "ainfo/wikipedia.h" // currently disabled
#include "ainfo/lyricsreg.h"

#define WKED "<ol class=\"references\">"
Expand All @@ -38,9 +37,8 @@

// Add your's here
GlyPlugin ainfo_providers[] = {
// full name key coloredname use? parser callback geturl callback free url?
// full name key coloredname use? parser callback geturl callback free url?
{"lastfm", "l", "last"C_R"."C_"fm", false, {ainfo_lastfm_parse, ainfo_lastfm_url, NULL, true }, GRP_SAFE | GRP_FAST},
// {"wikipedia", "w", "wikipedia", false, {ainfo_wikipedia_parse, ainfo_wikipedia_url, WKED, false}, GRP_SAFE | GRP_FAST}, // not working yet.
{"allmusic", "m", C_"all"C_C"music", false, {ainfo_allmusic_parse, ainfo_allmusic_url, NULL, false}, GRP_USFE | GRP_SLOW},
{"lyricsreg", "r", C_"lyricsreg", false, {ainfo_lyricsreg_parse, ainfo_lyricsreg_url, LGED, false}, GRP_USFE | GRP_FAST},
{ NULL, NULL,NULL, false, {NULL, NULL, NULL, false}, GRP_NONE | GRP_NONE},
Expand Down
40 changes: 0 additions & 40 deletions lib/ainfo/wikipedia.c

This file was deleted.

27 changes: 0 additions & 27 deletions lib/ainfo/wikipedia.h

This file was deleted.

2 changes: 1 addition & 1 deletion lib/glyr.c
Expand Up @@ -236,7 +236,7 @@ int GlyOpt_lang(GlyQuery * s, char * langcode)
int GlyOpt_number(GlyQuery * s, unsigned int num)
{
if(s == NULL) return GLYRE_EMPTY_STRUCT;
s->number = num == 0 ? UINT_MAX : num;
s->number = num == 0 ? INT_MAX : num;
return GLYRE_OK;
}

Expand Down
5 changes: 4 additions & 1 deletion lib/glyr.h
Expand Up @@ -39,7 +39,7 @@ extern "C"

// Cleanup curl, libglyr does not use any global vars,
// but libcurl does. That's the only reason why there is a init/cleanup:
// both aren't threadsafe.
// both aren't threadsafe. (It's safe to Init at programstart and to do atexit(Gly_cleanup))
void Gly_cleanup(void);

// the actual main of glyr
Expand Down Expand Up @@ -106,6 +106,9 @@ extern "C"
// write binary file, this is for use in language bindings mainly, which partly can't easily write them themself
int Gly_write(GlyQuery * s, GlyMemCache * data, const char * path);

// Also include the translation API
#include "translate.h"


#ifdef _cplusplus
}
Expand Down
14 changes: 10 additions & 4 deletions lib/translate.c
Expand Up @@ -14,8 +14,10 @@
#include "types.h"
#include "core.h"

// Please use your own key if you copy this - it's free!
#define GOOGLE_TRANSLATE_API_KEY "AIzaSyDzfBNb-W5G9pvZY6KGbEoRK4JvOIhUsjI"

/* Module prototypes */
static const char * gtrans_get_trans_url(const char * input, const char * from, const char * to);
static const char * gtrans_get_detector_url(const char * input);
static char * json_get_single_value(char * sval, size_t keylen);
Expand All @@ -32,7 +34,7 @@ static const char * gtrans_get_trans_url(const char * input, const char * from,
if(escape_input != NULL) {
resultURL = strdup_printf("https://www.googleapis.com/language/translate/v2?key=%s%s%s&target=%s&prettyprint=true&q=%s",
GOOGLE_TRANSLATE_API_KEY,
(from==NULL) ? "" : "&source=", // &source field can be omitted
(from==NULL) ? "" : "&source=", // &source field can be omitted, autodetect then.
(from==NULL) ? "" : from,
to,escape_input
);
Expand Down Expand Up @@ -148,12 +150,16 @@ static char * gtrans_parse_detector_json(GlyMemCache * cache, float * correctnes
#define BLOCK_BUF 500
#define NEWLINE_MARKUP "__"
/* Modifies $to_translate with the translation */
void Gly_translate_text(GlyQuery * s, GlyMemCache * to_translate)
void Gly_gtrans_translate(GlyQuery * s, GlyMemCache * to_translate)
{
char * concat_chain = NULL;
char block_buf[BLOCK_BUF+2];
if(s && to_translate && s->gtrans.target) {

// so yesterday I translated an image. O RLY?
if(to_translate->is_image)
return;

// no need to translate, eh?
if(s->gtrans.source && !strcmp(s->gtrans.target,s->gtrans.source))
return;
Expand Down Expand Up @@ -243,7 +249,7 @@ void Gly_translate_text(GlyQuery * s, GlyMemCache * to_translate)
/* ------------------------------------------------------------------- */

/* Ask google translator what language we are dealing with, NULL if unknown */
char * Gly_lookup_language(GlyQuery * s, const char * snippet, float * correctness)
char * Gly_gtrans_lookup(GlyQuery * s, const char * snippet, float * correctness)
{
char * result_lang = NULL;
if(s && snippet) {
Expand All @@ -262,7 +268,7 @@ char * Gly_lookup_language(GlyQuery * s, const char * snippet, float * correctne

/* ------------------------------------------------------------------- */

char ** Gly_list_supported_languages(GlyQuery * s)
char ** Gly_gtrans_list(GlyQuery * s)
{
char ** result_list = NULL;
if(s != NULL) {
Expand Down
28 changes: 25 additions & 3 deletions lib/translate.h
@@ -1,9 +1,31 @@
#ifndef G_TRANSLATE_H
#define G_TRANSLATE_H

// gtrans method family

#include "types.h"
void Gly_translate_text(GlyQuery * s, GlyMemCache * to_translate);
char * Gly_lookup_language(GlyQuery * s, const char * snippet, float * correctness);
char ** Gly_list_supported_languages(GlyQuery * s);
/* Takes the cache struct to_translate and translate the text according to the setting stored in the GlyQuery s *
It will be translated IF to_translate is not an image (is_image == false) and the targetlang != sourcelang, *
and both languages are valid. Note that the usage of these functions is restricted by google to a certain limit *
being at the moment at 100,000 chars per day and IP.
The buffer is directly modified so make copies before if you need.
*/
void Gly_gtrans_translate(GlyQuery * s, GlyMemCache * to_translate);

/* Ask google what language the snippet given as const char is written in *
Optionally you can give a float pointer where the probability of the *
result being correct is stored in, (from 0.0 to 1.0), long snippets *
usually give better results. The result is returned as newly allocated *
char * - free it.
*/
char * Gly_gtrans_lookup(GlyQuery * s, const char * snippet, float * correctness);

/* Queries google for a list of all supported languages *
Returned as a list of char pointers, free both the *
single strings and the return value. *
If you only want to know all languages: *
'glyrc gtrans list' does the same. *
*/
char ** Gly_gtrans_list(GlyQuery * s);

#endif

0 comments on commit 7ebf353

Please sign in to comment.