aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-01-19 13:32:49 -0800
committerScott Jackson <daneren2005@gmail.com>2014-01-19 13:32:49 -0800
commitb6bb20380fe2ab87d0e1415cd02bf3f6f3f14196 (patch)
treeb5c00c9505df099d48fa1579c799a2e9f5f75b72 /src/github
parent99fec3f3de854d4fa358713595b8ab5b26873aac (diff)
downloaddsub-b6bb20380fe2ab87d0e1415cd02bf3f6f3f14196.tar.gz
dsub-b6bb20380fe2ab87d0e1415cd02bf3f6f3f14196.tar.bz2
dsub-b6bb20380fe2ab87d0e1415cd02bf3f6f3f14196.zip
#253 Try to base query off of tags
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/util/Util.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index 05267699..e944f125 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -421,7 +421,14 @@ public final class Util {
}
public static String parseOfflineIDSearch(Context context, String id, String cacheLocation) {
- String name = id.replace(cacheLocation, "");
+ // Try to get this info based off of tags first
+ String name = parseOfflineIDSearch(id);
+ if(name != null) {
+ return name;
+ }
+
+ // Otherwise go nuts trying to parse from file structure
+ name = id.replace(cacheLocation, "");
if(name.startsWith("/")) {
name = name.substring(1);
}
@@ -458,6 +465,31 @@ public final class Util {
return name;
}
+ public static String parseOfflineIDSearch(String id) {
+ MusicDirectory.Entry entry = new MusicDirectory.Entry();
+ File file = new File(id);
+
+ if(file.exists()) {
+ entry.loadMetadata(file);
+
+ if(entry.getArtist() != null) {
+ String title = file.getName();
+ int index = title.lastIndexOf(".");
+ title = index == -1 ? title : title.substring(0, index);
+ title = title.substring(title.indexOf('-') + 1);
+
+ String query = "artist:\"" + entry.getArtist() + "\"" +
+ " AND title:\"" + title + "\"";
+
+ return query;
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
public static String getContentType(HttpEntity entity) {
if (entity == null || entity.getContentType() == null) {
return null;