@@ -0,0 +1,821 @@
+from __future__ import unicode_literals%0A%0Aimport re%0A%0Afrom mopidy.models import Ref%0A%0A%0Adef unparse_uri(variant, identifier):%0A    return b'dirble:%25s:%25s' %25 (variant, identifier)%0A%0A%0Adef parse_uri(uri):%0A    result = re.findall(r'%5Edirble:(%5Ba-z%5D+)(?::(%5Cd+))?$', uri)%0A    if result:%0A        return result%5B0%5D%0A    return None, None%0A%0A%0Adef station_to_ref(station):%0A    name = station.get('name', station%5B'streamurl'%5D)%0A    if station.get('country'):%0A        name += ' (%25s)' %25 station%5B'country'%5D%0A    uri = unparse_uri(b'station', station%5B'id'%5D)%0A    return Ref.track(uri=uri, name=name)%0A%0A%0Adef category_to_ref(category, primary=True):%0A    if primary:%0A        uri = unparse_uri(b'category', category%5B'id'%5D)%0A    else:%0A        uri = unparse_uri(b'subcategory', category%5B'id'%5D)%0A    return Ref.directory(uri=uri, name=category.get('name', uri))%0A

Add translator for (un)parsing uris and converting data to refs