def __init__(self, name, **kwargs): self.href = kwargs.pop('href') if kwargs.get('href', False) else None self.category_id = kwargs.get('category_id', None) if self.category_id is None: get_category_id = self._find_category_id(category=name) if get_category_id is None and self.href is not None: find_category_id = re.match('/(.*?)/(.*?)/(.*?)/', self.href, re.I | re.M) if find_category_id: self.category_id = find_category_id.group(2) else: raise InvalidCategory( 'Invalid Category Name, it does not match a category id' ) elif get_category_id is not None: self.category_id = get_category_id else: raise InvalidCategory( 'Invalid Category Name, it does not match a category id') super(YouPornCategory, self).__init__(name=name, **kwargs)
def __init__(self,name,**kwargs): self.category_id = kwargs.get('category_id',None) if self.category_id is None: get_category_id = self._find_category_id(category=name) if get_category_id is None: raise InvalidCategory('Invalid Category Name:{name}, it does not match a category id'.format(name=name)) self.category_id = get_category_id super(XhamsterCategory,self).__init__(name=name,**kwargs)
def __init__(self, video_file, title=Title(), tags=(Tag(), ), category=Category(), description=Description(), **kwargs): self.video_file = video_file self._verify_video_file() if not isinstance(title, Title): raise InvalidTitle('title is not a valid Title instance') if not isinstance(description, Description): raise InvalidDescription( 'description is not a valid Description instance') if isinstance(category, (list, tuple)): for c in category: if not isinstance(c, Category): raise InvalidCategory('c is not a valid Category instance') else: if not isinstance(category, Category): raise InvalidCategory( 'category is not a valid Category instance') if isinstance(tags, (list, tuple)): for t in tags: if not isinstance(t, Tag): raise InvalidTag('t is not a valid Tag instance') else: if not isinstance(tags, Tag): raise InvalidTag('tags is not a valid Tag instance') self.title = title self.tags = tags self.category = category self.description = description self._success = None
def __init__(self, url, video_id=None, title=Title(), tags=(Tag(), ), category=Category(), description=Description(), username=None, date_uploaded=datetime.datetime.now().strftime( "%m-%d-%Y %H:%M:%S"), **kwargs): if not isinstance(title, Title): raise InvalidTitle('title is not a valid Title instance') if not isinstance(category, Category): raise InvalidCategory('category is not a valid Category instance') if not isinstance(description, Description): raise InvalidDescription( 'description is not a valid Description instance') if isinstance(tags, (list, tuple)): for t in tags: if not isinstance(t, Tag): raise InvalidTag('t is not a valid Tag instance') else: if not isinstance(tags, Tag): raise InvalidTag('tags is not a valid Tag instance') self.url = url self.video_id = video_id self.title = title self.tags = tags self.category = category self.description = description self.username = username self.date_uploaded = date_uploaded super(VideoUploaded, self).__init__(**kwargs)
def start(self): try: if not isinstance(self.video_upload_request, HardSexTubeVideoUploadRequest): raise InvalidVideoUploadRequest( 'Invalid video_upload_request, ' 'it needs to be a HardSexTubeVideoUploadRequest instance') if not isinstance(self.account, HardSexTubeAccount): raise InvalidAccount( 'Invalid account, it needs to be a HardSexTubeAccount instance' ) if not self.account.is_logined(): raise NotLogined('HardSexTube account is not logined') session = self.account.http_settings.session proxy = self.account.http_settings.proxy video_file = self.video_upload_request.video_file tags = self.video_upload_request.tags title = self.video_upload_request.title description = self.video_upload_request.description tags = self.video_upload_request.tags porn_star = self.video_upload_request.porn_star thumbnail_id = self.video_upload_request.thumbnail_id category = self.video_upload_request.category if isinstance(category, HardSexTubeCategoryStraight): orientation = 'straight' elif isinstance(category, HardSexTubeCategoryGay): orientation = 'gay' elif isinstance(category, HardSexTubeCategoryTranssexual): orientation = 'tranny' else: raise InvalidCategory('Hardsextube category needs to be straight' \ ' gay or transsexual') self.call_hook('started', video_upload_request=self.video_upload_request, account=self.account) go_to_upload_center = session.get( 'http://uploadcenter.hardsextube.com/', proxies=proxy) doc = etree.fromstring(go_to_upload_center.content, HTMLParser()) found_upload_id = doc.xpath('//input[@name="upload_id"]/@value') if not found_upload_id: raise CannotFindVar( 'Unable to find upload_id for hardsextube upload') upload_id = found_upload_id[0] thumbnail_ids = self._upload(video_file, upload_id) if int(thumbnail_id) > len(thumbnail_ids): raise InvalidThumbnailId( 'Invalid thumbnail_id:{i} for HardSexTube video'.format( i=thumbnail_id)) self._log_start(upload_id) self._log_client(upload_id) self._submit_upload('form_validation', upload_id, title, description, orientation, category, tags, porn_star, thumbnail_id) self._submit_upload('store', upload_id, title, description, orientation, category, tags, porn_star, thumbnail_id) except Exception as exc: self.call_hook('failed', video_upload_request=self.video_upload_request, account=self.account, traceback=traceback.format_exc(), exc_info=sys.exc_info()) if self.bubble_up_exception: raise exc else: self.call_hook('finished', video_request=self.video_upload_request, account=self.account, settings={''}) return {'status': True}
def _find_category_id(self, category): if not category.lower() in self.CATEGORIES: raise InvalidCategory('Invalid category id ') else: return self.CATEGORIES[category.lower()]