Skip to content

Commit

Permalink
scrape album info for scrobbles (ShazamScrobbler#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilmenon committed Nov 6, 2021
1 parent da00524 commit 587b573
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ShazamScrobbler/LastFmController.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ + (void)scrobble:(Song *)song withTag:(NSInteger)tag {

if (seconds <= 0) {
// Scrobble a track
[[LastFm sharedInstance] sendScrobbledTrack:song.song byArtist:song.artist onAlbum:nil withDuration:30 atTimestamp:(int)[song.date timeIntervalSince1970] successHandler:^(NSDictionary *result) {
[[LastFm sharedInstance] sendScrobbledTrack:song.song byArtist:song.artist onAlbum:song.album withDuration:30 atTimestamp:(int)[song.date timeIntervalSince1970] successHandler:^(NSDictionary *result) {

// We need to re-check if the user is connected and the scrobbling is enabled
// in case the configuration changed during the last 30 seconds
Expand Down
2 changes: 1 addition & 1 deletion ShazamScrobbler/ShazamController.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ + (Song*)createSongFromTag:(NSInteger)tag {
FMDatabase *database = [FMDatabase databaseWithPath:[ShazamConstants getSqlitePath]];
if([database open])
{
FMResultSet *songWithGivenTag = [database executeQuery:[NSString stringWithFormat:@"select track.Z_PK as ZID, ZDATE, ZTRACKNAME, ZNAME from ZSHARTISTMO artist, ZSHTAGRESULTMO track where ZID = %ld", tag]];
FMResultSet *songWithGivenTag = [database executeQuery:[NSString stringWithFormat:@"select track.Z_PK as ZID, ZDATE, ZTRACKNAME, ZNAME, (select ZVALUE from ZSHMETADATAMO, ZSHTAGRESULTMO where ZKEY = 'Album' and ZTAGRESULT = ZSHTAGRESULTMO.Z_PK) as ZALBUMNAME from ZSHARTISTMO artist, ZSHTAGRESULTMO track where ZID = %ld", tag]];
[database close];
return [[Song alloc] initWithResultSet:songWithGivenTag];
}
Expand Down
3 changes: 3 additions & 0 deletions ShazamScrobbler/Song.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ - (id)initWithSong:(NSString *)song artist:(NSString *)artist date:(NSDate *)dat
if (self) {
_song = [song copy];
_artist = artist;
_album: nil;
_scrobbled = NO;
_date = date;
_tag = tag;
Expand All @@ -30,10 +31,12 @@ - (id)initWithResultSet:(FMResultSet *)rs {
NSInteger tag = [rs intForColumn:@"ZID"];
NSString *artist = [NSString stringWithFormat:@"%@",[rs stringForColumn:@"ZNAME"]];
NSString *track = [NSString stringWithFormat:@"%@",[rs stringForColumn:@"ZTRACKNAME"]];
NSString *album = [NSString stringWithFormat:@"%@",[rs stringForColumn:@"ZALBUMNAME"]];
NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:[[rs stringForColumn:@"ZDATE"] doubleValue]];
if (self) {
_song = [track copy];
_artist = [artist copy];
_album = [album copy];
_scrobbled = NO;
_date = [date copy];
_tag = tag;
Expand Down

0 comments on commit 587b573

Please sign in to comment.