Created
July 4, 2020 12:50
-
-
Save ongaeshi/b0d9f36149cc5c93ae3d439ef2975d2e 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
| # coding: utf-8 | |
| require "radiko/radiko" | |
| include Radiko | |
| def c(channel, wday) | |
| Radiko::Radiko.new(channel, last_wday(wday + 1, 1, 0)).astr(channel) | |
| end | |
| def ann(title, wday) | |
| print title, "\n", | |
| c("LFR", wday), " ", | |
| c("CBC", wday), " ", | |
| c("RNB", wday), " ", | |
| c("MRT", wday), " ", | |
| c("YBC", wday), " ", | |
| c("MRO", wday), " ", | |
| "\n\n" | |
| end | |
| ann("菅田将暉", 1) | |
| ann("星野源", 2) | |
| ann("AKB48", 3) | |
| ann("ナインティナイン岡村隆史", 4) | |
| ann("三代目J Soul Brothers 山下健二郎", 5) | |
| ann("オードリー", 6) |
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
| # coding: utf-8 | |
| require "radiko/radiko" | |
| include Radiko | |
| def c(channel, wday) | |
| Radiko::Radiko.new(channel, last_wday(wday + 1, 1, 0)).astr(channel) | |
| end | |
| def junk(title, wday) | |
| print title, "\n", | |
| c("TBS", wday), " ", | |
| c("RBC", wday), " ", | |
| c("CRK", wday), " ", | |
| c("RKB", wday), " ", | |
| c("HBC", wday), " ", | |
| "\n\n" | |
| end | |
| junk("伊集院光・深夜の馬鹿力", 1) | |
| junk("爆笑問題カーボーイ", 2) | |
| junk("山里亮太の不毛な議論", 3) | |
| junk("おぎやはぎのメガネびいき", 4) | |
| junk("バナナマンのバナナムーンGOLD", 5) |
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
| # coding: utf-8 | |
| module Radiko | |
| class Radiko | |
| # channel | |
| # TBS .. TBSラジオ | |
| # RN1 .. ラジオNIKKEI第1 | |
| # RN2 .. ラジオNIKKEI第2 | |
| # RBC .. RBCiラジオ | |
| # CRK .. ラジオ関西 | |
| # RKB .. RKBラジオ | |
| # HBC .. HBCラジオ | |
| # | |
| # time | |
| # Timeオブジェクト | |
| def initialize(channel, time = Time.now) | |
| @channel = channel | |
| @time = time | |
| end | |
| def time_url | |
| sprintf( | |
| "%04d%02d%02d%02d%02d%02d", | |
| @time.year, | |
| @time.month, | |
| @time.day, | |
| @time.hour, | |
| @time.min, | |
| @time.sec | |
| ) | |
| end | |
| def url | |
| "radiko://radiko.jp/share/?sid=#{@channel}&t=#{time_url}" | |
| end | |
| def astr(title) | |
| #p url | |
| AttrString.new(title, link: url) | |
| end | |
| end | |
| def last_wday(wday, hour, min) | |
| t = Time.now | |
| t = Time.local(t.year, t.month, t.day, hour, min) | |
| if t.wday >= wday | |
| d = t.wday - wday | |
| else | |
| d = t.wday + 7 - wday | |
| end | |
| t - d * (24 * 60 * 60) | |
| end | |
| def cc(channel, wday, hour, min) | |
| Radiko.new(channel, last_wday(wday, hour, min)).astr(channel) | |
| end | |
| def chan(title, chans, wday, hour, min) | |
| puts title | |
| chans.each do |e| | |
| print cc(e, wday, hour, min), " " | |
| end | |
| puts | |
| puts | |
| end | |
| def parse_whm(src) | |
| r = [] | |
| w, t = src.split(" ") | |
| week = %w(sun mon tue wed thu fri sat) | |
| # weekday | |
| wi = week.index(w.downcase) | |
| # hour | |
| hour, min = t.split(":") | |
| hour = hour.to_i | |
| if hour >= 24 | |
| hour -= 24 | |
| wi = wi == 6 ? 0 : wi + 1 | |
| end | |
| r << wi | |
| r << hour | |
| # min | |
| r << min.to_i | |
| r | |
| end | |
| def c(name, whm, chans) | |
| chan "#{name}(#{whm})", chans, *parse_whm(whm) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment