Skip to content

Commit

Permalink
Drive link thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratikshakhandagale committed Oct 4, 2024
1 parent 9cc775e commit a307790
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 23 deletions.
6 changes: 5 additions & 1 deletion capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const config: CapacitorConfig = {
loggingBehavior: "none",
webDir: 'www',
server: {
androidScheme: 'https'
androidScheme: 'https',
allowNavigation: [
"https://drive.google.com",
"https://docs.google.com"
]
},
plugins: {
CapacitorSQLite: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<!-- <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="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_')) ? 'https://ejaaduipitara.ncert.gov.in/assets/img/cards.jpg' : ''" alt="">

Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/mypitara/mypitara.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<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="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>
Expand Down
14 changes: 2 additions & 12 deletions src/app/pages/playlist-details/playlist-details.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,12 @@
<div class="cards-container" *ngFor="let content of playlists; let i = index">
<div class="card" *ngIf="content?.metaData">
<div class="card__img" (click)="playContent(content)">
<!-- <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 appThumbnail [appThumbnail]="content?.metaData" 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 === 'text/html'"> -->


<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 appThumbnail [appThumbnail]="'assets/images/yt.jpeg'" alt="" *ngIf="content.metaData.mimetype === mimeType.YOUTUBE"> -->
<img appThumbnail [appThumbnail]="content?.metaData" alt="" *ngIf="content?.metaData?.mimetype === mimeType.YOUTUBE && !content.play">
<!-- <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]="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_')) ? (content?.metaData?.thumbnail) : '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="">

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/qr-scan-result/qr-scan-result.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<img appThumbnail [appThumbnail]="content?.metaData" 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 || content.metaData.mimetype === mimeType.WEBM">
<img [src]="(content?.metaData?.thumbnail && !content.metaData.identifier.startsWith('do_')) ? content?.metaData?.thumbnail :'assets/images/PDF.png'" alt="" *ngIf="content.metaData.mimetype === mimeType.PDF">

<!-- <ion-img [src]="content.metaData.thumbnail" alt=""/>
<ion-img *ngIf="!content.metaData.thumbnail" src="assets/images/defaultImg.png" alt=""/> -->
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/app/pages/search/search.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@

<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="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 === 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
4 changes: 2 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,8 +8,8 @@
<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="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">
Expand Down
19 changes: 17 additions & 2 deletions src/app/services/api/http.capacitor.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ export class HttpCapacitorAdapter implements HttpClient {
return match ? match[1] : null;
}


convertGoogleDriveUrl(driveUrl: string): string | null {
const regex = /\/d\/([a-zA-Z0-9_-]+)\//;
const match = driveUrl.match(regex);

if (match && match[1]) {
const fileId = match[1];
return `https://drive.google.com/thumbnail?id=${fileId}`;
}

return null; // Return null if no match
}


private invokeRequest(type: ApiHttpRequestType, url: string, parametersOrData: any,
headers: { [key: string]: string }): Observable<ApiResponse> {
const observable = new Subject<ApiResponse>();
Expand Down Expand Up @@ -144,7 +158,8 @@ export class HttpCapacitorAdapter implements HttpClient {
receivedData.data.djp_contents.forEach((item : any) => {
// let mimetype = item?.url ? this.checkMimieType(item?.url) : 'text/html';
let url = this.isGoogleDriveLink(item?.url) ? item?.url.replace('/view', '/preview'): item?.url;
let thumbnail = item?.thumbnail != null && this.isGoogleDriveLink(item?.thumbnail) ? "" : "";
item.thumbnail = (item?.thumbnail != null && this.isGoogleDriveLink(item?.thumbnail)) ? this.convertGoogleDriveUrl(item?.thumbnail): item?.thumbnail;

let mimetype = this.checkMimieType(url);
// Traverse through the items array of each provider
const content: SearchContentMetaData = {
Expand All @@ -162,7 +177,7 @@ export class HttpCapacitorAdapter implements HttpClient {
provider_name: item.provider_name,
name: item.name,
description: item.description,
thumbnail: thumbnail,
thumbnail: item?.thumbnail,
domain: item.domain,
unique_id: item.unique_id,
language: item.language,
Expand Down

0 comments on commit a307790

Please sign in to comment.