Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Add some nicolinks! #19

Merged
merged 1 commit into from Apr 26, 2017
Merged

Conversation

execjosh
Copy link

@execjosh execjosh commented Apr 21, 2017

FAQを基に作ったけどあまり詳しくないので、もし間違ったところあれば直します!ご指摘ください!

Issue #3

# frozen_string_literal: true

class NicoLink
NICOLINK_RE = /(?<pre>^|[^\/\)\w])((?<id1>(ap|ar|az|ch|co|dw|im|jps|kn|lv|nc|nw|td)[0-9]+)|(?<id2>sm[0-9]+)(?<time>#[0-9]{1,2}:[0-5][0-9])?)/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id2(動画リンク)は sm の他にも so は少なくとも欲しいかな。厳密には昔のが他にもあるけど。あと lvもむしろ id2かな。時間アンカー付くので

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

後追いで是非対応IDを増やしていきたいですね!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

秒数指定を実装してみた

@masarakki
Copy link

これはさすがにテスト欲しくなる
たぶんhtml_safeあたりかまさないとな気がする

@execjosh execjosh force-pushed the feature/nicolinks branch 2 times, most recently from 4f60dd1 to 33bbcf8 Compare April 22, 2017 15:41
@execjosh
Copy link
Author

execjosh commented Apr 22, 2017

こんな記事があったのか:http://dic.nicovideo.jp/a/id

時間アンカーはひとまず措いて im lv sm so を実装することにした。
テスト、こんなので充分かな。網羅できてないケースをぜひ指摘・援助を乞う!

たぶんhtml_safeあたりかまさないとな気がする

既に処理の最後に通っているようだけど、これとは違うものかな?

so
].freeze

NICOLINK_RE = %r{(?<prefix>^|[^\/\)\w])(?<nico_id>(#{ALL_TYPES.join('|')})[0-9]+)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あぁこれ普通に \d+ でええやん

class NicoLink
BASE_URI = URI.parse('https://nico.ms')

TEMPORAL_TYPES = %w[
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

巧いネーミングが思い付かなかった・・・(´・ω・`)

@masarakki
Copy link

squashとrebaseよろー

取り敢えず次の種類を実装する。

- 分秒可
  - lv 生放送
  - sm 動画
  - so 公式動画
- 分秒無し
  - im 静画
@execjosh
Copy link
Author

✅ rebase
✅ squash

@masarakki masarakki merged commit 5b47c98 into dwango:friends.nico Apr 26, 2017
@masarakki
Copy link

thx :nicoru:

@execjosh execjosh deleted the feature/nicolinks branch May 1, 2017 04:34
execjosh pushed a commit to execjosh/mastodon that referenced this pull request May 1, 2017
acid-chicken added a commit to 346design/twista.283.cloud that referenced this pull request Apr 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants