diff --git a/app/controllers/podcasts_controller.rb b/app/controllers/podcasts_controller.rb
index 46733c31..5412e90e 100644
--- a/app/controllers/podcasts_controller.rb
+++ b/app/controllers/podcasts_controller.rb
@@ -35,8 +35,6 @@ def show
private
def convert_shownote(content)
- youtube_id = @episode.content.match(/watch\?v=((\w)*)/)[1]
-
shownote = <<~HTML
đ¤
@@ -44,10 +42,11 @@ def convert_shownote(content)
(芹ăăăă¨)
HTML
-
content.gsub!(/(#+) Shownote/) { shownote }
- return content unless content.match?(Podcast::TIMESTAMP_REGEX)
+ return content unless content.match?(Podcast::YOUTUBE_ID_REGEX)
+ return content unless content.match?(Podcast::TIMESTAMP_REGEX)
+ youtube_id = @episode.content.match(Podcast::YOUTUBE_ID_REGEX)[1]
content.gsub!(Podcast::TIMESTAMP_REGEX) do
t = $1
t = (t.size == '0:00'.size) ? '0' + t : t
diff --git a/app/models/podcast.rb b/app/models/podcast.rb
index ab490f9b..d4add910 100644
--- a/app/models/podcast.rb
+++ b/app/models/podcast.rb
@@ -2,7 +2,8 @@ class Podcast < ApplicationRecord
self.table_name = 'podcasts'
DIR_PATH = 'public/podcasts'
WDAY2JAPANESE = %w(ćĽ ć çŤ ć°´ ć¨ é ĺ)
- TIMESTAMP_REGEX = /-\s((\d:)?\d{1,}:\d{2})/
+ TIMESTAMP_REGEX = /-\s((\d:)?\d{1,}:\d{2})/
+ YOUTUBE_ID_REGEX = /watch\?v=((\w)*)/
validates :title, presence: true
validates :content_size, presence: true