Skip to content

Commit

Permalink
Updated footer for 2025, removed non info sections about 24 hour broa…
Browse files Browse the repository at this point in the history
…dcast
  • Loading branch information
CheeseLad committed Jan 3, 2025
1 parent cdff12a commit b71c08e
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 104 deletions.
212 changes: 126 additions & 86 deletions mps_site/scripts.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
from datetime import datetime
import feedparser
import yt_dlp as youtube_dl
import requests
import requests
from bs4 import BeautifulSoup
import json
import pandas as pd
import re


def construct_tcv_url(per_page=3, category=None):
base_url = "https://thecollegeview.ie/wp-json/wp/v2/posts"
query_params = f"?per_page={per_page}&orderby=date&_fields=id,date,title,content,link,author,featured_media"
if category:
query_params += f"&categories={category}"
return base_url + query_params


def fetch_data(url):
try:
response = requests.get(url, timeout=10)
Expand All @@ -23,10 +25,13 @@ def fetch_data(url):
print(f"An error occurred: {e}")
return None


def get_featured_media(media_id):
media_data = fetch_data(f"https://thecollegeview.ie/wp-json/wp/v2/media/{media_id}")
media_data = fetch_data(
f"https://thecollegeview.ie/wp-json/wp/v2/media/{media_id}")
return media_data['guid']['rendered'] if media_data else None


def tcv_posts(url):
posts = fetch_data(url)
if not posts:
Expand All @@ -36,11 +41,14 @@ def tcv_posts(url):
soup = BeautifulSoup(post['content']['rendered'], 'html.parser')
post['content_plain'] = soup.get_text()
first_image = soup.find('img')
post['first_image'] = first_image['src'] if first_image else get_featured_media(post['featured_media'])

post['formatted_date'] = datetime.strptime(post['date'], '%Y-%m-%dT%H:%M:%S').strftime('%B %d, %Y')
post['first_image'] = first_image['src'] if first_image else get_featured_media(
post['featured_media'])

post['formatted_date'] = datetime.strptime(
post['date'], '%Y-%m-%dT%H:%M:%S').strftime('%B %d, %Y')

author_data = fetch_data(f"https://thecollegeview.ie/wp-json/wp/v2/users/{post['author']}")
author_data = fetch_data(
f"https://thecollegeview.ie/wp-json/wp/v2/users/{post['author']}")
if author_data:
post['author_name'] = author_data.get('name')
post['author_slug'] = author_data.get('slug')
Expand All @@ -49,15 +57,17 @@ def tcv_posts(url):

return posts


def process_linktree_data(sheet_url):
url_1 = sheet_url.replace('/edit', '/export?format=csv&')
texts = pd.read_csv(url_1, usecols= ['TEXT'])
links = pd.read_csv(url_1, usecols= ['LINK'])
texts = pd.read_csv(url_1, usecols=['TEXT'])
links = pd.read_csv(url_1, usecols=['LINK'])
text = [i[0] for i in texts.values]
link = [i[0] for i in links.values]
linktree = zip(text, link)
return linktree


def get_date_time():
date = datetime.now()
day_name = date.strftime("%A")
Expand Down Expand Up @@ -136,14 +146,18 @@ def get_date_time():
}

if day_name in timetable and 9 <= hour <= 20:
current_show = timetable[day_name].get(hour, "No shows on at the moment")
previous_show = timetable[day_name].get(hour - 1, "No shows on at the moment")
next_show = timetable[day_name].get(hour + 1, "No shows on at the moment")
current_show = timetable[day_name].get(
hour, "No shows on at the moment")
previous_show = timetable[day_name].get(
hour - 1, "No shows on at the moment")
next_show = timetable[day_name].get(
hour + 1, "No shows on at the moment")
else:
current_show = previous_show = next_show = "No shows on at the moment"

return previous_show, current_show, next_show


def get_latest_video_id(channel_url):
feed = feedparser.parse(channel_url)

Expand All @@ -153,7 +167,8 @@ def get_latest_video_id(channel_url):
return video_id
else:
return None



def get_latest_video_ids(channel_url):
feed = feedparser.parse(channel_url)
video_ids = []
Expand All @@ -165,6 +180,7 @@ def get_latest_video_ids(channel_url):

return video_ids


def get_most_popular_video_ids(channel_url, n=9):
ydl_opts = {
'quiet': True,
Expand All @@ -179,17 +195,18 @@ def get_most_popular_video_ids(channel_url, n=9):
info = ydl.extract_info(channel_url, download=False)
video_ids = [entry['id'] for entry in info['entries']]
return video_ids

def get_donation_count_fm():


def get_donation_count():
URL = "https://www.idonate.ie/fundraiser/MediaProductionSociety12"
headers = {
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0"}
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0"}

data = {
'totalRaised': 0,
'targetAmount': 0
}

try:
r = requests.get(url=URL, headers=headers, timeout=10)
r.raise_for_status()
Expand All @@ -201,79 +218,102 @@ def get_donation_count_fm():

total_raised_match = js_content.replace('\\', '').split(',')



for item in total_raised_match:
if '"totalRaised":' in item:
data['totalRaised'] = int(float(item.split(':')[1].replace('"', '')))
data['totalRaised'] = int(
float(item.split(':')[1].replace('"', '')))
if '"targetAmount":' in item:
data['targetAmount'] = int(float(item.split(':')[1].replace('"', '')))

data['targetAmount'] = int(
float(item.split(':')[1].replace('"', '')))

return data

except (requests.RequestException, ValueError, IndexError, AttributeError) as e:
return data

def get_event_data():
data = {}
events = {}
URL = f"https://dcuclubsandsocs.ie/society/media-production"
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0"}
r = requests.get(url=URL, headers=headers)
soup = BeautifulSoup(r.content, 'html5lib')
events_data = soup.find('div', attrs = {'id':'events'})
try:
event_count = int(events_data.find('span', attrs = {'class':'float-right badge badge-light'}).text)
except:
event_count = 0
if event_count == 0:
data['event_count'] = event_count
data['events'] = None
return data
event_table = events_data.find('div', attrs = {'class':'table-responsive'})
events_info_list = event_table.find_all('tr', attrs={'class':'show_info pointer'})
events_info_hidden = event_table.find_all('tr', attrs={'class':'d-none'})

for i in range(0, len(events_info_list) - 1, 2):
event_info = events_info_list[i]
try:
event_image = event_info.find('img')['src']
except:
event_image = "static/assets/img/other/upcoming_event.png"
event_name = event_info.find('th', attrs={'class': 'h5 align-middle'}).text.strip()
events["event_" + str(i // 2)] = {'name': event_name, 'image': event_image}

for i in range(1, len(events_info_list), 2):
event_info = events_info_list[i]
event_data = event_info.find_all('td', attrs={'class': 'text-center align-middle'})
events["event_" + str(i // 2)]['start'] = event_data[1].find('b').text
events["event_" + str(i // 2)]['end'] = event_data[2].find('b').text
events["event_" + str(i // 2)]['cost'] = event_data[3].find('b').text
events["event_" + str(i // 2)]['capacity'] = event_data[4].find('b').text
events["event_" + str(i // 2)]['type'] = event_data[5].find('b').text
events["event_" + str(i // 2)]['location'] = events_info_hidden[i].find('b').text
events["event_" + str(i // 2)]['description'] = events_info_hidden[i].find('p')

data['event_count'] = event_count
data['events'] = events
return data



FOLDER_ID = ''
API_KEY = ''

def list_images():
url = f'https://www.googleapis.com/drive/v3/files?q="{FOLDER_ID}" in parents&key={API_KEY}'
response = requests.get(url)
data = response.json()

image_urls = []
if 'files' in data:
for item in data['files']:
file_id = item['id']
file_name = item['name']
file_url = f'https://drive.usercontent.google.com/download?id={file_id}'
image_urls.append({'name': file_name, 'url': file_url})

return image_urls

def get_live_broadcast_shows():
date = datetime.now()
day_name = date.strftime("%A")
current_time = date.strftime("%H:%M")
current_hour = date.hour
current_minute = date.minute

timetable = {
"Wednesday": {
"20:00": "Broadcast Introduction",
"20:30": "Lip Sync Battle",
"21:00": "The Oscars",
"21:30": "Focus Interview",
"22:00": "Hot Wans",
"22:30": "Sa(m)tas Corner",
"23:00": "DCeUrovision",
"23:30": "Freshers on Air",
},
"Friday": {
"00:00": "Storytime with Holly",
"00:20": "Doghouse",
"00:40": "Inkmaster",
"01:00": "Crowtalk",
"01:30": "CommiTEA",
"02:00": "Game Changer",
"02:20": "Undercover boss",
"02:40": "Weird Films & Queer Men in music",
"03:00": "Bird Brains III: Bait Masters",
"03:30": "Carpool Kareoke",
"04:00": "Sexy Calendar",
"04:30": "The Lore",
"05:00": "Competitive Yapping",
"05:20": "What did they just say?",
"05:40": "The Wheel",
"06:00": "The Thing is...",
"06:30": "Are you smarter than a Comms Student?",
"07:00": "Infuriating Guessing Game",
"07:30": "Committee Bake off",
"08:00": "Get Flexy!",
"08:30": "The Voice DCU",
"09:00": "This & Yap",
"09:30": "Family Feud",
"10:00": "Unlikely Things to Hear / Would I lie to you?",
"10:30": "Spill your Guts or Fill your Guts",
"11:00": "Battle of the FM Flagships",
"11:30": "The DIBS Boys",
"12:00": "Drama",
"12:30": "Comms Dine with me",
"13:00": "Her Campus",
"13:30": "DCUtv Guesses",
"14:00": "Action Replay vs The Dugout",
"14:30": "Taskmaster",
"15:00": "Price is Right: Londis Edition",
"15:30": "Expectations Vs Reality",
"16:00": "Franks Butcher Shop",
"16:30": "Breaking News",
"17:00": "DCU Seagulls",
"17:30": "Six One",
"18:00": "Lip Sync Battle 2",
"18:30": "GoldenCards",
"19:00": "Early Early Product Placement",
"19:30": "Thursday Night Live",
"20:00": "Farewells",
}
}

if day_name in timetable:
sorted_times = sorted(timetable[day_name].keys())

current_show_b = "No shows on at the moment"
previous_show_b = "No shows on at the moment"
next_show_b = "No shows on at the moment"

for i, show_time in enumerate(sorted_times):
if current_time >= show_time:
current_show_b = timetable[day_name][show_time]
if i > 0:
previous_show_b = timetable[day_name][sorted_times[i - 1]]
if i + 1 < len(sorted_times):
next_show_b = timetable[day_name][sorted_times[i + 1]]
break
else:
current_show_b = previous_show_b = next_show_b = "No shows on at the moment"

return previous_show_b, current_show_b, next_show_b
2 changes: 1 addition & 1 deletion mps_site/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<li><a href="http://youtube.com/dcumps" target="_blank" aria-label="DCU MPS YouTube"><i class="fa-brands fa-youtube"></i></a></li>
<li><a href="https://www.tiktok.com/@dcumps" target="_blank" aria-label="DCU MPS TikTok"><i class="fa-brands fa-tiktok"></i></a></li>
</ul>
<p>© 1985 - 2024 by DCU MPS. Designed and maintained by <a href="https://www.jakefarrell.ie" target="_blank"><strong>Jake Farrell</strong></a></p>
<p>© 1985 - 2025 by DCU MPS. Designed and maintained by <a href="https://www.jakefarrell.ie" target="_blank"><strong>Jake Farrell</strong></a></p>
<p>Powered with ❤️ by <a href="https://redbrick.dcu.ie" target="_blank"><strong>Redbrick</strong></a></p>
</div>
</footer>
Expand Down
4 changes: 2 additions & 2 deletions mps_site/templates/components/home/about_us.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1>About Us</h1>
<div class="row">
<div class="col-md-6">

<p>DCU’s Media Production Society was founded in 1985, with the aim of operating as a creative and social outlet to a broad variety of students within the university. Composed of three strands, MPS offers the opportunity for its members to gain practical experience in their chosen field of media and collaborate with other, like-minded creatives. Over our 39 years of experience, MPS has thrived across the board, winning a variety of awards at both a University and a National level.<br><br>
<p>DCU’s Media Production Society was founded in 1985, with the aim of operating as a creative and social outlet to a broad variety of students within the university. Composed of three strands, MPS offers the opportunity for its members to gain practical experience in their chosen field of media and collaborate with other, like-minded creatives. Over our 40 years of experience, MPS has thrived across the board, winning a variety of awards at both a University and a National level.<br><br>
DCUtv offers members the opportunity to fully immerse themselves in the world of visual media. DCUtv not only encourages all MPS members to create video content, but also to gain hands-on experience in the more technical aspects of video production. Through annual events run by our TV team, such as the DCUtv 24 hour broadcast, MPS offers the chance to our members to come together and create, catering to all experience levels and interests, both in front of and behind the camera. In 2023, our DCUtv Team won “Best Promotional Video” at the BICS, which are the National Society Awards.
</p>
</div>
Expand All @@ -16,7 +16,7 @@ <h1>About Us</h1>
<div class="col-md-12"> <!-- style="background-color: #202E4E; padding: 10px; border-radius: 25px;"-->
<p>DCUfm is Ireland’s Best Student Radio Station. DCUfm is run by our members and their wonderful ideas - you give us your concept and we show you how to take it on air. Additionally, our fantastic podcasting equipment allows members to continue their audio endeavours outside of the studio. DCUfm instils a profound love for audio creation in all of its members, with many of the station’s alumni currently working in stations such as Spin 103.8, Newstalk and FM104.<br><br>
The College View is DCU’s student newspaper. TCV offers members a way to enhance their writing skills and explore different types of journalism - from hard news to wacky satire, from the latest sports scores to reviewing what’s in the cinema. Stories are published online on www.thecollegeview.ie. There’s opportunities to attend and cover events across campus and outside DCU - with the Editorial Team always looking for writers to give their own edge on what’s going on in the University.<br><br>
After 39 years, thousands of members, (and not to mention a global pandemic), MPS continues to grow in numbers and talent year on year. This year, our passionate and dedicated Committee aims to see MPS succeed and function at the highest possible level, with weekly events, workshops and activities for all of our members. MPS seeks to present exciting opportunities to our members, both creatively and socially, and foster the immense potential within DCU students. We hope to continue to do so as we move forward in years to come.
After 40 years, thousands of members, (and not to mention a global pandemic), MPS continues to grow in numbers and talent year on year. This year, our passionate and dedicated Committee aims to see MPS succeed and function at the highest possible level, with weekly events, workshops and activities for all of our members. MPS seeks to present exciting opportunities to our members, both creatively and socially, and foster the immense potential within DCU students. We hope to continue to do so as we move forward in years to come.
</p>
</div>
</div>
Expand Down
Loading

0 comments on commit b71c08e

Please sign in to comment.