Created
January 22, 2019 17:44
-
-
Save eazyliving/baf5c055db875def56fa7fa3bd3b777e to your computer and use it in GitHub Desktop.
autocurate nullnummern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source json.tcl | |
# find json.tcl here: https://github.com/dbohdan/jimhttp/blob/master/json.tcl | |
set curl "curl -s" | |
set curation_id <THE_CURATIONS_ID> | |
set accesstoken <AN_ACCESSTOKEN_YOU_GET_FROM_YOUR_DEV_PAGE> | |
# get the 10 podcast added the last | |
set latest [::json::parse [eval exec $curl "https://api.fyyd.de/0.2/podcast/latest?count=10"] 1] | |
# extract the podcast_ids | |
dict for {key podcast} [dict get $latest data] { | |
lappend pids [dict get $podcast id] | |
} | |
foreach pid $pids { | |
# get the last 15 episodes inside this podcast | |
set episodes [::json::parse [eval exec $curl "https://api.fyyd.de/0.2/podcast/episodes?podcast_id=$pid&count=15"] 1] | |
set eids {} | |
dict for {key episode} [dict get $episodes data episodes] { | |
lappend eids [list [dict get $episode id] [clock scan [lindex [split [dict get $episode pubdate] \+] 0]]] | |
} | |
if {[llength $eids]<10} { | |
# this podcast has <10 episodes and therefore can be considered "new" | |
# maybe a check for "episodes are not older that x months" would be a good idea. On the other hand... | |
# so: find the first episode | |
set eid [lindex [lsort -integer -increasing -index 1 $eids] 0 0] | |
# NULLNUMMER! | |
set eid [lindex $eids 0] | |
# And here we are: post the episode to the curation!° | |
set ret [eval exec $curl -H \"Authorization: Bearer $accesstoken\" \"https://api.fyyd.de/0.2/curate\" --data \"curation_id=$curation_id&episode_id=$eid&force_state=1\"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment