Mercurial > audlegacy-plugins
comparison src/scrobbler/plugin.c @ 553:269841b8fb31 trunk
[svn] - submit gerpok tracks on immediate playback begin
| author | nenolod |
|---|---|
| date | Sat, 27 Jan 2007 06:35:52 -0800 |
| parents | d124034ebea3 |
| children | 7deaaa08706a |
comparison
equal
deleted
inserted
replaced
| 552:91bc67e7800b | 553:269841b8fb31 |
|---|---|
| 33 #define XS_SLEEP 1 | 33 #define XS_SLEEP 1 |
| 34 #define HS_SLEEP 10 | 34 #define HS_SLEEP 10 |
| 35 | 35 |
| 36 typedef struct submit_t | 36 typedef struct submit_t |
| 37 { | 37 { |
| 38 int dosubmit, pos_c, len; | 38 int dosubmit, pos_c, len, gerpok; |
| 39 } submit_t; | 39 } submit_t; |
| 40 | 40 |
| 41 static void init(void); | 41 static void init(void); |
| 42 static void cleanup(void); | 42 static void cleanup(void); |
| 43 static void *xs_thread(void *); | 43 static void *xs_thread(void *); |
| 246 submit_t dosubmit; | 246 submit_t dosubmit; |
| 247 | 247 |
| 248 struct timeval timetmp; | 248 struct timeval timetmp; |
| 249 | 249 |
| 250 /* clear dosubmit */ | 250 /* clear dosubmit */ |
| 251 dosubmit.dosubmit = dosubmit.pos_c = dosubmit.len = 0; | 251 dosubmit.dosubmit = dosubmit.pos_c = dosubmit.len = dosubmit.gerpok = 0; |
| 252 | 252 |
| 253 /* current music number */ | 253 /* current music number */ |
| 254 pos_c = xmms_remote_get_playlist_pos(XS_CS); | 254 pos_c = xmms_remote_get_playlist_pos(XS_CS); |
| 255 /* current file name */ | 255 /* current file name */ |
| 256 file_c = xmms_remote_get_playlist_file(XS_CS, pos_c); | 256 file_c = xmms_remote_get_playlist_file(XS_CS, pos_c); |
| 275 } | 275 } |
| 276 | 276 |
| 277 /* repeat setting */ | 277 /* repeat setting */ |
| 278 repeat = xmms_remote_is_repeat(XS_CS); | 278 repeat = xmms_remote_is_repeat(XS_CS); |
| 279 | 279 |
| 280 /* | |
| 281 #ifdef MAKE_XMMS | |
| 282 // advance setting (required xmms-1.2.11 or over) | |
| 283 advance = xmms_remote_is_advance(XS_CS); | |
| 284 #else | |
| 285 advance = 1; | |
| 286 #endif | |
| 287 */ | |
| 288 | |
| 289 if( ps_p == ps_stop && ps_c == ps_stop ) playstate = stopping; | 280 if( ps_p == ps_stop && ps_c == ps_stop ) playstate = stopping; |
| 290 else if( ps_p == ps_stop && ps_c == ps_play ) playstate = start; | 281 else if( ps_p == ps_stop && ps_c == ps_play ) playstate = start; |
| 291 /* else if( ps_p == ps_stop && ps_c == ps_pause ) ; */ | 282 /* else if( ps_p == ps_stop && ps_c == ps_pause ) ; */ |
| 292 else if( ps_p == ps_play && ps_c == ps_play ) playstate = playing; | 283 else if( ps_p == ps_play && ps_c == ps_play ) playstate = playing; |
| 293 else if( ps_p == ps_play && ps_c == ps_stop ) playstate = stop; | 284 else if( ps_p == ps_play && ps_c == ps_stop ) playstate = stop; |
| 322 seeked = 0; | 313 seeked = 0; |
| 323 | 314 |
| 324 switch( playstate ){ | 315 switch( playstate ){ |
| 325 case start: | 316 case start: |
| 326 pdebug("*** START ***", SUB_DEBUG); | 317 pdebug("*** START ***", SUB_DEBUG); |
| 318 dosubmit.gerpok = 1; | |
| 327 break; | 319 break; |
| 328 case stop: | 320 case stop: |
| 329 pdebug("*** STOP ***", SUB_DEBUG); | 321 pdebug("*** STOP ***", SUB_DEBUG); |
| 330 len = 0; | 322 len = 0; |
| 331 break; | 323 break; |
| 435 dosubmit.len = len; | 427 dosubmit.len = len; |
| 436 } | 428 } |
| 437 } | 429 } |
| 438 } | 430 } |
| 439 | 431 |
| 432 if (playstate != start) | |
| 433 dosubmit.gerpok = 0; | |
| 434 | |
| 440 g_free(file_p); | 435 g_free(file_p); |
| 441 | 436 |
| 442 /* keep current value for next iteration */ | 437 /* keep current value for next iteration */ |
| 443 ps_p = ps_c; | 438 ps_p = ps_c; |
| 444 file_p = file_c; | 439 file_p = file_c; |
| 475 hatena_sc_clear_error(); | 470 hatena_sc_clear_error(); |
| 476 } | 471 } |
| 477 | 472 |
| 478 /* Check for ability to submit */ | 473 /* Check for ability to submit */ |
| 479 dosubmit = get_song_status(); | 474 dosubmit = get_song_status(); |
| 475 | |
| 476 if(dosubmit.gerpok) { | |
| 477 TitleInput *tuple; | |
| 478 | |
| 479 pdebug("Submitting song.", DEBUG); | |
| 480 | |
| 481 tuple = playlist_get_tuple(playlist_get_active(), dosubmit.pos_c); | |
| 482 | |
| 483 if (ishttp(tuple->file_name)) | |
| 484 continue; | |
| 485 | |
| 486 if(tuple->performer != NULL && tuple->track_name != NULL) | |
| 487 { | |
| 488 pdebug(fmt_vastr( | |
| 489 "submitting artist: %s, title: %s", | |
| 490 tuple->performer, tuple->track_name), DEBUG); | |
| 491 gerpok_sc_addentry(m_scrobbler, tuple, | |
| 492 dosubmit.len/1000); | |
| 493 } | |
| 494 else | |
| 495 pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG); | |
| 496 } | |
| 480 | 497 |
| 481 if(dosubmit.dosubmit) { | 498 if(dosubmit.dosubmit) { |
| 482 TitleInput *tuple; | 499 TitleInput *tuple; |
| 483 | 500 |
| 484 pdebug("Submitting song.", DEBUG); | 501 pdebug("Submitting song.", DEBUG); |
| 493 pdebug(fmt_vastr( | 510 pdebug(fmt_vastr( |
| 494 "submitting artist: %s, title: %s", | 511 "submitting artist: %s, title: %s", |
| 495 tuple->performer, tuple->track_name), DEBUG); | 512 tuple->performer, tuple->track_name), DEBUG); |
| 496 sc_addentry(m_scrobbler, tuple, | 513 sc_addentry(m_scrobbler, tuple, |
| 497 dosubmit.len/1000); | 514 dosubmit.len/1000); |
| 498 gerpok_sc_addentry(m_scrobbler, tuple, | |
| 499 dosubmit.len/1000); | |
| 500 hatena_sc_addentry(m_scrobbler, tuple, | 515 hatena_sc_addentry(m_scrobbler, tuple, |
| 501 dosubmit.len/1000); | 516 dosubmit.len/1000); |
| 502 } | 517 } |
| 503 else | 518 else |
| 504 pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG); | 519 pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG); |
