Skip to content

Instantly share code, notes, and snippets.

@avamsi
Last active July 18, 2018 03:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avamsi/ca2043bfa064b5d7a524858e276aa33a to your computer and use it in GitHub Desktop.
Save avamsi/ca2043bfa064b5d7a524858e276aa33a to your computer and use it in GitHub Desktop.
import re
import pyquery
import requests
embedlink_base = {
'adhqmedia': 'http://www.adhqmedia.com/files/embed/',
'likeafool': 'http://embed.likeafool.com/files/embed/',
'vidbaba': 'http://www.mycollection.net/new_files/embed/'
}
def episodes():
pq = pyquery.PyQuery(requests.get(config['show_url']).text)
for a in pq('a'):
title = a.get('title')
if title is None or config['season'] not in title:
continue
season, episode, name = a.getchildren()
yield a.get('href'), season.text + episode.text + ' ' + name.text
def embedlinks():
for episode_url, name in episodes():
pq = pyquery.PyQuery(requests.get(episode_url).text)
for a in pq('a'):
link = a.get('data-actuallink')
if link is None or config['source'] not in link:
continue
uuid = link.rsplit('/', 1)[-1]
embedlink = embedlink_base[config['source']] + uuid
yield embedlink, name
break
def directlinks():
for embedlink, name in embedlinks():
resp = requests.get(embedlink)
# name = re.findall('<title>(.*)</title>', resp.text)[0]
urls = re.findall(r'(https://[^"]+)', resp.text)
if urls:
url = urls[-1]
print(url, name)
config = {
'season': 'Season',
'source': 'adhqmedia',
'show_url': 'http://www.watchepisodes3.com/narcos'
}
directlinks()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment