Created
July 27, 2016 09:50
-
-
Save surajnarwade/fad0be5c0560d76e13edf208d9af1c41 to your computer and use it in GitHub Desktop.
to download POI season 5
This file contains hidden or 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
import urllib2 | |
import urllib | |
import sys | |
import time | |
import os | |
from BeautifulSoup import BeautifulSoup as bs | |
repo_list=[] | |
REPO_URL = 'http://dl.tehmovies.com/94/series/person.of.interest/S5/' | |
REPO_PATH = '/opt/POI' | |
url = urllib.urlopen(REPO_URL) | |
content=url.read() | |
soup=bs(content) | |
def reporthook(count, block_size, total_size): | |
global start_time | |
if count == 0: | |
start_time = time.time() | |
return | |
duration = time.time() - start_time | |
progress_size = int(count * block_size) | |
speed = int(progress_size / (1024 * duration)) | |
percent = int(count * block_size * 100 / total_size) | |
sys.stdout.write("\r...%d%%, %d MB, %d KB/s, %d seconds passed" % | |
(percent, progress_size / (1024 * 1024), speed, duration)) | |
sys.stdout.flush() | |
for tag in soup.findAll('a', href=True): | |
if tag['href'][-22:] == '720p.Tehmovies.org.mkv': | |
repo_list.append(tag['href']) | |
#print(repo_list) | |
for repo_name in repo_list: | |
repo_url = os.path.join(REPO_URL, "%s" % repo_name) | |
repo_path = os.path.join(REPO_PATH, "%s" % repo_name) | |
print(repo_url) | |
print(REPO_PATH) | |
urllib.urlretrieve(repo_url, repo_path, reporthook) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment