public static function querySlay(Module_Slaytags $module) { if (false === ($data = self::requestSlay($module))) { return self::dummySong($module); } $data = $data['data']; // var_dump(($data)); // $data = new Slay_Response($data); if (isset($data['live']) && $data['live']) { return self::querySlayLiveshow($module, $data['redirect_url']); } # Timing $duration = (int) $data['duration']; $left = (int) $data['next_song_expected']; $now = $duration - $left; // $started = time() - $now; // $ending = time() + $left; // var_dump("LEFT: $left. NOW: $now."); // $si = $data['slay_info']; $si = $data; $slay_id = $si['id']; $artist = $si['artist']; $title = $si['title']; $album = $si['album']; // $composer = $si['SID_composer']; $sid_path = isset($si['sid_path']) ? $si['sid_path'] : NULL; $rko_id = 0; $rko_vote = 0; if (isset($data['r64_id']) && $data['r64_id'] > 0) { // $ri = $data['rko_info']; $ri = $data; $rko_id = $ri['r64_id']; $rko_vote = $ri['r64_vote']; // $sid_path = isset($ri['SID_path']) ? $ri['SID_path'] : $sid_path; } $sid_path = $sid_path === NULL ? NULL : Common::substrFrom($sid_path, '?sid_tune=', $sid_path); if (false === ($song = Slay_Song::getBySlayID($slay_id))) { if (false === ($song = Slay_Song::getByArtistTitle($artist, $title))) { $options = 0; $options |= $rko_id > 0 ? Slay_Song::HAS_DOWNLOAD : 0; $song = new Slay_Song(array('ss_id' => 0, 'ss_rko_id' => $rko_id, 'ss_c64_id' => 0, 'ss_slay_id' => $slay_id, 'ss_title' => $title, 'ss_artist' => $artist, 'ss_composer' => '', 'ss_taggers' => 0, 'ss_lyrics' => 0, 'ss_duration' => $duration, 'ss_played' => 0, 'ss_options' => $options, 'ss_last_played' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'ss_tag_cache' => NULL, 'ss_r64_vote' => $rko_vote, 'ss_sid_path' => $sid_path)); if (false === $song->insert()) { return self::dummySong($module); } } } if (GWF_Settings::getSetting(self::NP_KEY) != $song->getID()) { $song->increase('ss_played', 1); GWF_Settings::setSetting(self::NP_KEY, $song->getID()); GWF_Settings::setSetting(self::NP_NEXT_KEY, time() + $left + 1); } return $song; }