Sha256: 8aa77b79fc701d96d505af2ed1d1bb6b7cdc463e45a2c7506ca731348d7b087c
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
# -*- coding: utf-8 -*- require 'arxutils' require 'arxutils/store' require 'csv' require 'pp' require 'feedlr' require 'awesome_print' module Feedlrop class Feedlrop def initialize( token , kind, hs ) @oauth_access_token = token @dbmgr = Arxutils::Store.init(kind , hs ){ | register_time | Dbutil::DbMgr.new( register_time ) } @client = Feedlr::Client.new(sandbox: false , oauth_access_token: @oauth_access_token) @profile = @client.user_profile @categories = @client.user_categories end def get_output_file( ext ) n = Time.now fname = %Q!#{n.year}-#{n.month}-#{n.day}-#{n.hour}-#{n.min}-#{n.sec}.#{ext}! File.open( fname , "w") end def get_all_unread_count @categories.each do | x | f = true if x.class != String category_id = x.id.split('/')[-1] else f = false end next unless f en = @client.user_unread_counts( {:streamId => x.id } ) en.unreadcounts.each do |y| if y.id =~ /^feed\/(.+)/ url = $1 csv_add( category_id , url , y[:count] ) @dbmgr.add( category_id , url , y[:count] ) end end end end def print_user_profile pp @profile end def print_subscription option = {:plain => true } puts @client.user_subscriptions.size @client.user_subscriptions.map{|m| puts m.id} puts "===============" @client.user_subscriptions.map{|m| ap m , option } end def csv_open @csv = CSV.new(get_output_file("csv") , { :headers => %w!category_id id count!, :write_headers => true } ) end def csv_add(category_id , id , count) @csv << [category_id , id , count ] end def csv_close @csv.close end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
feedlrop-0.1.23 | lib/feedlrop/feedlrop.rb |
feedlrop-0.1.22 | lib/feedlrop/feedlrop.rb |