successfully posts
This commit is contained in:
parent
1a7deeaf76
commit
21a4034710
13
insta-feed.py
Normal file
13
insta-feed.py
Normal file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import instaloader
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
SINCE = datetime.now()-timedelta(hours=1)
|
||||
|
||||
L = instaloader.Instaloader()
|
||||
|
||||
L.load_session_from_file('2001beam')
|
||||
posts=L.download_feed_posts(max_count=20, fast_update=True, post_filter = ( lambda p: p.date > SINCE ))
|
||||
4
insta2toot.asd
Normal file
4
insta2toot.asd
Normal file
@ -0,0 +1,4 @@
|
||||
(asdf:defsystem "insta2toot"
|
||||
:version "0.1"
|
||||
:depends-on ("uiop" "local-time" "bordeaux-threads" "tooter" "cl-ppcre" "cl-json")
|
||||
:components ((:file "insta2toot")))
|
||||
36
insta2toot.lisp
Normal file
36
insta2toot.lisp
Normal file
@ -0,0 +1,36 @@
|
||||
(defvar *client* (make-instance 'tooter:client
|
||||
:base "https://pleroma.1of444.top"
|
||||
:name "insta2toot"))
|
||||
|
||||
(tooter:authorize *client*)
|
||||
(tooter:authorize *client* "I-kv18ow8ObPmODRetrZ6g58YZp6Fvz4b_SOTzvx17M")
|
||||
(tooter:account *client*)
|
||||
|
||||
(uiop:run-program '("rm" "-rf" ":feed"))
|
||||
(uiop:run-program '("instaloader" "-l" "2001beam" ) :input "instapass" :output t)
|
||||
(uiop:run-program '("python" "insta-feed.py") :output t)
|
||||
|
||||
(defun get-post-prefixes ()
|
||||
(loop for file in (uiop:directory-files ":feed")
|
||||
if (cl-ppcre:scan "json.xz$" (uiop:unix-namestring file))
|
||||
collect (subseq (uiop:unix-namestring file) 0 (- (length (uiop:unix-namestring file))
|
||||
(length ".json.xz")))))
|
||||
(defun repost-post (post-prefix)
|
||||
(let* ((json-file (concatenate 'string post-prefix ".json.xz"))
|
||||
(post-json (uiop:run-program `("xzcat" ,json-file) :output :string))
|
||||
(post-metadata (with-input-from-string (s post-json) ( cl-json:decode-json s)))
|
||||
(post-user (cdr (assoc :username (cdr (assoc :owner (cdr (assoc :node post-metadata)))))))
|
||||
(post-desc (or (cdr (assoc :text (cdr (assoc :node (car (cdr (assoc :edges (cdr (assoc :edge--media--to--caption (cdr (assoc :node post-metadata))))))))))) ""))
|
||||
(post-files (loop for file in (uiop:directory-files ":feed")
|
||||
if (and (cl-ppcre:scan post-prefix (uiop:unix-namestring file))
|
||||
(cl-ppcre:scan "(jpg$)|(png$)|(mp4$)" (uiop:unix-namestring file)))
|
||||
collect file))
|
||||
(medias (mapcar (lambda (x) (tooter:make-media *client* x))
|
||||
(subseq post-files 0 (min (length post-files) 4)))))
|
||||
(tooter:make-status *client*
|
||||
(format nil "~a
|
||||
-~a via instagram" post-desc post-user)
|
||||
:media medias)))
|
||||
|
||||
(loop for post-prefix in (get-post-prefixes)
|
||||
collect (repost-post post-prefix))
|
||||
Loading…
x
Reference in New Issue
Block a user