Farid Zakaria

Archive 1 min read

Python Download Script Updated


This post comes from my original WordPress blog, written between 2009 and 2018. It is kept here verbatim as an archive — the formatting did not always survive the move, and I no longer agree with all of it.

I'm so slow

I'm been so caught up in my new website project (downloading songs from HypeMachine as well), that I've really left the extension and python script fall behind.
In an attempt to try and rectify this, I've made the first step by fixing/updating the python script. I've already documented many of the changes that needed to occur in my previous blog post but now here is the full source for those who are curious!

You can download the script here: https://github.com/fzakaria/HypeScript

I've substantially cleaned up the code and removed the sqlite (database) aspect to it. This has resulted in a nice clean barebone downloader which does the one job it needs to do; download'em songs!. I'm always looking for advice, comments and feedback.

20 archived comments

Martin 2012-10-31

Thanks a lot Farid! :)

I get this error when running the script, maybe it has to do with “/” characters, I don’t know.

Any ideas?


FETCHING SONG.... Traceback (most recent call last):   File "hypeme.py", line 153, in 
main()   File "hypeme.py", line 150, in main
scraper.start()   File "hypeme.py", line 74, in start
self.download_songs(tracks, cookie)   File "hypeme.py", line 118, in download_songs
print "t{} by {}".format(title, artist) UnicodeEncodeError: 'ascii' codec can't encode character u'xe9' in position 21: ordinal not in range(128) -------

Martin 2012-10-31

Edit: After googling, it seems like it’s this: (é) character that your script doesn’t like?

Martin 2012-10-31

If I comment out line 118, the script runs.

§Also, I get this error, so I don’t think that “/” in the filename works either:

generic exception: [Errno 2] No such file or directory: ‘One Day / Reckoning Song (Wankelmut Remi….mp3’ ——

Martin 2012-10-31

Sorry Farid, but I also found that the script doesn’t respect the chosen download folder.

It always downloads to the folder where the hypeme.py script is run from.

Thanks again :) /Martin

Farid Zakaria 2012-10-31

Hey Martin!

I’ll look into all these problems now for you! :)

In the future I’d recommend opening up an ‘Issue’ on the gituhb page for the script here: https://github.com/fzakaria/HypeScript

I’ll respond back when I make the changes! :)

Farid Zakaria 2012-10-31

I just pushed a change.

I checked that 1) songs with forward slashes are working 2) filenames with accents (unicode) are working!

Martin 2012-11-01

Hey Farid

Thanks, it works fine now :)

One question, I have set the script to run automatically several times a day, and it scrapes my liked tracks.

I have set the script to download 1 page only, but everytime it runs it has to download all the songs from page 1 and I have a clean-up script to remove the duplicates.

There’s no way to get around that, now that the sql database is gone (the script doesn’t know which tracks it has already downloaded)?

Jökull 2012-11-05

Good stuff. I’m using your hypem download link site. I would love to see this script be pep8-ized though : )

Farid Zakaria 2012-11-05

Hey! Um i’ve never pep8’d a python module before but ti’s something I’d love to look into. There are a few to dos for the script as well. Thanks for the feedback! I actually have a huge re-design of the download site which I think everyone will love that I’ve done with a partner.

Farid Zakaria 2012-11-05

Hey Martin,

I initially removed the database checking to make the script simple for people to learn from.

I can look into making it a proper module for you.

Gregory Allan 2012-11-07

Hey I would really appreciate this too! : )

Martin 2012-11-08

Hey Farid

That would be great, I hope you find the time to do it :-)

Thanks Martin

Farid Zakaria 2012-11-08

I’m just a bit pre-occupied on my new site (http://metahypem.com).

I will try and fix it up. If any of you are python wiz’s I’d appreciate the help too! :)

Jorge 2014-07-04

می‌گه:ba salamdooste aziz bande yeki az mioardne site p30rank.ir hastamin site be hich onvan az fakezilla estefade nemikonad va nakardelotfan az roo bi etelaii in etelaate ghalat ra be mardom nadahidba tashakor

Tom 2014-07-04

是heavenly script 哼哼 然後其實語言學上Chinese是包括很多東西的 北京話 所謂的標準話 廣東話 上海話 閩南語…etc 就算是一個以北京話 啊還是你喜歡叫它台灣的中文 隨便 為母語的人 例如我 也沒辦法聽懂上海話 之前在上海機場被海關人員嚇到 也就是說 雖然是Chinese 但是有很多分支 有人說是方言 也有人認為只是口音 總之語言學家很多人就有很多種說法 所以聽不懂也可能是有可能的 嗯今天講話好多括號 題外話 你的哲學雞蛋糕信的確有助於我不小心瀏覽到有興趣的文章 然後不小心點進來這裡亂滾

Egypt 2014-07-04

I came, I read this article, I couenerqd.

Toni 2014-07-05

Now I feel stduip. That’s cleared it up for me

Open 2014-07-05

Way to use the internet to help people solve prlesbmo!

Ester 2014-07-06

That’s the thnniikg of a creative mind

Tommi 2014-07-21

It’s always a pleasure to hear from someone with exetrpise.