Showing posts with label SoundCloud. Show all posts
Showing posts with label SoundCloud. Show all posts

Wednesday, March 27, 2013

SCGet Status Update

Recently both Josh and I have been busy with soundcloud-get (scget) and it has been coming along quite nicely. We feel confident that it is currently at a stable place and are looking into how to release a python project and tag it as version 1.0.

The current command line options that scget supports are:

  • -u <song_url>- Downloads a song from the specified song url. This parameter can be provided multiple times.
  • -a <artist_url> - Downloads all songs from the specified artist url.
  • -o <folder> - Folder to download all songs to. If not provided or doesn't exist, all songs are downloaded to the current directory.
  • -m - If provided, downloads are multi-threaded.
  • -st <track_name> - Searches for tracks that are similar to the provided name and prints their titles.
  • -sa <artist_name> - Searches for artists that are similar to the provided name and prints their names.
  • -l <number> - Limits the number of results pulled back from either the search track or search artist queries. If not provided, each search defaults to 20 results.
Once we figure out how to release this project we do have a few ideas of what still needs to come for this project:
  • Ways for the user to choose songs/artists to download from the provided search results.
  • Being able to provide a yaml configuration instead of having so many command line arguments.
  • Add a default download directory structure instead of just the current directory.
  • Thread pooling for multi-threaded downloads to better manage the many download threads.
  • Track down Unicoder Coercion errors that happen on occasion.
Though, for now it is all working fine and as expected for almost all cases which is why we want to release it now and then tackle these other issues.

Remember you can always watch the progress of this project on our github page.

Wednesday, March 6, 2013

SCGet

I currently started to work on a new side project, scget. It's a command line tool that will allow users to easily download songs from SoundCloud. SoundCloud does allow downloads from the browser, but that requires one to navigate to the page, click download on each song they want, and specify an output folder. This command line tool is going to be simple, yet powerful alternative to downloading from the browser.

Some of the options that have already been thought of are:
  • Download a single song
  •  scget <trackUrl>  
    
  • Download multiple songs
  •  scget <trackUrl1> <trackUrl2> ... <trackUrlN>  
    
  • Download all songs from a particular artist
  •  scget -dj <userUrl>  
  • And of course, the ability to specify a download folder
  •  scget <trackUrl> -o <folder>  
    
Obviously this would be easier than having to navigate the webpage because you could just queue up a bunch of urls to download and then hit go. It will do all of the processing behind the scenes while you get back to what you were doing before.

For this project, I am working in collaboration with Josh Branchaud on this project because not only are we great friends, but we both love SoundCloud. You can follow our progress on this command line tool on our github page.

P.S. - If you have any suggestions about other functionality that should be included in this tool feel free to leave it in a comment.


Saturday, February 9, 2013

Gson and Date Formatting

Gson is a really cool tool to quickly convert regular POJOs to json strings and back. It's super simple to setup and even easier to use:

 final Gson gson = new GsonBuilder().create();  
 final String jsonString = gson.toJson(myPojo);  
 final Pojo myPojo = gson.fromJson(jsonString, Class);  

However, by default it appears that Gson uses a fairly simple date formatter that seems to be locale specific. In most cases, this should be alright unless you need to parse a more fine grained date, such as something like "2013/02/09 15:07:50 +0000". When using gson to parse a date like it does fail, and you get exceptions:

 Caused by: java.text.ParseException: Unparseable date: "2013/02/09 15:07:50 +0000"  

Obviously this is not wanted and knowing that this is a valid date makes it even stranger that gson couldn't handle it. The answer? You can override the date parsing adapter that gson uses by default with your own version. For my example, I had to override it with the following:

final GsonBuilder builder = new GsonBuilder();  
builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {  
    // Year in 4, month in 2, day in 2, hour in 24, minutes in hour, seconds in minute, timezone in 4  
    final DateFormat df = new SimpleDateFormat("yyyy/MM/dd kk:mm:ss Z");  
    @Override  
    public Date deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) throws JsonParseException {  
        try {  
            return df.parse(json.getAsString());  
        } catch (final java.text.ParseException e) {  
            e.printStackTrace();  
            return null;  
        }  
    }  
});  
return builder.create();  

So, this is a really simple yet powerful way to use gson even when you have difficult dates that need to parsed.