projects
/
cinaest
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ec13e71
)
IMDb downloader: let the RatingLineParser skip the header
author
Philipp Zabel
<philipp.zabel@gmail.com>
Wed, 6 Jan 2010 14:39:08 +0000
(15:39 +0100)
committer
Philipp Zabel
<philipp.zabel@gmail.com>
Wed, 6 Jan 2010 17:37:00 +0000
(18:37 +0100)
src/imdb/imdb-line-parser.vala
patch
|
blob
|
history
diff --git
a/src/imdb/imdb-line-parser.vala
b/src/imdb/imdb-line-parser.vala
index
25d1658
..
1218cbf
100644
(file)
--- a/
src/imdb/imdb-line-parser.vala
+++ b/
src/imdb/imdb-line-parser.vala
@@
-93,10
+93,16
@@
class GenreLineParser : LineParser {
}
class RatingLineParser : LineParser {
}
class RatingLineParser : LineParser {
+ enum RatingState {
+ HEADER,
+ NONE
+ }
+ RatingState state;
Regex re_rating;
public RatingLineParser (IMDbSqlite _sqlite) {
base (_sqlite);
Regex re_rating;
public RatingLineParser (IMDbSqlite _sqlite) {
base (_sqlite);
+ state = RatingState.HEADER;
try {
re_rating = new Regex ("^ .+ +([0-9]+) +([0-9.]+) +(.+)$");
} catch (RegexError e) {
try {
re_rating = new Regex ("^ .+ +([0-9]+) +([0-9.]+) +(.+)$");
} catch (RegexError e) {
@@
-105,6
+111,15
@@
class RatingLineParser : LineParser {
}
public override void parse_line (string line) {
}
public override void parse_line (string line) {
+ if (state == RatingState.HEADER) {
+ if (line == "MOVIE RATINGS REPORT")
+ state = RatingState.NONE;
+ return;
+ }
+
+ if (state != RatingState.NONE)
+ return;
+
MatchInfo matchinfo;
// Skip series episodes
MatchInfo matchinfo;
// Skip series episodes
@@
-117,7
+132,7
@@
class RatingLineParser : LineParser {
string title;
string votes = matchinfo.fetch (1);
string rating = matchinfo.fetch (2);
string title;
string votes = matchinfo.fetch (1);
string rating = matchinfo.fetch (2);
- try {
+ try {
title = convert(matchinfo.fetch (3), -1, "utf-8", "latin1");
} catch (ConvertError e) {
return;
title = convert(matchinfo.fetch (3), -1, "utf-8", "latin1");
} catch (ConvertError e) {
return;