Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

505 mock issue solved #548

Closed
wants to merge 15 commits into from
1 change: 1 addition & 0 deletions app/scrapers/dailymotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def parse_response(soup):
urls = []

video_list = json.loads(str(soup))['list']

for item in video_list:
title = item['title']
link = 'https://www.dailymotion.com/video/' + str(item['id'])
Expand Down
8 changes: 8 additions & 0 deletions app/scrapers/generalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def get_page(self, query, startIndex=0, qtype=''):
if self.name == 'mojeek' and qtype == 'news':
payload['fmt'] = 'news'
response = requests.get(url, headers=self.headers, params=payload)
if "dailymotion" in response.url:
url = response.url
index = url.index('?')
url = url[0:index + 1] + url[index + 3:len(url)]
response = requests.get(
url=url,
headers=self.headers
)
print(response.url)
return response

Expand Down
14 changes: 14 additions & 0 deletions test/test_dailymotion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from app.scrapers import DailyMotion


def test_parse_response():
json_data = '{"list":[{"id":"x6ilw2u",' \
'"title":"Job Interviews - Stand Up Comedy by ' \
'Piyush Sharma","channel":"fun",' \
'"owner":"x24pst6"}]}'

expected_resp = [{
'link': 'https://www.dailymotion.com/video/x6ilw2u',
'title': u'Job Interviews - Stand Up Comedy by Piyush Sharma'}]
resp = DailyMotion().parse_response(json_data)
assert resp == expected_resp