Skip to content

Instantly share code, notes, and snippets.

View gravelld's full-sized avatar

Dan Gravell gravelld

View GitHub Profile
@gravelld
gravelld / gist:3177368
Created July 25, 2012 17:21
How I update resources in bliss... (at the moment)
final Resource[] resourcesToUpdate = FelixObrUtils.getLatestBundleResourcesToInstall(repoAdminSupplier);
final Resource[] resourcesToUpdateExceptUpdater = Iterables.toArray(
Iterables.filter(
ImmutableList.copyOf(resourcesToUpdate),
Predicates.not(FelixObrUtils.isResourceSymbolicName("com.elsten.bliss.updater"))),
Resource.class);
final Resolver resolver = repoAdminSupplier.get().resolver();
for (Resource resource : resourcesToUpdateExceptUpdater) {
resolver.add(resource);
@gravelld
gravelld / DiscogsTrackPositionParser.scala
Last active January 20, 2016 11:15
A parboiled2 parser for Discogs track positions
package com.elsten.adb.extract.discogs.release
import org.parboiled2._
/*
* Parses strings according to http://www.discogs.com/help/doc/submission-guidelines-release-trk#Position
*/
class DiscogsTrackPositionParser(val input: ParserInput, val isMultiDisc: Boolean = false, val isAutocoupled: Boolean = false) extends Parser {
def mediumPrefixKnownFormat = rule { "DVD" | "CD" }
# bliss regex rule for assessing and fixing disc and track numbers in music files.
# Checks that the selected numeric tags do no have "part of set" delimiters, e.g. "1/12".
# If they do, offer a one click fix to remove the delimiter and total number, e.g. change to "1"
rule partofset with label "Remove part of set" has alternatives
PART_ONLY {
find /([\d]+)//[\d]+/ replace with "$1"
}
applies to disc_number, track_number
# Rickroll your music library!
#
# Never gonna give you up
# Never gonna let you down
# Never gonna run around and desert you
# Never gonna make you cry
# Never gonna say goodbye
# Never gonna tell a lie and hurt you
rule rickroll with label "Rickroll me" has alternatives
NEVER_GONNA_GIVE_YOU_UP {
# Rule to limit album fields to 92 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the album name to exactly 92 characters.
rule sonosAlbumCharLimit with label "Sonos album name character limit" has alternatives
92_CHARS {
find /^(.{0,92}+).+$/ replace with "$1"
}
applies to album_name
# Rule to limit artist fields to 76 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the artist or album artist name to exactly 76 characters.
rule sonosArtistCharLimit with label "Sonos artist character limit" has alternatives
76_CHARS {
find /^(.{0,76}+).+$/ replace with "$1"
}
applies to artist, album_artist
# Rule to limit genre fields to 22 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the genre to exactly 22 characters.
rule sonosGenreCharLimit with label "Sonos genre character limit" has alternatives
22_CHARS {
find /^(.{0,22}+).+$/ replace with "$1"
}
applies to genre
# Rule to limit track name fields to 100 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the track name to exactly 100 characters.
rule sonosTrackCharLimit with label "Sonos track name character limit" has alternatives
100_CHARS {
find /^(.{0,100}+).+$/ replace with "$1"
}
applies to track_name
# Rule to limit track fields to 100 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the track to exactly 97 characters with a three character ellipsis at the end
rule sonosTrackCharLimit with label "Sonos track name character limit" has alternatives
100_CHARS {
find /^(.{0,97}+)(.{0,3}+).+$/ replace with "$1..."
}
applies to track_name
@gravelld
gravelld / remove-pirate-juice.regexrule
Created December 2, 2016 11:26
Regex rule to remove strings from the end of fields
# Rule to remove annoying pirate juice inserts in the tags downloaded
rule removePirateJuice with label "Remove MP3PirateJuice tags" has alternatives
REMOVE {
find /^(.*) - \[MP3PIRATEJUICE.COM\]$/ replace with "$1"
}
applies to artist, album_name, genre, track_name