Compare commits

..
Author SHA1 Message Date
zeppi 54f5c1f0f1 hub desktop related wip 2021-10-05 12:59:41 -04:00
9 changed files with 200 additions and 123 deletions

No files matched your search

+8
View File
@@ -2180,5 +2180,13 @@
"Creator": "Creator",
"From comments": "From comments",
"From search": "From search",
"Manage tags": "Manage tags",
"Enter the full channel name or URL to search.\n\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8": "Enter the full channel name or URL to search.\n\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8",
"Trending for #Btc": "Trending for #Btc",
"Block and muted channels": "Block and muted channels",
"Claiming credits...": "Claiming credits...",
"Strict": "Strict",
"MatchCount": "MatchCount",
"Word Count": "Word Count",
"--end--": "--end--"
}
+3 -3
View File
@@ -240,7 +240,7 @@ const analytics: Analytics = {
startWatchmanIntervalIfNotRunning();
}
},
videoStartEvent: (claimId, timeToStartVideo, poweredBy, passedUserId, canonicalUrl, passedPlayer) => {
videoStartEvent: (claimId, duration, poweredBy, passedUserId, canonicalUrl, passedPlayer) => {
// populate values for watchman when video starts
userId = passedUserId;
claimUrl = canonicalUrl;
@@ -249,8 +249,8 @@ const analytics: Analytics = {
videoType = passedPlayer.currentSource().type;
videoPlayer = passedPlayer;
sendPromMetric('time_to_start', timeToStartVideo);
sendMatomoEvent('Media', 'TimeToStart', claimId, timeToStartVideo);
sendPromMetric('time_to_start', duration);
sendMatomoEvent('Media', 'TimeToStart', claimId, duration);
},
error: (message) => {
return new Promise((resolve) => {
+13 -11
View File
@@ -327,17 +327,19 @@ function App(props: Props) {
// Load IMA3 SDK for aniview: DISABLED FOR NOW
// @if TARGET='web'
useEffect(() => {
const script = document.createElement('script');
script.src = `https://imasdk.googleapis.com/js/sdkloader/ima3.js`;
script.async = true;
// $FlowFixMe
document.body.appendChild(script);
return () => {
// $FlowFixMe
document.body.removeChild(script);
};
});
// useEffect(() => {
// if (ENABLE_PREROLL_ADS) {
// const script = document.createElement('script');
// script.src = `https://imasdk.googleapis.com/js/sdkloader/ima3.js`;
// script.async = true;
// // $FlowFixMe
// document.body.appendChild(script);
// return () => {
// // $FlowFixMe
// document.body.removeChild(script);
// };
// }
// });
// @endif
// @if TARGET='app'
+6
View File
@@ -53,6 +53,7 @@ type Props = {
streamType?: string | Array<string>,
defaultStreamType?: string | Array<string>,
searchText?: string,
empty?: string,
feeAmount?: string,
releaseTime?: string,
@@ -122,6 +123,7 @@ function ClaimListDiscover(props: Props) {
name,
claimType,
pageSize,
searchText,
defaultClaimType,
streamType = SIMPLE_SITE ? [CS.FILE_VIDEO, CS.FILE_AUDIO] : undefined,
defaultStreamType = SIMPLE_SITE ? CS.FILE_VIDEO : undefined, // add param for DEFAULT_STREAM_TYPE
@@ -281,6 +283,10 @@ function ClaimListDiscover(props: Props) {
options.channel_ids = channelIdsParam;
}
if (searchText) {
options.text = searchText;
}
if (tagsParam) {
if (tagsParam !== CS.TAGS_ALL && tagsParam !== '') {
if (tagsParam === CS.TAGS_FOLLOWED) {
+130 -6
View File
@@ -9,6 +9,9 @@ import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
import Button from 'component/button';
import classnames from 'classnames';
import RecSys from 'recsys';
import { FormField } from '../common/form-components/form-field';
import I18nMessage from '../i18nMessage';
import CreditAmount from '../common/credit-amount';
const VIEW_ALL_RELATED = 'view_all_related';
const VIEW_MORE_FROM = 'view_more_from';
@@ -36,6 +39,8 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
claimId,
} = props;
const [viewMode, setViewMode] = React.useState(VIEW_ALL_RELATED);
const [strict, setStrict] = React.useState(false);
const [wordCount, setWordCount] = React.useState(3);
const signingChannel = claim && claim.signing_channel;
const channelName = signingChannel ? signingChannel.name : null;
const isMobile = useIsMobile();
@@ -64,14 +69,81 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
}
}
function getSearchTextForClaim(claim) {
const wordMap = {};
const addToWordmap = (word) => {
if (wordMap[word]) {
wordMap[word]++;
} else {
wordMap[word] = 1;
}
};
claim.name.split('-').map((word) => addToWordmap(word));
if (claim.value.title) {
claim.value.title.split(' ').map((word) => addToWordmap(word));
}
if (claim.value.tags) {
claim.value.tags.forEach((tag) => tag.split(' ').map((word) => addToWordmap(word)));
}
if (claim.value.description) {
claim.value.description.split(' ').map((word) => addToWordmap(word));
}
console.log('wordMap', wordMap);
const sorted = Object.entries(wordMap)
.sort(([, a], [, b]) => b - a)
.map(([el, val]) => el)
.filter((e) => e.length >= 4);
let searchText = sorted.slice(0, wordCount).join(strict ? ' +' : ' ');
console.log('searchText', searchText);
// console.log('claim.title');
// if (claim.value && claim.value.title) {
// searchText += claim.value.title;
// }
// if (claim.value.description) {
// searchText += claim.value.description;
// }
console.log('searchText', searchText);
return searchText;
}
const searchText = claim ? getSearchTextForClaim(claim) : undefined;
return (
<Card
isBodyList
smallTitle={!isMobile && !isMedium}
className="file-page__recommended"
title={__('Related')}
titleActions={
signingChannel && (
// title={__('Related')}
// titleActions={
// signingChannel && (
// <>
//
// <div className="recommended-content__toggles">
//
// <Button
// className={classnames('button-toggle', {
// 'button-toggle--active': viewMode === VIEW_ALL_RELATED,
// })}
// label={__('All')}
// onClick={() => setViewMode(VIEW_ALL_RELATED)}
// />
//
// <Button
// className={classnames('button-toggle', {
// 'button-toggle--active': viewMode === VIEW_MORE_FROM,
// })}
// label={__('More from %claim_name%', { claim_name: channelName })}
// onClick={() => setViewMode(VIEW_MORE_FROM)}
// />
// </div>
// </>
// )
// }
subtitle={
<div className="card__whatever">
<div className="recommended-content__toggles">
<Button
className={classnames('button-toggle', {
@@ -89,21 +161,73 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
onClick={() => setViewMode(VIEW_MORE_FROM)}
/>
</div>
)
<div className="section section__actions--between">
<FormField
name="word_count"
label={__('Word Count')}
min="0"
step="1"
type="number"
value={wordCount}
onChange={(event) => setWordCount(event.target.value)}
/>
<FormField
name="search_strict"
label={__('Strict')}
type="checkbox"
checked={strict}
onChange={() => setStrict(!strict)}
/>
</div>
<p>{searchText}</p>
</div>
}
body={
<div>
{viewMode === VIEW_ALL_RELATED && (
{viewMode === VIEW_ALL_RELATED && IS_WEB && (
<ClaimList
type="small"
loading={isSearching}
uris={recommendedContentUris}
hideMenu={isMobile}
infiniteScroll
injectedItem={SHOW_ADS && IS_WEB && !isAuthenticated && <Ads small type={'video'} />}
empty={__('No related content found')}
onClick={handleRecommendationClicked}
/>
)}
{/*{viewMode === VIEW_ALL_RELATED && !IS_WEB && (*/}
{/* <ClaimList*/}
{/* type="small"*/}
{/* loading={isSearching}*/}
{/* uris={recommendedContentUris}*/}
{/* hideMenu={isMobile}*/}
{/* infiniteScroll*/}
{/* injectedItem={SHOW_ADS && IS_WEB && !isAuthenticated && <Ads small type={'video'} />}*/}
{/* empty={__('No related content found')}*/}
{/* onClick={handleRecommendationClicked}*/}
{/* />*/}
{/*)}*/}
{viewMode === VIEW_ALL_RELATED && !IS_WEB && (
<ClaimListDiscover
hideAdvancedFilter
tileLayout={false}
showHeader={false}
type="small"
claimType={['stream']}
// orderBy={['trending_group', 'trending_mixed']}
orderBy={'new'}
pageSize={20}
infiniteScroll
hideFilters
searchText={searchText}
// channelIds={[signingChannel.claim_id]}
loading={isSearching}
hideMenu={isMobile}
injectedItem={SHOW_ADS && IS_WEB && !isAuthenticated && <Ads small type={'video'} />}
empty={__('No related content found')}
/>
)}
{viewMode === VIEW_MORE_FROM && signingChannel && (
<ClaimListDiscover
hideAdvancedFilter
@@ -113,7 +237,7 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
claimType={['stream']}
orderBy="new"
pageSize={20}
infiniteScroll={false}
infiniteScroll={true}
hideFilters
channelIds={[signingChannel.claim_id]}
loading={isSearching}
@@ -30,11 +30,9 @@ const select = (state, props) => {
const urlParams = new URLSearchParams(search);
const autoplay = urlParams.get('autoplay');
const uri = props.uri;
// TODO: eventually this should be received from DB and not local state (https://github.com/lbryio/lbry-desktop/issues/6796)
const position = urlParams.get('t') !== null ? urlParams.get('t') : makeSelectContentPositionForUri(uri)(state);
const userId = selectUser(state) && selectUser(state).id;
const internalFeature = selectUser(state) && selectUser(state).internal_feature;
const playingUri = selectPlayingUri(state);
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || (playingUri && playingUri.collectionId);
const isMarkdownOrComment = playingUri && (playingUri.source === 'markdown' || playingUri.source === 'comment');
@@ -52,7 +50,6 @@ const select = (state, props) => {
return {
position,
userId,
internalFeature,
collectionId,
nextRecommendedUri,
previousListUri,
@@ -26,19 +26,13 @@ const VERSION = '0.0.1';
* */
// TEST PRE-ROLL WITH THIS TAG:
// const macroUrl = 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonly&cmsid=496&vid=short_onecue&correlator=';
// live channel
// b354389c7adb506d0bd9a4
// ford ad
// 612fb75a42715a07645a614c
// https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonly&cmsid=496&vid=short_onecue&correlator=
// Modified to work with IMA
const macroUrl =
`https://vast.aniview.com/api/adserver61/vast/` +
`?AV_PUBLISHERID=60afcbc58cfdb065440d2426` +
`&AV_CHANNELID=612fb75a42715a07645a614c` +
`&AV_CHANNELID=60b354389c7adb506d0bd9a4` +
`&AV_URL=[URL]` +
`&cb=[CACHEBUSTING]` +
`&AV_WIDTH=[WIDTH]` +
@@ -51,7 +45,7 @@ const macroUrl =
`&skiptimer=5` +
`&logo=true` +
`&usevslot=true` +
`&vastretry=2` +
`&vastretry=5` +
`&hidecontrols=false`;
const defaults = {
@@ -75,16 +69,16 @@ class AniviewPlugin extends Component {
this.player = player;
// request ads whenever there's new video content
player.on('contentchanged', () => {
/* player.on('contentchanged', () => {
// in a real plugin, you might fetch your ad inventory here
player.trigger('adsready');
});
}); */
// Plugin event listeners
player.on('readyforpreroll', (event) => this.onReadyForPreroll(event));
// player.on('readyforpreroll', (event) => this.onReadyForPreroll(event));
}
onReadyForPreroll(event) {
/* onReadyForPreroll(event) {
// send event when ad is playing to remove loading spinner
this.player.one('adplaying', () => {
this.player.trigger('ads-ad-started');
@@ -94,7 +88,7 @@ class AniviewPlugin extends Component {
this.player.one('adended', () => {
this.player.ads.endLinearAdMode();
});
}
} */
log(...args) {
if (this.options_.debug) {
@@ -16,7 +16,7 @@ import qualityLevels from 'videojs-contrib-quality-levels';
import isUserTyping from 'util/detect-typing';
// @if TARGET='web'
// Disabled for now.
import './plugins/videojs-aniview/plugin';
// import './plugins/videojs-aniview/plugin';
// @endif
const isDev = process.env.NODE_ENV !== 'production';
@@ -60,8 +60,7 @@ type Props = {
adUrl: ?string,
claimId: ?string,
userId: ?number,
allowPreRoll: ?boolean,
internalFeatureEnabled: ?boolean,
// allowPreRoll: ?boolean,
shareTelemetry: boolean,
replay: boolean,
videoTheaterMode: boolean,
@@ -78,30 +77,6 @@ type Props = {
// muted?: boolean,
// };
function hitsTwentyPercent() {
// from 0 - 999
var rand = Math.floor(Math.random() * (1000 + 1));
console.log(rand);
console.log('rand');
setTimeout(function(){
console.log('play here');
player.play()
}, 1000)
return true
if (rand > 799) {
return true;
} else {
return false;
}
}
const videoPlaybackRates = [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 1.75, 2];
const IS_IOS =
@@ -203,8 +178,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
adUrl,
claimId,
userId,
allowPreRoll,
internalFeatureEnabled,
// allowPreRoll,
shareTelemetry,
replay,
videoTheaterMode,
@@ -565,14 +539,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
// this seems like a weird thing to have to check for here
if (!player) return;
// always have ads on if internal feature is on,
// otherwise if not authed, roll for 20% to see an ad
const shouldShowAnAd = internalFeatureEnabled || (allowPreRoll && hitsTwentyPercent());
if (shouldShowAnAd) {
vjs.aniview();
}
// Add various event listeners to player
player.one('play', onInitialPlay);
player.on('play', resolveCtrlText);
@@ -613,7 +579,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
// I think this is a callback function
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
onPlayerReady(player, videoNode);
});
+29 -48
View File
@@ -55,7 +55,6 @@ type Props = {
setVideoPlaybackRate: (number) => void,
authenticated: boolean,
userId: number,
internalFeature: boolean,
homepageData?: { [string]: HomepageCat },
shareTelemetry: boolean,
isFloating: boolean,
@@ -99,7 +98,6 @@ function VideoViewer(props: Props) {
homepageData,
authenticated,
userId,
internalFeature,
shareTelemetry,
isFloating,
doPlayUri,
@@ -154,7 +152,6 @@ function VideoViewer(props: Props) {
};
}, [embedded, videoPlaybackRate]);
// TODO: analytics functionality
function doTrackingBuffered(e: Event, data: any) {
fetch(source, { method: 'HEAD', cache: 'no-store' }).then((response) => {
data.playerPoweredBy = response.headers.get('x-powered-by');
@@ -162,37 +159,21 @@ function VideoViewer(props: Props) {
});
}
/**
* Analytics functionality that is run on first video start
* @param e - event from videojs (from the plugin?)
* @param data - only has secondsToLoad property
*/
function doTrackingFirstPlay(e: Event, data: any) {
// how long until the video starts
let timeToStartVideo = data.secondsToLoad;
let timeToStart = data.secondsToLoad;
// TODO: what's happening here briefly?
if (!IS_WEB) {
if (desktopPlayStartTime !== undefined) {
const differenceToAdd = Date.now() - desktopPlayStartTime;
timeToStartVideo += differenceToAdd;
}
if (desktopPlayStartTime !== undefined) {
const differenceToAdd = Date.now() - desktopPlayStartTime;
timeToStart += differenceToAdd;
}
// send matomo event (embedded is boolean)
analytics.playerStartedEvent(embedded);
// figure out what server the video is served from and then run start analytic event
fetch(source, { method: 'HEAD', cache: 'no-store' }).then((response) => {
// server string such as 'eu-p6'
let playerPoweredBy = response.headers.get('x-powered-by') || '';
// populates data for watchman, sends prom and matomo event
analytics.videoStartEvent(claimId, timeToStartVideo, playerPoweredBy, userId, claim.canonical_url, this);
analytics.videoStartEvent(claimId, timeToStart, playerPoweredBy, userId, claim.canonical_url, this);
});
// hit backend to mark a view
doAnalyticsView(uri, timeToStartVideo).then(() => {
doAnalyticsView(uri, timeToStart).then(() => {
claimRewards();
});
}
@@ -275,7 +256,6 @@ function VideoViewer(props: Props) {
clearPosition(uri);
}, [adUrl, autoplayNext, clearPosition, collectionId, embedded, ended, setAdUrl, uri]);
// MORE ON PLAY STUFF
function onPlay(player) {
setEnded(false);
setIsLoading(false);
@@ -456,28 +436,29 @@ function VideoViewer(props: Props) {
</>
)}
<VideoJs
adUrl={adUrl}
source={adUrl || source}
sourceType={forcePlayer || adUrl ? 'video/mp4' : contentType}
isAudio={isAudio}
poster={isAudio || (embedded && !autoplayIfEmbedded) ? thumbnail : ''}
onPlayerReady={onPlayerReady}
startMuted={autoplayIfEmbedded}
toggleVideoTheaterMode={toggleVideoTheaterMode}
autoplay={!embedded || autoplayIfEmbedded}
autoplaySetting={autoplayNext}
claimId={claimId}
userId={userId}
allowPreRoll={!authenticated} // used to not include embeds, removed for now
internalFeatureEnabled={internalFeature}
shareTelemetry={shareTelemetry}
replay={replay}
videoTheaterMode={videoTheaterMode}
playNext={doPlayNext}
playPrevious={doPlayPrevious}
embedded={embedded}
/>
{!isFetchingAd && (
<VideoJs
adUrl={adUrl}
source={adUrl || source}
sourceType={forcePlayer || adUrl ? 'video/mp4' : contentType}
isAudio={isAudio}
poster={isAudio || (embedded && !autoplayIfEmbedded) ? thumbnail : ''}
onPlayerReady={onPlayerReady}
startMuted={autoplayIfEmbedded}
toggleVideoTheaterMode={toggleVideoTheaterMode}
autoplay={!embedded || autoplayIfEmbedded}
autoplaySetting={autoplayNext}
claimId={claimId}
userId={userId}
allowPreRoll={!embedded && !authenticated}
shareTelemetry={shareTelemetry}
replay={replay}
videoTheaterMode={videoTheaterMode}
playNext={doPlayNext}
playPrevious={doPlayPrevious}
embedded={embedded}
/>
)}
</div>
);
}