-
-
Save JeremyJames/2300945 to your computer and use it in GitHub Desktop.
Offliberpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
# Version 2, December 2004 | |
# | |
# Copyright (C) 2013 Bixed | |
# | |
# Everyone is permitted to copy and distribute verbatim or modified | |
# copies of this license document, and changing it is allowed as long | |
# as the name is changed. | |
# | |
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
# | |
# 0. You just DO WHAT THE FUCK YOU WANT TO. | |
import sys | |
import os | |
from urllib import urlopen | |
from urllib import urlencode | |
from subprocess import call | |
from re import search | |
from pyquery import PyQuery as pq | |
post_url = "http://offliberty.com/off.php" | |
def parse_response(response): | |
return search(b'<A HREF="(.*)" class="download"', response).group(1) | |
def get_response(url): | |
return urlopen( | |
post_url, | |
urlencode({ | |
'track': url, | |
'reftext': ''}).encode('utf-8')).read() | |
def offliberpy(url): | |
d = pq(url=url) | |
for index in range(len(d(".video-list-item"))): | |
title = d(".video-list-item").eq(index).attr("data-video-title") | |
link = d(".video-list-item > a").eq(index).attr('href').split('&')[0] | |
hash = link.split('=')[1] | |
print title, 'http://youtube.com' + link, hash | |
if os.path.exists(title + '.mp3'): | |
print ("Skipping %s.mp3" % hash) | |
else: | |
print ("Downloading %s.mp3" % hash) | |
try: | |
call(['curl', | |
parse_response( | |
get_response('http://youtube.com' + link)), | |
'-o', hash + '.mp3.dl']) | |
os.rename(hash + '.mp3.dl', title + '.mp3') | |
print ("Done") | |
except: | |
print ("The Video is offline or Offliberty limit exceeded)") | |
if __name__ == '__main__': | |
print(offliberpy(sys.argv[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment