Created
August 23, 2019 20:01
-
-
Save urielhdz/85f5fee7fd79fcf493a6deda1eb965d3 to your computer and use it in GitHub Desktop.
This file contains 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
require 'digest/sha1' | |
require "google/cloud/firestore" | |
firebase_credentials = File.open('./firebase-key.json').read | |
firestore = Google::Cloud::Firestore.new(project_id: 'livemusiccodigofacilito', credentials: './firebase-key.json') | |
track_ref = firestore.doc "tracks/main" | |
music_data = "" | |
loop do | |
sleep(2) | |
file_content = File.read("./music.txt") | |
if file_content != music_data | |
# Upload to firebase | |
data = file_content.split("-") | |
song = data[0].strip | |
singer = data[1].strip | |
response = track_ref.set({ singer: singer, song: song }) | |
puts response.to_yaml | |
end | |
music_data = file_content | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment