Пример #1
0
def get(path_name, url, best_audio):
	def __get(path_name, url, best_audio): 
		f_links, audio_flinks = fili_links.get_fili_links(url, best_audio) #fili_links czyli linki embed, sel_audio_links czyli linki z wybranego audio
		host_links, audio_hlinks = down2.get_host_links(f_links, audio_flinks)
		download_links = down2.get_dl_links(host_links, audio_hlinks)
		down2.download(download_links, path_name)
	
	while True:
		downloader.kill_printer()
		try:
			informator.info(f'Pobieram: {path_name}')
			__get(path_name, url, best_audio)
			informator.success(f"Pobrano: {path_name}!")
			break
		except: 
			if have_connection():
				print(traceback.format_exc())
				print(f"Can't get: {path_name}")
				informator.error(f"Nie udało się pobrać: {path_name}")
				break
			else: # nie mam internetu, więc czekam aż będę mieć i ponawiam
				while not have_connection(): 
					print('Trying to reconnect...')
					informator.warning('Próbuję się połączyć...')
					time.sleep(3)
		print('Connected!')
		informator.info('Połączono!')
Пример #2
0
def start_movie(full_url, dir_to_save, best_audio): 
	movie_name = get_name_of_movie(full_url)
	path_name = f'{dir_to_save}/Filmy/{movie_name}.mp4'
	if os.path.isdir(f'{dir_to_save}/Filmy'):
		if os.path.exists(path_name):
			print(f'Nie pobieram bo jest na dysku: {movie_name}')
			informator.info(f'Już znajduje się na dysku: {movie_name}')
			return
	else:
		os.mkdir(f'{dir_to_save}/Filmy')
		
	get(path_name, full_url, best_audio)
Пример #3
0
		def simulate():
			while True: #wykonuje dopóki skończy mi się queue
				try:
					dl_links, path_name = self.result_queue.get()
				except queue.Empty: 
					informator.success('Skończono') # to nie jest callowane z jakiegos powodu
					break
				print("DL LINKS: ", dl_links, " PATH_NAME: ", path_name)
				if not dl_links:
					informator.warning("NIE MA DLINKOW DLA ", path_name, ', KONTYNUUJE')
					continue
				informator.info(f'Pobieram {path_name.split("/").pop()}...')
				down2.download(dl_links, path_name)
				informator.success(f'Pobrano!')
Пример #4
0
def get_proper_links(url, best_audio):
	while True:
		try:
			informator.info('GETTING PROPER LINKS')
			f_links, audio_flinks = fili_links.get_fili_links(url, best_audio) #fili_links czyli linki embed, sel_audio_links czyli linki z wybranego audio
			if not f_links:
				informator.warning("NIE MA FLINKOW DLA ", url)
			informator.info('GOT F LINKS')
			host_links, audio_hlinks = down2.get_host_links(f_links, audio_flinks)
			if not host_links:
				informator.warning("NIE MA HLINKOW DLA ", url)
			informator.info('GOT H LINKS')
			download_links = down2.get_dl_links(host_links, audio_hlinks)
			if not download_links:
				informator.warning("NIE MA DLINKOW DLA ", url)
			informator.info('GOT D LINKS')
			return download_links
		except: 
			if have_connection():
				print(traceback.format_exc())
				print(f"Can't get proper links to: {url}")
				break
			else:
				while not have_connection(): 
					print('Trying to reconnect...')
					informator.warning('Próbuję się połączyć...')
					time.sleep(3)
Пример #5
0
def download(links, name):
    set_no_proxy()
    for link in links:
        try:
            print(f"Downloading from: {link}")
            informator.info(f"Pobieranie {name}")
            dl = downloader.start(link, name, 8)
            return  #kończe pętle, bo pobrałem
        except Exception:
            print(traceback.format_exc())
            print("Something went wrong :( I'll try again...")
            informator.warning("Coś poszło nie tak... Próbuję jeszcze raz...")
            continue
    #jeśli doszło do tego momentu to żaden z linków nie zadziałał, najprawdopodobniej z powodu braku internetu
    raise Exception('Żaden z linków nie zadziałał (down2/download)')
Пример #6
0
def download(dl_links, path_name):
	while True:
		downloader.kill_printer()
		try:
			informator.info(f'Pobieram: {path_name}')
			down2.download(dl_links, path_name)
			informator.success(f"Pobrano: {path_name}!")
			break
		except: 
			if have_connection():
				print(traceback.format_exc())
				print(f"Can't get: {path_name}")
				informator.error(f"Nie udało się pobrać: {path_name}")
				break
			else: # nie mam internetu, więc czekam aż będę mieć i ponawiam
				while not have_connection(): 
					print('Trying to reconnect...')
					informator.warning('Próbuję się połączyć...')
					time.sleep(3)
		print('Connected!')
		informator.info('Połączono!')
Пример #7
0
	def create_app(self):
		#INITIALIZATION
		self.root = tk.Tk()
		self.root.title("Fili Downloader")
		self.root.grid_columnconfigure(0, weight=1) #scalable x urls_box, dl_progress	 https://stackoverflow.com/questions/28419763/expand-text-widget-to-fill-the-entire-parent-frame-in-tkinter
		
		self.root.grid_columnconfigure(1, weight=1) #scalable x infobox, dl_progress
		self.root.grid_rowconfigure(0, weight=1) #scalable y

		#URLS BOX
		self.urls_box = tk.Text(self.root, height=8, width=50, wrap='word')
		self.urls_box.tag_config("placeholder", foreground="#b2b2b2")
		self.urls_box.insert(1.0, "Podaj linki z fili.cc do całego serialu (np. https://fili.cc/serial/zagubieni-w-kosmosie/1235), " 
															"filmu (np. https://fili.cc/film/zielona-mila-1999/62) lub "
															"odcinku (np. https://fili.cc/serial/smoczy-ksiaze/s01e03/pelnia-ksiezyca/45296). "
															"Możesz też spróbować wpisać frazę (np. serial zagubieni w kosmosie), lecz nie gwarantuje to 100% "
															"pewności, że dostaniesz to, co chcesz.\n"
															"Możesz też wybrać język (na dole), który będzie domyślnym dla każdego pobieranego wideo,"
															"ale nie ma pewności, czy będzie dostępny. Jeśli nie będzie można znaleźć takiego audio jaki"
															"jest zaznaczony, zostanie wybrany najbardziej podobny, np. jeśli nie ma lektora to wyszuka kolejno: "
															"DUBBING>NAPISY_PL>ENG>INNE", ('placeholder')) #miejsce insertion, placeholder, tag placeholdera
		self.urls_box.bind("<Button-1>", self.clear_placeholder) #usuwanie placeholdera gdy kliknie się na to
		self.urls_box.grid(row=0, column=0, sticky='NSWE')

		#INFO BOX
		self.info_box = tk.Text(self.root, height=8, width=40, state='disabled', background='#cccccc', wrap='char')
		self.info_box.grid(row=0, column=1, sticky='NSWE')

		#PROGRESS BAR
		self.dl_progress = ttk.Progressbar(self.root, orient='horizontal', length=730, mode='determinate') #length to powinien być width bo orient=horizontal, ale tak nie jest i nie wiem dlaczego, ale 570 idealnie pasuje
		self.dl_progress.grid(row=1, columnspan=2, sticky='WE')
				
		#INFORMATOR
		informator.initialize(self.root, self.info_box, self.dl_progress)

		#CHECKBUTTONS NA PÓŹNIEJ
		self.bottom_frame = tk.Frame(self.root, width=50)
		self.bottom_frame.grid(row=2, column=0, sticky='NSWE')
		self.bottom_frame.grid_columnconfigure(0, weight=0) #żeby można było używać sticky='W' itp.
		self.bottom_frame.grid_columnconfigure(1, weight=1) #żeby zajmował całe miejsce po środku
		#FILE SET BUTTON
		self.file_butt = tk.Button(self.bottom_frame, text='Wybierz folder', command=self.file_dialog)
		self.file_butt.grid(sticky='W',padx=2, pady=2, row=0, column=0)
		
		self.dl_dir = os.getcwd().replace('\\', '/') #zamieniam slash na backslash dla kompatybilności #default
		
		self.file_label = tk.Label(self.bottom_frame, text=self.dl_dir+'/Filmy|Nazwa_serialu', anchor='w')
		self.file_label.grid(sticky='WE', row=0, column=1)
		#AUDIO LIST
		self.audio_list = ttk.Combobox(self.bottom_frame, state='readonly')
		self.audio_list.grid(sticky='E', row=0, column=2, ipady=2)
		
		self.audio_list['values'] = ['Dubbing', 'Lektor PL','Napisy PL', 'Angielski', 'Inne']
		self.audio_list.set('Lektor PL')

		#START BUTTON
		self.start_butt = tk.Button(self.root, text='Rozpocznij', command=self.initialize)#)lambda: start_download(lambda: start(self.urls_box))) #start
		self.start_butt.grid(row=2, column=1, sticky='WE')

		informator.info('Zainicjalizowano')

		self.root.mainloop() 
		
		print('KONIEC')
		self.root = None
		clear()
Пример #8
0
	def __get_later_links(self, i):
		type = self.config_chunks[i].type
		best_audio = self.get_best_audio()
		
		if type == 'SERIES':
			start_index = self.config_chunks[i].start_slider.get()
			end_index = self.config_chunks[i].end_slider.get() + 1 
			url_list = self.config_chunks[i].url_list[start_index:end_index]
			episode_list = self.config_chunks[i].episode_list[start_index:end_index]
			
			full_list = []
			for i in range(len(url_list)):
				full_list.append((url_list[i], episode_list[i])) 
			
			series_name = fili2.get_name_of_series(url_list[0])
			
			debug_list = []
			for url, ep_name in full_list:
				path_name = f'{self.dl_dir}/{series_name}/{ep_name}.mp4'
				print(path_name)
				if os.path.isdir(f"{self.dl_dir}/{series_name}"):
					if os.path.exists(path_name):
						informator.success(f'Już znajduje się na dysku: {path_name}')
						continue
				else:
					informator.info(f'Tworzę folder {self.dl_dir}/{series_name}')
					os.mkdir(f"{self.dl_dir}/{series_name}")
					
				dl_links = fili2.get_proper_links(url, best_audio=best_audio) 
				
				debug_list.append((dl_links, path_name))
				
				self.result_queue.put((dl_links, path_name))
			print(f"Skonczono uzyskiwac linki dla {series_name}, sa to: {debug_list}")
			informator.info(f"Skonczono uzyskiwac linki dla {series_name}, sa to: {debug_list}")
		elif self.config_chunks[i].chckbutt_var.get():  
			url = self.config_chunks[i].url
			name = self.config_chunks[i].name
			
			if type == 'MOVIE':
				movie_name = get_name_of_movie(url)
				path_name = f'{self.dl_dir}/Filmy/{movie_name}.mp4'
				
				if os.path.isdir(f'{self.dl_dir}/Filmy'):
					if os.path.exists(path_name):
						informator.success(f'Już znajduje się na dysku: {path_name}')
						return 
				else:
					informator.info(f'Tworzę folder {self.dl_dir}/Filmy')
					os.mkdir(f"{self.dl_dir}/Filmy")
				
				dl_links = fili2.get_proper_links(url, best_audio=best_audio)
				
				self.result_queue.put((dl_links, path_name))
				
				
			elif type == 'EPISODE':				
				series_name = fili2.get_name_of_series(url)
				ep_name = fili2.get_name_of_episode(url)
				path_name = f'{self.dl_dir}/{series_name}/{ep_name}.mp4' 
				if os.path.isdir(f"{self.dl_dir}/{series_name}"):
					if os.path.exists(path_name):
						informator.success(f'Już znajduje się na dysku: {path_name}')
						return
				else:
					informator.info(f'Tworzę folder {self.dl_dir}/{series_name}')
					os.mkdir(f"{self.dl_dir}/{series_name}")

				dl_links = fili2.get_proper_links(url, best_audio=best_audio)	
				
				self.result_queue.put((dl_link, path_name))
Пример #9
0
def start(url, ep_name, chunk_count=8):
	global DL_OK
	DL_OK = True
	url = url
	ep_filename = ep_name
	headers = requests.head(url).headers
	size = 0
	#print(headers)
	if 'content-length' in headers:
		size = headers['content-length']

	if 'accept-ranges' in headers and size != 0:
		print("Asynchronous downloading")
		informator.info("Pobieram asynchronicznie")
		chunk_count = chunk_count
		chunk_dl_size = int(size)/chunk_count
		chunks = []
		
		tmp_dir_path = create_tmp_dir()

		for chunk_number in range(chunk_count):
			start_byte = int(chunk_number * chunk_dl_size)
			end_byte = int((chunk_number + 1) * chunk_dl_size - 1)
			new_chunk = my_chunk(url, start_byte, end_byte, chunk_number, tmp_dir_path)
			chunks.append(new_chunk)
			
		my_printer = printer(mode='async', dl_size=size)
		time.sleep(2) #żeby chunki się zainicjalizowały
		filenames = []
		for chunk in chunks:
			print(f'Aktywne rdzenie: {threading.active_count()}')
			chunk.thread.join()
			filenames.append(chunk.filename)
			
		active_chunks = len([thread for thread in threading.enumerate() if thread.name.startswith('DlChunk')])
		if active_chunks > 0: 
			print('Warning! Too many chunks')
			time.sleep(5)
		
		my_printer.stop_printing()
		stop_downloading()
		
		if DL_OK == True: #bo gdy nie pobierze się wszystko to po 5 próbach w każdym chunku to i tak się wykona, a plik wyjściowy będzie skoruptowany
			informator.info('Łączenie plików...')
			merge.start(filenames, ep_filename, chunk_count)
			clear(tmp_dir_path)
		else:
			informator.info('Coś poszło nie tak przy pobieraniu')
			clear(tmp_dir_path)
			raise Exception('Nie pobrałem dobrze pliku')
	else:
		with open(ep_filename + '.download', 'wb') as f:
			print("Normal downloading")
			informator.info("Pobieram normalnym sposobem")
			if size:
				my_printer = printer(mode='async', size=size)
			else:
				print("Downloading, but I can't give you much info about that process:")
				print(ep_filename)
				my_printer = printer(mode='sync', filename=ep_filename)
			sync_download(url, f, ep_name)
		if os.path.exists(ep_name + '.download'):
				os.rename(ep_name + '.download', ep_name)
				my_printer.stop_printing() #dla zgodności bo nie do końca może działać jeszcze
	set_default()