We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 9458e995 authored by elleo's avatar elleo

Merge commit 'refs/merge-requests/62' of git://gitorious.org/foocorp/gnu-fm into merge62

parents 115409a2 f93ac6f2
#!/usr/bin/env python
import xml.etree.cElementTree as ElementTree
import sys, gzip, time
import sys, gzip, time, httplib
import psycopg2 as ordbms
JAMENDO_MIRROR = "gigue.rrbone.net"
genremap = {
0 : "Blues",
1 : "Classic Rock",
......@@ -195,11 +197,11 @@ class JamendoImport:
for track in album["tracks"]:
if "http://creativecommons.org/licenses/by-sa" not in track["license"] and not "http://creativecommons.org/licenses/by/" in track["license"] and not "http://artlibre.org/licence.php/lal.html" in track["license"]:
streamable = 0
else:
if self.free_license(track["license"]) and self.is_in_mirror(track["id"]):
streamable = 1
any_streamable_tracks = 1
else:
streamable = 0
try:
duration = int(track["duration"])
......@@ -406,6 +408,20 @@ class JamendoImport:
except:
return False
def free_license(self, license):
return ("http://creativecommons.org/licenses/by-sa" in license or "http://creativecommons.org/licenses/by/" in license or "http://artlibre.org/licence.php/lal.html" in license)
def is_in_mirror(self, id):
try:
trackfile = "/" + str(id) + ".ogg2"
connection = httplib.HTTPConnection(JAMENDO_MIRROR)
connection.request("HEAD", trackfile)
response = connection.getresponse()
connection.close()
except:
return False
else:
return response.status == 200 and response.getheader('Content-Type') == 'audio/ogg'
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment