Skip to content

Instantly share code, notes, and snippets.

@mikeflynn
Last active July 7, 2020 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeflynn/e181b503f5c0ccf254bfc83025820036 to your computer and use it in GitHub Desktop.
Save mikeflynn/e181b503f5c0ccf254bfc83025820036 to your computer and use it in GitHub Desktop.
(require '[api.service.tools :as csv])
(require '[pipeline.youtube.api :as api])
(require '[api.channel :as c])
(require '[api.cms :as cms])
(defn foobar
[infile outfile country]
(->> (slurp infile)
(csv/csv-to-map)
(map #(assoc % :cms-name (->> (c/get :id (:id %) :fields [:cms])
:cms
(cms/get :id)
:name)))
(map #(assoc % :country country))
(map #(assoc % :earnings (->> (api/get-metrics [(:id %)]
;:cms-name (:cms-name %)
:start "2016-01-01"
:end "2017-01-01"
:country country
:metrics "estimatedRevenue")
first
:earnings)))
;(map #(println %))
map-to-csv
(spit outfile)
))
(foobar "/home/ubuntu/2016-channel-list-test.csv" "/home/ubuntu/2016-channel-list-global.csv" nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment