-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathSubtitleExtractor.py
executable file
·108 lines (83 loc) · 3.34 KB
/
SubtitleExtractor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /usr/bin/env python3
import os
import getpass
from netflix import netflixExtractor
from hulu import huluExtractor
from youtube import youtubeExtractor
from newamazon import amazonExtractor
from bbc import bbcExtractor
from crunchyroll import crunchyrollExtractor
from fox import foxExtractor
from crackle import crackleExtractor
from comedycentral import comedycentralExtractor
# import vudu
# import epix
# import syfy
# import sky
# import shomi
print("Downloading Subtitles")
class Subtitle(object):
"""This is the main class which holds all the information for the main module"""
def __init__(self):
self.urlName = ""
self.serviceType = ""
self.supportedServices = {
"hulu": huluExtractor, "netflix": netflixExtractor, "youtube": youtubeExtractor,
"amazon": amazonExtractor, "bbc": bbcExtractor, "crunchyroll": crunchyrollExtractor, "fox": foxExtractor,
"crackle": crackleExtractor, "comedyCentral": comedycentralExtractor}
#"hbo","vudu","epix","syfy","sky","shomi"]
# Dictionary of all the supported services with the respective class
# name as the value.
self.testMode = False
def getServiceName(self, url):
self.urlName = url
for names in self.supportedServices:
if names in self.urlName: # Parsing URL input
self.serviceType = names
break
def serviceProcess(self):
if self.serviceType:
self.serviceClass = self.supportedServices[self.serviceType](
self.urlName, self.testMode) # Creating instance of the sub-class
try:
# if self.serviceClass.loginRequired is True:
# print("Login is required. Your details are safe and secure\n")
# self.serviceClass.username = input("Username : ")
# self.serviceClass.password = getpass.getpass("Password : ")
# print(self.serviceClass.password)
returnValue = self.serviceClass.getSubtitles()
if not returnValue:
print(
"Please report the issue and make sure that the video contains subtitles.")
return 0
return 1
except ValueError:
print(
"Unable to get the subtitles. Please try again and open an issue to request for support for this video.")
return 0
else:
print(
"Service Not Supported. Please open an issue to request for support.")
return 0
def getServiceinfo(self):
pass
def main():
try:
Extractor = Subtitle()
url = input("Paste the link here : ")
#Parse the URL and find out which Internet service it is
Extractor.getServiceName(url)
if Extractor.serviceType:
print(Extractor.serviceType)
finalStatus = Extractor.serviceProcess()
# Proces the corresponding
# sub-module
if finalStatus:
print("Subtitles downloaded successfully !")
else:
print("Subtitles not downloaded.")
except IndexError:
print("An unknown error occurred")
pass
if __name__ == "__main__":
main()