Permalink
Browse files

Check if episode is finished on all events

  • Loading branch information...
josh committed Feb 28, 2017
1 parent 1c3408b commit 570933d0a5a405ac0636fcd3b67021a89c3b3f75
Showing with 5 additions and 10 deletions.
  1. +4 −3 overcast.php
  2. +1 −7 smapi.php
View
@@ -275,7 +275,10 @@ function fetchEpisodeProgress($token, $id) {
function updateEpisodeProgress($token, $id, $position) {
global $memcache;
- if ($position == 2147483647) {
+ $episode = fetchEpisode($id);
+
+ if (isset($episode->duration) && $position >= $episode->duration) {
+ $position = 2147483647;
invalidateAccountCache($token);
}
@@ -285,8 +288,6 @@ function updateEpisodeProgress($token, $id, $position) {
unserialize(decrypt($rawProgress, $token)) :
fetchEpisodeProgress($token, $id);
- $episode = fetchEpisode($id);
-
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://overcast.fm/podcasts/set_progress/" . $episode->itemId);
View
@@ -218,13 +218,7 @@ function setPlayedSeconds($params) {
$offsetMillis = $params->offsetMillis;
if ($offsetMillis) {
- $episode = fetchEpisode($id);
- $seconds = $offsetMillis / 1000;
- if (isset($episode->duration) && $seconds > $episode->duration - 3) {
- $seconds = 2147483647;
- }
-
- updateEpisodeProgress($this->sessionId, $id, $seconds);
+ updateEpisodeProgress($this->sessionId, $id, $offsetMillis / 1000);
}
$response = new StdClass();

0 comments on commit 570933d

Please sign in to comment.