Exemple #1
0
    def __init__(self,
                 cookies_folder_path: str,
                 extensions_folder_path: str,
                 host: Optional[str] = None,
                 port: Optional[int] = None,
                 headless: bool = False):
        self.browser = Firefox(cookies_folder_path,
                               extensions_folder_path,
                               host=host,
                               port=port,
                               headless=headless)

        try:
            self.browser.get(PT_URL)
            time.sleep(1.5)

            if self.browser.has_cookies_for_current_website():
                self.browser.load_cookies()
                time.sleep(1.5)
                self.browser.refresh()
                time.sleep(0.5)
            else:
                input('Log in then press enter')
                self.browser.get(PT_URL)
                time.sleep(1.5)
                self.browser.save_cookies()
        except:
            traceback.print_exc()
            self.browser.driver.quit()

            raise
Exemple #2
0
def test_upload(video_path: str, metadata: dict):
    current_working_dir = str(Path.cwd())
    browser = Firefox(current_working_dir, current_working_dir)
    uploader = YouTubeUploader(video_path, metadata, browser)
    # if not using monetization, use:
    # was_video_uploaded, video_id = uploader.upload(False)
    was_video_uploaded, video_id = uploader.upload()
    assert was_video_uploaded
 def __init__(self, video_path: str, metadata_json_path: Optional[str] = None) -> None:
     self.video_path = video_path
     self.metadata_dict = load_metadata(metadata_json_path)
     current_working_dir = str(Path.cwd())
     self.browser = Firefox(current_working_dir, current_working_dir)
     self.logger = logging.getLogger(__name__)
     self.logger.setLevel(logging.DEBUG)
     self.__validate_inputs()
Exemple #4
0
 def __init__(self, headless: bool, cookies_path: str,
              channel: str) -> None:
     self.channel = channel
     cookies_path = str(Path(cookies_path)) if cookies_path else str(
         Path.cwd())
     assert os.path.isdir(
         cookies_path), f"Directory '{cookies_path}' does not exist!"
     self.browser = Firefox(cookies_path, cookies_path, headless=headless)
 def __init__(self, username, cookies_path="") -> None:
     # Optional cookies_path to override username
     # for debugging purposes
     if cookies_path == "":
         cookies_path = YouTubeLogin.get_cookie_path_from_username(username)
     self.username = username
     self.browser = Firefox(full_screen=False,
                            cookies_folder_path=cookies_path,
                            default_find_func_timeout=10)
     self.logger = logging.getLogger()
	def __init__(self, video_path: str, metadata_json_path: Optional[str] = None, thumbnail_path: Optional[str] = None) -> None:
		self.video_path = video_path
		self.thumbnail_path = thumbnail_path
		self.metadata_dict = load_metadata(metadata_json_path)
		current_working_dir = str(Path.cwd())
		self.browser = Firefox(current_working_dir, current_working_dir)
		self.logger = logging.getLogger(__name__)
		self.logger.setLevel(logging.DEBUG)
		self.__validate_inputs()
		
		self.is_mac = False
		if not any(os_name in platform.platform() for os_name in ["Windows", "Linux"]):
			self.is_mac = True
Exemple #7
0
    def __init__(self,
                 video_path: str,
                 metadata_json_path: Optional[str] = None) -> None:
        self.video_path = video_path

        metadata_dict = load_metadata(metadata_json_path)
        self.meta_title = metadata_dict[Constant.VIDEO_TITLE]
        self.meta_description = metadata_dict[Constant.VIDEO_DESCRIPTION]

        current_working_dir = str(Path.cwd())
        self.browser = Firefox(current_working_dir, current_working_dir)
        self.logger = logging.getLogger(__name__)
        self.logger.setLevel(logging.DEBUG)
        self.__validate_inputs()
Exemple #8
0
 def __init__(self,
              video_path: str,
              metadata_json_path: Optional[str] = None) -> None:
     self.video_path = video_path
     self.metadata_dict = load_metadata(metadata_json_path)
     #current_working_dir = str(Path.cwd()).replace("bin","dependencies")
     #os.chdir(os.path.dirname(os.path.realpath(__file__)))
     #print(os.getcwd())
     #print(current_working_dir)
     directory = '..\\..\\dependencies\\geckodriver.exe'
     self.browser = Firefox(directory, directory)
     self.logger = logging.getLogger(__name__)
     self.logger.setLevel(logging.DEBUG)
     self.__validate_inputs()
Exemple #9
0
    def __init__(self,
                 cookies_folder_path: Optional[str] = None,
                 extensions_folder_path: Optional[str] = None,
                 email: Optional[str] = None,
                 password: Optional[str] = None,
                 host: Optional[str] = None,
                 port: Optional[int] = None,
                 screen_size: Optional[Tuple[int, int]] = None,
                 full_screen: bool = False,
                 disable_images: bool = False,
                 user_agent: Optional[str] = None,
                 login_prompt_callback: Optional[Callable[[str], None]] = None,
                 headless: bool = False):
        self.browser = Firefox(cookies_folder_path,
                               extensions_folder_path,
                               host=host,
                               port=port,
                               screen_size=screen_size,
                               user_agent=user_agent,
                               full_screen=full_screen,
                               disable_images=disable_images,
                               headless=headless)
        self.channel_id = None
        self.browser.get(YT_URL)
        self.__dismiss_alerts()

        try:
            self.__internal_channel_id = cookies_folder_path.strip('/').split(
                '/')[-1]
        except:
            self.__internal_channel_id = cookies_folder_path or self.browser.cookies_folder_path

        try:
            if self.browser.login_via_cookies(YT_URL, LOGIN_INFO_COOKIE_NAME):
                time.sleep(0.5)
                self.browser.get(YT_URL)
                time.sleep(0.5)
                self.browser.save_cookies()
                time.sleep(0.5)
                self.channel_id = self.get_current_channel_id()
            elif email and password:
                self.login(email=email,
                           password=password,
                           login_prompt_callback=login_prompt_callback)
        except Exception as e:
            print(e)
            self.quit()

            raise
Exemple #10
0
 def __init__(self,
              video_path: str,
              metadata_json_path: Optional[str] = None,
              thumbnail_path: Optional[str] = None) -> None:
     self.video_path = video_path
     self.thumbnail_path = thumbnail_path
     self.metadata_dict = load_metadata(metadata_json_path)
     self.current_working_dir = str(Path.cwd())
     self.browser = Firefox(self.current_working_dir,
                            self.current_working_dir,
                            headless=True,
                            geckodriver_path="/usr/local/bin/geckodriver")
     self.logger = logging.getLogger(__name__)
     self.logger.setLevel(logging.DEBUG)
     self.__validate_inputs()
Exemple #11
0
    def upload(self, file, *args, **kwargs) -> str:
        options = copy.deepcopy(self.options)
        options.update(kwargs)

        browser = Firefox(self._cookie_folder,
                          self._extension_folder,
                          headless=True)
        uploader = BaseYoutubeSeleniumUploader(file, options, browser)

        was_uploaded, video_id = uploader.upload()

        if was_uploaded is False:
            raise VideoWasNotUploaded()

        if self._playlist:
            self._insert_to_playlist(video_id)

        self._logger.info('Video was uploaded {} with options {}'.format(
            video_id, options))

        return video_id
 def __init__(self):
     self.browser = Firefox(full_screen=False)
     self.logger = logging.getLogger()