Last active
July 7, 2020 23:09
-
-
Save mikeflynn/e181b503f5c0ccf254bfc83025820036 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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