Created
June 18, 2013 04:32
-
-
Save kimhunter/5802691 to your computer and use it in GitHub Desktop.
Missing wwdc2013 videos from my own renaming format
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 'nokogiri' | |
doc = Nokogiri::HTML(File.open("Videoswwdc.html")) | |
items = {} | |
doc.xpath("//li[@class='session']").each do |session| | |
session_id = session['id'].sub('-video', '').to_i | |
title = session.children.xpath("li[@class='title']").text | |
items[session_id] = title | |
end | |
items.each {|k,v| puts "#{k} => #{v}"} | |
PREFIX="/Volumes/GTech/WWDC2013/" | |
# PREFIX="/Users/kim/Downloads/pdfs/" | |
files = Dir["#{PREFIX}WWDC2013*.mov"] | |
base_names = files.map {|d| d.sub(PREFIX, '') } | |
have_numbers = [] | |
base_names.each do |file| | |
have_numbers << $1.to_i if file =~ /WWDC2013 ([0-9]+) / | |
end | |
# build a list of missing session | |
have_nots = (items.keys - have_numbers).sort | |
missing_sessions = have_nots.map do |num| | |
"#{num} - #{items[num]}" | |
end | |
puts missing_sessions.sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment