|
|
|
@ -28,6 +28,12 @@
|
|
|
|
(create-directory (dir)
|
|
|
|
(create-directory (dir)
|
|
|
|
(ensure-directories-exist (uiop:ensure-directory-pathname (make-pathname :name dir))))
|
|
|
|
(ensure-directories-exist (uiop:ensure-directory-pathname (make-pathname :name dir))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(download (item)
|
|
|
|
|
|
|
|
(download-media (generate-filename item)
|
|
|
|
|
|
|
|
(format-url domain "Items/~A/Download"
|
|
|
|
|
|
|
|
(gethash "Id" item))
|
|
|
|
|
|
|
|
auth))
|
|
|
|
|
|
|
|
|
|
|
|
(download-item-or-children (item)
|
|
|
|
(download-item-or-children (item)
|
|
|
|
;; PARENTS is a list of all parent names with FIRST being
|
|
|
|
;; PARENTS is a list of all parent names with FIRST being
|
|
|
|
;; the oldest grandparent (for building complete download path)
|
|
|
|
;; the oldest grandparent (for building complete download path)
|
|
|
|
@ -47,17 +53,15 @@
|
|
|
|
(gethash "Id" item))
|
|
|
|
(gethash "Id" item))
|
|
|
|
:auth auth)))))
|
|
|
|
:auth auth)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(if (zerop (gethash "ChildCount" root 0))
|
|
|
|
|
|
|
|
(download root)
|
|
|
|
(loop :for child :across children
|
|
|
|
(loop :for child :across children
|
|
|
|
:if (zerop (gethash "ChildCount" child 0))
|
|
|
|
:if (zerop (gethash "ChildCount" child 0))
|
|
|
|
:do
|
|
|
|
:do
|
|
|
|
;; download single file
|
|
|
|
;; download single file
|
|
|
|
(when (getf opts :verbose)
|
|
|
|
(when (getf opts :verbose)
|
|
|
|
(format t "Downloading ~A~%" (generate-filename child)))
|
|
|
|
(format t "Downloading ~A~%" (generate-filename child)))
|
|
|
|
(download-media (generate-filename child)
|
|
|
|
(download child)
|
|
|
|
(format-url domain "Items/~A/Download"
|
|
|
|
|
|
|
|
(gethash "Id" child))
|
|
|
|
|
|
|
|
auth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:else
|
|
|
|
:else
|
|
|
|
:do
|
|
|
|
:do
|
|
|
|
@ -67,7 +71,7 @@
|
|
|
|
;; ensure that a directory exists for Parent
|
|
|
|
;; ensure that a directory exists for Parent
|
|
|
|
;; then recurse with children
|
|
|
|
;; then recurse with children
|
|
|
|
(uiop:with-current-directory ((create-directory (gethash "Name" child)))
|
|
|
|
(uiop:with-current-directory ((create-directory (gethash "Name" child)))
|
|
|
|
(download-item-or-children child))))))
|
|
|
|
(download-item-or-children child)))))))
|
|
|
|
|
|
|
|
|
|
|
|
(when (or (getf opts :assume-yes)
|
|
|
|
(when (or (getf opts :assume-yes)
|
|
|
|
(y-or-n-p "Download \"~A\"" (generate-root-name)))
|
|
|
|
(y-or-n-p "Download \"~A\"" (generate-root-name)))
|
|
|
|
@ -89,7 +93,9 @@
|
|
|
|
(and (every #'null args)
|
|
|
|
(and (every #'null args)
|
|
|
|
(every #'null opts)))
|
|
|
|
(every #'null opts)))
|
|
|
|
(opts:describe :usage-of "seanut"
|
|
|
|
(opts:describe :usage-of "seanut"
|
|
|
|
:args "DOMAIN MEDIA-NAME")
|
|
|
|
:args "DOMAIN MEDIA-NAME"
|
|
|
|
|
|
|
|
:suffix (format nil *command-line-brief*
|
|
|
|
|
|
|
|
*valid-media-types*))
|
|
|
|
(uiop:quit 0))
|
|
|
|
(uiop:quit 0))
|
|
|
|
|
|
|
|
|
|
|
|
(when (getf opts :version)
|
|
|
|
(when (getf opts :version)
|
|
|
|
@ -116,15 +122,8 @@
|
|
|
|
(getf opts :media-type)
|
|
|
|
(getf opts :media-type)
|
|
|
|
(url-encode search-term))))
|
|
|
|
(url-encode search-term))))
|
|
|
|
(if (< 0 (length results))
|
|
|
|
(if (< 0 (length results))
|
|
|
|
;; FIXME: for some reason this access token is not "valid" enough to get
|
|
|
|
|
|
|
|
;; certain info? when we run the parentID search it craps out on us?
|
|
|
|
|
|
|
|
;; maybe its not something wrong with the token, but the auth string as a
|
|
|
|
|
|
|
|
;; whole? look into this more tomorrow
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
;; after reading more
|
|
|
|
|
|
|
|
(loop :for item :across results
|
|
|
|
(loop :for item :across results
|
|
|
|
:do (prompt-and-download domain authorization
|
|
|
|
:do (prompt-and-download domain authorization item opts))
|
|
|
|
item opts))
|
|
|
|
|
|
|
|
(quit-with-message 0 "No results found for ~A" search-term)))))
|
|
|
|
(quit-with-message 0 "No results found for ~A" search-term)))))
|
|
|
|
|
|
|
|
|
|
|
|
(error (e)
|
|
|
|
(error (e)
|
|
|
|
|