Volume 1 of wanting to make your favorite SCANDAL LINE bot

The bot you want to make

A bot that randomly sends a SCANDAL MV at a fixed time every day

The idea in my head for that (created with rails)

  1. First, make something that moves on the WEB
  2. Make it a LINEbot
  3. Add functions from there (for example, if you send with ACIDMAN and LINE, ACIDMAN songs will be returned randomly)

What I was able to do for the time being

  1. First, make something that moves on the WEB

Referenced articles

I referred to the YouTube Data API reference based on the Qiita article.

Qiita https://qiita.com/sakakinn/items/46c0d4945e4646f346f6

YouTube Data API https://developers.google.com/youtube/v3/docs?hl=ja



<% number = 0 %>
<% ran = rand(1..11) %>
<% @youtube_data.items.each do |item| %>
  <% number = number + 1 %>
  <% if number == ran %>
   <% snippet = item.snippet %>
   <p><%= snippet.title %></p>
   <p><%= snippet.published_at %><%= snippet.channel_title %></p>
   <div><iframe width="560" height="315" src="https://www.youtube.com/embed/<%= item.id.video_id %>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>
  <% end %>
<% end %>


class YoutubeController < ApplicationController
  def find_videos(keyword)
    service = Google::Apis::YoutubeV3::YouTubeService.new
    service.key = ENV["YOUTUBEKEY"]

    next_page_token = nil
    opt = {
      q: keyword,
      type: 'video',
      channel_id: 'UCSNX8VGaawLFG_bAZuMyQ3Q',
      max_results: 11,
      order: :date,
      page_token: next_page_token
    service.list_searches(:snippet, opt)

  def index
    @youtube_data = find_videos('SCANDAL')

Output result ↓ https://twitter.com/pompom06yutoz/status/1273869183491559425?s=21

Challenges we know now

  1. Since I am accessing 11 data in View, I want to eliminate it and randomly retrieve only one data from the channel. (Help me ~ ww)
  2. If it is left as it is, the channel will be fixed (once through)

What to do next

For the time being, try using this as a LINE bot, and think about it when an issue emerges.


It's been about 4 months since I started learning programming, and I'm enjoying it so much. If you have any good alternatives, please feel free to comment. Also, if you like SCANDAL, please do. to be continued

Recommended Posts

Volume 1 of wanting to make your favorite SCANDAL LINE bot
Easy to make LINE BOT with Java Servlet
Easy to make Slack Bot in Java
How to make a Discord bot (Java)
[LINE @] I tried to make a Japanese calendar Western calendar conversion BOT [Messaging API]