Skip to content

Commit

Permalink
Add random UUID to bypass cache (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
nylonee authored Oct 16, 2024
1 parent cbe01de commit dc9ef85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/main/scala/plex/PlexUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import io.circe.generic.extras.auto._
import io.circe.syntax.EncoderOps
import org.http4s.client.UnexpectedStatus

import java.util.UUID

trait PlexUtils {

private val logger = LoggerFactory.getLogger(getClass)
Expand All @@ -21,7 +23,10 @@ trait PlexUtils {
extras.Configuration.default.withDefaults

protected def fetchWatchlistFromRss(client: HttpClient)(url: Uri): IO[Set[Item]] = {
val jsonFormatUrl = url.withQueryParam("format", "json")
val randomUUID = UUID.randomUUID().toString.take(12)
val jsonFormatUrl = url
.withQueryParam("format", "json")
.withQueryParam("cache_buster", randomUUID)

client.httpRequest(Method.GET, jsonFormatUrl).map {
case Left(UnexpectedStatus(s, _, _)) if s.code == 500 =>
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/plex/PlexUtilsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PlexUtilsSpec extends AnyFlatSpec with Matchers with PlexUtils with MockFa
(mockClient.httpRequest _)
.expects(
Method.GET,
Uri.unsafeFromString("http://localhost:9090?format=json"),
*,
None,
None
)
Expand All @@ -40,7 +40,7 @@ class PlexUtilsSpec extends AnyFlatSpec with Matchers with PlexUtils with MockFa
(mockClient.httpRequest _)
.expects(
Method.GET,
Uri.unsafeFromString("http://localhost:9090?format=json"),
*,
None,
None
)
Expand Down

0 comments on commit dc9ef85

Please sign in to comment.