Skip to content

Commit

Permalink
Fix #46
Browse files Browse the repository at this point in the history
  • Loading branch information
Egsago-n committed Apr 9, 2024
1 parent 46116ce commit d1e758c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/phub/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ class re:
get_user_type = find( r'\/(model|pornstar|channels|user|users)\/.*?' ) # Get a user type
get_thumb_id = find( r'\/([a-z0-9]+?)\/(?=original|thumb)' ) # Get video id from its thumbnail
remove_host = subc( _raw_root, '' ) # Remove the HOST root from a URL
is_favorite = find( r'<div class=\".*?js-favoriteBtn.*?active\"' ) # Check if is favorite
eval_video = find( engine.DOTALL, r'id=\"(.*?)\".*?-vkey=\"(.*?)\".*?title=\"(.*?)\".*?src=\"(.'
r'*?)\".*?-mediabook=\"(.*?)\".*?marker-overlays.*?>(.*?)</div' ) # Parse video data
is_favorite = find( r'<div class=\".*?js-favoriteBtn.*?active\"' ) # Check if is favorite
eval_video = find( engine.DOTALL, r'id=\"(.*?)\".*?-vkey=\"(.*?)\".*?title=\"(.*?)\".*?src=\"(.*?)\".*?</div' ) # Parse video data
eval_public_video = find( engine.DOTALL, r'-mediabook=\"(.*?)\".*?marker-overlays.*?>(.*?)' ) # Parse public-only video data
user_avatar = find( engine.DOTALL, r'previewAvatarPicture\">.*?src=\"(.*?)\"' ) # get the user avatar
query_counter = find( engine.DOTALL, r'showing(?:Counter|Info).*?\">.*?(\d+)\s*<\/' ) # Get a query's video amount
user_bio = find( engine.DOTALL, r'\"aboutMeSection.*?\"title.*?<div>\s*(.*?)\s*<\/' ) # Get the user bio
Expand Down
9 changes: 6 additions & 3 deletions src/phub/objects/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,13 @@ def _eval_video(self, raw: str) -> dict:
# Evaluate video data.
# Can be used externally from this query

keys = ('id', 'key', 'title', 'image', 'preview', 'markers')
data = {k: v for k, v in zip(keys, consts.re.eval_video(raw))} | {'raw': raw}
html_entries = consts.re.eval_video(raw)
html_public_entries = consts.re.eval_public_video(raw, False) or ()

return data
data = {k: v for v, k in zip(html_entries, ('id', 'key', 'title', 'image'))}
public_data = {k: v for v, k in zip(html_public_entries, ('preview', 'markers'))}

return {'mediabook': None, 'markers': ''} | data | public_data | {'raw': raw}

def _parse_item(self, raw: str) -> Video:

Expand Down
2 changes: 1 addition & 1 deletion src/phub/objects/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def image(self) -> Image:

else:
url = self.fetch('data@thumb')
servers = self.fetch('data@thumbs')
servers = self.data.get('data@thumbs') or [] # TODO - Use cache on prop Image.servers

return Image(client = self.client,
url = url,
Expand Down

0 comments on commit d1e758c

Please sign in to comment.