Finally have some time
I've received numerous (very nice hearing how many people have been using my software) e-mails and responses regarding how my hypescript and batch downloader are no longer working.
I've recently accepted a new position at Amazon in Seattle and the move was very time consuming. I was saddened at the state of the code and how I felt like I was letting people down by not fixing it in a timely fashion. Now that it's been a month or so since my move I've finally had time to work on fixing them for you guys! :)
The fix
The HypeMachine guys keep breaking the script due to my terrible regular expression I was using to scrape the site for the id & keys. I'm hoping the current regex I've updated it to is more robust and will thwart a few more attempts from them from breaking it!
What needs to be parsed
trackList[document.location.href]['item_1n361'] = {
seq: trackList[document.location.href].length,
type:'normal',
id:'1n361',
time:'266',
ts: '1340722642',
postid:'1852087',
posturl:'http://www.gorillavsbear.net/2012/06/26/mp3-premiere-erika-spring-hidden-jensen-sportag-remix/',
fav:'0',
key: 'c3f03b16ecce82ef18b6bf6e25c8e52b',
artist:'Erika Spring',
song:'Erika Spring -Hidden_ (Sportag Remix)_MS...',
thumb_url_large: 'http://static-ak.hypem.net/images/blog_images/15203.png'
};
trackList[document.location.href].push(trackList[document.location.href]['item_1n361']);
My regular expression
#old regex
idMatches = re.findall("[ t]id:'(w*)(?=')", contents)
keyMatches = re.findall("(?<=tkey: ')w*(?=')", contents)
songMatches= re.findall("(?<=tsong:').*(?=')", contents)
artistMatches= re.findall("(?<=tartist:').*(?=')", contents)
#new regex
idMatches = re.findall("s+id:s*'(.+)'", contents)
keyMatches = re.findall("s+key:s*'(.+)'", contents)
songMatches = re.findall("s+song:s*'(.+)'", contents)
artistMatches = re.findall("s+artist:s*'(.+)'", contents)
If you are more of a wiz at regex than me please recommend a better pattern :)
16 archived comments
jonny · 2012-08-19
it looks like the extension isn’t working anymore…well at least with my mac at home ( 10.5.8 ) . My mac at work running lion and prob the latest version of chrome works still.
Farid Zakaria · 2012-08-19
It’s a constant game of catchup. I’ll take a look when I’m back from vacation (i’m currently in Istanbul, Turkey).
You’ve been using the latest on GitHub?
Martin · 2012-08-21
I use the script every day, hope you’ll update it Farid :)
It stopped working for me 4 or 5 days ago.
Just says “Found 0 songs.”
Farid Zakaria · 2012-08-22
@Martin:
It’s #1 on my TODO list as soon as I get back from Turkey :)
tim · 2012-08-28
Hello, I don’t know how to use git hub, but I wrote some new regex for you guys. Tested and working as of today.
Works based on assumptions of the JSON format. Searches based on “”:”” pattern. Will accommodate any kind of spacing within the fields. #Key: ‘[,”]+[^”]?key[”:]+(w+)[,”]+’ #Id: ‘[,”]+[^”p]?id[”:]+(w+)[,”]+’ #Song: ‘[,”]+[^”]?song[”:]+(w+)[,”]+’ #Artist: (‘[,”]+[^”]?artist[”:]+(w+)[,”]+’);
tim · 2012-08-28
[wW]
Sorry, that was premature, see below for revised regex
’(?<!=)[,”]+[^”p]?id[”:]+(w+)[,”]+' '(?<!=)[,”]+[^”]?key[”:]+(w+)[,”]+' '(?<!=)[,”]+[^”]?song[”:]+([wW]+?)[,”]+' '(?<!=)[,”]+[^”]?artist[”:]+([wW]+?)[,”]+'
Martin · 2012-08-29
tim, thanks for posting.
I can’t get the formatting to work, could you post the complete lines of code from your hypeme.py script, please?
Thanks /Martin
Martin · 2012-08-29
tim, it works now, it looks like the first pling –> ‘ in line 1 has the wrong formatting.
One thing I noticed is, that it wouldn’t download this song: (37ea67fe5689988150e108807fd3c8df, Obedear (Noah Hydes Magic Sword Remix), Purity Ring/Noah Hyde/ Magic Sword)
I think it’s because of the forward slashes “/” in the name - any way to fix that?
Thanks again :-) /Martin
John · 2012-09-03
Hey! I REALLY love your script! I wanted to give you a heads up though that on my version of Chrome (21.0.1180.83 m) the plugin no longer will install due to the deprecation of using manifest 1. If you do any updates, please include them with manifest 2 so that it works again :) Thanks!
sean · 2012-09-05
@John: +1
Farid Zakaria · 2012-09-07
Hey everyone! Please check latest blog post, I have updated the extension. I am looking for help with fixing the CSS however!
Martin · 2012-09-10
Hope you’ll fix the script too :)
Thanks!
tim · 2012-09-11
@tim:
Thanks for pointing that one out. The regex pattern assumed that the song name and artist would contain only letters and spaces. [wW]
Slightly more complicated version:
(?<!=)[,”]+[^”]?song[”:]+(.+?)(?<!)[,”]+ (?<!=)[,”]+[^”]?artist[”:]+(.+?)(?<!)[,”]+
Can handle any character in the name. It will also ignore quotations marks in the name, as long as they are escaped.
All working: “song”:”Aus”tra” = Aus”tra “song”:”Aus/ra” = Aus/ra “song”:”Aus()ra” = Aus()ra
Farid Zakaria · 2012-09-11
@tim: Hey Tim!
Can you drop this as a bug on GitHub or something? I’ll try to remember to look at it (validate) and incorporate the fix however Im swamped with work this week.
Martin · 2012-09-13
@tim: Could you post the complete lines from the hypeme.py script please?
I tried copy/pasting your new regex in, but I get syntax errors.
Martin · 2012-09-13
@tim: Hey Tim
Here you can see my 2 lines from hypeme.py, Python 2.7 gives me an “unbalanced parenthesis” error:
songMatches = re.findall(‘(?<!=)[,”]+[^”]?song[”:]+(.+?)(?<!)[,”]+', html_contents) artistMatches = re.findall('(?<!=)[,”]+[^”]?artist[”:]+(.+?)(?<!)[,”]+', html_contents)