[SCM] morituri/master: * misc/offsets.py (added): Add a script to calculate list of offsets based on AccurateRip's online database, according to popularity.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:09:15 UTC 2014
The following commit has been merged in the master branch:
commit 77d77013f14f98bf7c457c70add47d82679b24eb
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Sun Mar 14 12:51:03 2010 +0000
* misc/offsets.py (added):
Add a script to calculate list of offsets based on AccurateRip's
online database, according to popularity.
diff --git a/ChangeLog b/ChangeLog
index cd0c448..8fa0294 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-03-14 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * misc/offsets.py (added):
+ Add a script to calculate list of offsets based on AccurateRip's
+ online database, according to popularity.
+
2010-02-28 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/encode.py:
diff --git a/misc/offsets.py b/misc/offsets.py
new file mode 100644
index 0000000..3e22168
--- /dev/null
+++ b/misc/offsets.py
@@ -0,0 +1,71 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+# show all possible offsets, in order of popularity, from a download of
+# http://www.accuraterip.com/driveoffsets.htm
+
+import sys
+
+import BeautifulSoup
+
+handle = open(sys.argv[1])
+
+doc = handle.read()
+
+soup = BeautifulSoup.BeautifulSoup(doc)
+
+offsets = {} # offset -> total count
+
+rows = soup.findAll('tr')
+for row in rows:
+ columns = row.findAll('td')
+ if len(columns) == 4:
+ first, second, third, fourth = columns
+ name = first.find(text=True)
+ offset = second.find(text=True)
+ count = third.find(text=True)
+
+ # only use sensible offsets
+ try:
+ int(offset)
+ except:
+ continue
+
+ if offset not in offsets.keys():
+ offsets[offset] = 0
+ # first line is text, so int will fail with ValueError
+ # purged entries will have None as count, so TypeError
+ try:
+ offsets[offset] += int(count)
+ except (ValueError, TypeError):
+ pass
+
+# now sort offsets by count
+counts = []
+for offset, count in offsets.items():
+ counts.append((count, offset))
+
+counts.sort()
+counts.reverse()
+
+offsets = []
+for count, offset in counts:
+ offsets.append(offset)
+
+# now format it for code inclusion
+lines = []
+line = 'OFFSETS = "'
+
+for offset in offsets:
+ line += offset + ", "
+ if len(line) > 60:
+ line += "\" + \\"
+ lines.append(line)
+ line = ' "'
+
+# get last line too, trimming the comma and adding the quote
+if len(line) > 11:
+ line = line[:-2] + '"'
+ lines.append(line)
+
+print "\n".join(lines)
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list