forked from bps/scrobblepod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBGTrackCollector.h
79 lines (73 loc) · 3.18 KB
/
BGTrackCollector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// BGTrackCollector.h
// ScrobblePod
//
// Created by Ben on 13/01/08.
// Copyright 2008 Ben Gummer. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <libxml/tree.h>
#import "BGLastFmSong.h"
@class BGLastFmSong, BGTrackCollector;
@interface BGTrackCollector : NSObject {
NSMutableArray *wantedTracks;
@private
// Reference to the libxml parser context
xmlParserCtxtPtr context;
NSURLConnection *rssConnection;
// Overall state of the parser, used to exit the run loop.
BOOL done;
// State variable used to determine whether or not to ignore a given XML element
BOOL parsingASong;
// The following state variables deal with getting character data from XML elements. This is a potentially expensive
// operation. The character data in a given element may be delivered over the course of multiple callbacks, so that
// data must be appended to a buffer. The optimal way of doing this is to use a C string buffer that grows exponentially.
// When all the characters have been delivered, an NSString is constructed and the buffer is reset.
BOOL storingCharacters;
BOOL scrobblePodcasts;
BOOL scrobbleVideo;
BOOL isValidTrack;
int longerThan;
BOOL parsingTracks;
NSString *commentToIgnore;
NSString *genreToIgnore;
NSString *currentKeyString;
NSMutableData *characterBuffer;
// A reference to the current song the parser is working with.
BGLastFmSong *currentSong;
NSDateFormatter *playDateFormatter;
NSDate *cutOffDate;
// The number of parsed songs is tracked so that the autorelease pool for the parsing thread can be periodically
// emptied to keep the memory footprint under control.
NSUInteger sillyCounter;
NSUInteger countOfParsedSongs;
NSAutoreleasePool *downloadAndParsePool;
NSTimeInterval startTimeReference;
}
//@property (nonatomic, retain) NSMutableArray *parsedSongs;
// new parser properties
@property BOOL storingCharacters;
@property (nonatomic, retain) NSMutableData *characterBuffer;
@property BOOL done;
@property BOOL parsingASong;
// Track validation
@property BOOL isValidTrack;
@property BOOL scrobblePodcasts;
@property BOOL scrobbleVideo;
@property BOOL parsingTracks;
@property int longerThan;
@property (nonatomic, retain) NSString *commentToIgnore;
@property (nonatomic, retain) NSString *genreToIgnore;
@property NSUInteger countOfParsedSongs;
@property NSUInteger sillyCounter;
@property (nonatomic, retain) NSString *currentKeyString;
@property (nonatomic, retain) NSMutableArray *wantedTracks;
@property (nonatomic, retain) BGLastFmSong *currentSong;
@property (nonatomic, retain) NSURLConnection *rssConnection;
@property (nonatomic, retain) NSDateFormatter *playDateFormatter;
@property (nonatomic, retain) NSDate *cutOffDate;
// The autorelease pool property is assign because autorelease pools cannot be retained.
@property (nonatomic, assign) NSAutoreleasePool *downloadAndParsePool;
-(NSMutableArray *)collectTracksFromXMLFile:(NSString *)xmlPath withCutoffDate:(NSDate *)cutoffDate includingPodcasts:(BOOL)includePodcasts includingVideo:(BOOL)includeVideo ignoringComment:(NSString *)ignoreString ignoringGenre:(NSString *)genreString withMinimumDuration:(int)minimumDuration;
- (NSString *)currentString;
@end