summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <arch@njw.me.uk>2007-03-04 20:10:28 +0000
committerNick White <arch@njw.me.uk>2007-03-04 20:10:28 +0000
commit79f155fe6f3e7d105c5ef971fbfc7286a1f9b661 (patch)
treea6ade144755f54a8963fcea04077ab31984735ba
parentc85db409583755f6975d97b94b8437c7b9657ab5 (diff)
Improve UI, workaround cover bug, fix mediarev
Replaced line-feed with newline on download completion Worked around attempt to download cover when non-existant Removed whitespace mediarev parsing restrictions Fixed bug miscounting media items parsed Misc mediarev tidying git-archimport-id: getht@sv.gnu.org/getht--mainline--0.1--patch-2
-rw-r--r--download.c5
-rw-r--r--mediarev.c44
2 files changed, 35 insertions, 14 deletions
diff --git a/download.c b/download.c
index c099c1f..099a65f 100644
--- a/download.c
+++ b/download.c
@@ -112,7 +112,7 @@ void save_file(CURL *curl_handle, char *url, char *filepath)
*/
fclose(file);
- printf("\r");
+ printf("\n");
}
else {
fprintf(stderr,"Error: curl failed to initialise.\n");
@@ -152,7 +152,8 @@ void downloadissue(CURL *curl_handle, char * directory, iss * issue, int force)
scanf("%s", newdir); /* TODO: incorporate tab-completion */
}
- if(issue->cover.title[0])
+ /* not reliable - workaround until malloc is completed */
+ if(!strncmp(issue->cover.uri, "http://www.", 11))
{
snprintf(filename,STR_MAX,"%s/cover.pdf", newdir);
if(!force){
diff --git a/mediarev.c b/mediarev.c
index 8181c19..9877561 100644
--- a/mediarev.c
+++ b/mediarev.c
@@ -26,7 +26,9 @@
#include "getht.h"
#include "issue.h"
+int smilurl(char * smilurl, med * cur_media);
void getquote(char * input, char * label);
+void removeleadingspace(char * cur_line);
int parsemediagz(char * media_path, med * cur_media, int * no_of_media)
/* Parses gzipped adobe pagemaker files for media urls and metadata,
@@ -51,30 +53,27 @@ int parsemediagz(char * media_path, med * cur_media, int * no_of_media)
{
strcpy(cur_line,""); /* reset cur_line */
gzgets(mediagz, cur_line, STR_MAX);
- cur_line[strlen(cur_line)-1] = '\0'; /* get rid of trailing newline */
+ cur_line[strlen(cur_line)-1] = '\0'; /* remove trailing newline */
- if(!strncmp(cur_line," set the filename of player \"player1\" to \"",45))
+ removeleadingspace(cur_line);
+
+ if(!strncmp(cur_line,"set the filename of player \"player1\" to \"",41))
{
- /* todo: if smil follow, otherwise load into media->url */
- sscanf(cur_line," set the filename of player \"player1\" to \"%s\"",cur_media->uri);
- cur_media->uri[strlen(cur_media->uri)-1] = '\0'; /* workaround extra final character */
+ /* todo: check if smil, if so follow to find uri */
+ sscanf(cur_line,"set the filename of player \"player1\" to \"%s\"",cur_media->uri);
+ cur_media->uri[strlen(cur_media->uri)-1] = '\0'; /* workaround extra character */
}
- else if(!strncmp(cur_line," set the label of this stack to \"",36))
+ else if(!strncmp(cur_line,"set the label of this stack to \"",32))
{
getquote(cur_line,cur_media->title);
}
- else if(!strncmp(cur_line," statusMsg \(\"",16))
+ else if(!strncmp(cur_line,"statusMsg \(\"",12))
{
getquote(cur_line,cur_media->comment);
}
- /* else
- * fprintf(stderr,"Interesting line to put in struct: '%s'\n",cur_line);
- */
-
}
*cur_media++;
(*no_of_media)++;
- cur_media->uri[0] = '\0';
}
strcpy(cur_line,""); /* reset cur_line */
}
@@ -111,3 +110,24 @@ void getquote(char * input, char * quote)
*cur_pos = '\0';
}
+
+void removeleadingspace(char * cur_line)
+{
+ int tmp, newpos;
+
+ char temp_str[STR_MAX];
+
+ /* advance past whitespace */
+ tmp = 0;
+ while (cur_line[tmp] == ' ' || cur_line[tmp] == '\t')
+ tmp++;
+
+ /* copy from there to temp_str */
+ for(newpos = 0; cur_line[tmp]; tmp++, newpos++)
+ temp_str[newpos] = cur_line[tmp];
+
+ temp_str[newpos] = '\0';
+
+ /* copy temp_str to cur_line */
+ strncpy(cur_line, temp_str, sizeof(temp_str));
+}