Sha256: 8ab913f527b22cae5686e35c2be99e38b777672e7a87ca81ddaaf025b95a0a5c
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
module CureLine require "open-uri" require "json" class User attr_reader :user_id include ResourceMethods # @param user_id [String] # # @example # # read https://timeline.line.me/user/_dYbbV3vmaJrvqBoV5ZlpCbPN2CWUZdDQayBvjBE # user = CureLine::User.new("_dYbbV3vmaJrvqBoV5ZlpCbPN2CWUZdDQayBvjBE") def initialize(user_id) @user_id = user_id end # @return [CureLine::Mash] def info preloaded_state["userHome"]["homeInfo"]["userInfo"] end # @return [String] def header_url resource_url(preloaded_state["userHome"]["homeInfo"]["resourceId"]) end # @return [Array<CureLine::Post>] def posts preloaded_state["userHome"]["feeds"].map { |feed| CureLine::Post.new(feed) } end # @return [CureLine::Mash] def preloaded_state return @preloaded_state if @preloaded_state options = {} options["User-Agent"] = CureLine.config.user_agent if CureLine.config.user_agent url = "https://timeline.line.me/user/#{user_id}" html = open(url, options).read m = html.match(/window.__PRELOADED_STATE__\s*=\s*({.+})/) raise "Not Found window.__PRELOADED_STATE__ in #{url}" unless m @preloaded_state = CureLine::Mash.new(JSON.parse(m[1])) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cure_line-0.1.2 | lib/cure_line/user.rb |
cure_line-0.1.1 | lib/cure_line/user.rb |
cure_line-0.1.0 | lib/cure_line/user.rb |