Almost done with overseerr, just need requests to work now

This commit is contained in:
Kiran Shila
2022-01-10 15:33:09 -08:00
parent 93f8e0f9fb
commit c303fefbc3
7 changed files with 39 additions and 20 deletions

View File

@@ -2,6 +2,7 @@
(:require
[doplarr.backends.overseerr.impl :as impl]
[doplarr.utils :as utils]
[config.core :refer [env]]
[clojure.core.async :as a]))
(defn search [term media-type]
@@ -16,10 +17,26 @@
(defn additional-options [result media-type]
(a/go
(let [type (impl/media-type media-type)
details (a/<! (impl/details (:id result) type))]
details (a/<! (impl/details (:id result) type))
{:keys [partial-seasons]} env]
(when (= media-type :series)
{:season (impl/seasons-list details)}))))
(let [seasons (impl/seasons-list details)
backend-partial-seasons? (a/<! (impl/partial-seasons?))]
{:season (cond
(= 1 (count seasons)) (:id (first seasons))
(false? partial-seasons) -1
(false? backend-partial-seasons?) -1
:else (impl/seasons-list details))})))))
(defn request-embed [] ["" "4K"])
(defn request-embed [{:keys [title id season]} media-type]
(a/go
(let [fourk (a/<! (impl/backend-4k? media-type))
details (a/<! (impl/details id (impl/media-type media-type)))]
{:title title
:overview (:overview details)
:poster (str impl/poster-path (:poster-path details))
:media-type media-type
:request-formats [""]
:season season})))
(defn request [payload])

View File

@@ -58,16 +58,22 @@
:id ssn})
{:name "All Seasons" :id -1}))
;;; NOT MODIFED YET
(defn backend-4k? [media-type]
(defn backend-4k? [media]
(a/go
(->> (a/<! (GET (str "/settings/" (if (= media-type "tv") "sonarr" "radarr"))))
(->> (a/<! (GET (str "/settings/" (if (= (media-type media) "tv") "sonarr" "radarr"))))
(then #(->> (:body %)
(map :is4k)
(some identity)))
(else #(fatal % "Exception on checking Overseeerr 4K backend support")))))
(defn partial-seasons? []
(a/go
(->> (a/<! (GET "/settings/main"))
(then #(->> (utils/from-camel (:body %))
:partial-requests-enabled))
(else #(fatal % "Exception testing for partial seasons")))))
;;; NOT MODIFED YET
(defn num-users []
(a/go
(->> (a/<! (GET "/user" {:query-params {:take 1}}))
@@ -137,10 +143,3 @@
:content-type :json
:headers {"X-API-User" (str ovsr-id)}}))
(then (constantly nil)))))
(defn partial-seasons? []
(a/go
(->> (a/<! (GET "/settings/main"))
(then #(->> (:body %)
:partialRequestsEnabled))
(else #(fatal % "Exception testing for partial seasons")))))

View File

@@ -27,7 +27,7 @@
(= 1 (count quality-profiles)) (:id (first quality-profiles))
:else quality-profiles)})))
(defn request-embed [{:keys [title quality-profile-id tmdb-id]}]
(defn request-embed [{:keys [title quality-profile-id tmdb-id]} _]
(a/go
(let [quality-profiles (a/<! (impl/quality-profiles))
details (a/<! (impl/get-from-tmdb tmdb-id))]

View File

@@ -45,7 +45,7 @@
(= 1 (count language-profiles)) (:id (first language-profiles))
:else language-profiles)})))
(defn request-embed [{:keys [title quality-profile-id language-profile-id tvdb-id season]}]
(defn request-embed [{:keys [title quality-profile-id language-profile-id tvdb-id season]} _]
(a/go
(let [quality-profiles (a/<! (impl/quality-profiles))
language-profiles (a/<! (impl/language-profiles))

View File

@@ -10,7 +10,8 @@
[doplarr.state :as state]
[doplarr.interaction-state-machine :as ism]
[doplarr.discord :as discord]
[clojure.core.async :as a])
[clojure.core.async :as a]
[clojure.string :as str])
(:gen-class))
; Pipe tools.logging to timbre
@@ -52,8 +53,9 @@
(discord/set-permission bot-id messaging id command-id))))
(defmethod handle-event! :default
[event-type _]
(debug "Got unhandled event" event-type))
[event-type data]
(debug "Got unhandled event" event-type)
(debug data))
(defn start-bot! []
(let [event-ch (a/chan 100)

View File

@@ -115,6 +115,7 @@
:thumbnail {:url (media-type request-thumbnail)}
:fields (filterv
identity
; Some overrides to make things pretty
[(when quality-profile
{:name "Profile"
:value quality-profile})

View File

@@ -47,7 +47,7 @@
{:keys [media-type token payload]} (get @state/cache uuid)]
(if (empty? pending-opts)
(let [embed (log-on-error
(a/<! ((utils/media-fn media-type "request-embed") payload))
(a/<! ((utils/media-fn media-type "request-embed") payload media-type))
"Exception from request-embed")]
(->> @(m/edit-original-interaction-response! messaging bot-id token (discord/request embed uuid))
(else #(fatal % "Error in sending request embed"))))