Skip to content

Commit

Permalink
Drive link support added
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratikshakhandagale committed Sep 18, 2024
1 parent f6af397 commit 7d6d625
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/app/appConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export class MimeType {
'application/vnd.ekstep.html-archive'
];
public static readonly YOUTUBE = "video/x-youtube"
static LINK: string;
}

export const regDiksha = [{
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
<!-- <img [src]="loadYoutubeImg(content.metaData.identifier)" alt="" *ngIf="content.metaData.mimetype === mimeType.YOUTUBE && !content.play"> -->
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/Video.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.MP4">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/PDF.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.PDF">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? content?.metaData?.thumbnail : 'assets/images/LINK.png'" alt="" *ngIf="content?.metaData?.mimetype === 'text/html'">
<img src="assets/images/LINK.png" alt="" *ngIf="content?.metaData?.mimetype === mimeType?.LINK">

<img [src]="(content?.metaData?.thumbnail =='' && !content.metaData.identifier.startsWith('do_')) ? 'https://ejaaduipitara.ncert.gov.in/assets/img/cards.jpg' : ''" alt="">

<!-- <ion-img *ngIf="content.metaData.thumbnail && !content.play" [src]="content.metaData.thumbnail" alt=""/>
Expand Down
8 changes: 5 additions & 3 deletions src/app/pages/mypitara/mypitara.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
<div class="grid-slider__container">
<div class="grid-slider__container__card" *ngFor="let content of contentList">
<div (click)="playContent(content)">
<ion-card *ngIf="content?.metaData?.thumbnail">
<ion-card *ngIf="content?.metaData">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/Audio.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.AUDIO">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/youtube-video.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.YOUTUBE">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/Video.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.MP4">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/PDF.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.PDF">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK">
<!-- <img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK"> -->
<img src="assets/images/LINK.png" alt="" *ngIf="content?.metaData?.mimetype === mimeType?.LINK">

</ion-card>
<div class="card-title" *ngIf="content?.metaData?.name">{{content.metaData.name |translate}}</div>
</div>
Expand Down Expand Up @@ -76,4 +78,4 @@
</div> -->
<!--New playlist page ends here-->

</ion-content>
</ion-content>
6 changes: 4 additions & 2 deletions src/app/pages/playlist-details/playlist-details.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
<!-- <img [src]="loadYoutubeImg(content.metaData.identifier)" alt="" *ngIf="content.metaData.mimetype === mimeType.YOUTUBE && !content.play"> -->
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/Video.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.MP4">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/PDF.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.PDF">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? content?.metaData?.thumbnail : 'assets/images/LINK.png'" alt="" *ngIf="content?.metaData?.mimetype === 'text/html'">
<!-- <img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK"> -->
<!-- <img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? content?.metaData?.thumbnail : 'assets/images/LINK.png'" alt="" *ngIf="content?.metaData?.mimetype === 'text/html'"> -->
<img src="assets/images/LINK.png" alt="" *ngIf="content?.metaData?.mimetype === mimeType?.LINK">

<img [src]="(content?.metaData?.thumbnail =='' && !content.metaData.identifier.startsWith('do_')) ? 'https://ejaaduipitara.ncert.gov.in/assets/img/cards.jpg' : ''" alt="">

<!-- <ion-img *ngIf="content.metaData.thumbnail && !content.play" [src]="content.metaData.thumbnail" alt=""/>
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/search/search.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@

<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/Video.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.MP4">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/PDF.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.PDF">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK">
<img src="assets/images/LINK.png" alt="" *ngIf="content?.metaData?.mimetype === mimeType?.LINK">

<!-- <img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK"> -->
<!-- <img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? content?.metaData?.thumbnail : 'assets/images/LINK.png'" alt="" *ngIf="content?.metaData?.mimetype === 'text/html'"> -->
</div>
<div class="card__metadata">
Expand Down
6 changes: 4 additions & 2 deletions src/app/pages/view-all/view-all.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/youtube-video.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.YOUTUBE">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/Video.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.MP4">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/PDF.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.PDF">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK">
<!-- <img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? (content?.metaData?.thumbnail) : 'assets/images/LINK.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.LINK"> -->
<img src="assets/images/LINK.png" alt="" *ngIf="content?.metaData?.mimetype === mimeType?.LINK">

</div>
<div class="card__metadata">
<div class="card__title" *ngIf="content?.metaData?.name">{{content?.metaData?.name}}</div>
Expand Down Expand Up @@ -40,4 +42,4 @@
</ion-button>
</div>
</div>
</div>
</div>
26 changes: 21 additions & 5 deletions src/app/services/api/http.capacitor.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export class HttpCapacitorAdapter implements HttpClient {
return this.invokeRequest(ApiHttpRequestType.POST, baseUrl + path, body, headers);
}

isGoogleDriveLink(url: string): boolean {
return url.includes('drive.google.com') || url.includes('docs.google.com');
}


checkMimieType(url: any)
{

Expand All @@ -92,10 +97,19 @@ export class HttpCapacitorAdapter implements HttpClient {
return 'video/x-youtube'; // // YouTube video
} else if (mediaUrl.endsWith(".mp4")) {
return 'video/mp4'; // MP4 video
} else {
} else if(this.isGoogleDriveLink(url)){
return 'text/html';
}
else{
return 'text/html';
}
}

getDriveFileId(url : string) {
const regex = /\/d\/([a-zA-Z0-9_-]+)\//;
const match = url.match(regex);
return match ? match[1] : null;
}

private invokeRequest(type: ApiHttpRequestType, url: string, parametersOrData: any,
headers: { [key: string]: string }): Observable<ApiResponse> {
Expand All @@ -119,7 +133,7 @@ export class HttpCapacitorAdapter implements HttpClient {
requestOptions['params'] = parametersOrData;
}

this.http.request(requestOptions).then((response: HttpResponse) => {
this.http.request(requestOptions).then((response: HttpResponse) => {
response.data = response.data;
let receivedData = response.data;

Expand All @@ -129,7 +143,9 @@ export class HttpCapacitorAdapter implements HttpClient {
if (receivedData.data && receivedData.data.djp_contents !== null && receivedData.data.djp_contents !== undefined) {
receivedData.data.djp_contents.forEach((item : any) => {
// let mimetype = item?.url ? this.checkMimieType(item?.url) : 'text/html';
let mimetype = this.checkMimieType(item?.url);
let url = this.isGoogleDriveLink(item?.url) ? item?.url.replace('/view', '/preview'): item?.url;
let thumbnail = item?.thumbnail != null && this.isGoogleDriveLink(item?.thumbnail) ? "" : "";
let mimetype = this.checkMimieType(url);
// Traverse through the items array of each provider
const content: SearchContentMetaData = {
agegroup: item.agegroup,
Expand All @@ -146,11 +162,11 @@ export class HttpCapacitorAdapter implements HttpClient {
provider_name: item.provider_name,
name: item.name,
description: item.description,
thumbnail: item.thumbnail,
thumbnail: thumbnail,
domain: item.domain,
unique_id: item.unique_id,
language: item.language,
url: item.url,
url: url,
sourceOrganisation: item.sourceorg,
midea: item.midea,
keywords: item.keywords,
Expand Down
8 changes: 6 additions & 2 deletions src/app/services/content/util/content.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export class ContentUtil {
case 'youtube':
mimeType = MimeType.YOUTUBE
break;
case 'link':
mimeType = MimeType.LINK
break;
default:
break;
}
Expand All @@ -65,8 +68,9 @@ export class ContentUtil {
mp3: '/assets/images/Audio.png',
mp4: '/assets/images/Video.png',
webm: '/assets/images/Video.png',
pdf: '/assets/images/PDF.png'
pdf: '/assets/images/PDF.png',
link: '/assets/images/LINK.png'
}
return mimeTypes[mimeType];
}
}
}

0 comments on commit 7d6d625

Please sign in to comment.