Skip to content

Instantly share code, notes, and snippets.

@tsuwatch
Created May 18, 2013 08:30
Show Gist options
  • Save tsuwatch/5603732 to your computer and use it in GitHub Desktop.
Save tsuwatch/5603732 to your computer and use it in GitHub Desktop.
anime mp4 downloader
from BeautifulSoup import BeautifulSoup
import urllib2
import urllib
import sys
import re
argc = len(sys.argv)
if (argc != 2):
print 'Usage: # python %s eyeonanime.com\'s url' % sys.argv[0]
quit()
html = urllib2.urlopen(sys.argv[1]).read()
soup = BeautifulSoup(html)
items = []
for li in soup('li', {'class': 'page_item'}):
for a in li('a'):
items.append(a)
items.reverse()
def progress (block_count, block_size, total_size):
percentage = 100.0 * block_count * block_size / total_size
sys.stdout.write("%.2f %% (%d KB)\r" % (percentage, total_size / 1024))
for a in items:
title = a.renderContents()
url = a.get('href')
html = urllib2.urlopen(url)
soup = BeautifulSoup(html)
embed_url = soup.find('iframe', {'src': re.compile(r'http://auengine\.com')}).get('src')
html = urllib2.urlopen(embed_url)
soup = BeautifulSoup(html)
scripts = soup.findAll('script')
for script in scripts:
url = re.search(r"'(http://s[0-9]+\.auengine\.com%2Fvideos%2F.+)'", str(script))
if url:
urllib.urlretrieve(
url = urllib.unquote(url.group(1)),
filename = title + ".mp4",
reporthook = progress
)
print
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment