-
Notifications
You must be signed in to change notification settings - Fork 2
/
podcast.py
110 lines (103 loc) · 3.94 KB
/
podcast.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
109
110
from other_funcs import author_split, citation_format, date_fix
class Podcast:
def __init__(self, title, host, publisher, podcast, date, url, duration):
self.host = host
self.title = title
self.publisher = publisher
self.podcast = podcast
self.date = date_fix(date)
self.url = url
self.duration = duration
if len(date) == 3:
self.month = date[0]
self.day = date[1]
self.year = date[2]
elif len(date) == 2:
self.month = date[0]
self.year = date[1]
else:
self.year = date[0]
def mla(self) -> str:
"""Builds citation string for MLA Style Citation."""
citation = ""
if self.title != "":
citation += f'"{self.title}." '
if self.podcast != "":
citation += f"<em>{self.podcast}</em> "
if self.publisher != "":
citation += f"from {self.publisher}, "
if self.year != "":
try:
citation += f"{self.day} {self.month} {self.year}, "
except NameError:
try:
citation += f"{self.month} {self.year}, "
except NameError:
citation += f"{self.year}, "
if self.url != "":
citation += f"{self.url}. "
citation = citation.strip()
citation = citation_format(citation)
return citation
def apa(self) -> str:
"""Builds citation string for APA Style Citation."""
citation = ""
if self.host != []:
if len(self.host) == 1:
citation += f"{self.host[0]}, {self.host[1][0]}. "
if self.year != "":
try:
citation += f"({self.year}, {self.month} {self.day}). "
except NameError:
try:
citation += f"({self.year}, {self.month}). "
except NameError:
citation += f"({self.year}). "
if self.title != "":
citation += f"{self.title}. "
if self.podcast != "":
citation += f"In <em>{self.podcast}</em>. "
if self.publisher != "":
citation += f"{self.publisher}. "
if self.url != "":
citation += f"{self.url}"
citation.strip()
citation = citation_format(citation)
return citation
def chicago(self) -> str:
"""Builds citation string for Chicago Style Citation."""
citation = ""
if self.host != []:
if len(self.host) == 1:
citation += f"{self.host[0][0]}, {self.host[0][1]}. "
elif len(self.host) == 2:
citation += f"{self.host[0][0]}, {self.host[0][1]} and {self.host[1][1]} {self.host[1][0]}. "
if self.publisher != "":
citation += f"Produced by {self.publisher}. "
if self.podcast != "":
citation += f"<em>{self.podcast}</em>. "
if self.year != "":
try:
citation += f"{self.month} {self.day}, {self.year}. "
except NameError:
try:
citation += f"{self.month} {self.year}. "
except NameError:
citation += f"{self.year}. "
if self.duration != "":
citation += f"Podcast, MP3 audio, {self.duration}, "
if self.url != "":
citation += f"{self.url}. "
citation.strip()
citation = citation_format(citation)
return citation
def podcast_ask(sources) -> None:
"""Prompts for inputting information about a Podcast source."""
title = input("Episode name?: ")
host = input("Host?: ")
publisher = input("Publisher?: ")
podcast = input("Title of podcast?: ")
date = input("Date of release (MM, DD, YYYY; MM, YYYY; or YYYY): ")
url = input("URL?: ")
duration = input("Duration? (H:M:S): ")
sources.append(Podcast(title, host, publisher, podcast, date, url, duration))