-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYouTubeChannelToInfinity.rb
executable file
·56 lines (42 loc) · 1.65 KB
/
YouTubeChannelToInfinity.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# encoding: UTF-8
require_relative "Libs/loader.rb"
=begin
yt-dlp \
-o '%(upload_date)s-%(title)s-%(id)s.%(ext)s' \
-f 'bestvideo[height<=720]+bestaudio/best[height<=720]' \
"https://www.youtube.com/@veritasium/videos"
=end
youTubeURL = "https://www.youtube.com/@jomakaze/videos"
tmpDirectoryName = SecureRandom.hex(5)
puts "Downloading videos"
query = <<-QUERY
mkdir /Users/pascal/Desktop/#{tmpDirectoryName}
cd /Users/pascal/Desktop/#{tmpDirectoryName}
yt-dlp \
-o '%(upload_date)s-%(title)s-%(id)s.%(ext)s' \
-f 'bestvideo[height<=720]+bestaudio/best[height<=720]' \
"#{youTubeURL}"
QUERY
system(query)
positions = Items::mikuType("NxTask")
.select{|item| item["parentuuid-0014"].nil? }
.sort_by{|item| item["global-positioning-4233"] }
.map{|item| item["global-positioning-4233"] }
insertions = positions.zip(positions.drop(1))
.select{|pair| pair.compact.size == 2 }
.map{|pair| 0.5 * (pair[0] + pair[1]) }
.drop(10) # we skip the first 10 positions
filepaths = LucilleCore::locationsAtFolder("/Users/pascal/Desktop/#{tmpDirectoryName}")
while insertions.size < filepaths.size do
insertions << insertions.last + 1
end
coordinates = filepaths.zip(insertions)
coordinates.each{|filepath, position|
item = NxTasks::locationToTask(File.basename(filepath), filepath)
Items::setAttribute(item["uuid"], "global-positioning-4233", position)
Items::setAttribute(item["uuid"], "x:filepath", filepath)
item = Items::itemOrNull(item["uuid"])
puts JSON.pretty_generate(item)
}
LucilleCore::removeFileSystemLocation("/Users/pascal/Desktop/#{tmpDirectoryName}")
puts "process completed"